Skip to content

fix(ai-vault): resume Claude sessions from their start directory - #9499

Merged
nwparker merged 1 commit into
stablyai:mainfrom
choihjin:fix/claude-resume-start-cwd
Jul 24, 2026
Merged

nwparker merged 1 commit into
stablyai:mainfrom
choihjin:fix/claude-resume-start-cwd

Conversation

@choihjin

@choihjin choihjin commented Jul 20, 2026 •

Copy link
Copy Markdown
Contributor

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) and src/main/ai-vault/session-scanner-claude-cwd-drift.test.ts (test).
  • Test session-scanner-claude-cwd-drift.test.ts passes 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: oxlint on 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.

@coderabbitai

coderabbitai Bot commented Jul 20, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 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.

❤️ Share

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

The AI Vault session scanner recorded a session's cwd by overwriting it with
every transcript record that carried one, so a session that changed working
directory mid-run ended up with its last-seen cwd. That value drives the resume
command (cd <cwd> && claude --resume <id>) and the history panel's grouping and
filtering.

For Claude this breaks resume: transcripts live under
~/.claude/projects/<slug-of-start-dir>/, and claude --resume <id> only searches
the project dir derived from the current cwd, so resuming from the drifted cwd
fails with "No conversation found". Capture the first-seen (start) cwd instead,
which transcripts write up front; this fixes resume, grouping, and filtering at
once. updateLatestLocation is only used by the Claude parser, so no other agent
is affected.

Fixes stablyai#9361
@nwparker
nwparker force-pushed the fix/claude-resume-start-cwd branch from 6072665 to e8033a8 Compare July 23, 2026 11:49
@nwparker
nwparker merged commit cb19e79 into stablyai:main Jul 24, 2026
@nwparker

Copy link
Copy Markdown
Contributor

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! 🙏

enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…blyai#9499)

The AI Vault session scanner recorded a session's cwd by overwriting it with
every transcript record that carried one, so a session that changed working
directory mid-run ended up with its last-seen cwd. That value drives the resume
command (cd <cwd> && claude --resume <id>) and the history panel's grouping and
filtering.

For Claude this breaks resume: transcripts live under
~/.claude/projects/<slug-of-start-dir>/, and claude --resume <id> only searches
the project dir derived from the current cwd, so resuming from the drifted cwd
fails with "No conversation found". Capture the first-seen (start) cwd instead,
which transcripts write up front; this fixes resume, grouping, and filtering at
once. updateLatestLocation is only used by the Claude parser, so no other agent
is affected.

Fixes stablyai#9361
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