feat: Add per-account usage caching, session affinity, and account email widget#219
Open
carterross wants to merge 1 commit intosirmalloc:mainfrom
Open
feat: Add per-account usage caching, session affinity, and account email widget#219carterross wants to merge 1 commit intosirmalloc:mainfrom
carterross wants to merge 1 commit intosirmalloc:mainfrom
Conversation
…ail widget
Adds multi-account support so each Claude Code session displays the
correct usage stats and account email, even when multiple sessions
are logged into different accounts simultaneously.
Changes:
- Per-token cache files (usage-{hash}.json, profile-{hash}.json)
instead of a single global cache, preventing cross-account data bleed
- Session affinity (session-tokens.json) pins each session to its
starting account; smart conflict resolution detects in-session /login
vs cross-session account switches
- Shared OAuth credential module (credentials.ts) with macOS keychain
discovery for Claude Code v2.x suffixed entries, using execFileSync
to avoid shell injection
- New account-email widget showing the current account's email address
- Profile API integration (/api/oauth/profile) with 24-hour caching
Co-Authored-By: Claude Opus 4.6 <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.
Summary
Adds multi-account support so each Claude Code session displays the correct usage stats and account email, even when multiple sessions are logged into different accounts simultaneously.
usage-{hash}.json,profile-{hash}.json) instead of a single global cache, preventing cross-account data bleed/loginvs cross-session account switchescredentials.ts) with macOS keychain discovery for Claude Code v2.x suffixed entriesaccount-emailwidget showing the current account's email address via/api/oauth/profilewith 24-hour cachingMotivation
When switching between multiple Anthropic accounts (e.g. personal and work), the status line would show whichever account's data was fetched last — even in sessions logged into a different account. This made usage stats unreliable for users with multiple accounts.
Changes
credentials.ts(new)session-affinity.ts(new)/logindetectionprofile-fetch.ts(new)profile-prefetch.ts(new)AccountEmail.ts(new)usage-fetch.tsusage-prefetch.tsccstatusline.tsRenderContext.tsprofileDatafieldwidget-manifest.tsaccount-emailwidgetwidgets/index.tsAccountEmailWidgetusage-fetch.test.tsTest plan
account-emailwidget and verify email displays/loginwithin a session — verify it updates to the new account🤖 Generated with Claude Code