Scope usage per CLAUDE_CONFIG_DIR, includin authentication#266
Open
davidmgvaz wants to merge 1 commit intosirmalloc:mainfrom
Open
Scope usage per CLAUDE_CONFIG_DIR, includin authentication#266davidmgvaz wants to merge 1 commit intosirmalloc:mainfrom
davidmgvaz wants to merge 1 commit intosirmalloc:mainfrom
Conversation
…g token authentication
The usage cache (usage.json) and lock file (usage.lock) were shared
across all Claude Code profiles, causing session-usage, weekly-usage,
reset-timer, and weekly-reset-timer widgets to display data from the
wrong account when CLAUDE_CONFIG_DIR pointed to a non-default profile.
Replace the hardcoded file paths with per-profile paths using a
SHA-256 hash of the resolved CLAUDE_CONFIG_DIR, matching the existing
pattern used by getBlockCachePath() in jsonl-cache.ts.
Claude Code stores per-profile credentials in the macOS keychain using the service
name Claude Code-credentials-{sha256(configDir)[:8]}. For ~/.claude-boost, that's
Claude Code-credentials-ac4e02fa. The old code never looked up this specific entry —
it only tried the generic Claude Code-credentials service, then sorted all candidates by mtime.
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.
This pull request updates the usage tracking logic to support multiple configuration profiles by scoping the usage cache and lock files to the current config directory. It also improves the logic for retrieving API credentials, especially on macOS, by first checking for a config-directory-specific keychain entry. The test suite has been updated to reflect these changes and add coverage for the new fallback behavior.
The usage cache (usage.json) and lock file (usage.lock) were shared
across all Claude Code profiles, causing session-usage, weekly-usage,
reset-timer and weekly-reset-timer widgets to display data from the
wrong account when CLAUDE_CONFIG_DIR pointed to a non-default profile.
Replace the hardcoded file paths with per-profile paths using a
SHA-256 hash of the resolved CLAUDE_CONFIG_DIR, matching the existing
pattern used by getBlockCachePath() in jsonl-cache.ts.
Claude Code stores per-profile credentials in the macOS keychain using the service
name Claude Code-credentials-{sha256(configDir)[:8]}. For ~/.claude-boost, that's
Claude Code-credentials-ac4e02fa. The old code never looked up this specific entry —
it only tried the generic Claude Code-credentials service, then sorted all candidates by mtime.