Skip to content

Scope usage per CLAUDE_CONFIG_DIR, includin authentication#266

Open
davidmgvaz wants to merge 1 commit intosirmalloc:mainfrom
davidmgvaz:main
Open

Scope usage per CLAUDE_CONFIG_DIR, includin authentication#266
davidmgvaz wants to merge 1 commit intosirmalloc:mainfrom
davidmgvaz:main

Conversation

@davidmgvaz
Copy link
Copy Markdown

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.

…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.
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