feat(web): show current-provider usage in the chat box - #8445
feat(web): show current-provider usage in the chat box#8445Aditya190803 wants to merge 2 commits into
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:
Comment |
| if (!date) return null; | ||
| // Cursor's panel is date-only ("Resets 16 Sept"). We store that as UTC | ||
| // midnight; including a clock would invent a local time like 5:30 AM. | ||
| if (/T00:00:00(?:\.000)?Z$/.test(resetsAt)) { |
There was a problem hiding this comment.
🟡 Medium usage/ProviderQuotaLimits.tsx:39
formatUsageResetDate renders every T00:00:00Z reset as a date-only UTC value, so real midnight-UTC instants from providers such as Claude lose their meaningful clock and display the wrong local calendar date for users west of UTC. The date-only classification must come from the provider/source (for example, via an explicit flag), rather than the timestamp shape alone.
🤖 Copy this AI Prompt to have your agent fix this:
In file @apps/web/src/components/usage/ProviderQuotaLimits.tsx around line 39:
`formatUsageResetDate` renders every `T00:00:00Z` reset as a date-only UTC value, so real midnight-UTC instants from providers such as Claude lose their meaningful clock and display the wrong local calendar date for users west of UTC. The date-only classification must come from the provider/source (for example, via an explicit flag), rather than the timestamp shape alone.
| source: published.source, | ||
| available: true, | ||
| checkedAt: published.checkedAt, | ||
| windows: mergeUsageLimitWindows(probed.windows, livePatchedWindows), |
There was a problem hiding this comment.
🟡 Medium provider/providerUsageLimits.ts:200
A concurrent runtime update can overwrite the probe's current resetsAt and windowDurationMins with stale values, so the published quota bar shows an obsolete reset time and duration. applyRuntimeUsageLimits has already filled those omitted fields into the live patch, and mergeUsageLimitWindows(probed.windows, livePatchedWindows) gives the patch precedence as if they were freshly reported. Preserve the probe's metadata while applying the live percentage-only update, or retain which fields were actually present in the runtime event.
🤖 Copy this AI Prompt to have your agent fix this:
In file @apps/server/src/provider/providerUsageLimits.ts around line 200:
A concurrent runtime update can overwrite the probe's current `resetsAt` and `windowDurationMins` with stale values, so the published quota bar shows an obsolete reset time and duration. `applyRuntimeUsageLimits` has already filled those omitted fields into the live patch, and `mergeUsageLimitWindows(probed.windows, livePatchedWindows)` gives the patch precedence as if they were freshly reported. Preserve the probe's metadata while applying the live percentage-only update, or retain which fields were actually present in the runtime event.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3168a0c74c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const rateLimitsResponse = yield* client.request("account/rateLimits/read", undefined).pipe( | ||
| Effect.timeoutOption(Duration.millis(RATE_LIMITS_PROBE_TIMEOUT_MS)), | ||
| Effect.catchCause((cause) => | ||
| Cause.hasInterrupts(cause) ? Effect.failCause(cause) : Effect.succeed(Option.none()), |
There was a problem hiding this comment.
Keep quota reading outside Codex's 10-second status deadline
When the existing account/models/skills requests consume most of AUTH_PROBE_TIMEOUT_MS, this new sequential request can still be pending when the outer timeout fires. That interrupt is deliberately rethrown here, so checkCodexProviderStatus returns its full error snapshot instead of retaining a healthy Codex status with usage omitted; this occurs for otherwise working accounts whenever account/rateLimits/read cannot finish in the remaining probe budget.
Useful? React with 👍 / 👎.
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.
Reviewed by Cursor Bugbot for commit e464240. Configure here.
| ? window.windowDurationMins | ||
| : reported.length > 1 && index === 0 | ||
| ? CODEX_SESSION_WINDOW_DURATION_MINS | ||
| : CODEX_WEEKLY_WINDOW_DURATION_MINS; |
There was a problem hiding this comment.
Sparse Codex updates mislabel session
Medium Severity
Live Codex account.rate-limits.updated payloads are run through resolveCodexRateLimitSnapshotUsageLimits, which treats a lone duration-less primary window as weekly. That heuristic is correct for a full snapshot after Codex dropped the session cap, but runtime notifications are documented as sparse. A primary-only event then upserts the weekly bar (via kind-keyed merge) with session utilization, so the chat meter and Usage page show the wrong window during a turn.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit e464240. Configure here.
ApprovabilityVerdict: Not approved Macroscope's review found this PR not approvable — This PR adds a new opt-in quota-usage capability across settings and the production chat composer, including a new meter and context-window integration, rather than making a small isolated adjustment. The new product default and unresolved runtime concerns around quota updates, probe timing, and composer layout warrant human review. Not approved because:
Adjust the Minimum Blocking Severity for this repo — including turning it Off — in Settings. You can add or adjust custom eligibility rules. Learn more. |
|
Could it display the reset date for both the session and weekly limits? Thanks! |
| if (isGrokFreeTier(provider)) { | ||
| return GROK_FREE_TIER_USAGE_MESSAGE; | ||
| } | ||
| if (!provider.usageLimits) return "Usage data unavailable"; |
There was a problem hiding this comment.
🟡 Medium usage/ProviderQuotaLimits.tsx:85
An available usageLimits snapshot with an empty windows array produces a blank provider card: providerQuotaNotice returns null, then ProviderUsageBars returns null without rendering anything. Forward-compatible decoding can drop all unrecognized windows, so treat this state as unavailable (or hide the provider) instead of reporting no notice.
| if (!provider.usageLimits) return "Usage data unavailable"; | |
| if (!provider.usageLimits || provider.usageLimits.windows.length === 0) return "Usage data unavailable"; |
🤖 Copy this AI Prompt to have your agent fix this:
In file @apps/web/src/components/usage/ProviderQuotaLimits.tsx around line 85:
An available `usageLimits` snapshot with an empty `windows` array produces a blank provider card: `providerQuotaNotice` returns `null`, then `ProviderUsageBars` returns `null` without rendering anything. Forward-compatible decoding can drop all unrecognized windows, so treat this state as unavailable (or hide the provider) instead of reporting no notice.
| ) : null} | ||
| <ComposerFooterPrimaryActions | ||
| compact={isComposerResting || isComposerPrimaryActionsCompact} | ||
| composerUsage={composerUsage} |
There was a problem hiding this comment.
🟡 Medium chat/ChatComposer.tsx:5626
When the desktop composer is resting without activeContextWindow, composerUsage adds a percent button beside the send controls, but the prompt row still reserves only pr-12 (or pr-20 with Attach), so the meter and send controls overlap the end of the one-line prompt for opted-in providers with quota data. Increase the resting prompt’s right padding to account for the usage meter, or keep the meter outside that absolutely positioned footer.
🤖 Copy this AI Prompt to have your agent fix this:
In file @apps/web/src/components/chat/ChatComposer.tsx around line 5626:
When the desktop composer is resting without `activeContextWindow`, `composerUsage` adds a percent button beside the send controls, but the prompt row still reserves only `pr-12` (or `pr-20` with Attach), so the meter and send controls overlap the end of the one-line prompt for opted-in providers with quota data. Increase the resting prompt’s right padding to account for the usage meter, or keep the meter outside that absolutely positioned footer.
| }), | ||
| }); | ||
| return new NodePtyProcess(ptyProcess); | ||
| return new NodePtyProcess(ptyProcess, platform); |
There was a problem hiding this comment.
🟠 High terminal/NodePtyAdapter.ts:223
On Windows, process.kill("SIGTERM") now force-terminates the entire PTY process tree immediately, so applications cannot perform graceful shutdown and may lose in-progress state. Passing platform enables NodePtyProcess.kill to ignore the requested signal and always run taskkill ... /F; preserve the SIGTERM grace period and reserve forceful tree termination for SIGKILL.
🤖 Copy this AI Prompt to have your agent fix this:
In file @apps/server/src/terminal/NodePtyAdapter.ts around line 223:
On Windows, `process.kill("SIGTERM")` now force-terminates the entire PTY process tree immediately, so applications cannot perform graceful shutdown and may lose in-progress state. Passing `platform` enables `NodePtyProcess.kill` to ignore the requested signal and always run `taskkill ... /F`; preserve the `SIGTERM` grace period and reserve forceful tree termination for `SIGKILL`.
Bugbot is paused — on-demand spend limit reachedBugbot uses usage-based billing for this team and has hit its on-demand spend limit. A team admin can raise the spend limit in the Cursor dashboard, or wait for the next billing cycle to continue. |
eefe51d to
c8a54fb
Compare
Opt-in Settings toggle renders the thread provider's subscription windows next to send after the first message, reusing the Limits model already on main.
c8a54fb to
91c82ae
Compare
Bugbot is paused — on-demand spend limit reachedBugbot uses usage-based billing for this team and has hit its on-demand spend limit. A team admin can raise the spend limit in the Cursor dashboard, or wait for the next billing cycle to continue. |


Adds opt-in remaining session/weekly usage for the current thread's provider next to the chat box.
Before — setting off, chat box unchanged
After — usage bars in the chat box hover
Test plan
Note
Add provider usage meter to chat composer
showProviderUsageInComposersetting (defaultfalse) in settings.ts and exposes it in General settings with search support.resolveComposerUsageMeterin ComposerUsageMeter.logic.ts to compute usage visibility based on the setting, turn state, and selected provider.ComposerUsageMetercomponent in ChatComposer.tsx and ContextWindowMeter.tsx to display quota windows with threshold-based colors at 70% and 90%.showProviderUsageInComposerdefaults tofalse.isGrokFreeTierin ComposerUsageMeter.logic.ts suppresses usage for free-tier Grok providers, and missing or empty usage snapshots are hidden.Macroscope summarized 346f6b8.