feat: show Codex and Claude usage limits - #4326
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
ApprovabilityVerdict: Needs human review This PR introduces a new user-facing feature (provider usage limits display) with substantial new logic including external API response parsing, new UI components, and cross-layer integration. New features of this scope warrant human review. You can customize Macroscope's approvability policy. Learn more. |
071bb91 to
f5305f0
Compare
f5305f0 to
a2649d8
Compare
a2649d8 to
81f671d
Compare
346301f to
ba2f487
Compare
|
@juliusmarminge could you or someone get some eyes on this please? I know, I know, but this functionality is legit the last major QoL thing for me (and at least a few others). Would (mostly) close out an OG issue too ;). More than happy to make any changes if needed quickly to get this in unless y'all just disagree with the entire concept, but I think I have something pretty sensible here |
|
Would it also make sense to surface the same session/weekly usage progress-bars charts following a |
0abc172 to
752b4df
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want fixes drafted automatically? Bugbot Autofix can create code changes for findings. A team admin can enable Autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 752b4df. Configure here.
| ], | ||
| { concurrency: "unbounded" }, | ||
| ).pipe( | ||
| Effect.timeoutOption(USAGE_PROBE_TIMEOUT_MS), |
There was a problem hiding this comment.
Auth hang drops usage results
Medium Severity
probeClaudeUsageLimits applies one four-second timeoutOption around the combined /usage and auth status Effect.all. If auth status is still running when that budget elapses, the whole probe is interrupted and successful /usage output is discarded, so limits disappear even though usage already completed.
Reviewed by Cursor Bugbot for commit 752b4df. Configure here.
|
Closing in favor of #5684 |


Fixes #228.
What Changed
Adds provider subscription usage visibility for Codex and Claude.
account/rateLimits/readapp-server method.claude --print "/usage" --output-format json.Why
Provider limits are easy to exhaust without any explanation in T3 Code. Users currently have to leave the app and repeatedly run
/usageor/statusto understand why a session stopped responding or how much capacity remains.Provider settings provide a consistent place to inspect limits. The optional chat presentation gives users who check frequently quicker access without changing what the context-window gauge represents.
Implementation Notes
Out Of Scope
This PR reports subscription rate-limit windows only. The Codex
account/rateLimits/readresponse also carriescredits,individualLimit,planType,spendControlReached,rateLimitReachedType, and a multi-bucketrateLimitsByLimitIdview, none of which are read here.Two consequences worth knowing: accounts on usage-based plans or running purely on credits show no usage rather than wrong usage, and a window that reads fully consumed does not by itself mean work is blocked when credits remain. Representing balances needs a currency-denominated contract shape rather than the current percent-only window, so it is left as a follow-up.
UI Changes
Settings > Providers
Collapsed provider rows show a compact summary such as:
Session 16% · Weekly (all models) 80% · Weekly (Fable) 68% remainingExpanded provider details show the full progress bars and reset timestamps.
Before:
After:
Optional context popover
When enabled under General settings, the context-window popover includes a visually separated
Provider limitssection.Before:
After:
Verification
Prior Work and Feedback
This builds on the original implementation work in #1732 by @Aditya190803 and the discussion in #228. @dtown123 also identified the current Claude JSON-envelope command used here.
The narrower implementation incorporates feedback from those threads by:
Reviewer Notes
Claude Code currently returns usage as human-readable text inside a JSON
resultenvelope. The parser intentionally fails closed: malformed JSON, changed output text, non-zero exits, and timeouts omit usage without changing provider health.An independent Claude Opus 4.8 review found and prompted fixes for:
A second Opus 4.8 review found no remaining blocking issues. Residual risk is limited to upstream Claude
/usagewording changes, which fail closed.Checklist
Note
Medium Risk
Adds best-effort child-process and app-server probes on provider health checks; failures are isolated but Claude output parsing is brittle if upstream wording changes.
Overview
Adds subscription rate-limit visibility for Codex and Claude by extending provider snapshots with
usageLimits(dynamic windows with used %, optional reset times) and surfacing them in Settings and optionally in chat.Server: Codex probes
account/rateLimits/readfor ChatGPT accounts (2s timeout, concurrent with existing app-server probe). Claude runs--print /usageJSON plusauth status --json, parses human-readable output viaproviderUsageLimits, skips API key/Bedrock, verifies email against capabilities, and caches probes per instance inClaudeDriver(5 min on success, immediate expiry on failure).Contracts: New
ServerProviderUsageLimits/ window schema onServerProvider; client settingshowProviderUsageInContextPopover(default off).Web:
ProviderUsageRows/ summary on provider cards; context-window popover can show a separated “Provider limits” section when the setting is enabled, keyed to the active thread’s provider instance.Reviewed by Cursor Bugbot for commit 752b4df. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Show Codex and Claude subscription usage limits in the UI
probeClaudeUsageLimitsto fetch Claude account identity and usage windows via--print /usage, with a 4s timeout and per-identity caching inClaudeDriver.probeCodexAppServerProviderviaaccount/rateLimits/readwith a 2s timeout.usageLimitsFromCodexRateLimitsandparseClaudeUsageLimitsJsonin providerUsageLimits.ts to normalize provider-specific data into a sharedServerProviderUsageLimitscontract shape.ProviderUsageRowsandProviderUsageSummarycomponents, surfaced in the context window popover and provider settings panel.showProviderUsageInContextPopoverclient setting (defaultfalse) to gate display of usage in the chat composer popover.Macroscope summarized 752b4df.