Repository navigation
Conversation
…ectron net The token endpoint answers 429 to Chromium's network stack while the same refresh_token grant from Node succeeds, so every Orca-owned refresh failed silently: inactive managed accounts never got a new token and their usage rows stayed blank, and the launch-time refresh only worked because the claude CLI refreshed on its own afterwards. Route the POST through undici's fetch. Proxy resolution mirrors what child processes get: Orca's configured proxy wins over the shell's and its bypass list replaces NO_PROXY; SOCKS proxies fall back to a direct connection with a warning since undici only tunnels through HTTP proxies. The usage fetch keeps using net.fetch, which the usage endpoint accepts. Fixes stablyai#18716
There was a problem hiding this comment.
ℹ️ No critical issues — minor suggestions inline.
Reviewed changes
This PR makes the inactive Claude account switcher rows report why usage is missing instead of a blank row, reusing the active account's existing failure classification rather than adding a parallel path.
- OAuth refresh outcome —
refreshClaudeOauthCredentialsWithOutcomereports why a refresh failed (no-refresh-token,invalid-grant,rate-limited,rejected,network) on top of the existingstring | nullcontract. - Inactive-account classification — a dead refresh token becomes a
reauth-requiredrow without spending a usage call; a failed usage GET becomes a classified error row (stale-token,rate-limitedwithretryAtMs,server,network) through the sharedclassifyClaudeOAuthUsageError/makeClaudeUsageClassificationError. - Service error row — the per-account
catchwrites an error row throughapplyStalePolicy, so last-known windows survive a transient failure and a hard failure still produces a row. - Switcher label —
unavailableUsageLabelmaps auth kinds to "Sign in to see usage",rate-limitedto "Usage temporarily unavailable", and everything else to "Usage unavailable". - Type + i18n — new
reauth-requiredUsageRateLimitFailureKindvalue and two English strings.
ℹ️ Nitpicks
reauth-requiredis not handled by the Claudeswitches inusage-error-copy.ts(getProviderUsageStatusLabel/getProviderUsageErrorMessage), so it degrades to the generic "Refresh failed" copy. It isn't reachable today — only the inactive path emits it, and those rows useunavailableUsageLabel— but the roster follow-up (#10688) will surface it.AUTH_FAILURE_KINDSis typedReadonlySet<string>;ReadonlySet<UsageRateLimitFailureKind>would let the compiler catch a misspelled auth-kind entry.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (6)
🚧 Files skipped from review as they are similar to previous changes (4)
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review. 📝 WalkthroughWalkthroughThe OAuth refresh flow now uses Node’s Merge Risk: ⚪ Minimal · up to This change replaces blank inactive-account usage rows with classified authentication, rate-limit, network, and general error states while preserving usable cached usage data during transient failures. The covered failure paths do not show an outstanding merge-blocking risk. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Team
Run ID: 5c41a927-228a-4bee-8c5c-ff76bdcdacb6
📥 Commits
Reviewing files that changed from the base of the PR and between 8064d1f and 786a06b0377e3ff0a0db33be16308337a8e6caf6.
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (11)
package.jsonsrc/main/claude-accounts/oauth-refresh.test.tssrc/main/claude-accounts/oauth-refresh.tssrc/main/rate-limits/claude-fetcher-managed-account-usage.test.tssrc/main/rate-limits/claude-managed-account-usage.tssrc/main/rate-limits/service-inactive-account-previews.test.tssrc/main/rate-limits/service/service-inactive-accounts.tssrc/renderer/src/components/status-bar/InlineProviderUsage.tsxsrc/renderer/src/components/status-bar/inline-usage-bars.test.tsxsrc/renderer/src/i18n/locales/en.jsonsrc/shared/rate-limit-types.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.
…a SOCKS proxy in the refresh Review follow-ups on stablyai#18732: the refresh request now aborts with the caller's signal instead of waiting out its own timeout, and a configured SOCKS proxy (which undici cannot tunnel through) skips the refresh with a warning instead of connecting directly around the configured egress route.
…stead of a blank row The inactive-account usage path threw on any OAuth failure and the service swallowed it without writing a row, so a 401, a 429, or a dead refresh token all looked like "no data" in the account switcher. The active-account path already classifies these failures; reuse that classification for inactive accounts and give the switcher a label for each case. - OAuth refresh reports why it failed (invalid_grant, rate-limited, rejected, network); a dead refresh token becomes a `reauth-required` row without spending a usage call. - The usage GET failure becomes a classified error row (stale-token, rate-limited with retry-at, server, network) instead of a throw. - The service still catches thrown failures, but writes an error row and keeps last-known windows through the existing stale policy. - Inline usage bars say "Sign in to see usage" only for auth failures; a throttle reads "Usage temporarily unavailable" and anything else "Usage unavailable". Part of stablyai#14833 (points 3 and 5). Stacked on stablyai#18732.
… rows - Name the two new switcher strings with intent IDs under components.status.bar.inlineUsage instead of hash-based auto keys. - Classify a failure that escapes the fetcher as 'unknown', since network and HTTP failures are already classified inside it. - After a transient refresh failure, do not send an already-expired token to the usage endpoint; report the refresh failure kind instead. Inside the refresh buffer the stored token is still tried once. - Surface an unsupported (SOCKS) proxy as its own refresh outcome.
786a06b to
68b17b4
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Team
Run ID: 3ef2014a-9536-42e2-a344-28c6fdc5fcba
📥 Commits
Reviewing files that changed from the base of the PR and between 786a06b0377e3ff0a0db33be16308337a8e6caf6 and 68b17b4.
📒 Files selected for processing (8)
src/main/claude-accounts/oauth-refresh.test.tssrc/main/claude-accounts/oauth-refresh.tssrc/main/rate-limits/claude-fetcher-managed-account-usage.test.tssrc/main/rate-limits/claude-managed-account-usage.tssrc/main/rate-limits/service-inactive-account-previews.test.tssrc/main/rate-limits/service/service-inactive-accounts.tssrc/renderer/src/components/status-bar/InlineProviderUsage.tsxsrc/renderer/src/i18n/locales/en.json
🚧 Files skipped from review as they are similar to previous changes (1)
- src/renderer/src/i18n/locales/en.json
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.
There was a problem hiding this comment.
ℹ️ No critical issues — one minor metadata nit inline.
Reviewed changes
Since the prior review (786a06b), the branch was rebased onto an updated #18732 and a review-follow-ups commit landed.
- Expired-token refresh failure — added
isOauthTokenExpiredplusrefreshFailedResult/REFRESH_FAILURE_KINDSso a stored token already past expiry reports a classified error row instead of sending a token doomed to 401. - SOCKS proxy refusal —
resolveRefreshRoutenow refuses (rather than silently bypasses) a SOCKS proxy, returning a newunsupported-proxyfailure kind. - Caller cancellation — the refresh forwards the caller
signalthroughAbortSignal.anyso the inactive fetch settles promptly on abort. - Service failure kind — the per-account
catchnow writesfailureKind: 'unknown', addressing the prior review'snetwork-mislabel note. - i18n keys — the two new labels moved from auto-hash keys to an explicit
inlineUsage.*namespace.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
A stored blob with no refresh token was mapped to 'refreshable-credentials-without-token', which claims the opposite: that the account is refreshable and the UI should say "Refreshing sign-in". Nothing can refresh it, so the row promised a recovery that never arrived, and the inactive-account stale policy kept serving the old windows instead of the "Sign in to see usage" row. Route 'no-refresh-token' to 'reauth-required' once the access token is expired, and drop it from the transient-failure map by type so the inverted mapping cannot come back. Inside the refresh buffer the still-valid access token is tried as before. Also stop the inactive-Claude catch from evicting the cache of an account that is still listed. A generation bump alone now leaves the snapshot in place; refreshForClaudeAccountChange seeds the outgoing account's row and nothing refetches it on the spot, so the eviction blanked the row it had just filled. pruneInactiveClaudeState already removes accounts that left the list.
|
Pushed
Tests: Gates on Windows 11 / Node 24, The 9 failures are pre-existing on this machine, not from this stack — the same 9 fail on the base commit |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Since the prior review (68b17b4), one follow-up commit landed that corrects the no-refresh-token mapping and preserves switch-time snapshots.
- Missing refresh token → reauth-required — a stored blob with no refresh token and an already-expired access token now yields a
reauth-requiredrow (Sign in to this account again) instead of the invertedrefreshable-credentials-without-tokenmapping, addressing the prior review's note. - Type-narrowed transient map —
REFRESH_FAILURE_KINDSis nowRecord<TransientRefreshFailure, UsageRateLimitFailureKind>(excludinginvalid-grantandno-refresh-tokenby type), so a non-refreshable account can no longer be asserted refreshable. - Snapshot survives a stale fetch — the inactive
catch's stale/aborted branch deletes the cache only when the account is no longer current, sorefreshForClaudeAccountChange's switch-time snapshot isn't wiped by an in-flight same-id fetch that later rejects. - Regression tests — added a
no-refresh-tokencase (no token call, no usage call) and a switch-time-snapshot case; thedeferredtest helper gainedreject.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
|
Thanks @Tauri-EPO! Closing — the usage code this targets has since been rewritten on main, so this change no longer applies. |

