Files
claudecodeui/server/modules/providers/list/codex
Haileyesus 684e127213 fix(chat): make provider message totals reflect what the user actually sees
The session `total` value was diverging from the number of rendered chat rows,
which created confusing UI states (for example: "showing 12 of 21" when only 12
messages exist visually).

Why this was happening:
- Providers were counting transport/normalized records, not renderable chat rows.
- `tool_result` records are normalized and needed for tool wiring, but the UI
  does not render them as standalone bubbles; they are attached to their
  corresponding `tool_use`.
- As a result, totals were inflated by implementation details in the history
  format rather than user-visible conversation content.

Why this change:
- `total` is a user-facing metric and should represent frontend-visible messages.
- We need provider behavior to be consistent (Codex/Claude/Cursor/Gemini) so
  pagination labels, load-more affordances, and session stats match user
  expectations.
- Correctness here is UX-critical: users interpret `total` as conversation
  message count, not internal event count.

Implementation approach:
- Replace post-hoc generic counting logic with explicit per-provider total
  trackers in each `fetchHistory` flow.
- Increment totals during provider message processing so counting rules are
  owned by the provider pipeline itself.
- Exclude `tool_result` from the total tracker since it is rendered as attached
  tool output, not as a standalone chat message.

Behavioral impact:
- `total` now aligns with rendered chat rows.
- Pagination mechanics remain based on normalized history payloads, so loading
  behavior is unchanged while user-visible totals are corrected.
- Tool result attachment behavior is preserved.

Touched providers:
- codex-sessions.provider.ts
- claude-sessions.provider.ts
- cursor-sessions.provider.ts
- gemini-sessions.provider.ts
2026-05-08 15:13:23 +03:00
..