Skip to content

fix(status-bar): surface signed-out Claude usage instead of hiding the segment - #20120

Closed
mmarabel wants to merge 4 commits into
stablyai:mainfrom
mmarabel:fix/claude-signed-out-usage-segment
Closed

mmarabel wants to merge 4 commits into
stablyai:mainfrom
mmarabel:fix/claude-signed-out-usage-segment

Conversation

@mmarabel

@mmarabel mmarabel commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

When your Claude sign-in quietly expires, Orca's status bar used to just delete the Claude usage meter with no explanation. Now it keeps the meter and says "not signed in", with the usual sign-in button in the usage popover.

What Changed

  • src/main/rate-limits/claude-oauth-credentials.ts: credential reads now report hasEmptyStoredEntry when the Keychain item / credentials file parses but holds no usable tokens (previously this collapsed into "no credentials at all").
  • src/main/rate-limits/claude-usage-error-classification.ts: that state classifies as a new terminal signed-out failure kind.
  • src/main/rate-limits/claude-active-usage-fetch.ts: the no-credentials fallback returns status error (Claude sign-in expired) for signed-out instead of unavailable, so existing visibility logic keeps the segment rendered. Truly-never-configured setups still return unavailable and stay hidden.
  • src/shared/rate-limit-types.ts: added 'signed-out' to UsageRateLimitFailureKind.
  • src/renderer/src/components/status-bar/usage-error-copy.ts: signed-out Claude labels as "not signed in" (reuses the existing roster key, no new strings).
  • src/renderer/src/components/status-bar/usage-roster-row-state.ts: signed-out earns the sign-in CTA row, which opens Settings → Accounts.

Why

