Repository navigation
fix(accounts): an account-switch restart resumes Claude in the folder it was started in - #33659
Conversation
… it was started in The restart built 'claude --resume <id>' without the spawn folder, so #33527's recorded-cwd prefix never applied and a 'cd pkg && claude' session came back in the tab's start folder. Refs #31545 Co-authored-by: asunghong <[email protected]>
Walkthrough
Priority: Merge Risk:
|
There was a problem hiding this comment.
Actionable comments posted: 1

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:
05ec0049-adf9-4a7c-a52d-48d2be6b093c
Files selected for processing: 2-
src/renderer/src/lib/agent-account-restart-startup.test.tssrc/renderer/src/lib/agent-account-restart-startup.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
-
| shell: resumeTarget.shell, | ||
| // Both restart executors spawn in the tab's start folder. | ||
| launchCwd: | ||
| state.tabsByWorktree[args.worktreeId]?.find((tab) => tab.id === args.tabId)?.startupCwd ?? | ||
| worktree?.path |
There was a problem hiding this comment.
Restrict launchCwd to providers that require the original folder.
The account-restart resolver now supplies launchCwd for Codex sessions. The shared builder therefore prefixes the resume command with cd <recorded cwd>. If that recorded directory no longer exists, cd fails and Codex never receives the resume command. Codex can resume from any folder, so preserve its previous command behavior and apply launchCwd only to providers that require it.
ELI5
If you start Claude from a sub-folder (
cd pkg && claude) and then switch Claude accounts, Orca restarts the session withclaude --resume <id>. That ran in the tab's start folder, so Claude carried on in the wrong folder: it asked to trust the folder and ran without that folder'sCLAUDE.mdand hooks. Now the restart runscd pkg && claude --resume <id>, the same way cold restore and sleep wake already do since #33527.Root cause
providerSession.cwd).buildAgentResumeStartupPlanaddscd <cwd> &&only when the caller passeslaunchCwd, the folder the resume shell starts in (src/shared/tui-agent-resume-startup.ts).resolveAgentAccountRestartResumeStartup) did not, so the recorded folder was ignored.HOME/CLAUDE_CONFIG_DIR):claude --resume <id>resumes from the current folder whatever folder the session started in. SessionStart reportssource: resume, cwd: <current folder>, and a new project bucket is created for it.What changed
agent-account-restart-startup.ts: passlaunchCwd= the tab'sstartupCwd, else the worktree path. That is the folder both restart executors spawn in (TerminalOverlaySlotcwd={startupCwd ?? worktreePath}for mounted panes,codex-detached-pane-restart.tsfor unmounted ones). A session started in that folder still gets the same bare command as before.How verified
main(claude '--resume' '<id>') and passes here (cd '/repo/pkg' && claude '--resume' '<id>'). The account-restart, detached/mounted restart executor and session-move suites pass (51 tests).pnpm tcandcheck:code-quality:changedpass.proj/pkg, then resumed fromproj:claude -p again --resume <id>(main's command): SessionStartresumewithcwd=/…/proj, plus a new-…-projproject bucket.cd '/…/proj/pkg' && claude -p again --resume <id>(this PR's command): SessionStartresumewithcwd=/…/proj/pkg.cds (raw PTY capture, 0 sequences). The terminal's tracked folder follows the shell, not the agent.Risk / scope
cmd/PowerShell quoting and WSL UNC comparison come from fix(agents): resume an agent from the folder it ran in, not the pane's start folder #33527.cwdand keep today's behaviour./effortis saved in each managed profile's own copiedsettings.json, so carrying it over needs a product decision.Refs #31545. Supersedes the folder-matching part of #32033 by @asunghong. That PR derives the folder from the transcript bucket name; #33527 now records it directly from hooks.
Co-authored-by: asunghong [email protected]