Skip to content

fix(status-bar): prefer totalPercentUsed and Cursor Models bucket for Cursor usage display - #23531

Closed
Dacadev97 wants to merge 2 commits into
stablyai:mainfrom
Dacadev97:fix/cursor-usage-plan-percent-23515
Closed

Dacadev97 wants to merge 2 commits into
stablyai:mainfrom
Dacadev97:fix/cursor-usage-plan-percent-23515

Conversation

@Dacadev97

@Dacadev97 Dacadev97 commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

When Cursor Pro Plus accounts consume their base allowance, the status bar incorrectly showed 100% usage even when model pools still had available capacity. This change ensures Cursor displays the actual tightest model pool percentage instead of falsely reporting 100%.

What Changed

  • Before: Cursor users with Pro Plus plans saw the status bar display 100% usage when their base allowance hit limit, even though their primary model pool usage was low.
  • After: The status bar and usage roster show the actual tightest usage based on the active model pools.
  • Mechanism:
    • planPercent now reads totalPercentUsed directly instead of preferring the raw used/limit ratio.
    • getTightestUsageSection and providerMaxUsed prioritize the primary Cursor Models bucket when picking the headline percentage and sorting for Cursor.

Why

  • totalPercentUsed matches how sibling pool percentages (Cursor Models and Other Models) are already derived.
  • Prioritizing Cursor Models for Cursor accounts surfaces the relevant quota metric without altering behavior for any other provider (Claude, Codex, Gemini).

Linked Issue

Fixes #23515

Visual Proof

N/A - Numeric usage selection change in existing status bar label; no layout, styling, or element additions.

Testing

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

Ran existing test suite and added comprehensive tests covering totalPercentUsed extraction, Cursor Models bucket prioritization, and non-Cursor provider isolation:

  • src/main/rate-limits/cursor-usage-mapping.test.ts
  • src/renderer/src/components/status-bar/UsageRosterPanel.test.tsx
  • src/renderer/src/components/status-bar/provider-segment-monthly-window.test.tsx

AI Disclosure

Built through this repo's agentic pipeline (enrich → plan → implement → review → qa-code → address-review) — implement split across Cursor (parser) and Claude (headline picker), plan/review on Claude, gated by strict TDD (RED before each source change, GREEN after).

Review

  • Cross-platform: no OS-specific code touched — this is pure percent-derivation and section-selection logic with no path, shell, or platform branching.
  • SSH/remote/local: N/A — Cursor usage polling and status-bar rendering don't depend on remote/SSH state.
  • Agent/integration compatibility: only Cursor's provider branch changed; provider-segment-monthly-window.test.tsx explicitly asserts Claude/Codex/Gemini keep the unmodified max(usedPercent) reduce.
  • Performance: negligible — a finiteNumber/nullish-coalescing read and a linear scan over ≤4 sections; no new loops, allocations, or I/O.
  • UI quality: before/after screenshots posted on this PR (100% → 7% · Cursor Models) confirm the compact status bar and roster row now show the real tightest pool.
  • Security: no new external input surface — the same Cursor API response fields are read, just combined differently; no new IPC, network calls, or injectable strings.

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Ensure no issues in: Security, Cross-platoform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance

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 (unscoped, full repo) and pnpm typecheck pass. pnpm test passes for the touched files. pnpm build's desktop/renderer/web-client steps succeed; its build-mobile-web-app-bundle step fails locally because mobile/node_modules isn't installed in this checkout (node_modules is untracked/branch-independent, so this is a local install gap, not something this diff introduced or could fix) — unrelated to this change, which touches no mobile/ code.

@coderabbitai

coderabbitai Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

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: e3ab50b3-5380-4c03-8162-8befb83869fd

📥 Commits

Reviewing files that changed from the base of the PR and between 163a664 and 7d0f02b.

📒 Files selected for processing (1)
  • src/main/rate-limits/cursor-usage-mapping.ts

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


