Skip to content

fix(sessions): default-account resume command clears an inherited CLAUDE_CONFIG_DIR - #173

Merged
grimmerk merged 2 commits into
mainfrom
fix-anchor-resume-config-dir
Nov 20, 2026
Merged

grimmerk merged 2 commits into
mainfrom
fix-anchor-resume-config-dir

Conversation

@grimmerk

@grimmerk grimmerk commented Nov 20, 2026 •

Copy link
Copy Markdown
Owner

Fixes #172.

What

The resume command CodeV builds for a session of the default (anchor) account now clears CLAUDE_CONFIG_DIR for that one process:

Session belongs to Before After
default account cd '<project>' && command claude --resume <id> cd '<project>' && env -u CLAUDE_CONFIG_DIR claude --resume <id>
another account cd '<project>' && CLAUDE_CONFIG_DIR='<dir>' command claude --resume <id> unchanged

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, where codev session resume or a pasted "Copy resume command" is run — Claude Code looked for the session under the other account and printed No conversation found with session ID: …. The command format is older than the codev session CLI (1.0.96), but the CLI made the case easy to reach.

Why this form

  • It is already in use on the same paths. The new-session launcher sends env -u CLAUDE_CONFIG_DIR claude for the default account through the same terminal code (iTerm2, Terminal.app, Ghostty, cmux), and the generated claude shell function launches the default account the same way.
  • env runs the binary from PATH, so it skips the claude shell function just as command claude did. The account is already decided; the function must not re-route it.
  • The new string adds no quote, backslash, $ or backtick, so the places that paste it into an AppleScript string or a /bin/sh double-quoted argument need no new escaping.
  • Not an explicit 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.
  • Not a warning in the CLI only: a pasted command would still fail.

The change is one function (formatResumeCommand in src/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's CLAUDE_CONFIG_DIR, with a stub claude on PATH that 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 the claude function 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 claude turns 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 status reported the second account (the old form's behaviour), env -u CLAUDE_CONFIG_DIR claude auth status reported the default account, and the calling shell still had its variable afterwards. Before the change, the old command with a default-account session id printed No conversation found with session ID: … there.

  • Tested by hand on a packaged build of this branch (yarn make, 1.0.98):

    • a default-account session resumed from the Sessions tab into Ghostty: the command typed was env -u CLAUDE_CONFIG_DIR claude --resume <id>, and the resumed session's status showed the default account;
    • the issue's own scenario: inside a Claude Code session of the other account, the default-account command from codev session show was run with -p appended (a non-interactive resume): it found the session and answered;
    • the command from "Copy resume command" for a default-account session, pasted into a shell that exports the other account's CLAUDE_CONFIG_DIR: it resumed the session.

Not verified:

  • A real resume through iTerm2, Terminal.app and cmux (Ghostty was run), and a resume of another account's session from the Sessions tab on this build (that command's form is unchanged).
  • fish (not installed here). The new form has no VAR=value prefix, which fish handles more easily than the old one.
  • cmux puts its own claude shim first on PATH; env … claude reaches it the same way command claude did, 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

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>
@coderabbitai

coderabbitai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Anchor-account resume commands now remove an inherited CLAUDE_CONFIG_DIR before invoking claude. Non-anchor commands continue to set the selected account’s directory. Tests cover both account types under bash and zsh.

Changes: Session resume command

Layer / File(s) Summary
Anchor and non-anchor command handling
src/cli/session-identity.ts, docs/claude-session-integration-design.md, src/claude-session-utility.ts, CHANGELOG.md, package.json
Anchor resume commands use env -u CLAUDE_CONFIG_DIR; non-anchor commands continue to set the selected account’s directory. The integration documentation and changelog describe this behavior, and the package version changes to 1.0.98.
Resume command tests
src/cli/session-identity.test.ts, src/cli/codev-session.test.ts
Tests check that anchor commands clear an inherited setting and preserve the project path and resume arguments. Shell integration tests cover anchor and non-anchor sessions under bash and zsh.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Low

