mirror of
https://github.com/siteboon/claudecodeui.git
synced 2026-05-30 08:15:31 +08:00
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
This commit is contained in:
@@ -225,7 +225,13 @@ export class CursorSessionsProvider implements IProviderSessions {
|
||||
try {
|
||||
const blobs = await this.loadCursorBlobs(sessionId, projectPath);
|
||||
const allNormalized = this.normalizeCursorBlobs(blobs, sessionId);
|
||||
const total = allNormalized.length;
|
||||
const totalNormalized = allNormalized.length;
|
||||
let total = 0;
|
||||
for (const msg of allNormalized) {
|
||||
if (msg.kind !== 'tool_result') {
|
||||
total += 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (limit !== null) {
|
||||
const start = offset;
|
||||
@@ -233,8 +239,8 @@ export class CursorSessionsProvider implements IProviderSessions {
|
||||
? []
|
||||
: allNormalized.slice(start, start + limit);
|
||||
const hasMore = limit === 0
|
||||
? start < total
|
||||
: start + limit < total;
|
||||
? start < totalNormalized
|
||||
: start + limit < totalNormalized;
|
||||
return {
|
||||
messages: page,
|
||||
total,
|
||||
|
||||
Reference in New Issue
Block a user