Skip to content

Session History: a repeat open keeps every older session of the workspace - #30586

Merged
brennanb2025 merged 3 commits into
mainfrom
brennanb2025/scan-cache-coverage
Oct 19, 2026
Merged

brennanb2025 merged 3 commits into
mainfrom
brennanb2025/scan-cache-coverage

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​58 $\color{#cf222e}{\Huge{\mathbf{−}}}$​18 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​40
Prod 5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​29 $\color{#cf222e}{\Huge{\mathbf{−}}}$​23 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​6

ELI5

Session History's Workspace and Project tabs showed every matching session the first time you opened them, then only 250 when you came back. Older sessions of that workspace or project disappeared on a repeat open or a tab revisit, including Codex sessions beyond the newest 250 on the machine. A fresh scan and a saved (cached) result were cut down by two different rules. Reusing a saved result no longer applies a second limit to matching sessions, so reopening retains the workspace or project sessions admitted by the scan.

What Changed

Before: on a real machine, the Workspace tab of a large workspace showed 341 sessions on first open (273 Codex, 68 Claude) and 250 on a repeat open (249 Codex, 1 Claude). The Project tab showed 380, then 250 on revisit: 57 Codex, 69 Claude and 4 Grok sessions were missing, including old sessions that were on screen a moment earlier. The All computers view capped Workspace and Project at 250 matching sessions even on a first open.

After: a repeat open, a tab revisit and the All computers view show every session the scan found for the workspace or project.

Mechanism. A scan keeps the newest N sessions overall and adds the workspace's or project's own sessions, found by a separate walk with its own per-agent budget. Every saved result, in the main process, in the per-remote-host cache and in the window, was cut again on reuse by truncateAiVaultListResult. That kept the newest N overall plus the newest N matching sessions, with one counter shared by all agents. So a reused result could hold fewer matching sessions than the scan that produced it.

  • truncateAiVaultListResult now bounds only the sessions outside the workspace or project: it keeps every matching session plus the newest N others. The scan already budgets matching sessions per source; reusing its result now preserves every matching row. With no workspace or project selected, the rule is the same newest N as before.
  • A saved result scanned at a larger depth used to serve a smaller one. For a workspace or project view, it now serves only a request of the same depth (aiVaultCachedDepthServes). Otherwise, lowering the depth menu would show the larger scan's matching sessions again. Lowering the depth there now runs a scan at the new depth. Views without a workspace or project still reuse a larger saved result, trimmed to the requested depth.

Why

The common pattern is to apply the scope filter before the limit and to serve a saved result exactly as it was fetched, keyed by the whole request. Orca's scan already filters by scope before its limit; the bug was only the second, different cut on reuse. Removing the second matching-session cap keeps selection in one place, and requiring the same depth for workspace and project reuse matches that request identity.

Alternatives considered:

  • Dropping the reuse of saved results entirely, so every depth change rescans. That brings back the slow scans just removed in Session History: the Workspace tab stops re-reading every transcript to find its sessions #30469, and still needs a rule for merging several hosts' lists, which the common pattern has no counterpart for.
  • Keeping "newest N overall" and making the scan itself end with the new rule. That could drop an unrelated session from a fresh All tab, an existing behavior an earlier change kept on purpose. Keeping the scanner return unchanged preserves fresh single-computer results in Workspace, Project and All. All computers can add matching rows and unrelated rows previously displaced by newer matching rows; it never removes a previously selected row.

Differences from the common pattern, labelled:

  • Intended: views without a workspace or project still let a larger saved result serve a smaller request, trimmed exactly to the depth. That is safe because nothing scope-related is kept beyond the depth there.
  • Intended: an older paired remote server still cuts its own saved results the old way until it updates. Old servers keep their current behavior, and the client keeps whatever they return.
  • Intended retained behavior: a Claude history folder can contain a session whose recorded working folder does not match the requested workspace. Such a row can still appear in a fresh All view and disappear on reuse, as before. This PR preserves the existing first-open listing and does not change folder admission.

Linked Issue

Tracked in STA-11167 (Linear). Found during QA of #30469 (STA-11097). It completes the older-session coverage from #29977.

Visual Proof

Real hidden Electron QA compared baseline 6c40f919 with final 94b1f8a91ee700227af5638e0ef1fdd78ed253c5 on the qa-gate-admitted M4Air, using the same frozen genuine history and complete ordered row identities. Workspace retained 341 matching sessions on fresh/repeat/revisit opens (baseline 341 → 250); Project retained 380 (baseline 380 → 250). A separate clean All first open kept the same 532 rows and order. Unlimited → 250 → reopen changed the complete result 548 → 522 → identical 522, removing only 26 rows outside the workspace. Mounted All-hosts scope revisits retained Workspace 341 and Project 380 with only a local host configured. Sparse history stayed 39 matching / 260 loaded.

Baseline Workspace repeat: 250 matching
Final head Workspace repeat: 341 matching

Full baseline/final screenshots and review findings, including Project, All, depth changes and local aggregation. No paired host was available; paired-host, SSH, WSL and mixed-version runtime checks remain unverified. The approved existing-sign-in Codex QA driver used Playwright CDP; no new sign-in or copied credentials. Processes were stopped, hook hashes and the corpus stayed unchanged, and the QA worktree was clean.

Testing

  • Manually tested in an isolated real Electron app on the admitted M4Air (details above)

  • Automated tests added/updated, or explained why not below

  • New regression test: a scan result with more matching sessions than the depth passes through the cut unchanged, and again on a second pass (the repeat-open bug).

  • New renderer test: a workspace view lowered from Unlimited to 250 scans again at 250, instead of reusing the larger scan.

  • Updated tests: the cut keeps every matching session; a deeper scan serving depth 1 keeps every matching session it found, with the pinned newest Hermes session still first; the main cache test now repeats the same request; two remote-host cache timer and concurrency tests check larger-depth reuse on views without a workspace.

  • Ran 9 named test files (160 tests) on macOS: depth, scope walk, main cache, host-leg cache, renderer refresh, list merge, projects, tab history switch and the IPC handler. Typecheck and lint run in CI.

Review

Full-path review finished on 94b1f8a91ee700227af5638e0ef1fdd78ed253c5: independent correctness and architecture reviews plus final readiness, performance and compatibility source checks found no confirmed production defect. No production fixes were needed in the loop. Main was merged once at the end, with no overlap and the ten PR files and patch unchanged. The exact-head full PR workflow and aggregate gate passed.

Deferred: an overbroad source comment about preserving every raw fresh row; the inherited unrelated history-folder admission exception remains as previously decided. The narrower automated depth-decrease test is supplemented by the actual complete-result QA above. Closing History still resets its host choice to Local Mac, as on baseline; All-hosts aggregation was tested using mounted scope revisits. No performance claim or authenticated-agent-turn/resume coverage is implied.

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

  • SSH and remote hosts: the per-host cache uses the same rule. Older servers keep their current behavior.
  • WSL: the existing scope matcher (distro-aware) is unchanged.
  • Folder workspaces: scope paths need no Git, so they are covered the same way.
  • Mobile: the app already sends its own depth (500, forced) and has no row limit; it keeps its own cache key.
  • No new saved data and no wire change.

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)
  • Before/after screenshots attached above and in the review status comment
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • Exact-head full PR workflow passed, including static analysis, tests, packaging and the aggregate gate; real Electron QA also passed

…d for a workspace

A repeat open or tab revisit of Session History's Workspace and Project
tabs dropped to 250 sessions, losing older matching sessions (341 -> 250
in QA). Every cache reuse re-cut the scan's result with a shared newest-N
counter for in-scope rows, which the scan's own per-agent budgets don't
match. The cut now bounds only out-of-scope rows, so a scan's result
passes through unchanged, and scoped requests reuse only a scan of their
own depth so lowering the depth rescans.

Tracked in STA-11167.
@brennanb2025
brennanb2025 marked this pull request as ready for review October 19, 2026 06:01
@coderabbitai

coderabbitai Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 2 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 4d76a599-b2a5-4c12-8d55-233b76d650dc
📥 Commits

Reviewing files that changed from the base of the PR and between 94b1f8a and 32268b9.

📒 Files selected for processing: 10
  • src/main/ai-vault/cached-session-list.test.ts
  • src/main/ai-vault/cached-session-list.ts
  • src/main/ai-vault/session-scanner-scope-walk.test.ts
  • src/main/ipc/ai-vault-host-leg-cache-retention.test.ts
  • src/main/ipc/ai-vault-host-leg-cache.ts
  • src/renderer/src/components/right-sidebar/ai-vault-session-list-request.ts
  • src/renderer/src/components/right-sidebar/ai-vault-session-refresh.test.ts
  • src/renderer/src/components/right-sidebar/ai-vault-session-result-cache.ts
  • src/shared/ai-vault-session-depth.test.ts
  • src/shared/ai-vault-session-depth.ts

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f1ce317a-5997-410f-be6d-2ad670a58e75
📥 Commits

Reviewing files that changed from the base of the PR and between b331710 and 94b1f8a.

📒 Files selected for processing: 10
  • src/main/ai-vault/cached-session-list.test.ts
  • src/main/ai-vault/cached-session-list.ts
  • src/main/ai-vault/session-scanner-scope-walk.test.ts
  • src/main/ipc/ai-vault-host-leg-cache-retention.test.ts
  • src/main/ipc/ai-vault-host-leg-cache.ts
  • src/renderer/src/components/right-sidebar/ai-vault-session-list-request.ts
  • src/renderer/src/components/right-sidebar/ai-vault-session-refresh.test.ts
  • src/renderer/src/components/right-sidebar/ai-vault-session-result-cache.ts
  • src/shared/ai-vault-session-depth.test.ts
  • src/shared/ai-vault-session-depth.ts

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

📝 Walkthrough

Scoped truncation now retains every session within the requested paths and applies the depth limit to out-of-scope sessions. Scoped cache requests require an exact depth match, while unscoped requests continue to use covering-depth checks. Main, host-leg, and renderer cache paths now apply scope-aware checks. Tests cover truncation, cache reuse, and rescanning after a scoped depth change.

Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to 94b1f

The scoped session-history change is mergeable after normal checks. Real-app QA remains pending, but no specific failure has been established.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 30.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 10 functions across 10 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Title check Passed The title clearly identifies the main user-facing change: repeat opens retain older sessions that belong to the workspace.
Description check Passed The description follows the required template and explains the user impact, implementation, rationale, linked tracking item, visual proof, testing, compatibility considerations, and checklist status. …
Full details: Description check

Explanation

The description follows the required template and explains the user impact, implementation, rationale, linked tracking item, visual proof, testing, compatibility considerations, and checklist status. It also documents known verification limits for paired hosts and older remote servers.

✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
  • 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

Comment @coderabbitai help to get the list of available commands.

@brennanb2025

brennanb2025 commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor Author

Session History showed older matching sessions on first open, then hid them when reopened: a cached list applied a second, different limit. This PR keeps every matching row returned by the scan in Workspace and Project, including local aggregation in All computers. Changing the depth for a workspace or project requests a scan at that depth.

Full-path review is complete on 32268b9. Independent correctness and architecture reviewers, followed by the final readiness, performance and compatibility source review, found no confirmed production defect. No production fixes were needed during the loop. A second final main sync imports the scanner update. All nine other PR files remain byte-identical to the reviewed head; the overlapping scope-walk test keeps both main’s new cases and this PR’s retention assertions. Eight named files passed, 92 tests. The history-depth default and bounded fresh scanner selection remain unchanged. The full PR workflow, including its aggregate gate, passed on this exact head.

Real Electron QA ran again on the qa-gate-admitted M4Air using the same frozen genuine history. The new final head was rebuilt and tested against current main 699b9a06 for clean first-open results; the original bug comparisons use baseline 6c40f919, explicitly labeled below. The approved existing-sign-in Codex driver used hidden Playwright CDP controls. Results compare complete ordered row identities, with only the disposable home prefix normalized between profiles:

Flow Original baseline Final head
Workspace fresh → repeat → revisit 341 → 250 → 250 matching 341 → 341 → 341 matching
Project fresh → repeat → revisit 380 → 250 → 250 matching 380 → 380 → 380 matching
Separate clean-profile All first open 532 rows (also re-proven on current main) Same 532 rows, same order
All after a Project revisit 399 rows 532 rows
Workspace Unlimited → 250 → reopen, full loaded result 548 → 428 → 428 548 → 522 → identical 522
Mounted All-hosts Workspace / Project, local host only 250 / 250 matching 341 / 380 matching, including revisits
Sparse Workspace repeat 39 matching / 260 loaded Same 39 / 260

At the final depth change, exactly 26 rows outside the workspace were removed; all 341 matching rows and their relative order remained. The new final head reproduced the previously reviewed head’s complete results, and its clean All result matched current main’s complete ordered IDs. All accepted states finished loading. Test processes and listeners were stopped, real hook-file hashes and all 577 frozen transcript files were unchanged, and the QA worktree was clean.

Deferred and limits: the automated depth-decrease test proves the new request rather than the entire result; real QA above supplies that missing evidence. One overbroad source comment remains a P3 nit: an inherited history-folder mismatch can admit an unrelated row on a fresh All listing and trim it on reuse. Changing that admission rule was previously deferred. Fresh Workspace and All exactly match current main; Project and the full final result sets match the previously reviewed head. The History depth default remains 250, with main’s bounded global list and scoped supplements retained. All-computers aggregation can add matching rows and unrelated rows previously displaced by them; it removes no previously selected row. Closing History resets the host selection to Local Mac, an inherited behavior; aggregation was therefore measured through mounted scope revisits with All hosts selected throughout. No paired host was configured, so real paired-host, SSH, WSL and mixed-version runtime behavior was not tested. Mobile, folder-workspace runtime behavior, authenticated agent turns, resume and native focus were also outside this QA run; compatibility and platform paths received source review. No performance improvement is claimed.

For Brennan’s review

Workspace repeat: baseline 250 matching; final head 341.

Original baseline Workspace repeat: 250 matching
Final head Workspace repeat: 341 matching

Project revisit: baseline 250 matching; final head 380.

Original baseline Project revisit: 250 matching
Final head Project revisit: 380 matching

Clean All first open: current main and final head both have the same 532 rows in the same order.

Current main 699b9a clean All first open: 532 rows
Final head clean All first open: 532 rows

Depth change and reopen: baseline 250 matching / 428 loaded; final head 341 matching / 522 loaded. The final Unlimited state loaded 548 rows before reducing depth.

Original baseline depth 250 reopen: 250 matching, 428 loaded
Final head Unlimited: 341 matching, 548 loaded
Final head depth 250 reopen: 341 matching, 522 loaded

All-hosts Workspace revisit, with only a local host configured: baseline 250 matching; final head 341. Project also retained 380 across mounted revisits.

Original baseline mounted All-hosts Workspace: 250 matching
Final head mounted All-hosts Workspace: 341 matching

Two judgment points in the change:

  • Depth identity: scoped reuse requires the same depth; unscoped reuse can still use a deeper scan.
  • Matching-row selection: matching rows survive; the depth bounds only other rows. The comment immediately above overstates preservation of unrelated rows, as disclosed above.

@brennanb2025
brennanb2025 merged commit 77195a1 into main Oct 19, 2026
37 checks passed
@brennanb2025
brennanb2025 deleted the brennanb2025/scan-cache-coverage branch October 19, 2026 09:04
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.

1 participant