Skip to content

feat(status-bar): show Claude spend cap when the plan has no 5h/weekly window - #31065

Closed
frank-bee wants to merge 2 commits into
stablyai:mainfrom
frank-bee:feat/claude-spend-limit-status-bar
Closed

frank-bee wants to merge 2 commits into
stablyai:mainfrom
frank-bee:feat/claude-spend-limit-status-bar

Conversation

@frank-bee

@frank-bee frank-bee commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

Claude Enterprise accounts don't have the usual 5-hour and weekly limits. They have a monthly spending cap instead. Orca already downloads that cap but never showed it, so the Claude meter in the status bar stayed empty. Now it shows how much of the monthly cap is used, the same way Orca shows monthly limits for Grok, Cursor and OpenCode Go.

What Changed

Before: for a Claude Enterprise login, the status bar shows only the Claude icon with no percentage or bar, even though the account is close to its limit.

After: the Claude chip shows the share of the monthly spend cap used (e.g. 83% 30d), and the usage popover lists it as "Monthly". With several Claude accounts, an inactive Enterprise account in the Claude account switcher shows the same 30d bar instead of an empty row.

Mechanism: the Claude usage fetcher (claude-oauth-usage-request.ts) already maps the spend / legacy extra_usage part of the /api/oauth/usage response into extraUsage. When the response has neither a five_hour nor a seven_day window, the fetcher now also turns that spend into the existing monthly window (mapClaudeSpendLimitWindow in claude-usage-credits.ts). The status bar chip already renders a monthly-only provider inline. The switcher's per-account rows (InlineUsageBars) only drew 5h/weekly/Fable, so they now add the monthly bar under the same "no 5h/7d window" rule. isUnavailableInactiveUsage also counts monthly, so such an account isn't treated as signed out. Inactive accounts go through the same fetcher, so they get the window without further changes.

Why

On Enterprise, the monthly spend cap is the only limit that applies, so an empty meter looks like "no data" when Orca has the number.

The spend is only promoted to the monthly window when there is no 5h/7d window. On Pro/Max, spend is overage that only applies after a plan limit is hit, and the existing balance display already handles that. A cap of 0, a missing percentage, or a balance without a cap produce no window, so nothing is made up. The alternative was a Claude-specific renderer branch that reads extraUsage directly. Reusing the monthly window instead keeps the chip, popover, roster, tone and overflow logic shared with the other monthly providers.

Linked Issue

Fixes #31061

Visual Proof

Before (current release, Claude Enterprise login):

before

After (this branch, same login):

after

Testing

  • Added 6 cases to claude-oauth-usage-extra-usage.test.ts: spend → monthly window when there are no plan windows; the same from legacy extra_usage; legacy cap used when spend has only a balance; legacy percentage derived from the amounts when utilization is a 0–1 fraction; no monthly window when a 5h window exists; no window from a balance without a cap.

  • Added 2 cases to inline-usage-bars.test.tsx: an inactive account with only a monthly window renders 80% used 30d and isn't treated as signed out; rows with plan windows don't add the monthly bar.

  • pnpm test src/main/rate-limits/ src/renderer/src/components/status-bar/ (1502 passed), pnpm tc:node, pnpm tc:web, oxlint and pnpm run check:code-quality:changed pass, and the files are formatted.

  • Full pnpm lint and pnpm typecheck pass.

  • Full pnpm test: 7 files fail locally (process-host-dev-rebuild, pr-auxiliary-preflight-admission, orca-runtime, packaged-cli-assets and three pty-* race tests). They fail on main (46d0a00) too, with the same set of files (20 failures on main, 19 on this branch), so they're environment/timing related, not caused by this change.

  • Ran pnpm dev on macOS (arm64) against a real Claude Enterprise login. The usage state came back status: ok, monthly.usedPercent: 83, and the chip rendered as shown above (status bar in the "verbose" usage mode, which shows the bars).

  • Not tested on Linux, Windows or over SSH. The change is in shared fetch/mapping code with no platform-specific paths.

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

AI Disclosure

Implemented with Claude (Opus 5.5) in Claude Code. I reviewed the change and checked the result in a dev build with my own account.

Review

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • Security: no new credentials, requests or logging; it reuses the response Orca already fetches.
  • Cross-platform/SSH: the mapping lives in the shared Claude usage fetcher, so it applies wherever that runs. No paths, shortcuts or process spawning are involved.
  • Backwards compatibility: monthly is an existing optional field on ProviderRateLimits. Older renderers already handle it.
  • The live statusline ingest path returns early when a post has no 5h/7d window, so it does not overwrite the monthly window for these accounts.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred): full pnpm lint and pnpm typecheck pass; pnpm test passes except 7 files that fail on main too (see Testing); pnpm build left to CI

…y window

