[Bug]: Orca's Claude account and usage state is wrong when Claude Code signs in with `CLAUDE_CODE_OAUTH_TOKEN`
Where were you using Orca?
Desktop only
Operating system
Windows
Remote host operating system
No response
Orca version
v1.4.262
Details
Short summary:
Orca only knows the sign-in stored in an account folder's .credentials.json. When Claude Code signs in with CLAUDE_CODE_OAUTH_TOKEN (the long-lived token from claude setup-token, documented at https://code.claude.com/docs/en/authentication#generate-a-long-lived-token), Orca shows a wrong usage state for that sign-in, and selecting a managed account silently stops deciding which account requests go to. Claude Code itself works fine in both cases; it is Orca's view of the account that is wrong.
What happened?
-
Selecting a managed Claude account doesn't change the account requests go to while
CLAUDE_CODE_OAUTH_TOKENis set. Orca's terminalclaudeshell function switchesCLAUDE_CONFIG_DIRbut leaves the variable in place, and Claude Code ranksCLAUDE_CODE_OAUTH_TOKENabove the folder's/logincredentials (https://code.claude.com/docs/en/authentication#authentication-precedence). Orca shows the selected account as active while every terminal session is billed to the token's account, with no warning. -
The usage panel reports a subscription sign-in as API key billing. A setup-token always belongs to a Claude subscription (Pro, Max, Team or Enterprise), yet with one in
CLAUDE_CODE_OAUTH_TOKENand no/loginin~/.claude,orca account list --jsonreturnsrateLimits.claudeasstatus: "unavailable",error: "No subscription plan — API key billing",failureKind: "missing-credentials", withsessionandweeklynull. The usage poll reads only.credentials.json, never the variable. -
The Claude usage bar appears while a session is responding and disappears a few minutes after it goes quiet. Orca does receive live usage for this sign-in: while such a session runs,
claude-statusline.cmdkeeps refreshing its stamp file (%TEMP%\orca-claude-statusline-last-<pane>.tmp), which it only writes after finding"rate_limits"in Claude Code's status line payload and right before posting to/statusline/claude. ButresolveClaudeFetchApplykeeps the live-session state only whileisLiveClaudeUsageFreshholds (updated within the last 5 minutes). After that, the failing poll result from 2 replaces it and the bar drops out. For a token sign-in the poll can never succeed, so the bar flickers with session activity for as long as "Claude usage polling" is on, which is the default.
How can we reproduce it?
For 1:
- Set
CLAUDE_CODE_OAUTH_TOKENto a valid setup-token as a user environment variable and start Orca. - Add a managed Claude account signed in to a different account and select it.
- Open a new Orca terminal and run
claude auth status:authMethodisoauth_token, notclaude.ai. Prompts run on the token's account.
I reproduced step 3 with a config folder whose .credentials.json holds a dummy access token with subscriptionType: "max". Without the variable, claude auth status in that folder reports authMethod: "claude.ai". In an Orca terminal with a valid token exported and CLAUDE_CONFIG_DIR pointing at that folder, it reports oauth_token, and a prompt gets a normal reply, which the dummy access token could not produce.
For 2 and 3:
- Use only
CLAUDE_CODE_OAUTH_TOKEN(no/loginin~/.claude), with the System default account and "Claude usage polling" on. - Start
claudein an Orca terminal and send one prompt. The Claude bar appears in the status bar. - Leave the session idle for more than 5 minutes. The bar disappears, and
orca account list --jsonshowsrateLimits.claudein the state described in 2.
Turning "Claude usage polling" off makes the bar stay, because claudeUsageWithoutOAuth then keeps the live values until their windows reset. That matches the setting's description ("Turn off to use live terminal readings only"), but nothing tells token users that the default setting can never work for them.
Expected:
- When
CLAUDE_CODE_OAUTH_TOKENis set in the environment Orca launches Claude with, the account settings say so and warn that it takes precedence over the selected account. - When the poll fails with
missing-credentialsormissing-scope, Orca keeps the last live-session usage the way it already does with polling off, instead of replacing it after 5 minutes. A token sign-in is never labeled as API key billing.
Anything else that might help:
- Claude Code 2.1.327, Windows 11.
GET https://api.anthropic.com/api/oauth/usagewith a setup-token returns 403oauth_scope_insufficient(OAuth token does not meet scope requirement user:profile). The token only hasuser:inference, so the poll can never serve these sign-ins; the live session data is the only usage source for them.- Per-model weekly limits such as Fable can't be shown for these sign-ins from any source. The status line only carries the 5-hour and 7-day (all models) windows, and Claude Code's own
/usageshows only "Current week (all models)" with "Other limits and usage credits aren't shown for this sign-in." So that row should simply stay hidden for token sign-ins. - Making setup-token a managed account type (#12002) would remove the conflict in 1 for users who adopt it. The warning is still needed for users who keep the variable exported.
- Related: #12002, #35497, #31905 (different cause: running sessions keep the old account after a switch).
Data point from a Linux headless serve host, Orca 1.4.271, Claude Code 2.1.332.
On Linux the usage reader reads only <configDir>/.credentials.json. It does not look at CLAUDE_CODE_OAUTH_TOKEN. With only setup-tokens on the host (no /login), the file does not exist, so the usage row shows the missing-credentials state.
Reading the env token alone does not fix it. GET https://api.anthropic.com/api/oauth/usage with a claude setup-token token returns 403 oauth_scope_insufficient (required scope user:profile). The setup-token has only the inference scope.
Smallest change that works with setup-tokens: use it when the credential source is CLAUDE_CODE_OAUTH_TOKEN, or when the usage endpoint answers 403 oauth_scope_insufficient. Then fill the usage row from the last rate_limit_event of a session on that sign-in (rate_limit_info.unifiedWindows.{five_hour,seven_day}), as #35497 asks. Show "usage known after the next response" until a frame arrives. Do not report it as API key billing.