Skip to content

Session History: the Workspace tab stops re-reading every transcript to find its sessions - #30469

Merged
brennanb2025 merged 8 commits into
mainfrom
brennanb2025/scan-slow-scope-facts
Oct 19, 2026
Merged

brennanb2025 merged 8 commits into
mainfrom
brennanb2025/scan-slow-scope-facts

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​335 $\color{#cf222e}{\Huge{\mathbf{−}}}$​2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​333
Prod 15 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​604 $\color{#cf222e}{\Huge{\mathbf{−}}}$​146 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​458

ELI5

Workspace Session History could spend over a minute reading thousands of files before showing sessions. The scan was reopening unrelated transcripts just to learn their folder. This change saves lightweight folder answers and reuses valid parsed results in batches, while retaining main’s ordered Workspace and Project results, including Codex sessions beyond the newest 250 on the machine. The pre-existing cache-reopen coverage gap below remains and is tracked in STA-11167 (Linear) and #30586.

What Changed

Before, finding an older matching session could require a full parse of unrelated histories, or repeated transcript-head reads. The existing History cache now also saves folder answers learned from a transcript head or a small companion file. Each answer is valid only while its transcript modified time, size, platform and observed companion file agree.

Current valid parsed results remain authoritative, including a parsed result with no folder. Membership is resolved through the cache owner immediately before a session can be excluded, so a parse published during a scan takes precedence. Batched database reads isolate malformed records, and an unresolved authoritative read falls back to normal parsing instead of excluding a session using weaker information.

Grok, Cursor, Rovo, Cline, Kiro and legacy OpenCode use their existing directory extraction from small metadata files. Codex and the existing header readers save their head answer too. Formats that need full parsing, a shared index or a multi-file join keep that path. This reduces membership work where a valid cheap or parsed answer exists; it does not promise zero transcript reads for every agent.

The new scope_cwds table contains only cheap folder answers. Parsed folder information is derived from the existing saved rows rather than duplicated. Both tables participate in existing missing-file and WSL cleanup. Unknown, failed and cancelled reads are not saved as a definitive absence of a folder.

Why

The common pattern is to let one owner hold session identity and folder information, then select matching sessions before applying the limit. Orca also reads histories written by external agent CLIs, so discovery and source validation must remain complete. The existing cache owns that validated information; a separate search index cannot replace it because search is optional and has different directory semantics.

Capping discovery would hide old sessions again. A new catalog would still need to reconcile externally written files and agent-specific dependencies. The chosen design keeps complete discovery and parser admission while avoiding repeated unrelated content reads where metadata suffices.

Linked Issue

Tracked in STA-11097 (Linear). Preserves the older-session coverage from #29977.

Visual Proof

Real hidden Electron UI on M4Air compared main 51530bb86cb2f799fb5162840654c64d9ff48fb2 with this exact head b6be62c6472b9b21c5861f2ed5fd14c4c3ec6168. The same frozen genuine-history subset contains 577 files / 1,534,151,807 bytes, including Codex, Grok and Claude. Selected old Codex sessions rank 720 and 644 behind newer ordinary native sessions. Corresponding main/branch cells have identical ordered session IDs, coverage and ranking, including Project and All; no out-of-scope rows appeared.

Click-to-settled milliseconds, one accepted sample per cell; variance is unmeasured. Fresh means a new app profile, repeat closes/reopens History in the same process, and clean restart retains the saved profile while proving History did not open before the measured click. These are bounded-subset timings, not disk-cold or whole-machine measurements. Heap is Chromium renderer used JavaScript heap at settlement, not peak or whole-process memory.

Scope Open Main ms Branch ms Rows shown, both Heap MiB, main / branch
Sparse Fresh 1534.8 1493.1 39 237.1 / 254.2
Sparse Repeat 287.7 250.9 39 248.1 / 255.1
Sparse Clean restart 511.1 514.8 39 249.3 / 224.6
Dense Fresh 4434.6 3739.6 341 227.5 / 265.5
Dense Repeat 277.0 260.8 250 252.1 / 252.1
Dense Clean restart 689.2 738.1 341 260.7 / 259.4

Fresh and repeat samples were faster on the branch; neither restart sample demonstrated a speedup. These single samples do not establish statistical performance or a regression. The optional scanner benchmark has zero accepted samples.

The minute-long scan, reproduced and removed. The real history above is too small to show the slow scan, so a second run used a generated history the size of the reported one: 3,210 sessions, 10.58 GB, in each agent's real file layout with synthetic text only. Mostly Grok (2,403 sessions with 4.4 MB histories each), plus Cursor and Codex (the in-scope Codex sessions are older than the newest 250). Ten sessions belong to the selected workspace. It ran on the M4Air, main (this branch's base 4940654, same dependencies) against this head b6be62c, on the identical files, three runs per cell, from the click on History to a settled list:

Open Main runs (s) Branch runs (s) Median, main / branch
Fresh profile 46.8, 23.8, 53.5 1.0, 1.0, 1.4 46.8 s / 1.0 s
After restart 2.4, 1.6, 0.8 1.2, 0.7, 0.6 1.6 s / 0.7 s

On main the strip sat at "Reading 3,066 / 3,074 files" for most of the wait, the reported symptom. The branch settled in about a second and never showed that strip in the captured samples. All twelve opens showed the same ten sessions in the same order. Heap at settlement was 226 to 260 MiB in both builds. Fresh profile is not disk-cold (no cache purge); restart ranges overlap, so no restart speedup is claimed.

Main: stuck reading, mid-scan Main: settled Branch: scanning Branch: settled
Main reading strip mid-scan Main settled list Branch scanning strip Branch settled list

Known, pre-existing coverage gap, tracked in STA-11167 (Linear) and #30586: both builds show 341 dense Workspace sessions on a fresh open, then 250 on repeat, losing 24 Codex and 67 Claude sessions; all 341 return after restart. Project revisit similarly drops from 380 to 250, losing 57 Codex, 69 Claude and 4 Grok sessions, including the selected old Codex and Grok rows. Cache hits re-truncate with truncateAiVaultListResult, while a fresh scan combines separately limited results. This PR does not fix that gap. Its follow-up will give result selection one owner. Dense fresh-versus-repeat timings compare different result sets and cannot establish a repeat-open speedup.

Main: dense fresh, 341 rows Branch: dense fresh, 341 rows
Main dense fresh Branch dense fresh
Branch: dense repeat, 250 rows, known gap Branch: genuine old Claude detail
Branch dense repeat loses older rows Branch old Claude
Main: sparse old Grok detail Branch: sparse old Codex detail
Main old Grok Branch old Codex

The lane owner approved the existing signed-in Codex QA worker driving the isolated app directly through CDP, without copied credentials or new sign-ins. The normal internal hook listener used its approved OS-assigned port; controlled ports remained gate-assigned. Actual process arguments and isolation environment were verified on every launch. Hook-bearing real configuration hashes remained equal; other config drift was external, also observed with the rig stopped. All recorded rig processes/listeners stopped, the final corpus rehash matched, and the QA checkout is clean.

Normal tabs, row details and refresh-close-reopen were exercised. Authenticated agent resume remains unproven, Grok authentication unverified, and a live folder-workspace flow was not exercised; folder and remote compatibility have source-review evidence only. No SSH/WSL live or peak-memory claim is made.

Testing

Full review path: this changes saved cache data and scan concurrency, so the light path does not apply.

  • Historical author checks: 12 named files passed on Windows low on the first commit; five affected files passed after the file-length split.
  • Two whole-flow contracts failed on reviewed production 3e20d188c39da1cdfa707c4100ca986d2907f0b8 and passed on the repair. They cover concurrent parsed publication across eviction and pending/committed persistence, and malformed rows plus failed authoritative reads after a real SQLite restart. Six named files / 65 tests passed on Windows high; the normal commit hook passed.
  • Fresh round-2 correctness review agreed with both repairs and found no new proven defect. Current head b6be62c6472b9b21c5861f2ed5fd14c4c3ec6168 adds the duplicate-import correction and two explicit registrations so the SQLite scope tests run under Node. The runtime boundary test and both affected scope files passed again on Windows: 21 tests, with matching real-config hashes. The normal staged commit hook passed.
  • Static readiness and dedicated performance source review found no additional proven defect caused by this PR. Real Electron comparison and all sparse/dense fresh, repeat and clean-restart cells are recorded above. The full PR workflow is green on this exact head (run 39194168438, including the aggregate gate). CI is the full lint and typecheck gate. The optional scanner benchmark has zero accepted samples; its setup config drift has unverified attribution.

Review

The full review’s single status comment records the two repaired findings, real UI evidence and remaining limits. The lane owner assigned the pre-existing cached-result coverage gap to a follow-up PR and accepted exact parity with main for this PR. Readiness is checked on the exact head after the status comment is updated.

Agent skill upstream boundary

  • Not applicable; this change copies no upstream skill-installer implementation or artifacts.

Notes

  • Source validation instead of write-time updates: intended. Agent CLIs write their own histories. Orca checks source identity and companion dependencies before reusing membership information.
  • Latest valid parsed folder takes precedence: intended. An opening head can differ after a later directory change. This preserves Session History: find every agent's older sessions in Workspace and Project views #29977's policy, including after hot-cache eviction and restart.
  • Existing complex readers: intended. Antigravity still needs its multi-file join, Kimi its shared index and the other parse-only formats their current parsing. No discovery cap or agent support is removed.
  • Fewer unrelated Cline read warnings: intended. A file rejected from valid metadata is no longer opened just to discover it is unrelated. Actual attempted-read errors and host refusal feedback remain.
  • Execution-host boundaries: intended. There is no wire change. Committed-cache reuse after restart applies to Electron desktop and Electron serve. Standalone orcad, including its SSH and independent WSL route, remains memory-only as before. Windows Electron reading WSL files may use the Windows host's persistent cache. No new server persistence feature is included.

Checklist

  • The problem, user-facing result, mechanism and alternatives are described.
  • Final-head before/after screenshots and timings attached.
  • Review, platform/remote source checks and measured performance evidence recorded, with live-QA limitations and the known follow-up stated above.
  • Full PR workflow green on the final head; CI covers lint and typecheck.

@brennanb2025
brennanb2025 marked this pull request as ready for review October 19, 2026 00:54
@coderabbitai

coderabbitai Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

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: 6edc0db6-6006-4823-881d-e5a4b6520324
📥 Commits

Reviewing files that changed from the base of the PR and between 3e20d18 and 4ac699f.

📒 Files selected for processing: 8
  • src/main/ai-vault/session-parse-cache-database.ts
  • src/main/ai-vault/session-parse-cache-persistence.ts
  • src/main/ai-vault/session-parse-cache-store.ts
  • src/main/ai-vault/session-scanner-cursor-chat-meta.test.ts
  • src/main/ai-vault/session-scanner-scope-cwd-facts.test.ts
  • src/main/ai-vault/session-scanner-scope-walk.test.ts
  • src/main/ai-vault/session-scanner-scope-walk.ts
  • src/main/ai-vault/session-scope-cwds-table.ts

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

📝 Walkthrough

Session scope scans now read CWD metadata from selected agent sources and cache CWD stamps in memory and in the parse-cache database. The scan uses matching stamps to filter candidates and reads CWD when no valid stamp is available. Database persistence includes scope-CWD rows in batch reads, writes, stale-path selection, and cleanup. Parser helpers expose agent-specific CWD extraction. Tests cover scoped scanning, cache persistence, and changing Cursor metadata.

Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to 4ac69

No actionable merge-blocking issue is established. The change is mergeable after the remaining normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 38.46% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 65 functions across 17 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 summarizes the primary change: Session History avoids re-reading unrelated transcripts while finding workspace sessions.
Description check Passed The description is detailed and covers the required user impact, changes, rationale, issue reference, visual proof, testing, review notes, compatibility considerations, and checklist. The AI Disclosur…
Full details: Description check

Explanation

The description is detailed and covers the required user impact, changes, rationale, issue reference, visual proof, testing, review notes, compatibility considerations, and checklist. The AI Disclosure section is omitted, and the linked issue is referenced as STA-11097 rather than with the template's Fixes # format.

  • Fix all pre-merge checks with AI
✨ 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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3a954787-17f2-4233-9661-f3d0bb1670d1
📥 Commits

Reviewing files that changed from the base of the PR and between cf460ab and 72826b3.

📒 Files selected for processing: 16
  • src/main/ai-vault/session-parse-cache-database.ts
  • src/main/ai-vault/session-parse-cache-persistence.ts
  • src/main/ai-vault/session-parse-cache-store.ts
  • src/main/ai-vault/session-scanner-cline-parser.ts
  • src/main/ai-vault/session-scanner-cursor-chat-meta.test.ts
  • src/main/ai-vault/session-scanner-cursor-chat-meta.ts
  • src/main/ai-vault/session-scanner-graph-parsers.ts
  • src/main/ai-vault/session-scanner-grok-parser.ts
  • src/main/ai-vault/session-scanner-kiro-parser.ts
  • src/main/ai-vault/session-scanner-opencode-parser.ts
  • src/main/ai-vault/session-scanner-scope-cwd-facts.test.ts
  • src/main/ai-vault/session-scanner-scope-walk.test.ts
  • src/main/ai-vault/session-scanner-scope-walk.ts
  • src/main/ai-vault/session-scope-cwd.ts
  • src/main/ai-vault/session-scope-cwds-table.ts
  • src/main/ai-vault/session-sidecar-stat.ts
💤 Files with no reviewable changes: 1
  • src/main/ai-vault/session-scanner-scope-walk.test.ts

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

@brennanb2025

brennanb2025 commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor Author

Workspace and Project history could repeatedly read unrelated transcripts before finding older matching sessions. This PR saves validated folder answers in the existing cache and resolves membership through its current parsed results, retaining main’s ordered results while reducing repeated content reads.

Full review completed on b6be62c6472b9b21c5861f2ed5fd14c4c3ec6168: two confirmed session-hiding defects were repaired and independently re-reviewed. A parse published during a scan now wins across eviction, malformed saved records cannot discard healthy batch answers, and failed authoritative reads fall back to normal parsing. The regression contracts failed before repair; six named Windows files / 65 tests passed, then the SQLite runtime-boundary follow-up passed 21 tests. The full PR workflow and aggregate gate are green on this exact head, with no conflicts.

Real hidden Electron QA compared pinned main 51530bb86cb2f799fb5162840654c64d9ff48fb2 and this head on M4Air using the same 577-file / 1,534,151,807-byte genuine Codex, Claude and Grok subset. Every corresponding Workspace/Project/All result had identical ordered IDs, coverage and ranking. All six paired fresh/repeat/clean-restart cells, renderer heap and six image uploads are in the PR body. Samples are one per cell, with no measured variance. Sparse fresh/repeat/restart were main 1534.8/287.7/511.1 ms versus branch 1493.1/250.9/514.8 ms; dense were 4434.6/277.0/689.2 ms versus 3739.6/260.8/738.1 ms. Neither restart sample demonstrated a speedup. The optional scanner benchmark has zero accepted samples.

Known pre-existing gap, tracked in a follow-up PR: both builds lose older matching rows on cached revisits. Dense Workspace falls from 341 to 250, losing 24 Codex and 67 Claude rows; Project falls from 380 to 250, losing 57 Codex, 69 Claude and 4 Grok rows, including selected old Codex/Grok sessions. Cached results are trimmed again with a different budget from a fresh scan. The lane owner will fix result selection in a separate PR and explicitly accepted parity with main here. This PR does not fix that gap. Dense first/repeat opens show different result sets and cannot establish a repeat-open speedup.

The approved existing-sign-in Codex driver exception used direct CDP with fully isolated app homes and verified actual process arguments/environment. No credentials were copied and no sign-ins made. Critical real hook/settings hashes stayed equal; other config drift was external, also observed with the rig stopped. Final corpus integrity matched, all owned rig processes/listeners stopped, and the QA checkout is clean. Authenticated resume remains unproven, Grok authentication unverified, and a live folder-workspace flow was not exercised; folder/remote compatibility has source-review evidence only. No SSH/WSL live or peak-memory claim is made. The intended reduction in unrelated Cline read warnings remains documented; no further code was changed in this resumed loop.

For Brennan’s review:

Main dense fresh: 341 rows Branch dense fresh: 341 rows
Main dense fresh Branch dense fresh
Branch repeat: known 250-row gap Branch genuine old Claude
Branch dense repeat Branch old Claude
Main sparse: old Grok Branch sparse: old Codex
Main old Grok Branch old Codex

The judgment points are current parsed authority, membership before parsing, and malformed-row isolation.

@brennanb2025
brennanb2025 merged commit da58ee0 into main Oct 19, 2026
45 checks passed
@brennanb2025
brennanb2025 deleted the brennanb2025/scan-slow-scope-facts branch October 19, 2026 08:29
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.

3 participants