Repository navigation
fix(widget): claude-account-email respects CLAUDE_CONFIG_DIR - #339
Merged
sirmalloc merged 2 commits intoApr 27, 2026
Merged
Conversation
Closes sirmalloc#317. The widget computed the .claude.json path as ${configDir}/../.claude.json, which only happens to work when configDir is the default ~/.claude (going up one level lands at $HOME). When CLAUDE_CONFIG_DIR points elsewhere (e.g. ~/.claude-work), the same .. heuristic still lands at $HOME, so all profiles read the same .claude.json and display the same account email — the symptom reported in the issue. Fix: branch the path resolution on whether CLAUDE_CONFIG_DIR is set. Claude Code stores .claude.json inside CLAUDE_CONFIG_DIR when that env var is set, otherwise it lives at ~/.claude.json. Also tightened the surrounding code while in the area: - Drop redundant existsSync check (readFileSync ENOENT is already caught) - Drop redundant path.resolve on already-absolute paths - Tighten email field check from truthy (!email) to typeof+length, so a non-string oauthAccount.emailAddress can't render as Account: 12345 New tests cover: - $CLAUDE_CONFIG_DIR/.claude.json is read when env var is set (regression) - $HOME/.claude.json is NOT silently read when CLAUDE_CONFIG_DIR points to a dir without one (no profile leak) - Non-string emailAddress returns null (typeof guard)
…laudeSettingsPath and getClaudeConfigDir
Owner
|
Thanks. I made one small tweak the centralize the logic to grab the json path in case we need to use it outside that widget in the future. |
tahodev
pushed a commit
to tahodev/ccstatusline
that referenced
this pull request
Oct 20, 2026
…oc#339) * fix(widget): claude-account-email respects CLAUDE_CONFIG_DIR Closes sirmalloc#317. The widget computed the .claude.json path as ${configDir}/../.claude.json, which only happens to work when configDir is the default ~/.claude (going up one level lands at $HOME). When CLAUDE_CONFIG_DIR points elsewhere (e.g. ~/.claude-work), the same .. heuristic still lands at $HOME, so all profiles read the same .claude.json and display the same account email — the symptom reported in the issue. Fix: branch the path resolution on whether CLAUDE_CONFIG_DIR is set. Claude Code stores .claude.json inside CLAUDE_CONFIG_DIR when that env var is set, otherwise it lives at ~/.claude.json. Also tightened the surrounding code while in the area: - Drop redundant existsSync check (readFileSync ENOENT is already caught) - Drop redundant path.resolve on already-absolute paths - Tighten email field check from truthy (!email) to typeof+length, so a non-string oauthAccount.emailAddress can't render as Account: 12345 New tests cover: - $CLAUDE_CONFIG_DIR/.claude.json is read when env var is set (regression) - $HOME/.claude.json is NOT silently read when CLAUDE_CONFIG_DIR points to a dir without one (no profile leak) - Non-string emailAddress returns null (typeof guard) * chore: Centralize implementation of getClaudeJsonPath similar to getClaudeSettingsPath and getClaudeConfigDir --------- Co-authored-by: Matthew Breedlove <sirmalloc@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #317.
The widget reads the same
.claude.jsonno matter whatCLAUDE_CONFIG_DIRis set to, so every profile ends up showing the same account email.The path was built like this:
That works for the default
~/.claudeconfig dir, since going up one level lands at$HOMEwhere.claude.jsonactually lives. But when someone setsCLAUDE_CONFIG_DIR=~/.claude-work, the..still lands at$HOME, so every profile keeps reading the same file.The reason it's not a simple fix:
.claude.jsonlives at$HOMEby default, but Claude Code moves it insideCLAUDE_CONFIG_DIRwhen that env var is set. The path needs to branch on whether the env var is there:A few small extra changes I made in the same render method:
existsSynccheck beforereadFileSync. The outer try/catch already handles missing files, and dropping the check also closes a small race window between the two calls.path.resolveon a path that was already absolute.if (!email)totypeof email === 'string' && email.length > 0. The old check would let a non-stringemailAddressfield through, so{"emailAddress": 12345}would have rendered asAccount: 12345.Tests
Three new tests:
$CLAUDE_CONFIG_DIR/.claude.jsonwhen the env var is set. This is the regression test.CLAUDE_CONFIG_DIRpoints at a directory with no.claude.json, even if$HOME/.claude.jsonexists. Guards against the old fallback coming back.emailAddressreturns null.All existing tests still pass.
bun run lint,bun test, andbun run buildare all clean.@daren-porter — if you have a minute, could you check this against your work/personal alias setup? The new tests mirror what you described in the issue, but a real-world confirmation would help.