ELI5
When a saved Claude account could not report its usage, the account switcher showed nothing at all: no bars, no error. A blocked login, a throttled endpoint, and a network blip all looked identical to "no data". Now each saved account says what happened: "Sign in to see usage" when the login is dead, "Usage temporarily unavailable" when Anthropic throttled us, "Usage unavailable" otherwise, and the last known bars stay on screen through a transient failure.
What Changed
oauth-refresh.ts:refreshClaudeOauthCredentialsWithOutcomereports why a refresh failed (no-refresh-token/invalid-grant/rate-limited/rejected/network).refreshClaudeOauthCredentialskeeps itsstring | nullcontract on top of it.claude-managed-account-usage.ts(inactive accounts): a refresh token that is missing (no-refresh-token) or rejected (invalid_grant) returns areauth-requirederror row without spending a usage call; both need a new login, so neither reaches the transient-failure map. A failed usage GET returns a classified error row through the sameclassifyClaudeOAuthUsageError+makeClaudeUsageClassificationErrorthe active account already uses (stale-token,rate-limitedwithretryAtMs,server,network), instead of throwing. A transient refresh failure on an already-expired token is reported by kind instead of being sent to the usage endpoint; inside the refresh buffer the stored token is still tried once.service/service-inactive-accounts.ts: the per-accountcatchwrites an error row throughapplyStalePolicyinstead of leaving the cache untouched, so last-known windows survive a transient failure and a hard failure still produces a row. It evicts the cache only when the account has left the resolver list, so a generation bump mid-flight no longer blanks a row the account switch just seeded.InlineProviderUsage.tsx: the empty-error label is chosen byfailureKind. Auth kinds keep "Sign in to see usage";rate-limitedreads "Usage temporarily unavailable"; anything else "Usage unavailable". Two new English strings.rate-limit-types.ts: newfailureKindvaluereauth-required(optional string field; old clients ignore it).Why
Points 3 and 5 of #14833: the inactive path threw on any OAuth failure and the service swallowed it, so Switch to could not distinguish a dead login from a throttle from a bug. #18732 fixes the refresh itself; this PR makes the remaining failures visible and actionable. The existing classification and result builders cover every case, so this reuses them rather than adding a parallel path.
Linked Issue
Part of #14833 (does not close it: fetch triggers, persistence, and roster rows follow in separate PRs).
Depends on #18716 / #18732.
Visual Proof
N/A for screenshots: the change is a text label inside the account switcher rows. The live run below shows the rows the switcher receives.
Testing
Platforms: Windows 11 (local). Not run on macOS/Linux/SSH; main-process plus one renderer label, platform-neutral.
Live, real
fetchInactiveClaudeAccountUsagefrom this branch (Electron stubbed forapp.getPath), against two managed accounts on my machine. No credential file was rewritten:vitest run --config config/vitest.config.tsoversrc/main/claude-accounts, the Claude fetcher suites,service-inactive-account-previews,service-live-claude-usage,claude-usage-error-classification,inline-usage-bars,codex-status-sign-in: 32 files, 283 tests, 282 passed. New tests: 5 refresh-outcome cases, 4 inactive-path cases (401 tostale-tokenrow, 429 torate-limitedwithretryAtMs,invalid_granttoreauth-requiredwith no usage call, transient refresh failure still tries the stored token), 2 service cases (thrown fetch produces an error row; last-known windows kept), 1 label case.The single failure is pre-existing on Windows and unrelated:
service-inactive-account-previews > allows usage-panel Fable supplementsexpectsallowUsagePanelSupplement: true, which is darwin/linux-only (fails identically on cleanmain).Full typecheck (
run-typecheck-projects-in-parallel.mjs): clean.oxlintandoxfmt --checkon changed files: clean.verify-localization-catalog,verify-localization-extraction,audit-localization-coverage --check, runtime catalog generator: all exit 0, no generated diff.I manually tested these changes locally
Automated tests added/updated, or explained why not below
AI Disclosure
Implementation and tests by Claude (Fable 5.1) via Claude Code, driven and verified by me; the live run above was executed on my machine.
Review
Agent code-review summary:
readClaudeManagedCredentialsJson; a keychain failure now surfaces as anunknown-kind error row ("Usage unavailable") instead of a gap.ProviderRateLimitsshape.reauth-requiredis a new value of an existing optional string field. Old desktop and mobile clients fall into their generic error handling; no new opcode or required field.InlineUsageSignInAction).invalid_grantshort-circuits before the usage GET, one fewer call per dead account per switcher open. No new polling.text-[10px] text-muted-foregroundstyle. No inline "Sign in" button in the Claude switcher yet; the Accounts pane has re-auth, and an inline action like the Codex one is a natural follow-up.errorfield.Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
Review follow-ups (68b17b4): intent-named localization IDs (
components.status.bar.inlineUsage.*),'unknown'for failures that escape the fetcher, no usage call with an already-expired token after a transient refresh failure, andunsupported-proxyas its own refresh outcome. Rebased on the updated #18732.pnpm build:desktopdid not run on this worktree: the nativewindows-process-treerebuild fails on this path length (MAX_PATH) and pnpm 12 refuses to run scripts until the install completes. The sibling branch #18732 built cleanly with the same toolchain minutes earlier, and this diff is TypeScript-only with the full typecheck clean, so CI covers the build.Follow-ups for #14833, each its own PR: fetch inactive accounts on Usage popover open and on Refresh; persist last-known per account with validity until
resetsAt; per-account rows in the Usage popover (#10688 keeps the Accounts pane).Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)Author
X: @EnricoPin