Skip to content

feat: on-demand usage meter with cap alerts - #80

Merged
CodyKoInABox merged 1 commit into
mainfrom
feat/on-demand-meter
Nov 10, 2026
Merged

CodyKoInABox merged 1 commit into
mainfrom
feat/on-demand-meter

Conversation

@CodyKoInABox

Copy link
Copy Markdown
Owner

What

Adds an On-demand meter to the sidebar, between Other Models and the usage windows. It shows spend against the per-user cap set in Cursor, for example .40 / .00, the percent of the limit used, and what is left.

  • Fixed cap: bar fills to the cap. At the cap the subtitle reads "Limit reached" in the error color.
  • Off (cap is 0 or missing): headline Off, no bar, with spend shown if any.
  • Unlimited (cap is the API no-limit sentinel 2147483647): spend only, no bar.
  • Absent spendLimitUsage block: the section is hidden. No fake ``.

Threshold alerts (cursorPlanUsage.alertThresholds, default 80 and 95) also cover the on-demand cap, once per threshold per billing cycle. Off and unlimited produce no alert.

Data source

Field names and units come from Cursor's own dashboard client, found in the installed app bundle, not guessed:

  • spendLimitUsage.individualUsed (cents): on-demand spend this cycle
  • spendLimitUsage.individualLimit (cents): the cap; 0 or missing means off; >= 2147483647 means unlimited

The parser is in src/onDemand.ts and is pure, so it is covered by tests without the VS Code host.

Tests

  • src/onDemand.test.ts: parsing for each mode and missing fields, formatting, view strings, alert readings and once-per-cycle alerting
  • src/media/view.test.ts: section placement, headline, bar, Off, unlimited, limit-reached, and hidden-when-absent in jsdom
  • src/contract.test.ts: new currentPeriodUsageOnDemand.json fixture

npm run check, npm test (231 passing), npm run compile and npm run package all pass locally.

Notes

  • usageViewProvider.sameUsage compares onDemand, so the sidebar re-renders when only on-demand spend changes.
  • Not verified against a live account. Compare the sidebar value with the Cursor dashboard after reloading the window.

Show on-demand spend against the per-user cap from spendLimitUsage (individualUsed / individualLimit, cents) as its own section under Other Models. Off, unlimited, and limit-reached states are handled. The cap also feeds the threshold alerts, once per cycle.

Co-authored-by: Cursor <cursoragent@cursor.com>
@CodyKoInABox
CodyKoInABox merged commit dcdbbd3 into main Nov 10, 2026
4 checks passed
@CodyKoInABox
CodyKoInABox deleted the feat/on-demand-meter branch November 10, 2026 23:18
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.

1 participant