Repository navigation
feat(rate-limits): add Cursor usage tracking - #22633
Conversation
There was a problem hiding this comment.
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→ IDEstate.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.tscallscursor.com/api/usage-summaryon the default session with manualCookie/Origin/Refererheaders, 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 acursorAuthConfiguredpresence 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
_cursorStatusBarDefaultAddedflag. - Keychain extraction — Claude's
security(1)wrapper relocated byte-for-byte tosrc/main/macos-keychain/generic-password.ts; bothchild_processallowlists 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 usecursor: provider('unavailable', { provider: 'grok' }); the mismatched provider id is harmless here (isUsageEmptyStateonly readsstatus) 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.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
ℹ️ 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.tsxaddsisVisibleStatusBarBucket(Geminiallowlist ORisCursorUsageBucket) and falls back tosession ?? monthlywhen every bucket is filtered, so a Cursor snapshot no longer renders as a bare icon. Backed by the newstatus-bar-cursor-segment.test.tsx. - Plan total kept in roster/tooltip —
getWindowSectionsnow appendsmonthlyalongside buckets (labeledPlanfor Cursor), so the number closest to the cap is no longer dropped. - Redirect handling —
redirect: 'manual'plus a3xxcheck maps the dashboard's bounce to/loginontostale-tokeninstead of a generic network failure. - Owned-plan guard —
mapCursorUsageSummarygates the pools onplanEnabled, so a team-billed account reporting0%pools falls through to the legacy request-quota fallback rather than painting a false0%. - Desktop read errors — a transient
state.vscdblock no longer pins an alert bar; the error is dropped from the surfacederrorslist. - Cleanups —
handleRefreshUsageno longer double-loads status after a refresh, and the test JWT helpers get a namedJwtSegmenttype.
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.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review. 📝 WalkthroughWalkthroughAdds 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 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 ReviewSecurity architecture risk: 🔵 Low · up to 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
Security review detailsSecurity Blast Radius
Security Findings and Attack Paths
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation 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.)
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. Comment ✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
|
There was a problem hiding this comment.
Actionable comments posted: 7
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 40e9e23f-5d91-40ca-a632-735a2fecfd99
📒 Files selected for processing (73)
config/tsconfig.cli.jsonmobile/src/components/accounts-snapshot.tssrc/main/claude-accounts/keychain.tssrc/main/cursor-accounts/status.tssrc/main/ipc/cursor-accounts.tssrc/main/ipc/register-core-handlers/register-core-handlers.test.tssrc/main/ipc/register-core-handlers/register-core-handlers.tssrc/main/macos-keychain/generic-password.test.tssrc/main/macos-keychain/generic-password.tssrc/main/rate-limits/cursor-auth-paths.tssrc/main/rate-limits/cursor-auth.test.tssrc/main/rate-limits/cursor-auth.tssrc/main/rate-limits/cursor-desktop-state-db.tssrc/main/rate-limits/cursor-fetcher.test.tssrc/main/rate-limits/cursor-fetcher.tssrc/main/rate-limits/cursor-session-token.test.tssrc/main/rate-limits/cursor-session-token.tssrc/main/rate-limits/cursor-usage-mapping.test.tssrc/main/rate-limits/cursor-usage-mapping.tssrc/main/rate-limits/rate-limit-service-test-harness.tssrc/main/rate-limits/service-account-target-selection.test.tssrc/main/rate-limits/service-antigravity-usage.test.tssrc/main/rate-limits/service-cursor-usage.test.tssrc/main/rate-limits/service-inactive-account-previews.test.tssrc/main/rate-limits/service-live-claude-usage.test.tssrc/main/rate-limits/service-minimax-usage.test.tssrc/main/rate-limits/service-refresh-orchestration.test.tssrc/main/rate-limits/service-window-activation.test.tssrc/main/rate-limits/service/service-configuration.tssrc/main/rate-limits/service/service-full-cycle-application.tssrc/main/rate-limits/service/service-full-cycle-preparation.tssrc/main/rate-limits/service/service-polling.tssrc/main/rate-limits/service/service-result-policy.tssrc/main/rate-limits/service/service-sibling-provider-result.tssrc/main/rate-limits/service/service-state.tssrc/main/rate-limits/service/service-types.tssrc/preload/api-types.tssrc/preload/api/agent-account-api.tssrc/preload/api/cursor-accounts-bridge.tssrc/preload/index.tssrc/renderer/src/components/settings/AccountsPane.tsxsrc/renderer/src/components/settings/AppearanceWindowSidebarSection.tsxsrc/renderer/src/components/settings/CursorAccountsSection.tsxsrc/renderer/src/components/settings/accounts-search.tssrc/renderer/src/components/settings/appearance-status-bar-cursor-toggle-search.tssrc/renderer/src/components/settings/appearance-status-bar-minimax-toggle-search.tssrc/renderer/src/components/settings/appearance-status-bar-search.tssrc/renderer/src/components/status-bar/StatusBarProviderSegment.tsxsrc/renderer/src/components/status-bar/StatusBarVisibilityMenu.tsxsrc/renderer/src/components/status-bar/status-bar-cursor-segment.test.tsxsrc/renderer/src/components/status-bar/status-bar-provider-visibility.test.tssrc/renderer/src/components/status-bar/status-bar-provider-visibility.tssrc/renderer/src/components/status-bar/tooltip.tsxsrc/renderer/src/components/status-bar/usage-error-copy.tssrc/renderer/src/components/status-bar/usage-provider-settings-target.tssrc/renderer/src/components/status-bar/use-status-bar-controller.tssrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/store/slices/ui-hydration-workspace-preferences.test.tssrc/renderer/src/store/slices/ui/ui-slice-hydration-actions.tssrc/renderer/src/store/slices/ui/ui-slice-hydration-status-bar-items.tssrc/renderer/src/web/preload-api/web-agent-accounts-api.tssrc/renderer/src/web/web-preload-api-composition.test.tssrc/renderer/src/web/web-preload-api.tssrc/shared/child-process/__fixtures__/child-process-import-allowlist.txtsrc/shared/child-process/__fixtures__/windows-console-visibility-allowlist.txtsrc/shared/cursor-usage-buckets.tssrc/shared/persisted-ui-state-types.tssrc/shared/rate-limit-state-factory.tssrc/shared/rate-limit-types.test.tssrc/shared/rate-limit-types.tssrc/shared/rpc-contract/client-ui-params.tssrc/shared/status-bar-defaults.tssrc/shared/ui-chrome-types.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
bcc330c to
78ef304
Compare
|
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:
Regression tests cover both in Linux CI. Confirmed by the shard before I could fix it — the three cases you named failed on Nitpicks. Both valid, both fixed:
One thing that was not mine. The Branch is rebased onto current main. |
There was a problem hiding this comment.
ℹ️ No critical issues — the prior blocker is fixed; one documentation nit inline.
Reviewed changes
- Pinned
process.platformtodarwinin the Cursor auth tests and added Linux/Windows fall-through cases, fixing the three keychain-precedence tests that failed onubuntu-latest. - Corrected the
status-bar-provider-visibility.test.tsfixtures to useprovider: 'cursor'. - Added
docs/reference/cursor-usage-credentials.mdand allowlisted it in.gitignore. - Repinned
SESSION_ROUTE_MODULESto4221in the mobile session-route closure census. - Added
src/main/macos-keychain/generic-password.tstoconfig/tsconfig.cli.json. - Added the Cursor verbose/plan i18n strings and the
cursormobile provider id.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: d770be7b-452d-418c-9f4f-1da807e944b3
📒 Files selected for processing (6)
.gitignoreconfig/scripts/mobile-web-app-session-terminal-closure.test.mjsdocs/reference/cursor-usage-credentials.mdsrc/main/rate-limits/cursor-auth.test.tssrc/renderer/src/components/status-bar/status-bar-provider-visibility.test.tssrc/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.
|
Second round addressed in CodeRabbit
Pullfrog
Gates green locally: |
There was a problem hiding this comment.
ℹ️ 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
readCursorAuthSessionnow 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. usageSummarySchemaacceptsnullpool sub-objects (.nullish()), so anullsibling 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.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: bb7d3e0f-2986-42c5-8491-5554948bb579
📒 Files selected for processing (13)
config/scripts/mobile-web-app-session-terminal-closure.test.mjsdocs/reference/cursor-usage-credentials.mdsrc/main/rate-limits/cursor-auth.test.tssrc/main/rate-limits/cursor-auth.tssrc/main/rate-limits/cursor-fetcher.tssrc/main/rate-limits/cursor-usage-mapping.test.tssrc/main/rate-limits/cursor-usage-mapping.tssrc/main/rate-limits/service-cursor-usage.test.tssrc/main/rate-limits/service/service-full-cycle-application.tssrc/renderer/src/components/settings/CursorAccountsSection.tsxsrc/renderer/src/i18n/en-runtime-required.jsonsrc/renderer/src/i18n/locales/en.jsonsrc/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.
|
Round three in
Fixed as you both suggested: every failure holding a readable session names its account; 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 Reworded signed-out copy never rendered (@pullfrog, with @coderabbitai on the same keys). Confirmed — Updated both strings in On @coderabbitai's narrower suggestion to change only Gates green locally: typecheck, oxlint, anti-slop, changed-code quality, all three localization gates, and 2277 tests across the touched suites. |
There was a problem hiding this comment.
ℹ️ 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:
createCursorAccountsApinow resolves itserrorstring throughtranslate('auto.components.web.preloadApi.cursorAccounts.hostOnly', …), and the key was added toen.json, replacing the hardcoded literal. The inline default matches the catalog value, soen-runtime-required.jsoncorrectly omits it;verify:localization-runtime-catalog,verify:localization-catalog,verify:localization-extraction, andaudit-localization-coverage --checkall pass on this head.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
c665ac7addresses both prior findings cleanly, and all Pullfrog threads on this PR are now resolved.
Reviewed changes
- Failures now name the account.
cursor-fetcher.tscomputesauthProvenanceonce 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 atservice-full-cycle-application.ts:207can 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.jsonsignedOut/signedOutHelpwere updated to match theCursorAccountsSectioninline defaults, and the now-superfluousCursorAccountsSectionblock was dropped fromen-runtime-required.json, so the reworded copy actually renders instead of being shadowed by the old catalog values. - Tests.
cursor-fetcher.test.tsasserts 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).
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes (incremental, df75095 → c665ac7)
- Account named on failure paths —
fetchDashboardJsonnow computesaccountFingerprint(session)once and stampsauthProvenanceon thestale-token(401/403/3xx),rate-limited(429),server(5xx), andparseresults, andcredentialFailurestamps it on the expired-session branch where the session is already in scope.missing-credentialsand credential-read errors still name none, since there is no account to name. This makes the account-switch guard inservice-full-cycle-application.ts:207-212reachable for the case it exists for: a switch whose first refresh fails. - Tests reflect the real shapes —
cursor-fetcher.test.tsasserts the same fingerprint across 401/429/5xx and an expired session, plus a negative case for a missing credential;service-cursor-usage.test.tsfeeds the actualstale-tokenresult the fetcher produces instead of a hand-shaped result. - Reworded signed-out copy now renders — both
signedOut/signedOutHelpvalues updated inen.json, and the staleen-runtime-required.jsonentries dropped, so the new inline defaults are no longer shadowed by the shipped catalog. Verified the runtime-catalog gate reports no missing/contradicting keys andverify-localization-catalog.mjspasses. - Web client host-only notice localized — the Cursor bridge explanation in
web-agent-accounts-api.tsnow goes throughtranslate(), matching the other web preload bridges.
The two prior review threads (account-switch guard, catalog-shadowed copy) are addressed and resolved.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 65bf0b26-3f68-42e1-8a30-ba64b09b2a80
📒 Files selected for processing (5)
src/main/rate-limits/cursor-fetcher.test.tssrc/main/rate-limits/cursor-fetcher.tssrc/main/rate-limits/service-cursor-usage.test.tssrc/renderer/src/i18n/locales/en.jsonsrc/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.
| "web": { | ||
| "preloadApi": { | ||
| "cursorAccounts": { | ||
| "hostOnly": "Cursor sign-in details are only readable on the computer running Orca." | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
📐 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
doneRepository: 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
|
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 -60Length of output: 20291
The inspected code attaches 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 usedIf 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. |
a2efe49 to
d9077c3
Compare
## 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.
d9077c3 to
402cc72
Compare
|
Merging with
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. |

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:
keychaincursor-access-token/cursor-usercursor-agent2026.06+cli~/.cursor/auth.json,%APPDATA%\Cursor\auth.json,$XDG_CONFIG_HOME/cursor/auth.jsoncursor-agentbuildsdesktopstate.vscdb, keycursorAuth/accessTokenA locked keychain cannot mask a readable
auth.json, and a lockedstate.vscdbcannot mask either.~/.cursor/cli-config.jsonsupplies 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 — withGET /api/usageas 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 loginand never writes, refreshes or rotates a Cursor credential.Credential detail. The stored token is a JWT.
cursor-agentrefreshes it when you use Cursor; Orca does not, because a refresh would rotate a credential another tool owns — so a lapsedexpshort-circuits to an actionable "runcursor-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.jsonsupplies 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-agentbuilds keep the session. On this machine (cursor-agent 2026.06.02) there is no~/.cursor/auth.jsonat all. So the three PRs that read onlyauth.jsonfind 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-agentowns its own token rotation, and refreshing would rotate a credential another tool owns. So a lapsedexpshort-circuits to an actionable "runcursor-agent login" instead of spending a request that can only 401. This is not a rare edge case —cursor-agent status --format jsonon this machine still reportsisAuthenticated: trueagainst 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 tounavailable, which hides the bar, rather than publishing a0%that reads as "no usage". The headline percentage prefersused / limitover 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.
readKeychainPasswordmoved out ofsrc/main/claude-accounts/keychain.tsintosrc/main/macos-keychain/generic-password.tsso Claude and Cursor share onesecurity(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 bothchild_processallowlists — neither ratchet count changes. I first tried the stronger fix (routingsecuritythroughrunProcess, 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):
Status bar — after, on a real account whose CLI token has lapsed:
Settings → Accounts → Cursor (email redacted), identity resolved from
cli-config.json:Attribution
The dashboard protocol here is not original work. The
WorkosCursorSessionTokencookie shape, theusage-summaryendpoint and the CSRFOrigin/Refererrequirement were worked out by steipete/CodexBar (MIT) and brought into Orca by #13837, #18119, #20469 and #21833. Theused / limitpreference 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
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.cursorAuthConfiguredflipped totrue, the meter rendered, and Settings → Accounts resolved the account email fromcli-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/limitover rounded percentages, unlimited plans, clamping, month-end cycle rollover), fetcher error policy (401/403/429 withRetry-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 (bothchild_processallowlists,register-core-handlers,web-preload-api-composition).pnpm tcclean ·oxlint0 errors ·check:code-quality:changedpasses · max-lines ratchet OK (two files I pushed over 300 lines were split, not suppressed) · localization catalogs synced.Platforms: verified on macOS. The
auth.jsonandstate.vscdbpaths 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 explicitprocess.platformcheck and returnsnullelsewhere, 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.jsonwith no empty bars. Screenshots in both Compact and Detailed modes are on #20469. That covers the Windowsauth.jsonpath, the two-pool render, and a pool at 100% — the cases I had only unit tests for.Still unverified: the Cursor IDE
state.vscdbpath 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
Notes
docs/reference/remote-wire-compatibility.md— no new stream opcode._cursorStatusBarDefaultAdded) so a user who hides it keeps it hidden.Retry-Afterhonoured on 429. The keychain probe runs on the fetch cycle, never ongetState(), which is hot.state.vscdbis opened read-only in place and only when the two cheaper sources miss.Checklist
pnpm lint,pnpm typecheck,pnpm testpass locally (see Testing);pnpm buildleft to CI