unavailable is the one snapshot status that hides a status-bar segment entirely (by design, for never-configured providers). An emptied credential store was misreported as unavailable/missing-credentials, so users with a checked "Claude Usage" toggle and a seemingly-connected account got a silently vanishing meter and no path to recovery. error snapshots stay visible by design (same convention as Grok's "sign-in expired"), so mapping signed-out to error restores the affordance with minimal new machinery.

Linked Issue

Fixes #20118

Does not fix the related refresh-loop reports. #20251 and #21935 describe a different mechanism (the live-PTY OAuth refresh gate never reopening, so a managed token is never refreshed while a Claude pane stays alive), and #14833 covers the absent last-known values that make the failure render as nothing at all. This PR only makes the signed-out state visible instead of silently removing the segment; all three stay open after it merges.

Visual Proof

No screenshots attached: this was developed in a headless Linux worktree and the affected surface is the desktop status bar. Verified instead via unit tests covering the full chain (empty-store fetch result → visibility gate → segment label → roster sign-in row) plus the live unavailable snapshot captured while diagnosing #20118. Happy to attach macOS before/after shots on request.

Testing

  • Reproduced from live app state first (rateLimits.claude: unavailable/missing-credentials/credentialSource: 'none' with an existing-but-empty Keychain entry), then added regression tests:
    • fetch-level: empty-token Keychain entry and empty-token credentials file both yield error/signed-out with no network or PTY calls
    • classification, visibility gate, segment label/message, roster sign-in row
  • I manually tested these changes locally (headless worktree — see Visual Proof)
  • Automated tests added
  • Platforms actually tested: Linux (unit/typecheck/build). Logic is platform-agnostic (no new platform branches; Keychain path unchanged and still darwin-guarded; file path uses existing joins). SSH/remote: snapshot keeps its authProvenance; no new host assumptions. Complements (does not touch) open feat(status-bar): add re-authenticate action to Claude usage menu #6828, which covers re-auth for managed accounts — this covers system-default.

AI Disclosure

Implemented with Muse Spark via the Pi coding agent under the author's direction; diagnosis verified against live app state on the author's Mac.

Review

Self-review (AI agent): cross-platform safe (no new OS branches, paths, or shortcuts); SSH/remote safe (provenance preserved, generic message with no host-specific command); provider-scoped to Claude (other providers' failureKind switches have fallthrough defaults; service policies only special-case rate-limited); no perf impact (parse-time boolean, and the error streak feeds the existing poll backoff); no security impact (no secrets read differently or logged — the existing warn log already emits only booleans/source names).

Agent skill upstream boundary

  • Not applicable — no skill sources copied or translated.

Notes

Rebased onto main @ 33ba1ff3df (2026-09-21) after the branch fell 1170 commits behind; replayed with no conflicts and the diff is unchanged at 11 files, +177/-9. Re-verified on the rebased branch: pnpm tc clean, 880 tests across src/main/rate-limits and src/renderer/src/components/status-bar pass, and the changed-code quality gate reports 0 findings across the 11 changed files (run against the real base — with no argument it resolves to a stale origin/main and reports unrelated mobile/ findings).

Security, cross-platform (Linux/Windows/Mac), remote SSH, backwards compatibility, and performance considered above; mobile untouched (shared union addition only, no mobile consumers of the new kind).

Checklist

  • This PR is small and focused
  • I explained what changed and why (including ELI5)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason (see Visual Proof)
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered
  • pnpm lint (changed-code quality gate: 0 findings), pnpm typecheck, pnpm test, and pnpm build pass locally

@coderabbitai

coderabbitai Bot commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

Understand this PR’s impact

Explore downstream dependencies and potential security impact with Blast Radius.

View blast radius →

Warning

Review limit reached

Next included review available in 16 seconds.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 276b660c-5fff-4552-84b4-dacfad51ac7d

📥 Commits

Reviewing files that changed from the base of the PR and between 04be21b and de4143c.

📒 Files selected for processing (11)
  • src/main/rate-limits/claude-active-usage-fetch.ts
  • src/main/rate-limits/claude-fetcher-keychain-credentials.test.ts
  • src/main/rate-limits/claude-oauth-credentials.ts
  • src/main/rate-limits/claude-usage-error-classification.test.ts
  • src/main/rate-limits/claude-usage-error-classification.ts
  • src/renderer/src/components/status-bar/status-bar-provider-visibility.test.ts
  • src/renderer/src/components/status-bar/usage-error-copy.test.ts
  • src/renderer/src/components/status-bar/usage-error-copy.ts
  • src/renderer/src/components/status-bar/usage-roster-row-state.test.ts
  • src/renderer/src/components/status-bar/usage-roster-row-state.ts
  • src/shared/rate-limit-types.ts

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: a3c2c72d-4801-4e13-b2e7-86fbef047d0b

📥 Commits

Reviewing files that changed from the base of the PR and between 58326fb and 04be21b.

📒 Files selected for processing (3)
  • src/renderer/src/components/status-bar/status-bar-provider-visibility.test.ts
  • src/renderer/src/components/status-bar/usage-error-copy.ts
  • src/shared/rate-limit-types.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

The change adds a signed-out failure kind for Claude OAuth entries that contain no usable tokens. Credential loading preserves this state from Keychain and credentials files. Usage fetching returns a terminal Claude sign-in expired error without network or PTY fallback calls. Status-bar logic keeps the provider visible, displays not signed in, and maps the state to the sign-in action. Tests cover credential sources, classification, visibility, labels, and row state.

Priority: ➖ Normal

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 10 functions across 11 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Issue #20118 requires a visible Claude state when stored system-default OAuth credentials contain empty tokens. The current code preserves empty stored entries in readClaudeOAuthCredentials, classif…
Out of Scope Changes check ✅ Passed The changes address only issue #20118. They cover empty Claude OAuth credential detection, signed-out classification, fetch ordering, status-bar visibility and labels, the existing sign-in action, sha…
Title check ✅ Passed The title clearly identifies the primary change: exposing signed-out Claude usage in the status bar.
Description check ✅ Passed The description covers the user impact, implementation, rationale, linked issue, testing, platform considerations, and checklist. The visual proof section explains why screenshots were not included, a…

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
src/main/rate-limits/claude-fetcher-keychain-credentials.test.ts (1)

473-473: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Exercise the default PTY fallback policy.

Both tests set allowPtyFallback: false. With the default policy, fetchActiveClaudeRateLimits reaches the CLI plan fallback after classifying an empty entry as signed-out, and fetchClaudeUsageViaCli calls fetchViaPty. Add a host-system test without this option. Assert signed-out and no fetchViaPty call.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: f8da5a95-6731-48e5-9c6a-797c53f3a715

📥 Commits

Reviewing files that changed from the base of the PR and between 9aa0f7e and a156c11.

📒 Files selected for processing (11)
  • src/main/rate-limits/claude-active-usage-fetch.ts
  • src/main/rate-limits/claude-fetcher-keychain-credentials.test.ts
  • src/main/rate-limits/claude-oauth-credentials.ts
  • src/main/rate-limits/claude-usage-error-classification.test.ts
  • src/main/rate-limits/claude-usage-error-classification.ts
  • src/renderer/src/components/status-bar/status-bar-provider-visibility.test.ts
  • src/renderer/src/components/status-bar/usage-error-copy.test.ts
  • src/renderer/src/components/status-bar/usage-error-copy.ts
  • src/renderer/src/components/status-bar/usage-roster-row-state.test.ts
  • src/renderer/src/components/status-bar/usage-roster-row-state.ts
  • src/shared/rate-limit-types.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

  • Emptied credential entries are now distinguishable — parseClaudeOAuthCredentialsJson sets an optional hasEmptyStoredEntry when a claudeAiOauth entry parses but holds no usable tokens, and readClaudeOAuthCredentials preserves that flag through the keychain/file precedence chain instead of collapsing it into missing-credentials.
  • New terminal signed-out failure kind — classifyClaudeCredentialAbsence maps hasEmptyStoredEntry to a terminal signed-out classification, and the kind is added to UsageRateLimitFailureKind.
  • Fetch surfaces error instead of hiding — fetchActiveClaudeRateLimits returns an error snapshot (Claude sign-in expired) for signed-out, which keeps the segment rendered by the existing error-stays-visible convention.
  • Renderer copy and CTA — the Claude status label resolves to "not signed in" and isConfirmedSignedOut earns the sign-in roster row.

The change is provider-scoped, additive (hasEmptyStoredEntry is optional and only consumed by Claude), and the new tests exercise the real darwin keychain path via setPlatform('darwin') with exact assertions (not tautological).

ℹ️ The signed-out affordance only surfaces for system-default accounts

The signed-out branch in fetchActiveClaudeRateLimits sits after the CLI fallback, so it is only reached when allowPtyFallback is false — i.e. system-default Claude (shouldAllowClaudePtyFallback → !isSystemDefaultClaudeAuth) or Windows. For a managed (non-system-default) account allowPtyFallback is true, so a signed-out CLI probe resolves to cli-unavailable before the signed-out check runs, leaving those accounts on their prior behavior. That matches the PR's stated scope (managed re-auth is #6828), but is worth carrying forward as a known boundary if signed-out is ever expected to cover managed accounts too.

Technical details
# Scope boundary: managed-account signed-out masking

## Affected sites
- src/main/rate-limits/claude-active-usage-fetch.ts:227 — CLI fallback runs for managed accounts before the signed-out check at :243
- src/main/rate-limits/service/service-fetch-targets.ts:133 — shouldAllowClaudePtyFallback returns false only for system-default (or Windows)

## Required outcome
- None for this PR. If managed-account signed-out should eventually surface "not signed in", the signed-out check would need to run before (or bypass) the CLI probe for managed accounts, or #6828 will handle it.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

Re-reviewed the single new commit since the prior Pullfrog review — it moves the signed-out terminal check ahead of the CLI fallback and trims blank access tokens.

  • signed-out now returns before the CLI fallback — the check moved from just before the final unavailable return to immediately after classifyClaudeCredentialAbsence, so an emptied credential store short-circuits before any refresh, live-session deferral, or PTY probe. Since signed-out is a terminal classification (shouldAttemptCliFallback: false), this also resolves the prior boundary note: managed accounts now surface "not signed in" instead of falling through to a cli-unavailable PTY result.
  • Blank access tokens are trimmed to null — parseClaudeOAuthCredentialsJson treats whitespace-only access tokens as absent, so an entry holding accessToken: "" counts as emptied (hasEmptyStoredEntry) rather than reaching the OAuth path with a garbage token. Valid tokens are returned trimmed.
  • Test tightened to the new contract — the keychain test drops the allowPtyFallback: false override and asserts fetchViaPty is never called even with PTY fallback allowed, matching the moved early return.

The move is safe with respect to live-session deferral: classifyClaudeCredentialAbsence checks managedRefreshDeferredByLivePty first, so a live session still classifies as deferred-by-live-session (not signed-out). hasEmptyStoredEntry only survives the keychain/file precedence chain when every source holds no usable token, so there is nothing for the CLI fallback to recover. Verified: 64 tests across the five changed test files pass.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

Re-reviewed the single new commit since the prior Pullfrog review — it makes the signed-out error message explicit in the renderer rather than relying on switch fall-through.

  • signed-out message surfaced verbatim via an explicit case — getProviderUsageErrorMessage now returns p.error for signed-out before the missing-credentials fallthrough, with a comment documenting that the main-process 'Claude sign-in expired' string is pattern-safe.

The change is behaviorally neutral: previously signed-out fell through the Claude switch and was returned verbatim by the trailing return p.error ('Claude sign-in expired' matches neither isUsageRateLimitError nor isUsageAuthError), so users saw the same message either way. Making it explicit is a sound robustness improvement — it decouples the renderer's signed-out copy from the auth-pattern block, so a future change to the main-process string cannot silently get rewritten into the generic auth copy.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

…onflicts

# Conflicts:
#	src/renderer/src/components/status-bar/usage-error-copy.test.ts
@mmarabel

Copy link
Copy Markdown
Contributor Author

This branch is stale against current main. The problem is tracked again in #48455. Closing.

@mmarabel mmarabel closed this Nov 24, 2026
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.

[Bug]: Status-bar Claude usage silently disappears when system-default OAuth tokens are empty — no error, no re-login hint

1 participant