Skip to content

fix(statusline): respect CLAUDE_CONFIG_DIR for active account detection - #7

Open
haddowg wants to merge 1 commit into
dr5hn:mainfrom
haddowg:fix/statusline-respect-claude-config-dir
Open

fix(statusline): respect CLAUDE_CONFIG_DIR for active account detection#7
haddowg wants to merge 1 commit into
dr5hn:mainfrom
haddowg:fix/statusline-respect-claude-config-dir

Conversation

@haddowg

@haddowg haddowg commented Jul 8, 2026

Copy link
Copy Markdown

Summary

When a Claude Code session runs inside an isolated profile (ccm switch --isolated <account>), the statusline's account line showed the globally-active account instead of the profile actually in use.

The root cause is in the statusline script generated by cmd_statusline. It resolves the account by reading oauthAccount.emailAddress from a hardcoded global path:

CONF="$HOME/.claude/.claude.json"
[[ -f "$CONF" ]] || CONF="$HOME/.claude.json"

Isolated profiles keep their own .claude.json under $CLAUDE_CONFIG_DIR, so this read always returned whatever account was last globally active — not the one bound to the running session. The CLAUDE_CODE_USER_EMAIL fast path would mask this, but it isn't always present, and the fallback then silently reports the wrong account.

The fix makes the generated statusline prefer $CLAUDE_CONFIG_DIR/.claude.json when CLAUDE_CONFIG_DIR is set, falling back to the previous global paths otherwise. This mirrors how isolated profiles are meant to be resolved and leaves non-isolated sessions completely unchanged. The CLAUDE_CODE_USER_EMAIL env-var fast path is untouched.

A CHANGELOG.md entry is included under ## [Unreleased].

Test plan

Verified by extracting the generated statusline from the modified ccm.sh and running it against a synthetic environment with a global config (account work) and an isolated profile config (account personal):

  • With CLAUDE_CONFIG_DIR pointing at the profile → account line shows personal
  • Without CLAUDE_CONFIG_DIR (global session) → account line still shows work (fallback unchanged, no regression)
  • bash -n passes on both ccm.sh and the generated statusline script

The statusline resolved the current account by reading
oauthAccount.emailAddress from ~/.claude/.claude.json (or ~/.claude.json)
unconditionally. Inside an isolated profile (ccm switch --isolated), the
active account lives in $CLAUDE_CONFIG_DIR/.claude.json, so the statusline
showed whatever account was globally active rather than the profile in use.

Prefer $CLAUDE_CONFIG_DIR/.claude.json when CLAUDE_CONFIG_DIR is set,
falling back to the previous global paths otherwise. The
CLAUDE_CODE_USER_EMAIL env-var fast path is unchanged.
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.

1 participant