Possibly related PRs

  • grimmerk/codev#171: Introduced the shared session identity resolver that builds the resume command updated here.
Merge Risk: Minimal · up to 661c6

Default-account sessions now resume correctly even when the shell has another account's CLAUDE_CONFIG_DIR set. Commands for other accounts are unchanged, and the new shell-level tests cover the behavior. No actionable merge-blocking risk remains.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: the default-account resume command now clears an inherited CLAUDE_CONFIG_DIR. The raw summary and PR objectives confirm that formatResumeCommand changes from command c…
Linked Issues check Passed Directly linked issue #172 requires that an anchor-account resume command resume the anchor session when the shell already exports another account's CLAUDE_CONFIG_DIR. The PR implements option A from …
Out of Scope Changes check Passed The changes fall within the scope of #172. Changes are: the formatResumeCommand anchor branch; comment updates in src/claude-session-utility.ts that describe the same account handling with no executab…
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Full details: Title check

Explanation

The title names the main change: the default-account resume command now clears an inherited CLAUDE_CONFIG_DIR. The raw summary and PR objectives confirm that formatResumeCommand changes from command claude to env -u CLAUDE_CONFIG_DIR claude for the default account. The title is specific and matches the changeset. The fix(sessions) prefix is a conventional commit style and does not affect the assessment.

Full details: Linked Issues check

Explanation

Directly linked issue #172 requires that an anchor-account resume command resume the anchor session when the shell already exports another account's CLAUDE_CONFIG_DIR. The PR implements option A from the issue. formatResumeCommand in src/cli/session-identity.ts now builds cd '&lt;project&gt;' &amp;&amp; env -u CLAUDE_CONFIG_DIR claude --resume &lt;id&gt; for anchor sessions. Non-anchor sessions keep CLAUDE_CONFIG_DIR='&lt;dir&gt;' command claude --resume &lt;id&gt;. Per the PR summary, every launcher, the copy action, and the CLI paths call this one function, so one change covers the terminal injection paths named in the issue. The issue's unit-test requirement is covered by the updated session-identity.test.ts expectations and the new shell-level zsh and bash tests in codev-session.test.ts. These tests run the generated shell function with an inherited CLAUDE_CONFIG_DIR and check that the stub claude sees the variable unset for anchor sessions. The issue's manual launcher runs and the reported live two-account check are non-coding verification and are not counted. Limitation: the function body was not read directly. The diff blob was unavailable and the file read was truncated before formatResumeCommand. The verdict relies on the PR summary, the AI-generated summary, and the test descriptions, which agree with each other.

Full details: Out of Scope Changes check

Explanation

The changes fall within the scope of #172. Changes are: the formatResumeCommand anchor branch; comment updates in src/claude-session-utility.ts that describe the same account handling with no executable change; test updates and new shell tests in src/cli/codev-session.test.ts and src/cli/session-identity.test.ts that check the fixed behavior; a design-doc update in docs/claude-session-integration-design.md that records the new command form; a CHANGELOG entry; and a package.json version bump to 1.0.98. The CHANGELOG, design-doc, and version bump are release and documentation items tied to this fix, and the PR description states them as such. The behavior change for sessions of unknown account (now targeting the default account) follows from the same formatResumeCommand change and is disclosed in the PR description. No unrelated functional change was identified in the available evidence.

Finishing Touches

Generate unit tests (beta)

  • 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

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3088d78f-ff91-4fa1-9dfd-8473570a5004
Commits

Reviewing files that changed from the base of the PR and between 7b9e9e4 and 661c614.

Files selected for processing: 7

  • CHANGELOG.md
  • docs/claude-session-integration-design.md
  • package.json
  • src/claude-session-utility.ts
  • src/cli/codev-session.test.ts
  • src/cli/session-identity.test.ts
  • src/cli/session-identity.ts

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

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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>
@grimmerk
grimmerk merged commit d50918e into main Nov 20, 2026
3 checks passed
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.

Resume command for the default account fails in a shell that already has CLAUDE_CONFIG_DIR set

1 participant