Enterprise seats have no five_hour/seven_day windows, so the Claude meter stayed empty although the usage response carries the monthly spend cap. Map it to the existing monthly window in that case only, and render that window in the account switcher's inline usage rows too.

Fixes stablyai#31061
@coderabbitai

coderabbitai Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

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: 678865a7-ab20-42c5-8138-94794393de2f
📥 Commits

Reviewing files that changed from the base of the PR and between 73c6aa8 and c28bba5.

📒 Files selected for processing: 3
  • src/main/rate-limits/claude-oauth-usage-extra-usage.test.ts
  • src/main/rate-limits/claude-oauth-usage-request.ts
  • src/main/rate-limits/claude-usage-credits.ts
🚧 Files skipped from review as they are similar to previous changes: 3
  • src/main/rate-limits/claude-oauth-usage-extra-usage.test.ts
  • src/main/rate-limits/claude-oauth-usage-request.ts
  • src/main/rate-limits/claude-usage-credits.ts

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

📝 Walkthrough

Claude OAuth usage now maps eligible spend data to a monthly window when session and weekly windows are absent. The status bar displays that monthly usage and includes its reset time in the countdown. Tests cover spend mapping, monthly usage display, inactive-error classification, and suppression when plan windows exist.

Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to c28bb

Monthly spend usage can display without a reset date; no confirmed issue remains that should block merging after normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 22.22% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 5 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly summarizes the primary change: displaying Claude spend-cap usage when 5-hour and weekly windows are unavailable.
Description check Passed The description is complete and aligned with the repository template. It explains the user impact, implementation, rationale, linked issue, visual proof, testing results, known full-test limitations, …
Linked Issues check Passed Issue #31061 requires monthly Claude spend usage when no 5-hour or weekly window exists. fetchClaudeOAuthUsage now maps spend or legacy extra_usage data to monthly only when both plan windows …
Out of Scope Changes check Passed The changes remain within issue #31061. The fetcher mapping, monthly-window helper, status-bar account-switcher rendering, and related tests directly support Claude Enterprise monthly spend display. N…
Full details: Description check

Explanation

The description is complete and aligned with the repository template. It explains the user impact, implementation, rationale, linked issue, visual proof, testing results, known full-test limitations, AI disclosure, compatibility considerations, and checklist status.

Full details: Linked Issues check

Explanation

Issue #31061 requires monthly Claude spend usage when no 5-hour or weekly window exists. fetchClaudeOAuthUsage now maps spend or legacy extra_usage data to monthly only when both plan windows are absent. Existing monthly rendering shows the percentage and 30d label. InlineUsageBars renders monthly-only inactive accounts and does not classify them as signed out. The reported tests cover spend and legacy inputs, suppression with plan windows, missing caps, and inactive-account rendering. The issue's amount and reset-date details are optional.

Full details: Out of Scope Changes check

Explanation

The changes remain within issue #31061. The fetcher mapping, monthly-window helper, status-bar account-switcher rendering, and related tests directly support Claude Enterprise monthly spend display. No unrelated provider or product-area changes are identified in the reviewed summary.

  • Fix all pre-merge checks with AI
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d0bba7a1-140c-4e64-89e2-f6fb487fe8c7
📥 Commits

Reviewing files that changed from the base of the PR and between 46d0a00 and 73c6aa8.

📒 Files selected for processing: 5
  • src/main/rate-limits/claude-oauth-usage-extra-usage.test.ts
  • src/main/rate-limits/claude-oauth-usage-request.ts
  • src/main/rate-limits/claude-usage-credits.ts
  • src/renderer/src/components/status-bar/InlineProviderUsage.tsx
  • src/renderer/src/components/status-bar/inline-usage-bars.test.tsx

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

… percent from amounts

A balance-only spend object no longer hides the cap from legacy extra_usage, and legacy utilization reported as a 0-1 fraction no longer understates the meter.
@nwparker

Copy link
Copy Markdown
Contributor

Thanks @frank-bee — your two commits landed (rebased) in #33655, merged with your co-author credit. Closing in favour of that.

nwparker added a commit that referenced this pull request Oct 25, 2026
… has no 5h/weekly window (#33655)

Claude Enterprise seats (null 5h/weekly windows, limit in spend/extra_usage) now show their spend cap as a monthly usage bar in the status bar chip, tooltip and account switcher instead of an empty meter.

Fixes #31061
Supersedes #31065

Co-authored-by: Frank Bernhardt <275327+frank-bee@users.noreply.github.com>
@nwparker nwparker closed this Oct 25, 2026
@frank-bee

frank-bee commented Oct 26, 2026 via email

Copy link
Copy Markdown
Contributor Author

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.

Status bar: show Claude monthly spend when an account has no 5h/weekly windows (Enterprise)

2 participants