Skip to content

feat(rate-limits): add Cursor usage tracking - #22633

Merged
nwparker merged 9 commits into
mainfrom
nwparker/cursor-usage
Sep 26, 2026
Merged

nwparker merged 9 commits into
mainfrom
nwparker/cursor-usage

Conversation

@nwparker

@nwparker nwparker commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 21 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1173 $\color{#cf222e}{\Huge{\mathbf{−}}}$​12 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1161
Prod 52 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1815 $\color{#cf222e}{\Huge{\mathbf{−}}}$​262 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1553

ELI5

If you use Cursor, Orca now shows how much of your monthly Cursor plan you have left, right next to the Claude, Codex and Grok meters, and in Settings → Accounts. It reads the Cursor sign-in that is already on your computer. It never changes that sign-in, and there is no new login to do.

What Changed

Before: Cursor was a first-class agent in Orca — icon, hooks, session scanning, AI-vault — but had no usage meter. Checking your remaining Cursor budget meant leaving Orca for cursor.com.

After: Cursor is a rate-limit provider like Grok: a status-bar meter (default-on, with its own toggle in the usage menu and in Appearance), a row in the usage roster, and a Settings → Accounts → Cursor section naming the signed-in account.

The mechanism. The credential is read from whichever of three local stores has it, first match wins, all read-only:

Order Source Where Who writes it
1 keychain macOS login keychain, cursor-access-token / cursor-user cursor-agent 2026.06+
2 cli ~/.cursor/auth.json, %APPDATA%\Cursor\auth.json, $XDG_CONFIG_HOME/cursor/auth.json older cursor-agent builds
3 desktop Cursor IDE state.vscdb, key cursorAuth/accessToken the Cursor IDE

A locked keychain cannot mask a readable auth.json, and a locked state.vscdb cannot mask either. ~/.cursor/cli-config.json supplies the account email/display name; it never holds a token.

Usage comes from GET cursor.com/api/usage-summary — the route Cursor's own dashboard reads — with GET /api/usage as a fallback for accounts still on request-quota billing. Per Cursor's pricing docs an individual plan has two pools, Cursor Models and Other Models, both resetting with the billing cycle, plus optional On-demand spend; each becomes a named bucket.

Orca never runs cursor-agent login and never writes, refreshes or rotates a Cursor credential.

Credential detail. The stored token is a JWT. cursor-agent refreshes it when you use Cursor; Orca does not, because a refresh would rotate a credential another tool owns — so a lapsed exp short-circuits to an actionable "run cursor-agent login" rather than spending a request that can only 401. A live session wins over precedence: an expired keychain token in front of a fresh Cursor IDE session resolves to the IDE, so an IDE-only user is never told "expired" while a usable session sits one source below. ~/.cursor/cli-config.json supplies the account email and display name; it never holds a token.

Why

Six open PRs implement this feature (#8669, #11780, #13837, #16815, #18119, #20469, #21833) and all of them are credited as co-authors here — this keeps what they verified live and takes the auth layer further.

Why the auth layer needed to go further: none of the six reads the macOS Keychain, and that is where current cursor-agent builds keep the session. On this machine (cursor-agent 2026.06.02) there is no ~/.cursor/auth.json at all. So the three PRs that read only auth.json find nothing on an up-to-date macOS install, and the three that read only the IDE database find nothing for CLI-only users. Reading all three in order is what makes the meter appear for everyone rather than for a subset.

Why an expired token is reported rather than refreshed: cursor-agent owns its own token rotation, and refreshing would rotate a credential another tool owns. So a lapsed exp short-circuits to an actionable "run cursor-agent login" instead of spending a request that can only 401. This is not a rare edge case — cursor-agent status --format json on this machine still reports isAuthenticated: true against a token that expired three months ago, which is exactly the state the screenshots below show.

Why the mapping is defensive: Cursor documents no individual-user usage API — every documented API is team- or Enterprise-scoped with a crsr_ key. This route is undocumented, so every field is optional and an unrecognised payload resolves to unavailable, which hides the bar, rather than publishing a 0% that reads as "no usage". The headline percentage prefers used / limit over the sibling percentage fields, which are pre-rounded for the dashboard's own copy.

Why this meter is not PATH-gated. Other CLI-backed meters hide when the agent is missing from PATH. Cursor does not, because an IDE-only session is real usage with no CLI to detect. It follows MiniMax instead: visible whenever a credential exists.

One thing worth a reviewer's eye. readKeychainPassword moved out of src/main/claude-accounts/keychain.ts into src/main/macos-keychain/generic-password.ts so Claude and Cursor share one security(1) wrapper. It is a byte-for-byte relocation, so Claude's credential path and its tests are untouched, and the entry moves with it in both child_process allowlists — neither ratchet count changes. I first tried the stronger fix (routing security through runProcess, which would have let me lower the pin 153 → 152), but it breaks Claude's own keychain tests, and rewriting a Claude credential-path test is not something I wanted to do inside a Cursor feature. Happy to drop the extraction entirely and import from the Claude module if a reviewer prefers no allowlist edit.

Linked Issue

Fixes #15516
Also closes #21832 (Cursor half; OpenRouter deliberately left out of scope) and #20067.

Visual Proof

Status bar — before (no Cursor meter):

before

Status bar — after, on a real account whose CLI token has lapsed:

after

Settings → Accounts → Cursor (email redacted), identity resolved from cli-config.json:

accounts

These show the expired-sign-in path because that is the honest state of the only Cursor account on my machine. A screenshot of live percentages is the one thing I could not produce myself — see Testing.

Attribution

The dashboard protocol here is not original work. The WorkosCursorSessionToken cookie shape, the usage-summary endpoint and the CSRF Origin/Referer requirement were worked out by steipete/CodexBar (MIT) and brought into Orca by #13837, #18119, #20469 and #21833. The used / limit preference over the rounded percentage fields, isUnlimited, and the legacy request-quota fallback all come from those PRs' live testing. All six PR authors are co-authors on the commit.

Thanks also to @lurunzi (#20469), who ran this branch against a live Cursor Pro account on Windows and confirmed the figures against the cursor.com dashboard — see Testing.

Try it

Installable build of this branch (macOS signed, Windows unsigned):
https://github.com/stablyai/orca-adhoc/releases/tag/v1.4.211-adhoc.20260924232116

Testing

  • I manually tested these changes locally
  • Automated tests added/updated

End-to-end in the real app (Electron dev build, CDP, background launch). After a refresh cycle the live store returned:

{"provider":"cursor","status":"error",
 "error":"Cursor sign-in expired — run `cursor-agent login` again",
 "usageMetadata":{"source":"cli","credentialSource":"keychain","failureKind":"stale-token"}}

credentialSource: "keychain" is the load-bearing part: the discovery path none of the prior PRs have, resolving in the real Electron runtime, with no keychain authorization prompt and correct expiry classification. cursorAuthConfigured flipped to true, the meter rendered, and Settings → Accounts resolved the account email from cli-config.json.

Automated: 51 new tests — credential precedence and every failure mode (locked keychain not masking auth.json, corrupt/absent files, paths kept out of error text), token parsing/expiry/cookie shape, pool mapping (both pools, on-demand only when enabled, used/limit over rounded percentages, unlimited plans, clamping, month-end cycle rollover), fetcher error policy (401/403/429 with Retry-After/5xx/parse/network), the legacy quota fallback, service-cycle integration, and the extracted keychain primitive.

Full suite: pnpm test — 88,322 passed. The 8 remaining failures are pre-existing: I stashed this entire change, re-ran them on a clean tree, and got byte-identical results (6 failed | 3 passed, 18 failed | 71 passed | 7 skipped). Four failures were mine and are fixed (both child_process allowlists, register-core-handlers, web-preload-api-composition).

pnpm tc clean · oxlint 0 errors · check:code-quality:changed passes · max-lines ratchet OK (two files I pushed over 300 lines were split, not suppressed) · localization catalogs synced.

Platforms: verified on macOS. The auth.json and state.vscdb paths are platform-branched and unit-tested for Windows/Linux but not exercised on those OSes. No native code, no new spawns. The keychain step is macOS-only by an explicit process.platform check and returns null elsewhere, so Linux/Windows fall straight through to the file sources.

Live confirmation on a paid account. I could not exercise the success path myself — the only Cursor account on this machine has a token that expired three months ago, which is why the screenshots above show the expired state. @lurunzi tested this branch on Windows with an active Cursor Pro account and reported the figures matching cursor.com exactly: Plan Pro, Cursor Models 78% (warning tier), Other Models 100% (full tier), reset in 1d 10h, credential resolved from %APPDATA%\Cursor\auth.json with no empty bars. Screenshots in both Compact and Detailed modes are on #20469. That covers the Windows auth.json path, the two-pool render, and a pool at 100% — the cases I had only unit tests for.

Still unverified: the Cursor IDE state.vscdb path on a live account, and a plan shape other than Pro (unlimited/Ultra, on-demand enabled, teams, legacy request-quota). Those degrade to "no bar" rather than to a wrong number, and each has unit coverage.

AI Disclosure

Written with Claude Opus 4.6 in Orca.

Review

Agent skill upstream boundary

  • Not applicable.

Notes

  • Security: credential reads only; no writes, no refresh, no rotation. Tokens stay in main and never cross IPC — the renderer sees percentages, a source label, and a boolean. Filesystem errors are replaced with fixed strings so local usernames and custom paths never reach the renderer, mobile, or an error toast.
  • Cross-platform: paths branch per platform; keychain is macOS-only behind a runtime check.
  • Remote SSH / mobile: the Cursor session belongs to the machine running Orca, so a web/remote client reports signed-out rather than guessing at the host's credential. The provider enum widened in the mobile snapshot decoder, which is a backward-compatible optional-field change per docs/reference/remote-wire-compatibility.md — no new stream opcode.
  • Backwards compatibility: new state fields are additive; the status-bar item is added by a one-shot migration flag (_cursorStatusBarDefaultAdded) so a user who hides it keeps it hidden.
  • Performance: one HTTP call per existing poll cycle, 10s timeout, Retry-After honoured on 429. The keychain probe runs on the fetch cycle, never on getState(), which is hot. state.vscdb is opened read-only in place and only when the two cheaper sources miss.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • Before/after screenshots attached
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered
  • pnpm lint, pnpm typecheck, pnpm test pass locally (see Testing); pnpm build left to CI

@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 new Cursor auth tests fail on the Linux CI runner, which will make the required test shards red. Separately, Cursor's bucket-only snapshot renders no percentage in the default status-bar mode. Both are detailed below and inline.

Reviewed changes

  • Cursor credential discovery — reads three read-only sources in precedence order (macOS Keychain → CLI auth.json → IDE state.vscdb), parses the WorkOS JWT locally, and short-circuits an expired token instead of issuing a request that must 401.
  • Usage fetch and mapping — cursor-fetcher.ts calls cursor.com/api/usage-summary on the default session with manual Cookie/Origin/Referer headers, maps two plan pools plus optional on-demand, and falls back to the legacy request-quota endpoint.
  • Service integration — Cursor is a sibling provider promise (service-sibling-provider-result.ts) wired into state, polling, stale policy, and a cursorAuthConfigured presence flag; a Cursor failure cannot take the rest of the cycle down.
  • Renderer surface — status-bar meter, visibility menu and Appearance toggles, usage roster, and Settings → Accounts → Cursor, added default-on via a one-shot _cursorStatusBarDefaultAdded flag.
  • Keychain extraction — Claude's security(1) wrapper relocated byte-for-byte to src/main/macos-keychain/generic-password.ts; both child_process allowlists updated (entry moves, counts unchanged).
  • Tests and i18n — ~51 new tests across auth, token, mapping, fetcher, service, visibility, and catalogs.

⚠️ Cursor's buckets render no percentage in the default status-bar mode

A typical paid Cursor snapshot carries buckets (Cursor Models, Other Models, optionally On-demand). The inline status-bar footer filters buckets through a Gemini-only allowlist (StatusBarProviderSegment.tsx:97), and its no-bucket-matched fallback requires p.session, which Cursor never sets — so in the default verbose mode Cursor renders just its icon and a bare bar with no number, and in a narrow bar nothing but the icon. The linked screenshot only shows the expired-sign-in path, so this data path was never seen live.

Technical details
# Cursor's buckets are filtered out of the verbose status-bar footer

## Affected sites
- src/renderer/src/components/status-bar/StatusBarProviderSegment.tsx:97 — `STATUS_BAR_BUCKET_NAMES` is `{'Flash','Pro','1.5 Pro'}` (Gemini only).
- src/renderer/src/components/status-bar/StatusBarProviderSegment.tsx:106-127 — `VerboseProviderUsage` emits only allowlisted buckets, and its fallback requires `p.session` (null for Cursor), so the fragment is empty.
- src/renderer/src/components/status-bar/tooltip.tsx:148-157 — `getWindowSections` returns buckets + `weekly` whenever `buckets` exist and never includes `monthly`, so Cursor's plan-total window is dropped from the roster/tooltip too.

## Required outcome
- A Cursor snapshot's usage number is visible in the default status bar, matching Grok/Gemini.
- Decide whether the plan total (`monthly`) should also appear in the roster/tooltip when `buckets` are present.

## Suggested approach
- Fall back to the tightest window (or match `isCursorUsageBucket` from `src/shared/cursor-usage-buckets.ts`) when no allowlisted bucket matches, or add the Cursor names to the allowlist.
- Consider including `monthly` in `getWindowSections` alongside buckets.

## Open questions for the human
- Is the plan-total percentage intended for the status bar, or only for Settings → Accounts?

ℹ️ Nitpicks

  • status-bar-provider-visibility.test.ts — four fixtures use cursor: provider('unavailable', { provider: 'grok' }); the mismatched provider id is harmless here (isUsageEmptyState only reads status) but reads as a copy-paste slip.
  • The PR description links docs/reference/cursor-usage-credentials.md, which is not present in the tree or the diff — the reference will 404 until the doc lands.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | 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.

ℹ️ The two follow-up commits are correct and cover the status-bar gap cleanly. No new issues found in the delta.

Reviewed changes (incremental, d9a2a6b → bcc330c)

  • Cursor pools now render in the status bar — StatusBarProviderSegment.tsx adds isVisibleStatusBarBucket (Gemini allowlist OR isCursorUsageBucket) and falls back to session ?? monthly when every bucket is filtered, so a Cursor snapshot no longer renders as a bare icon. Backed by the new status-bar-cursor-segment.test.tsx.
  • Plan total kept in roster/tooltip — getWindowSections now appends monthly alongside buckets (labeled Plan for Cursor), so the number closest to the cap is no longer dropped.
  • Redirect handling — redirect: 'manual' plus a 3xx check maps the dashboard's bounce to /login onto stale-token instead of a generic network failure.
  • Owned-plan guard — mapCursorUsageSummary gates the pools on planEnabled, so a team-billed account reporting 0% pools falls through to the legacy request-quota fallback rather than painting a false 0%.
  • Desktop read errors — a transient state.vscdb lock no longer pins an alert bar; the error is dropped from the surfaced errors list.
  • Cleanups — handleRefreshUsage no longer double-loads status after a refresh, and the test JWT helpers get a named JwtSegment type.

Still open from the previous review: the cursor-auth.test.ts Linux/Windows failure is not touched by these commits — readKeychainToken still short-circuits on process.platform !== 'darwin' before the mocked readKeychainPassword is reached, so the three keychain-precedence tests still fail on the ubuntu-latest runner. That remains the one merge blocker.

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

@coderabbitai

coderabbitai Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

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

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

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: fc32fc67-06d0-4fa9-80bd-9313160dc5cf

📥 Commits

Reviewing files that changed from the base of the PR and between a2efe49 and 402cc72.

📒 Files selected for processing (2)
  • src/renderer/src/i18n/locales/en.json
  • src/shared/child-process/__fixtures__/child-process-import-allowlist.txt

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


📝 Walkthrough

Walkthrough

Adds Cursor credential discovery from Keychain, CLI files, and the desktop state database, then uses those credentials to fetch and map Cursor usage. Integrates Cursor into rate-limit refresh state and exposes account status through IPC and preload APIs. Adds Cursor account settings and status-bar surfaces, including visibility, usage display, search, localization, and default-item hydration. Also moves macOS Keychain password operations into a reusable module.

Priority: ➖ Normal

Merge Risk: 🟡 Moderate · up to 402cc

When Cursor credentials cannot be read during an account switch, Orca may continue showing the previous account’s usage beside an error, making the displayed usage unreliable. Resolve that account-provenance case before merging; the missing translations have a working English fallback and are a bounded follow-up.

Security Architecture Review

Security architecture risk: 🔵 Low · up to 402cc

Cursor credentials remain in the desktop app’s main process, but a credential-read failure can leave an earlier account’s usage visible while the Accounts screen says the user is signed out. The apparent exposure is limited to usage information in the local app.

Retained concerns

  • Low · security · inferred: An unreadable Cursor login can leave recent usage from the prior account visible even though the account API reports signed out. If the underlying account changed, the displayed figures cannot be attributed to the current identity.
Security review details

Security Blast Radius

  • inferred — The identified failure concerns prior Cursor usage shown within the app’s account and shared usage surfaces. The inspected account IPC response does not carry the credential; broader dependent exposure was not established.

Security Findings and Attack Paths

  • inferred — After a successful usage read, an unreadable login can retain that snapshot while a separate status read says signed out; the renderer does not gate the usage figures on signed-in status. This is a conditional local account-attribution and privacy concern, not evidence of token disclosure.

Trust Boundaries and Controls

  • observed — The desktop database reader requests read-only access, dashboard redirects are not followed automatically, and only reduced account status crosses the new IPC handler.

Resilience and Maintainability Implications

  • observed — A completed missing-session refresh clears prior figures, and the service checks for cancellation before applying Cursor results. Credential-read errors follow a different path that can retain recent figures.

Hardening Proposals

  • proposed — Align the account-status and usage-state contracts for unreadable credentials: suppress retained figures when current account identity is unknown, or clearly associate any retained snapshot with its previously verified account rather than a signed-out state.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 22.22% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 81 functions across 52 files. (2 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description check ✅ Passed The description is complete and directly matches the template. It explains the user impact, implementation, motivation, linked issues, visual proof, testing, AI disclosure, review considerations, cros…
Title check ✅ Passed The title clearly and concisely identifies the primary change: adding Cursor usage tracking to rate limits.
Linked Issues check ✅ Passed The PR meets the coding requirements for Cursor in [#15516] and [#21832]. It adds Cursor to Accounts, the status bar, visibility settings, and the monthly rate-limit model. It reads existing keychain,…
Out of Scope Changes check ✅ Passed The reviewed changes stay connected to Cursor usage tracking. The shared macOS Keychain helper refactor supports read-only Cursor and existing account credential access. The tests and documentation ch…
Full details: Docstring Coverage

Explanation

Docstring coverage is 22.22% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 81 functions across 52 files. (2 skipped: 2 unsupported.)

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

✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR

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

Actionable comments posted: 7


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 40e9e23f-5d91-40ca-a632-735a2fecfd99

📥 Commits

Reviewing files that changed from the base of the PR and between 122b8c2 and bcc330c.

📒 Files selected for processing (73)
  • config/tsconfig.cli.json
  • mobile/src/components/accounts-snapshot.ts
  • src/main/claude-accounts/keychain.ts
  • src/main/cursor-accounts/status.ts
  • src/main/ipc/cursor-accounts.ts
  • src/main/ipc/register-core-handlers/register-core-handlers.test.ts
  • src/main/ipc/register-core-handlers/register-core-handlers.ts
  • src/main/macos-keychain/generic-password.test.ts
  • src/main/macos-keychain/generic-password.ts
  • src/main/rate-limits/cursor-auth-paths.ts
  • src/main/rate-limits/cursor-auth.test.ts
  • src/main/rate-limits/cursor-auth.ts
  • src/main/rate-limits/cursor-desktop-state-db.ts
  • src/main/rate-limits/cursor-fetcher.test.ts
  • src/main/rate-limits/cursor-fetcher.ts
  • src/main/rate-limits/cursor-session-token.test.ts
  • src/main/rate-limits/cursor-session-token.ts
  • src/main/rate-limits/cursor-usage-mapping.test.ts
  • src/main/rate-limits/cursor-usage-mapping.ts
  • src/main/rate-limits/rate-limit-service-test-harness.ts
  • src/main/rate-limits/service-account-target-selection.test.ts
  • src/main/rate-limits/service-antigravity-usage.test.ts
  • src/main/rate-limits/service-cursor-usage.test.ts
  • src/main/rate-limits/service-inactive-account-previews.test.ts
  • src/main/rate-limits/service-live-claude-usage.test.ts
  • src/main/rate-limits/service-minimax-usage.test.ts
  • src/main/rate-limits/service-refresh-orchestration.test.ts
  • src/main/rate-limits/service-window-activation.test.ts
  • src/main/rate-limits/service/service-configuration.ts
  • src/main/rate-limits/service/service-full-cycle-application.ts
  • src/main/rate-limits/service/service-full-cycle-preparation.ts
  • src/main/rate-limits/service/service-polling.ts
  • src/main/rate-limits/service/service-result-policy.ts
  • src/main/rate-limits/service/service-sibling-provider-result.ts
  • src/main/rate-limits/service/service-state.ts
  • src/main/rate-limits/service/service-types.ts
  • src/preload/api-types.ts
  • src/preload/api/agent-account-api.ts
  • src/preload/api/cursor-accounts-bridge.ts
  • src/preload/index.ts
  • src/renderer/src/components/settings/AccountsPane.tsx
  • src/renderer/src/components/settings/AppearanceWindowSidebarSection.tsx
  • src/renderer/src/components/settings/CursorAccountsSection.tsx
  • src/renderer/src/components/settings/accounts-search.ts
  • src/renderer/src/components/settings/appearance-status-bar-cursor-toggle-search.ts
  • src/renderer/src/components/settings/appearance-status-bar-minimax-toggle-search.ts
  • src/renderer/src/components/settings/appearance-status-bar-search.ts
  • src/renderer/src/components/status-bar/StatusBarProviderSegment.tsx
  • src/renderer/src/components/status-bar/StatusBarVisibilityMenu.tsx
  • src/renderer/src/components/status-bar/status-bar-cursor-segment.test.tsx
  • src/renderer/src/components/status-bar/status-bar-provider-visibility.test.ts
  • src/renderer/src/components/status-bar/status-bar-provider-visibility.ts
  • src/renderer/src/components/status-bar/tooltip.tsx
  • src/renderer/src/components/status-bar/usage-error-copy.ts
  • src/renderer/src/components/status-bar/usage-provider-settings-target.ts
  • src/renderer/src/components/status-bar/use-status-bar-controller.ts
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/store/slices/ui-hydration-workspace-preferences.test.ts
  • src/renderer/src/store/slices/ui/ui-slice-hydration-actions.ts
  • src/renderer/src/store/slices/ui/ui-slice-hydration-status-bar-items.ts
  • src/renderer/src/web/preload-api/web-agent-accounts-api.ts
  • src/renderer/src/web/web-preload-api-composition.test.ts
  • src/renderer/src/web/web-preload-api.ts
  • src/shared/child-process/__fixtures__/child-process-import-allowlist.txt
  • src/shared/child-process/__fixtures__/windows-console-visibility-allowlist.txt
  • src/shared/cursor-usage-buckets.ts
  • src/shared/persisted-ui-state-types.ts
  • src/shared/rate-limit-state-factory.ts
  • src/shared/rate-limit-types.test.ts
  • src/shared/rate-limit-types.ts
  • src/shared/rpc-contract/client-ui-params.ts
  • src/shared/status-bar-defaults.ts
  • src/shared/ui-chrome-types.ts

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

Comment thread src/main/rate-limits/cursor-auth.ts Resolved
Comment thread src/renderer/src/i18n/locales/en.json Resolved
@nwparker
nwparker force-pushed the nwparker/cursor-usage branch from bcc330c to 78ef304 Compare September 24, 2026 22:10
@nwparker

Copy link
Copy Markdown
Contributor Author

Both findings were real and are fixed. Thanks — the status-bar one was a genuine miss.

Cursor's buckets rendered no percentage. Correct, and the cause was exactly as described: STATUS_BAR_BUCKET_NAMES is Gemini's allowlist, and the no-bucket fallback wanted a session window Cursor never sets. My screenshots only showed the expired-sign-in path because the one Cursor account on this machine has a lapsed token, so the success path was never rendered. Fixed in 179e114:

  • the allowlist now also admits Cursor's pools via isCursorUsageBucket (which is what that helper was for — you were right that it was unwired);
  • the fallback accepts monthly when there is no session;
  • getWindowSections keeps monthly alongside buckets, labelled Plan for Cursor. To answer the open question directly: yes, the plan total belongs in the status bar. Cursor reports the headline number in monthly and the two sub-pools as buckets, so dropping it meant a plan at 92% read as 50% in the roster and in getTightestUsageSection — under-reporting exactly when the user is closest to their cap.

Regression tests cover both in status-bar-cursor-segment.test.tsx.

Linux CI. Confirmed by the shard before I could fix it — the three cases you named failed on ubuntu-latest for the reason you gave (readKeychainToken returns missing off-darwin before the mock is reached). Fixed in 9c18f67: those tests pin process.platform, and two new cases assert the off-macOS fall-through (Linux falls through to auth.json; Windows with only a keychain session reports signed-out).

Nitpicks. Both valid, both fixed:

  • the four visibility fixtures now use provider: 'cursor';
  • docs/reference/cursor-usage-credentials.md really was missing from the tree — docs/** is gitignored and a new reference doc needs its own allowlist entry. Now committed, so the link resolves.

One thing that was not mine. The mobile web app bundle failure is pre-existing drift on main: the census comment in mobile-web-app-session-terminal-closure.test.mjs already records #22301's two shared modules and 4219 -> 4221, but the constant was left at 4219. I measured a clean origin/main worktree at 4221 and confirmed this branch adds no module to that closure, then set the constant to the documented value (78ef304). The package failure (browser-route-webrtc-egress) is a dbus/Electron environment flake on the runner — this branch touches no browser file.

Branch is rebased onto current main.

@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 — the prior blocker is fixed; one documentation nit inline.

Reviewed changes

  • Pinned process.platform to darwin in the Cursor auth tests and added Linux/Windows fall-through cases, fixing the three keychain-precedence tests that failed on ubuntu-latest.
  • Corrected the status-bar-provider-visibility.test.ts fixtures to use provider: 'cursor'.
  • Added docs/reference/cursor-usage-credentials.md and allowlisted it in .gitignore.
  • Repinned SESSION_ROUTE_MODULES to 4221 in the mobile session-route closure census.
  • Added src/main/macos-keychain/generic-password.ts to config/tsconfig.cli.json.
  • Added the Cursor verbose/plan i18n strings and the cursor mobile provider id.

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

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: d770be7b-452d-418c-9f4f-1da807e944b3

📥 Commits

Reviewing files that changed from the base of the PR and between bcc330c and 78ef304.

📒 Files selected for processing (6)
  • .gitignore
  • config/scripts/mobile-web-app-session-terminal-closure.test.mjs
  • docs/reference/cursor-usage-credentials.md
  • src/main/rate-limits/cursor-auth.test.ts
  • src/renderer/src/components/status-bar/status-bar-provider-visibility.test.ts
  • src/renderer/src/i18n/locales/en.json
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/renderer/src/i18n/locales/en.json

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

@nwparker

Copy link
Copy Markdown
Contributor Author

Second round addressed in df75095. Both bots found real things — thanks.

CodeRabbit

  1. An expired higher-priority token hid a valid lower-priority session — correct, and the sharpest of the batch. Someone who ran cursor-agent login once and now works only in the IDE would have been told "sign-in expired" on every poll while a fresh state.vscdb session sat one source below. Implemented as suggested: a live session wins regardless of precedence, and the expired one is returned only when nothing live exists anywhere, so the actionable message still appears for a genuinely lapsed account. Two tests cover both directions.

  2. One null pool discarded the whole summary — correct, and the reasoning about undocumented APIs is exactly right. .nullish() on both the pools and the individualUsage wrapper, with tests for onDemand: null and individualUsage: null.

  3. Usage retained across an account change — real. The snapshot now carries authProvenance, a truncated sha256 of the WorkOS subject (hashed because it rides into renderer and mobile state, where a raw account id has no business being). The stale policy is skipped only when both the old and new identity are known and differ — an errored refresh that names no account still keeps its own last reading, which is the behaviour the stale policy exists for. Tests for both paths.

  4. Superseded account-status responses — real race. Guarded with a generation counter; only the newest read applies.

  5. Fetch failures invisible in Accounts — real. A signed-in account whose fetch failed rendered no numbers and no message. Now the failure is stated, and when a stale snapshot is still on screen it is said beside the numbers rather than instead of them, so the figures are never silently presented as current.

  6. "cursor-agent login" wording — fair, and it was in three places, not one: the Accounts copy, the signed-out help, and the fetcher's own SIGNED_OUT_MESSAGE. All now name both sign-in sources.

  7. Web client reporting signedIn: false — agreed on the substance, with one correction to the premise: remote Cursor usage already works, because the meter arrives over the rate-limit snapshot; it is only the Accounts sign-in detail that is host-local. That makes the bare false worse than you described — it contradicted a working meter sitting next to it. It now returns an explanation instead of asserting sign-out.

Pullfrog

  1. Census comment — right, and my first attempt was sloppy: I attributed the +2 to feat(native-chat): show context window usage in the composer #22301, which the comment already records before the pacer squash. The actual joiners are src/shared/agent-session-launch-args.ts and src/shared/agent-session-surface-tab-id.ts from feat(agent-session): let the host own a chat's tab id and let a create reserve it #22616 (f0b3f44f10), confirmed with git log --diff-filter=A. Recorded them in the file's own convention and re-measured on a clean origin/main worktree.

  2. Docs Enterprise claim — correct, thank you for the citation. Cloud Agents, Origin and the SDKs are all-plan; the narrowed wording now says the documented usage and billing surfaces are team-scoped and none exposes a solo subscriber's own consumption.

Gates green locally: pnpm tc, oxlint, audit:anti-slop, changed-code quality, the mobile census, and 2506 tests across the touched suites.

@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 in the delta — two minor findings inline: the new signed-out copy is shadowed by a stale catalog, and the account-switch guard only fires for network failures.

Reviewed changes

  • readCursorAuthSession now scans all three credential sources and prefers the first live session, falling back to an expired one only when none is live — so a lapsed keychain token no longer hides a fresh desktop session.
  • Cursor results carry a hashed usageMetadata.authProvenance, and the service drops the previous account's cached snapshot when it changes.
  • usageSummarySchema accepts null pool sub-objects (.nullish()), so a null sibling no longer discards valid pools and the billing cycle with them.
  • Settings → Accounts → Cursor gets a generation-guarded status load plus a "last known usage — refresh failed" line rendered beside a stale reading.
  • The signed-out copy and the web-client bridge explanation were reworded.

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

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

Actionable comments posted: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: bb7d3e0f-2986-42c5-8491-5554948bb579

📥 Commits

Reviewing files that changed from the base of the PR and between 78ef304 and df75095.

📒 Files selected for processing (13)
  • config/scripts/mobile-web-app-session-terminal-closure.test.mjs
  • docs/reference/cursor-usage-credentials.md
  • src/main/rate-limits/cursor-auth.test.ts
  • src/main/rate-limits/cursor-auth.ts
  • src/main/rate-limits/cursor-fetcher.ts
  • src/main/rate-limits/cursor-usage-mapping.test.ts
  • src/main/rate-limits/cursor-usage-mapping.ts
  • src/main/rate-limits/service-cursor-usage.test.ts
  • src/main/rate-limits/service/service-full-cycle-application.ts
  • src/renderer/src/components/settings/CursorAccountsSection.tsx
  • src/renderer/src/i18n/en-runtime-required.json
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/web/preload-api/web-agent-accounts-api.ts
🚧 Files skipped from review as they are similar to previous changes (7)
  • src/renderer/src/web/preload-api/web-agent-accounts-api.ts
  • docs/reference/cursor-usage-credentials.md
  • src/main/rate-limits/cursor-auth.ts
  • src/main/rate-limits/cursor-auth.test.ts
  • src/renderer/src/i18n/locales/en.json
  • src/main/rate-limits/cursor-usage-mapping.test.ts
  • src/main/rate-limits/cursor-usage-mapping.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.

Comment thread src/main/rate-limits/cursor-fetcher.ts Resolved
@nwparker

Copy link
Copy Markdown
Contributor Author

Round three in c665ac7. Both findings were cases where an earlier fix of mine didn't actually take effect — good catches, and the second one is a mechanism I'd have kept getting wrong.

authProvenance missing on failure paths (@pullfrog, @coderabbitai — same finding). Correct, and it made the account-switch guard unreachable in exactly the situation it exists for. The fetcher stamped provenance only on success and the thrown network path; stale-token, 429, 5xx and parse all omitted it, as did the expired-session branch that already had the session in scope. So "switch account, first refresh fails" — the whole point — still showed account A's figures under account B's name.

Fixed as you both suggested: every failure holding a readable session names its account; missing-credentials and credential-read errors still name none, since there is no account to name.

Pullfrog's open question — is retaining the prior account's numbers on an auth failure acceptable because the next cycle corrects it? No. The next successful cycle may be 15 minutes out, and until then Settings names the new account beside the old account's spend. That's the specific confusion the guard was added to prevent, so it should hold on auth failures too.

You were also right that my service test proved nothing: it fed an error result carrying authProvenance that the fetcher never produced on that path. It now uses the real stale-token shape, and the fetcher test asserts provenance across 401 / 429 / 5xx / expiry, plus a negative case for a missing credential.

Reworded signed-out copy never rendered (@pullfrog, with @coderabbitai on the same keys). Confirmed — en.json still held the old strings and a present catalog value beats the inline translate() fallback, so the copy I thought I'd changed was dead text. The trap is that sync:localization-catalog only adds missing keys; it does not update a changed default for a key that already exists, so nothing warned me.

Updated both strings in en.json. A side effect worth noting: the runtime-required catalog now drops both keys, because that generator only ships entries whose value differs from the inline default — so the diff removing them is the fix working, not copy going missing.

On @coderabbitai's narrower suggestion to change only signedOutHelp and leave signedOut as "Not signed in to Cursor": I changed both. "Not signed in" reads as a statement about the user's Cursor account, when what Orca actually knows is that it found no credential on this machine — a signed-in IDE user with a locked keychain would be told they aren't signed in. "No Cursor sign-in found on this computer" is the claim Orca can actually support.

Gates green locally: typecheck, oxlint, anti-slop, changed-code quality, all three localization gates, and 2277 tests across the touched suites.

@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 in this delta — the localization change is correct and passes every gate. The two findings from the prior review remain open and are untouched by this commit.

Reviewed changes

  • Localized the web client's Cursor host-only notice: createCursorAccountsApi now resolves its error string through translate('auto.components.web.preloadApi.cursorAccounts.hostOnly', …), and the key was added to en.json, replacing the hardcoded literal. The inline default matches the catalog value, so en-runtime-required.json correctly omits it; verify:localization-runtime-catalog, verify:localization-catalog, verify:localization-extraction, and audit-localization-coverage --check all pass on this head.

Pullfrog  | Fix it ➔ | 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 new issues found. c665ac7 addresses both prior findings cleanly, and all Pullfrog threads on this PR are now resolved.

Reviewed changes

  • Failures now name the account. cursor-fetcher.ts computes authProvenance once per request and stamps it on every failure that holds a readable session — stale-token (401/403/redirect), 429, 5xx, parse, and the expired-session branch — so the service's account-switch guard at service-full-cycle-application.ts:207 can clear a previous account's figures even when the switch's first refresh fails. Previously those paths omitted the fingerprint, which made the guard unreachable for HTTP/auth failures.
  • The reworded signed-out copy now ships. en.json signedOut/signedOutHelp were updated to match the CursorAccountsSection inline defaults, and the now-superfluous CursorAccountsSection block was dropped from en-runtime-required.json, so the reworded copy actually renders instead of being shadowed by the old catalog values.
  • Tests. cursor-fetcher.test.ts asserts a failed refresh still names the account (and stays unnamed when no session is readable); the service test now uses the fetcher's real stale-token shape.

Verified on this head: verify:localization-runtime-catalog, verify:localization-catalog, verify:localization-extraction, and audit-localization-coverage --check all pass, as do cursor-fetcher.test.ts (15), service-cursor-usage.test.ts (7), and runtime-required-catalog.test.ts (22).

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 new issues found.

Reviewed changes (incremental, df75095 → c665ac7)

  • Account named on failure paths — fetchDashboardJson now computes accountFingerprint(session) once and stamps authProvenance on the stale-token (401/403/3xx), rate-limited (429), server (5xx), and parse results, and credentialFailure stamps it on the expired-session branch where the session is already in scope. missing-credentials and credential-read errors still name none, since there is no account to name. This makes the account-switch guard in service-full-cycle-application.ts:207-212 reachable for the case it exists for: a switch whose first refresh fails.
  • Tests reflect the real shapes — cursor-fetcher.test.ts asserts the same fingerprint across 401/429/5xx and an expired session, plus a negative case for a missing credential; service-cursor-usage.test.ts feeds the actual stale-token result the fetcher produces instead of a hand-shaped result.
  • Reworded signed-out copy now renders — both signedOut/signedOutHelp values updated in en.json, and the stale en-runtime-required.json entries dropped, so the new inline defaults are no longer shadowed by the shipped catalog. Verified the runtime-catalog gate reports no missing/contradicting keys and verify-localization-catalog.mjs passes.
  • Web client host-only notice localized — the Cursor bridge explanation in web-agent-accounts-api.ts now goes through translate(), matching the other web preload bridges.

The two prior review threads (account-switch guard, catalog-shadowed copy) are addressed and resolved.

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

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 65bf0b26-3f68-42e1-8a30-ba64b09b2a80

📥 Commits

Reviewing files that changed from the base of the PR and between df75095 and c665ac7.

📒 Files selected for processing (5)
  • src/main/rate-limits/cursor-fetcher.test.ts
  • src/main/rate-limits/cursor-fetcher.ts
  • src/main/rate-limits/service-cursor-usage.test.ts
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/web/preload-api/web-agent-accounts-api.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/main/rate-limits/cursor-fetcher.test.ts
  • src/main/rate-limits/cursor-fetcher.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.

Comment on lines +17324 to 17330
"web": {
"preloadApi": {
"cursorAccounts": {
"hostOnly": "Cursor sign-in details are only readable on the computer running Orca."
}
}
}

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.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

#!/bin/bash
# Description: Check whether other locale files define the new Cursor host-only key.
set -euo pipefail

fd -e json . src/renderer/src/i18n/locales --exclude en.json | while IFS= read -r file; do
  echo "== $file =="
  python3 - "$file" <<'PY'
import json, sys
path = sys.argv[1]
with open(path, encoding="utf-8") as f:
    data = json.load(f)
node = data
for part in ["auto", "components", "web", "preloadApi", "cursorAccounts", "hostOnly"]:
    if isinstance(node, dict) and part in node:
        node = node[part]
    else:
        print("MISSING")
        break
else:
    print(repr(node))
PY
done

Repository: stablyai/orca

Length of output: 411


Add the new key to every supported locale.

es.json, fr.json, ja.json, ko.json, and zh.json do not define auto.components.web.preloadApi.cursorAccounts.hostOnly. Add a real translation for this key to each locale file.

Source: Learnings

@coderabbitai

coderabbitai Bot commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail
for f in src/main/rate-limits/cursor-fetcher.ts src/main/rate-limits/cursor-fetcher.test.ts src/main/rate-limits/service-cursor-usage.test.ts src/renderer/src/components/settings/CursorAccountsSection.tsx; do
  ast-grep outline "$f" --items all --type function --match 'fetchCursorRateLimits|CursorAccountsSection|test|it' || true
done
rg -n -C3 'authProvenance|SIGNED_OUT_MESSAGE|stale-token|missing-credentials' src/main/rate-limits/cursor-fetcher.ts src/main/rate-limits/cursor-fetcher.test.ts src/main/rate-limits/service-cursor-usage.test.ts
rg -n -C2 'signedOutHelp|signedOut|No Cursor sign-in found|Cursor IDE|cursor-agent login' src/renderer/src/components/settings/CursorAccountsSection.tsx src/renderer/src/i18n/locales/en.json src/renderer/src/i18n/en-runtime-required.json
git show --stat --oneline c665ac7 | head -60

Length of output: 20291


@nwparker, thanks for sending the shell results. I was wrong to say verification was unavailable.

The inspected code attaches authProvenance to failures with a readable session. The fetcher test checks 401, 429, server failure, and expiry against the same account fingerprint. It also checks that missing credentials have no fingerprint. The English catalog now matches both signed-out strings in CursorAccountsSection.tsx.

These results address the two findings I raised. I did not run the test suite, so I cannot independently confirm the reported gate results.


🧠 Learnings used
Learnt from: nwparker
Repo: stablyai/orca

Timestamp: 2026-09-24T23:26:26.332Z
Learning: For Cursor account copy in Orca, `src/renderer/src/i18n/locales/en.json` is the English translator source. `src/renderer/src/i18n/en-runtime-required.json` includes a key only when the catalog value cannot be reproduced from its inline default; matching entries can be omitted.

Learnt from: nwparker
Repo: stablyai/orca

Timestamp: 2026-09-24T23:26:26.332Z
Learning: In `src/renderer/src/components/settings/CursorAccountsSection.tsx`, failure to find a readable local Cursor credential does not establish that the user is signed out of Cursor. The signed-out state must describe the local observation, such as “No Cursor sign-in found on this computer.”

Learnt from: nwparker
Repo: stablyai/orca

Timestamp: 2026-09-24T23:26:23.595Z
Learning: In `src/main/rate-limits/cursor-fetcher.ts`, Cursor usage results with a readable session carry `usageMetadata.authProvenance` even when the dashboard request fails or the token has expired. `src/main/rate-limits/service/service-full-cycle-application.ts` compares this provenance to prevent usage from a previous Cursor account from surviving an account switch. Missing credentials and credential-read errors have no account provenance.

If you found this review helpful, would you consider giving us a shout-out on X?

Thank you for using CodeRabbit!

You are interacting with an AI system.

@nwparker
nwparker force-pushed the nwparker/cursor-usage branch from a2efe49 to d9077c3 Compare September 26, 2026 01:12
nwparker and others added 2 commits September 25, 2026 18:20
## ELI5

If you use Cursor, Orca now shows how much of your monthly Cursor plan you
have used, next to the Claude, Codex and Grok meters, and in Settings →
Accounts. It reads the sign-in Cursor already saved on this computer and never
changes it.

## What changed

Cursor becomes a rate-limit provider like Grok: a status-bar meter (default-on,
with its own toggle), a row in the usage roster, and a Settings → Accounts
section naming the signed-in account.

The credential is read from whichever of three stores has it, first match wins,
all read-only:

- the macOS login keychain item `cursor-access-token` / `cursor-user`, which is
  where `cursor-agent` 2026.06+ keeps the session;
- `~/.cursor/auth.json` and its platform variants, used by older CLIs;
- the Cursor IDE's `state.vscdb` (`cursorAuth/accessToken`), for people who
  never run the CLI.

The keychain entry is the one current CLIs use, and reading only `auth.json`
finds nothing on an up-to-date macOS install. A locked keychain cannot mask a
readable `auth.json`, and a locked `state.vscdb` cannot mask either.
`~/.cursor/cli-config.json` supplies the account's email and display name; it
never holds a token.

Usage comes from the dashboard route the Cursor web dashboard itself reads,
because Cursor documents no individual-user usage API — every documented API is
team- or Enterprise-scoped. Per Cursor's pricing docs an individual plan has two
pools, Cursor Models and Other Models, both resetting with the billing cycle,
plus optional on-demand spend; each becomes a named bucket. The headline
percentage prefers `used / limit` over the sibling percentage fields, which are
pre-rounded for the dashboard's own copy. Because the route is undocumented the
mapping is defensive: an unrecognised payload resolves to `unavailable` and
hides the bar rather than publishing a zero that reads as "no usage".

Orca never runs `cursor-agent login` and never writes, refreshes or rotates a
Cursor credential. An expired token short-circuits to an actionable
"run cursor-agent login" instead of spending a request that can only 401 — not a
rare case, since `cursor-agent status` still reports `isAuthenticated: true`
against a token that expired months ago.

## Why this shape

Six open PRs implement this feature and none reads the keychain, so each finds
nothing for a large share of users; this takes the auth layer further and keeps
what those PRs verified live. The bar is not gated on `cursor-agent` being on
PATH, unlike other CLI providers, because an IDE-only session is real usage with
no CLI to detect.

`readKeychainPassword` moved out of the Claude keychain reader into
`src/main/macos-keychain/generic-password.ts` so both providers share one
`security(1)` wrapper. It is a byte-for-byte relocation, so Claude's credential
path is unchanged; the two child_process allowlists move the entry with it and
neither ratchet count changes.

Co-authored-by: Preschian Febryantara <[email protected]>
Co-authored-by: Qwesdy <[email protected]>
Co-authored-by: ivo922 <[email protected]>
Co-authored-by: Mihail Vratchanski <[email protected]>
Co-authored-by: Tauri-EPO <[email protected]>
Co-authored-by: Raajik <[email protected]>
…ests

The anti-slop gate rejects a bare `object` parameter; the fixtures build a
claims record, so say that.
Review of the first commit found the meter effectively blank for a healthy
account, which the screenshots missed because the only Cursor session on hand
had expired and never reached the success path.

- The verbose status-bar segment filtered buckets through an allowlist written
  for Gemini's experimental models, so both Cursor pools were dropped and the
  fallback needed a `session` window Cursor never reports. A signed-in account
  rendered an icon and no number. The allowlist now admits Cursor's pools, and
  the fallback accepts a monthly window.
- `getWindowSections` dropped `monthly` whenever buckets existed. Cursor puts
  the plan total there and its sub-pools in buckets, so a plan at 92% showed as
  50% in the roster, the tooltip, and the tightest-usage pick.
- A plan reporting `enabled: false` still published its 0% pools, painting a
  healthy meter for a pool the account does not own and skipping the
  request-quota fallback.
- `redirect: 'error'` turned the dashboard's bounce to /login into a generic
  network failure, hiding the actionable sign-in message.
- A busy `state.vscdb` (the IDE holds it open) surfaced as a provider error,
  which would pin an alert bar on Cursor IDE users who never set Cursor up in
  Orca. It falls through to "no credential" instead.
- Refreshing the Accounts section read the keychain twice for one update.
Review caught three cases that assumed macOS: the keychain source is behind an
explicit `process.platform` check, so on the Linux CI runner the mocked read was
never reached and the tests read the CLI file instead. They now set the platform
they mean, and two new cases assert the off-macOS fall-through.

Also track the credentials reference doc (docs/** is ignored by default, so a
new reference needs its own allowlist entry) and give the visibility fixtures
their own provider id instead of Grok's.
…fresh

Review round two, from CodeRabbit and Pullfrog.

- Credential precedence returned the first token that parsed, so an expired
  keychain token in front of a fresh Cursor IDE session reported "sign-in
  expired" on every poll while a usable session sat one source below. A live
  session now wins; the expired one is returned only when nothing live exists,
  so the actionable message still appears in that case.
- The usage schema took `.optional()` where the route sends `null` for an absent
  sub-object, so one null pool failed the parse for the whole body and threw
  away valid pools and the billing cycle with it.
- Cursor usage could survive an account switch: a failed refresh for account B
  kept account A's figures beside B's name in Accounts. The snapshot now carries
  a hashed account fingerprint, and a known-and-changed identity clears the
  previous reading. A refresh that names no account still keeps its own.
- The Accounts section rendered nothing at all when a signed-in account's fetch
  failed, and could repaint an older account when two status reads overlapped.
  It now states the failure — beside the numbers when a stale snapshot remains —
  and ignores superseded reads.
- A web client claimed "not signed in" for a host it cannot read, contradicting
  the meter beside it; it now says the detail is host-only.
- Signed-out copy named `cursor-agent login` as the only way in, though an IDE
  sign-in works just as well.
- The census comment ended at 4219 after the pacer squash without naming the two
  modules #22616 added; recorded them, re-measured on a clean origin/main.
- Narrowed the docs claim: Cursor documents all-plan APIs, but no individual
  usage endpoint.
It reaches the Accounts pane like any other string, so the coverage gate is
right to want it in the catalog rather than allowlisted.
…ip the reworded copy

Review round three. Both findings say an earlier fix did not actually take.

- The account-switch guard reads `authProvenance` off the fresh result, but the
  fetcher stamped it only on success and network failures. The `stale-token`,
  429, 5xx and parse results omitted it, and so did the expired-session branch —
  so a switch whose first refresh failed, which is precisely the case the guard
  exists for, still rendered the previous account's figures under the new name.
  Every failure holding a readable session now names its account; a missing or
  unreadable credential still names none. The service test also fed a result
  shape the fetcher never produces, so it proved nothing; it now uses the real
  stale-token shape, and the fetcher test asserts provenance across 401/429/5xx
  and expiry.
- The reworded signed-out copy never rendered: a present catalog value beats the
  `translate()` fallback, and `sync:localization-catalog` only adds missing keys
  rather than updating changed defaults. Updated both strings in en.json, which
  also prunes them from the runtime-required catalog now that they match.
Its content lives in the PR description instead; docs/** stays ignored rather
than gaining an allowlist entry for this branch.
main removed `SESSION_ROUTE_MODULES` and re-pinned this lane on a different
count, so the paragraph this branch added documents a number series that is
gone. The branch touches nothing in this file now.
@nwparker
nwparker force-pushed the nwparker/cursor-usage branch from d9077c3 to 402cc72 Compare September 26, 2026 01:20
@nwparker

Copy link
Copy Markdown
Contributor Author

Merging with mobile web app bundle red. That failure is pre-existing on main, not from this branch.

config/scripts/mobile-web-app-terminal-render.test.mjs > takes back the frames it is owed, not only the timers fails with the document owed a frame at the moment dispose returned: expected 0 to be greater than 0. I reproduced it locally on this branch, then ran the same test in a clean origin/main worktree at 8d21fdbf60 — identical failure, 1 failed | 11 passed both times. This branch's only mobile change is adding 'cursor' to a zod provider enum in accounts-snapshot.ts, which has no connection to terminal frame disposal.

package (windows) ("grandchild never reported its pid") failed on the first run and passed on rerun — a timing flake. verify is the fan-in of the two.

Everything else is green: 22 checks passing, and locally typecheck, oxlint, anti-slop, the changed-code quality gate, all three localization gates, and 5875 tests across the affected suites.

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.

[Feature]: Cursor and OpenRouter usage providers in the status bar [Feature]: Add Cursor usage tracking (status-bar rate limits + Accounts pane)

1 participant