Skip to content

fix(session-history): list a rewound chat once instead of once per conversation - #50247

Merged
AmoabaKelvin merged 4 commits into
mainfrom
fix-47681-rewind-history-rows
Nov 27, 2026
Merged

AmoabaKelvin merged 4 commits into
mainfrom
fix-47681-rewind-history-rows

Conversation

@AmoabaKelvin

@AmoabaKelvin AmoabaKelvin commented Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator

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.

Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​28 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​28
Prod 16 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​133 $\color{#cf222e}{\Huge{\mathbf{−}}}$​50 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​83

What Changed

  • Before: a rewound Claude chat showed two "Reply with the word apple" rows in Session History: the original conversation and the provider's "(fork)" copy. Clicking either row opened the same chat, and Delete on either row removed the chat and hid both rows.
  • After: Session History lists each chat once, using the conversation the chat continues now (or, if that transcript isn't on disk yet, the newest one it has). Search does the same, including across "Load more" pages.

How it works:

  • A rewind doesn't create a second Orca chat. It adds the provider's new conversation to the same chat's 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. oneRowPerChat now keeps one row per chat: the head conversation's row, else the first listed.
  • Dropping rows made the list shorter than the depth the scan filled, and "Show more sessions" and the plugin depthReached flag both judge depth by row count. The listing now reports hiddenRowCount (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".
  • The runtime RPC lists one row per chat only for clients that advertise 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 plugin agent.resume looks 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:changed passes. 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 hiddenRowCount were 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:

  • An older desktop paired to an updated host doesn't advertise the capability, so it keeps today's list.
  • An updated desktop on an older host gets that host's old rows, so a chat on that host can still show twice until the host updates.
  • Mobile shows the collapsed list once its app update ships; until then it sees today's list.

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

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance

  • No platform-specific code. Remote and SSH rows pass through unchanged; each runtime host lists its own chats once.
  • Related, not in scope: STA-15946 (a rewind leaving a new Claude session behind).

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • I stated the risk: what could break, for whom, and how to back it out
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

…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.
@coderabbitai

coderabbitai Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

History listing now deduplicates owned rows by chat for clients that advertise the chat-row capability. Listing results carry hidden-row counts through validation, merging, and runtime scanning. History depth and the displayed loaded count include hidden rows. Search page appends omit duplicate structured-session hits.

Severity of issue fixed: Medium

Merge Risk: Minimal · up to bb294

Session History now lists one row per chat for clients that advertise the chat-row capability, and hidden rows are counted toward depth so "Show more" still reaches older history. Older clients keep the per-conversation rows. No concrete defect was established. One caveat remains: it was not confirmed how plugin resume by ID behaves for earlier conversations that the collapsed listing omits. The PR author reports this case is handled.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: Session History now lists a rewound chat once instead of once per conversation. It matches the summarized changes (one row per chat via oneRowPerChat and projection ch…
Linked Issues check Passed [#47681] The issue reports two Session History rows for one rewound Claude chat. Both rows open and delete the same chat. The issue accepts either a per-version behavior change or a clear whole-chat d…
Out of Scope Changes check Passed All changed areas connect to the one-row-per-chat behavior. Changes: the shared capability constant AI_VAULT_CHAT_ROWS_CLIENT_CAPABILITY and its registration in client capability lists (desktop, web, …
Description check Passed The description follows the template closely. It has a clear ELI5, a What Changed section with before and after behavior and the mechanism, a Why section that explains the chosen approach over two alt…
Full details: Title check

Explanation

The title names the main change: Session History now lists a rewound chat once instead of once per conversation. It matches the summarized changes (one row per chat via oneRowPerChat and projection changes) and the stated objective. It uses the conventional fix(scope) prefix and is specific. It is 79 characters, which is within a normal length.

Full details: Linked Issues check

Explanation

[#47681] The issue reports two Session History rows for one rewound Claude chat. Both rows open and delete the same chat. The issue accepts either a per-version behavior change or a clear whole-chat deletion message, and lists one row per chat as a suggested fix. The head is ownership-aware in projectStructuredAiVaultSessions: oneRowPerChat (history-row-ownership-lookup.ts) keeps one row per owned sessionId, preferring the role 'head' row, else the first listed. The search projection applies the same rule to hits. Rows are no longer duplicated for one chat, so a single row now represents the chat that Delete removes. The count fix (hiddenRowCount, added in the Show more and depthReached checks) keeps the depth logic correct after rows are dropped. Clients that advertise aiVault.chat-rows.v1 (desktop, web, mobile per the diff) receive collapsed rows. The issue's Fork-related claims are marked unverified and are not required here. Remaining uncertainty: the default listsChatOnce = true in projectStructuredAiVaultSessions conflicts with the PR text that says in-process readers keep one row per conversation. I did not verify the in-process caller arguments, so the in-process behavior is unconfirmed. This does not change the verdict for the RPC path that the issue reports.

Full details: Out of Scope Changes check

Explanation

All changed areas connect to the one-row-per-chat behavior. Changes: the shared capability constant AI_VAULT_CHAT_ROWS_CLIENT_CAPABILITY and its registration in client capability lists (desktop, web, mobile); the hiddenRowCount field in list result types, parsing, restamping, and merging; the depth checks in the plugin readHistory depthReached logic and AiVaultShowMoreSessionsRow; search page append dedup (appendSearchPage); result reuse identity; the RPC gate in aiVault.listSessions; and related test support and tests. Each change supports collapsing rows, keeping depth counts correct, or gating the collapse by client capability. No unrelated behavior change was identified in the summary. Scope is judged from the summary and the one focused read of structured-session-ownership.ts, not a full diff read.

Full details: Description check

Explanation

The description follows the template closely. It has a clear ELI5, a What Changed section with before and after behavior and the mechanism, a Why section that explains the chosen approach over two alternatives, a linked issue (Fixes #47681), Visual Proof with before and after images, Testing with checked boxes and a regression test description, a Performance line with reasoning, a Risk section with level and revert path, and a Notes section. Minor gaps: the AI Disclosure section is empty, and the Review section is present. The Testing section lists lint, typecheck, test, and build as passing only by checklist, with no command output. These gaps are non-critical, so the check passes.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0d7fdd7d-4b05-470d-8c4d-e199b6865fad
Commits

Reviewing files that changed from the base of the PR and between 2229c41 and bb29443.

Files selected for processing: 17

  • mobile/src/transport/connection/mobile-runtime-client-capabilities.ts
  • src/main/ai-vault/listing/session-list-result-validation.ts
  • src/main/ai-vault/listing/session-list-results.ts
  • src/main/ai-vault/runtime-hosts/runtime-session-scanner.ts
  • src/main/ai-vault/structured-sessions/history-row-ownership-lookup.ts
  • src/main/ai-vault/structured-sessions/structured-session-ownership.test-support.ts
  • src/main/ai-vault/structured-sessions/structured-session-ownership.test.ts
  • src/main/ai-vault/structured-sessions/structured-session-ownership.ts
  • src/main/plugins/workers/host-api/plugin-agent-history.ts
  • src/main/runtime/rpc/methods/history/ai-vault.ts
  • src/renderer/src/components/right-sidebar/ai-vault/panel/AiVaultPanel.tsx
  • src/renderer/src/components/right-sidebar/ai-vault/search/use-ai-vault-search.ts
  • src/renderer/src/components/right-sidebar/ai-vault/session-list/ai-vault-session-identity.ts
  • src/shared/ai-vault/contracts/ai-vault-runtime-capabilities.ts
  • src/shared/ai-vault/contracts/ai-vault-types.ts
  • src/shared/remote-runtime/protocol/electron-remote-runtime-client-capabilities.ts
  • src/shared/remote-runtime/protocol/web-runtime-client-capabilities.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.

@AmoabaKelvin
AmoabaKelvin merged commit f5572da into main Nov 27, 2026
100 of 102 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rewound/edited chat shows as two Session History rows; Delete on either removes the whole chat and hides both

1 participant