fix(ai-vault): resume Claude sessions from their start directory
Summary
Resuming a Claude session that changed directories mid-run no longer fails with "No conversation found" — sessions now resume from their original start directory.
ELI5
If you started a chat in one folder and later moved into a subfolder, the "resume" button used to point at the wrong folder and couldn't find your conversation. Now it always remembers where you began, so resume just works.
Root cause & fix
The AI Vault session scanner recorded each session's cwd by overwriting it with every transcript record, so a session that drifted into a subdirectory ended up with its last-seen cwd. Claude stores transcripts under ~/.claude/projects/<slug-of-start-dir>/ and claude --resume <id> only searches the project dir derived from the current cwd, so the rebuilt cd '<subdir>' && claude --resume <id> ran from the wrong place and failed. The fix captures the first-seen (start) cwd instead — transcripts are append-only and write the cwd up front, so the first record carrying one is the true start directory. This is fixed at the accumulator, the single source of session.cwd, repairing resume, folder grouping, and workspace filtering at once.
Evidence
Validated & rebased onto latest main during a bug-bash triage on 2026-07-23.
- Rebase clean; single commit touching only
src/main/ai-vault/session-scanner-accumulator.ts(fix) andsrc/main/ai-vault/session-scanner-claude-cwd-drift.test.ts(test). - Test
session-scanner-claude-cwd-drift.test.tspasses on branch: Test Files 1 passed (1); Tests 1 passed (1). - Reverting only the fix file (keeping the test) makes it fail, proving the test captures the bug:
expected cwd "/repo/app/services/api" to match "/repo/app"
expected resumeCommand
"cd '/repo/app/services/api' && claude --resume 'drift-session'"
to match "cd '/repo/app' && claude --resume 'drift-session'"
- Lint clean:
oxlinton the fix file reported no warnings or errors.
Trade-offs
None — pure fix.
Regression risk
Zero-regression: updateLatestLocation is called only by the Claude parser, so no other agent's behavior changes. The branch still tracks the latest location for its own use; only the persisted session.cwd derivation changes. Non-affected paths are byte-identical, and correctness is proven by the passing test plus the fail-on-revert assertion.
Credit to original author @choihjin (Gideon). Validated, rebased, and (where applicable) hardened via automated bug-bash review; original fix design preserved.
📝 Walkthrough
Walkthrough
The session accumulator now sets cwd only from the first eligible record, while retaining timestamp ordering checks and later branch updates. A regression test adds a Claude transcript with changing directories and verifies that scanning preserves the initial directory and generates a resume command that changes to it before invoking Claude.
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Description check | ⚠️ Warning | The description explains the bug and fix well, but it omits required template sections like Screenshots, Testing checklist, AI Review Report, Security Audit, and Notes. | Add the missing template sections, including Screenshots, explicit Testing items, an AI Review Report, a Security Audit, and Notes. |
✅ Passed checks (4 passed)
| Check name | Status | Explanation |
|---|---|---|
| Docstring Coverage | ✅ Passed | No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. |
| 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 main fix: Claude sessions now resume from their start directory. |
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.
Comment @coderabbitai help to get the list of available commands.
Thanks so much for this, @choihjin — resume Claude sessions from their start directory. Verified (fail-on-main/pass-on-branch), rebased on latest main, reviewed, and merged. Really appreciate it! 🙏