📝 Walkthrough

Walkthrough

Cursor monthly plan usage now uses totalPercentUsed when it is finite, with the existing pool percentage as a fallback. The on-demand pool retains its used / limit precedence. In the status bar, Cursor usage selection and sorting prefer the Cursor Models section when it exists. If it is absent, selection falls back to the maximum-used section. Tests cover percentage mapping, section selection, compact display, and provider ordering.

Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to 7d0f0

Cursor’s monthly percentage prefers its total percentage while retaining a fallback, and the status bar uses Cursor Models as its headline when available. No unresolved user-facing regression is evident; the PR is mergeable subject to normal checks.

Architecture Summary

Architecture risk: 🔵 Low · up to 7d0f0

The change affects 1 system.

Changed systems: src

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — src (service) was modified; 5 changed files map to changed impact.

Before / after behavior

  • observed — Modified behavior in src/main/rate-limits/cursor-usage-mapping.test.ts: The plan-pool test adds totalPercentUsed: 18 while retaining used, limit, and the automatic/API percentages.
  • observed — Modified behavior in src/main/rate-limits/cursor-usage-mapping.test.ts: The test now expects the monthly percentage to be 18 rather than 25; the reset-time assertion is unchanged.
  • observed — Modified behavior in src/main/rate-limits/cursor-usage-mapping.test.ts: The test asserting preference for the used/limit pair over Cursor’s rounded percentage is removed. A replacement test expects totalPercentUsed: 12 to be reported even when used equals limit.
  • observed — Modified behavior in src/main/rate-limits/cursor-usage-mapping.test.ts: The over-consumption test now supplies totalPercentUsed: 140 instead of used: 7_000 and limit: 5_000; its 100% expected result remains unchanged.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 44.44% 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 checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The PR meets the coding objectives in [#23515]. mapCursorUsageSummary prefers plan.totalPercentUsed and falls back to used / limit through poolPercent when the field is absent or invalid. `tig…
Out of Scope Changes check ✅ Passed The changes stay within [#23515]. The source changes update Cursor usage mapping, Cursor headline selection, and related provider sorting. The tests verify these behaviors and preserve maximum-usage s…
Title check ✅ Passed The title clearly and concisely identifies the two main changes: preferring totalPercentUsed and prioritizing the Cursor Models bucket for Cursor usage display.
Description check ✅ Passed The description is complete and relevant. It covers the user impact, implementation, rationale, linked issue, testing, compatibility considerations, and checklist status. It includes automated test co…
  • Fix all pre-merge checks with AI

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.

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

Important

The main-process change drops the used / limit fallback for the Cursor Plan window. That fails an existing, unmodified test (cursor-fetcher.test.ts) and silently hides the quota for accounts whose response omits totalPercentUsed. Details inline.

Reviewed changes

  • Cursor Plan percent source — mapCursorUsageSummary now reads plan.totalPercentUsed directly instead of preferring used / limit, so a base allowance at used == limit no longer reports 100%.
  • Cursor compact headline and sort order — tightestSection prefers the Cursor Models bucket for Cursor accounts in both getTightestUsageSection and providerMaxUsed; every other provider keeps the plain max reduce.
  • Tests — mapping and renderer tests updated for the new selection, plus non-Cursor isolation and worst-first sort tests.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@nwparker

Copy link
Copy Markdown
Contributor

@Dacadev97 can you include screenshots? Then I can merge

totalPercentUsed now wins for the monthly Plan window, but an account
whose Cursor response omits totalPercentUsed (used/limit only) was
silently losing its Plan quota entirely. Fall back to poolPercent's
used/limit derivation only when totalPercentUsed is absent.
@Dacadev97

Copy link
Copy Markdown
Contributor Author

@pullfrog you were right — verified and fixed in 7d0f02b.

cursor-fetcher.test.ts:70 ("publishes both plan pools and the cycle reset", fixture has used: 2500, limit: 5000, no totalPercentUsed) was RED against 163a664: expected undefined to be 50. planPercent now falls back to poolPercent(plan, 'totalPercentUsed') (used/limit) only when totalPercentUsed is absent, so accounts whose Cursor response omits it keep reporting their Plan quota instead of losing it. totalPercentUsed still wins when present, which is what #23515 needed.

All 38 tests across cursor-fetcher.test.ts, cursor-usage-mapping.test.ts, and service-cursor-usage.test.ts pass, and pnpm tc:node is clean.

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

✅ No new issues found.

Reviewed changes

Incremental review of the delta since the prior pullfrog review (163a6640ee → 7d0f02b3bd):

  • Restored the used/limit Plan fallback — mapCursorUsageSummary now computes planPercent as finiteNumber(plan?.totalPercentUsed) ?? poolPercent(plan, 'totalPercentUsed'), so totalPercentUsed stays authoritative while responses that omit it (only used/limit) still publish a Plan window.
  • Prior feedback addressed — this is exactly the fallback the previous review asked for; cursor-fetcher.test.ts:70 is green again and the "no allowance" degradation path is closed.

Verified locally: pnpm test src/main/rate-limits plus the two touched status-bar test files → 665 passed, 0 failed. Only cursor-usage-mapping.ts changed in the new commit; the renderer selection logic reviewed in the prior pass is unchanged.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

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

ℹ️ No critical issues — one stale doc line inline.

Reviewed changes

  • Cursor Plan percent source restored — mapCursorUsageSummary now treats totalPercentUsed as authoritative when present and falls back to poolPercent(plan, 'totalPercentUsed') (the used / limit pair) only when the account's response omits it, so a Pro Plus base allowance no longer reports 100% while quota-less responses keep their Plan window. cursor-fetcher.test.ts:70 is green again; the 38 tests across the three Cursor suites pass locally.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

Comment on lines +104 to +106
* Percent consumed for the on-demand pool. `used / limit` wins over
* `totalPercentUsed`: the raw pair is internally consistent, while the percentage
* is pre-rounded for the dashboard's own copy and disagrees with it on real accounts.

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.

This docstring still scopes poolPercent to "the on-demand pool", but 7d0f02b now also calls it for the Plan window's fallback (mapCursorUsageSummary line 160). The precedence it describes is accurate; only the scope phrase is stale.

Technical details
# Stale scope in `poolPercent` docstring

## Affected sites
- `src/main/rate-limits/cursor-usage-mapping.ts:104` — "for the on-demand pool" no longer matches the two call sites: `mapCursorUsageSummary` calls it for `plan` (line 160) and for `onDemand` (line 151).

## Required outcome
- Docstring names a generic usage pool rather than only on-demand.
Suggested change
* Percent consumed for the on-demand pool. `used / limit` wins over
* `totalPercentUsed`: the raw pair is internally consistent, while the percentage
* is pre-rounded for the dashboard's own copy and disagrees with it on real accounts.
* Percent consumed for a usage pool. `used / limit` wins over
* `totalPercentUsed`: the raw pair is internally consistent, while the percentage
* is pre-rounded for the dashboard's own copy and disagrees with it on real accounts.

@Dacadev97

Dacadev97 commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor Author
after-cursor-models-7-percent before-cursor-100-percent

@nwparker

nwparker commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

Thanks @Dacadev97 for the original proposal. The credited successor #24830 has now merged into main at 00da8e1e54cfe83eca16d790524a058b46fbc8f8 after all checks passed. The landed fix honors reported plan totals and the primary Cursor Models compact headline while preserving secondary-pool exhaustion warnings, sorting and collapse. Issue #23515 is closed by the merge. Closing this predecessor now that the successor is merged.

@nwparker nwparker closed this Oct 3, 2026
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.

[Bug]: Cursor usage shows 100% (Plan used/limit) while Cursor Models / Other Models pools are barely used

2 participants