Repository navigation
fix(sessions): default-account resume command clears an inherited CLAUDE_CONFIG_DIR - #173
Conversation
The default account's resume command was `command claude --resume <id>`, which keeps whatever CLAUDE_CONFIG_DIR the shell has. Inside another account's Claude Code session (its shell tool, a `!` command, an agent running `codev session resume`) that is the other account's folder, and Claude Code answered "No conversation found with session ID". The anchor's command is now `env -u CLAUDE_CONFIG_DIR claude --resume <id>`, the form the generated `claude` launcher and the account picker already use for the anchor. `env` runs the binary from PATH, so the dispatcher function is still skipped. Setting `~/.claude` explicitly was not used: it is not the same login (design doc section 3.4). Commands for other accounts are unchanged. Adds a test that runs `codev session resume` through the generated `codev()` shell function in zsh and bash with another account's CLAUDE_CONFIG_DIR exported, checking what a stub `claude` receives. Refs #172. Bumps to 1.0.98. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
There was a problem hiding this comment.
All reported issues were addressed across 7 files
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
Review round 1 on #173: the node showed a bare claude --resume, which neither form is. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Fixes #172.
What
The resume command CodeV builds for a session of the default (anchor) account now clears
CLAUDE_CONFIG_DIRfor that one process:cd '<project>' && command claude --resume <id>cd '<project>' && env -u CLAUDE_CONFIG_DIR claude --resume <id>cd '<project>' && CLAUDE_CONFIG_DIR='<dir>' command claude --resume <id>Why
The old default-account command set nothing, so it used whatever the shell had. In a shell that already has another account's
CLAUDE_CONFIG_DIR— most often a shell inside that account's Claude Code session, wherecodev session resumeor a pasted "Copy resume command" is run — Claude Code looked for the session under the other account and printedNo conversation found with session ID: …. The command format is older than thecodev sessionCLI (1.0.96), but the CLI made the case easy to reach.Why this form
env -u CLAUDE_CONFIG_DIR claudefor the default account through the same terminal code (iTerm2, Terminal.app, Ghostty, cmux), and the generatedclaudeshell function launches the default account the same way.envruns the binary fromPATH, so it skips theclaudeshell function just ascommand claudedid. The account is already decided; the function must not re-route it.$or backtick, so the places that paste it into an AppleScript string or a/bin/shdouble-quoted argument need no new escaping.CLAUDE_CONFIG_DIR='<home>/.claude': the multi-account design doc (§3.4) records that Claude Code then reads a different state file and shows the account as logged out. The default account is "variable unset", so the command unsets it.The change is one function (
formatResumeCommandinsrc/cli/session-identity.ts). Everything that shows or runs a resume command goes through it: the four terminal launchers, the copy action, the copy menu and details view,codev session show/self/resume, and the saved-list bulk open.One behaviour to know: when the account of a session is unknown (it is in no account's history and no label was passed), the command used to inherit the shell's value and now always targets the default account. Inside the app this changes nothing, because the app's environment has no such variable.
Verification
npx tsc --noEmit: 0 errors.yarn test: 18 files, 387 tests pass.New end-to-end test of the shell path, in zsh and in bash: the real CLI output, the real generated
accounts.sh,codev session resume <id>run in a shell that exports another account'sCLAUDE_CONFIG_DIR, with a stubclaudeonPATHthat records what it sees. The default-account session must reach the stub with the variable unset; a session of another account must reach it with that account's folder. The registry's global default is a third account, so a command that wrongly went through theclaudefunction would be caught too.Mutation check: restoring the old command turns 7 tests red (the shell tests receive the inherited value — the bug); sending the default account through a bare
claudeturns the two shell tests red.On one machine with two logged-in accounts, in a shell that exports the second account's folder:
command claude auth statusreported the second account (the old form's behaviour),env -u CLAUDE_CONFIG_DIR claude auth statusreported the default account, and the calling shell still had its variable afterwards. Before the change, the old command with a default-account session id printedNo conversation found with session ID: …there.Tested by hand on a packaged build of this branch (
yarn make, 1.0.98):env -u CLAUDE_CONFIG_DIR claude --resume <id>, and the resumed session's status showed the default account;codev session showwas run with-pappended (a non-interactive resume): it found the session and answered;CLAUDE_CONFIG_DIR: it resumed the session.Not verified:
VAR=valueprefix, which fish handles more easily than the old one.claudeshim first onPATH;env … claudereaches it the same waycommand claudedid, and the variable stays unset through it. That is reasoned from the code and from the new-session launcher's existing use of the same form, not run.Version 1.0.98, with a CHANGELOG entry and the design doc's command description updated.
🤖 Generated with Claude Code