Skip to content

feat(web): show current-provider usage in the chat box - #8445

Open
Aditya190803 wants to merge 2 commits into
pingdotgg:mainfrom
Aditya190803:feat/usage-in-chat
Open

feat(web): show current-provider usage in the chat box#8445
Aditya190803 wants to merge 2 commits into
pingdotgg:mainfrom
Aditya190803:feat/usage-in-chat

Conversation

@Aditya190803

@Aditya190803 Aditya190803 commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Adds opt-in remaining session/weekly usage for the current thread's provider next to the chat box.

  • Off by default: Settings → General → Show usage in chat
  • Hidden on a new thread until the first message is sent
  • Codex thread shows Codex only; switching providers switches the meter
  • Bars live in the context-window hover when a ring is visible, otherwise a compact percent control appears next to send
  • Providers without a usable quota snapshot hide the meter instead of showing an error

Before — setting off, chat box unchanged

Show usage in chat setting

After — usage bars in the chat box hover

Session and weekly usage in the context-window hover

Test plan

  • Toggle stays off by default; empty new thread shows no percent next to send
  • After enabling the setting and sending a message, the context-window hover shows Usage bars for the current provider
  • Switching the thread's provider switches the meter; providers without quota hide it

Note

Add provider usage meter to chat composer

  • Adds an opt-in showProviderUsageInComposer setting (default false) in settings.ts and exposes it in General settings with search support.
  • Introduces resolveComposerUsageMeter in ComposerUsageMeter.logic.ts to compute usage visibility based on the setting, turn state, and selected provider.
  • Renders the ComposerUsageMeter component in ChatComposer.tsx and ContextWindowMeter.tsx to display quota windows with threshold-based colors at 70% and 90%.
  • Behavioral Change: showProviderUsageInComposer defaults to false. isGrokFreeTier in ComposerUsageMeter.logic.ts suppresses usage for free-tier Grok providers, and missing or empty usage snapshots are hidden.

Macroscope summarized 346f6b8.

@coderabbitai

coderabbitai Bot commented Aug 27, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 49df763f-79db-490a-8fb0-56b2a5eb8058

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:XXL 1,000+ changed lines (additions + deletions). labels Aug 27, 2026
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)) {

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.

🟡 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.

Comment thread apps/server/src/provider/providerUsageLimits.ts Outdated
Comment thread apps/server/src/provider/claudeUsageProbe.ts Outdated
Comment thread docs/user/usage.md Outdated
Comment thread apps/mobile/src/features/usage/UsageRouteScreen.tsx Outdated
Comment thread apps/server/src/provider/runtimeUsageLimits.ts Outdated
source: published.source,
available: true,
checkedAt: published.checkedAt,
windows: mergeUsageLimitWindows(probed.windows, livePatchedWindows),

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.

🟡 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.

Comment thread apps/server/src/provider/Layers/CodexProvider.ts Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment on lines +411 to +414
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()),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

@cursor cursor 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.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ 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;

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.

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)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit e464240. Configure here.

@macroscopeapp

macroscopeapp Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: 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:

  • 5 blocking correctness issues found at or above your repo's Minimum Blocking Severity

Adjust the Minimum Blocking Severity for this repo — including turning it Off — in Settings. You can add or adjust custom eligibility rules. Learn more.

@Jardo-51

Copy link
Copy Markdown
Contributor

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";

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.

🟡 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.

Suggested change
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}

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.

🟡 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);

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.

🟠 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`.

@cursor

cursor Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Bugbot is paused — on-demand spend limit reached

Bugbot 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.

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.
@cursor

cursor Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Bugbot is paused — on-demand spend limit reached

Bugbot 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.

@github-actions github-actions Bot added size:L 100-499 changed lines (additions + deletions). and removed size:XXL 1,000+ changed lines (additions + deletions). labels Sep 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants