Repository navigation
fix: refresh quota when the Claude account is switched (#45) - #47
Merged
Merged
Conversation
The OAuth credentials were cached in memory and only re-read when the token expired. A switched-in account has a *valid* token, so that path never fired and the quota stayed on the previous account's numbers until a window reload. Re-read the credentials (file or macOS Keychain) on every quota fetch, and watch ~/.claude/.credentials.json so the switch is reflected promptly rather than after a full cache interval. The status-bar usage token counts come from a shared local folder and were never affected. Closes #45 Co-Authored-By: Claude <noreply@anthropic.com>
Carl723000
added a commit
to henrique-carvalho-dev/ClaudeCodeUsage
that referenced
this pull request
Jun 30, 2026
Brings in ClaudeCodeUsage#43 (session actions + clean quota), ClaudeCodeUsage#46 (pricing), ClaudeCodeUsage#47 (account-switch fix). Adds the pt-BR translations for the session-row action strings ClaudeCodeUsage#43 introduced (copy id / copy path / resume / delete + filters) so the pt-BR locale stays complete. Co-Authored-By: Claude <noreply@anthropic.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.
What
Fixes #45 — after switching Claude accounts the status bar stayed on the previous account's quota until a
Developer: Reload Window.Root cause
ClaudeApiClient.getValidCredentials()cached the OAuth credentials in memory and only re-read them from disk when the token expired. A switched-in account has a valid (non-expired) token, so that path never fired — the client kept calling/usagewith the old account's token.Fix
~/.claude/.credentials.jsonand expire the cached quota on change, so the switch is reflected within a refresh tick instead of after a full cache interval (≤120 s). Keychain-stored credentials (macOS) have no file to watch — those self-correct on the next tick.Local usage token counts come from a shared local folder and were never affected — this only touches the account-level quota panel.
Notes
fs.watchpattern (projects-dir watcher) with disposal indispose()./usageendpoint when the cache is force-expired.tscclean;node --testgreen (11/11).🤖 Generated with Claude Code