Skip to content

A named Claude login reads its own token; the CLI's estimate stays with the only login - #324

Merged
vinzdg merged 1 commit into
vinzdg:mainfrom
rafaelbarea:pr/named-claude-logins-read-their-own-token
Sep 23, 2026
Merged

vinzdg merged 1 commit into
vinzdg:mainfrom
rafaelbarea:pr/named-claude-logins-read-their-own-token

Conversation

@rafaelbarea

Copy link
Copy Markdown
Contributor

What

On a Mac with two Claude logins (~/.claude and a second CLAUDE_CONFIG_DIR), both rings showed the same percentage.

claude /usage in print mode answers for the whole machine, whatever CLAUDE_CONFIG_DIR is set to. Verified: identical output, requests and sessions included, for both directories. Its estimate is "based on local sessions on this machine", all of them, so it can only stand in for a ring while there is one login for it to describe.

  • ClaudeOAuthProvider.cliEstimateApplies(slug:loginCount:): the CLI path is taken only for the default login, and only while it is the sole one.
  • Named profiles, and the default profile once a second one exists, read their own token over the OAuth usage endpoint, as they did before the CLI path was added.
  • The login count is fixed at one under test so the existing CLI stubs stay reachable on any host.

Tests

  • ClaudeCLIEstimateScopeTests: only login may use the estimate; a named profile never does; the default login stops once a second exists.
  • make test: 1737 tests, 0 failures.

Related to #321, which handles the other half of the two-login problem (desktop sessions landing on the wrong ring); the two do not overlap in code.

🤖 Generated with Claude Code

…th the only login

`claude /usage` in print mode gives one answer for the whole machine
whatever CLAUDE_CONFIG_DIR says (verified: identical output, requests and
sessions included, for ~/.claude and a second config directory). With two
logins on a Mac it painted both rings with the same figure.

The estimate is now taken only for the default login, and only while it is
the sole one. Named profiles, and the default profile once a second one
exists, read their own token over the OAuth usage endpoint as before the
CLI path was added. The rule is a pure function so it has a test; the
login count itself is fixed at one under test so the CLI stubs stay
reachable whatever the host Mac has.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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.

2 participants