Repository navigation
fix(session-history): list a rewound chat once instead of once per conversation - #50247
Conversation
…nversation A rewind adds the provider's fork to the same chat, and History stamped every conversation the chat held with that chat, so one chat showed as several rows that all opened and deleted the same chat. Keep only the chat's head row (or its first listed one) in both the list and search.
…y depth Collapsing a chat's conversations (and hiding deleted chats) left fewer rows than the scan's depth, so Show more and the plugin depthReached flag thought the scan had ended. The listing now reports how many scanned rows it hid, and search keeps a chat listed once across pages.
…dden rows Older clients size Show more by row count alone, so a host keeps a row per conversation for them; desktop, web and mobile clients advertise aiVault.chat-rows.v1. A search page holding only already-listed chats keeps the shown list unchanged.
…readers Plugin agent.resume finds a chat's earlier conversations in the History list to refuse resuming them in a terminal, so only clients that advertise aiVault.chat-rows.v1 get one row per chat.
|
No actionable comments were generated in the recent review. Walkthrough
Severity of issue fixed: Medium Merge Risk:
|
ELI5
When you rewind a chat (or edit an earlier message and resend it), Session History showed that one chat twice. Both rows opened the same chat, and Delete on either one deleted the whole chat. Now the chat shows up once.
What Changed
How it works:
providerHandleChain. Session History lists one row per transcript on disk, and the projection (projectStructuredAiVaultSessions/projectStructuredAiVaultSearchResponse) stamped every conversation in a chat's chain with that chat.oneRowPerChatnow keeps one row per chat: the head conversation's row, else the first listed.depthReachedflag both judge depth by row count. The listing now reportshiddenRowCount(rows it hid, including the ones already hidden for deleted chats), and both checks add it back. This also fixes an existing case where deleted chats in the newest 250 hid "Show more".aiVault.chat-rows.v1(desktop, web and mobile now do). Older clients and in-process readers keep a row per conversation, as before. Older clients still judge "Show more" by row count alone, and pluginagent.resumelooks up a chat's earlier conversations by id so it can refuse to resume them in a terminal.Why
The thing a row opens and deletes is the chat, not the transcript, so the chat is the unit History should list. Every extra row of a chat opened the same chat and deleted the same chat, so it had nothing of its own to offer. Kelvin picked one row per chat over two alternatives: labelling the older row "Before rewind" and warning in the Delete dialog, or a new per-version delete. The first keeps rows that all open the same chat. The second needs a new one-conversation tombstone and RPC for a row that still can't open anything of its own. The transcripts stay on disk; History just no longer offers to copy the pre-rewind version to a terminal.
The fix lives in the one projection that desktop, web, mobile and remote hosts all list through, so every surface gets it without per-client code.
Linked Issue
Fixes #47681
Linear: STA-17580
Visual Proof
A real Claude chat in a hidden dev build: two turns, "Rewind to here" on the first message, then the edited message resent. Same profile and same chat in both builds.
Before (main):
(screenshot removed: contained real product data)
After (this branch):
(screenshot removed: contained real product data)
Testing
Reproduced on main in a hidden dev build (macOS) with a real Claude chat: rewind plus an edited resend left two History rows for the one chat. On this branch, with the same profile and chat, History lists one row (the current conversation).
A regression test calls the real projection with a chat that holds two conversations. It expects one row (the head) and
hiddenRowCount: 1, and it fails with the fix reverted (two rows).pnpm check:changedpasses. I also ran the focused tests for the changed modules.I manually tested these changes locally
Automated tests added/updated, or explained why not below
Every added test fails without this change and avoids the test anti-patterns
Performance
None, because the collapse is one linear pass with a Map that lives only for one projection, on lists and search pages that are already being projected. It adds no reads, scans, subprocesses, timers or subscriptions. A search page holding only already-listed chats keeps the shown array, so nothing downstream re-derives. A perf-scan pass graded at fleet scale found no regressions. One existing gap it noted stays as it was: with several hosts, "Show more" compares the merged count against one host's depth, exactly as main's raw row count did.
Risk
Level: Low
The riskiest part is the depth count. If
hiddenRowCountwere wrong, "Show more sessions" could show or hide at the wrong time; it's always one click away in the History depth menu. Mixed versions:A plain revert backs it out.
AI Disclosure
Review
Reviewed over four rounds, each by two independent reviewers plus a fleet-scale perf pass. Every P0/P1 they raised was fixed: the "Show more" depth count, the mixed-version client gate, the plugin resume guard and the duplicate-only search page.
Agent skill upstream boundary
Notes
Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)