Skip to content

feat(rate-limits): add Cursor subscription usage to the status bar and Accounts - #18119

Closed
Mivr wants to merge 9 commits into
stablyai:mainfrom
Mivr:feat/cursor-usage
Closed

Mivr wants to merge 9 commits into
stablyai:mainfrom
Mivr:feat/cursor-usage

Conversation

@Mivr

@Mivr Mivr commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

If you use Cursor as one of your agents, Orca now shows how much of your Cursor subscription you have used this month, right next to the Claude, Codex, and Grok meters, and in Settings → Accounts. It reads the login Cursor already has on this machine; it never changes it.

What Changed

  • Prep (commit 1, no behaviour change): refactor(status-bar) splits the appearance search entries and the status-bar default-on migration by provider; both upstream files were already at the 300-line ratchet.
  • New cursor rate-limit provider (commit 2): reads the Cursor desktop session token from state.vscdb (SQLite, read-only, in place, never copied) with the cursor-agent auth.json as fallback; per-platform roots (~/Library/Application Support, %APPDATA%, ${XDG_CONFIG_HOME:-~/.config}, XDG on Linux only). Fetches GET https://cursor.com/api/usage-summary (session cookie) and POST https://api2.cursor.sh/aiserver.v1.DashboardService/GetSandUsageStatus (Bearer) and maps them to the monthly pools: Cursor Models, Other Models, On-demand when present, and the separate Grok Bot pool. Wired into the existing split rate-limit service cycle with cancellation; no provider-specific queue.
  • Status bar (commit 3): Cursor segment and visibility toggle, tooltip with account identity (email, plan, subscription status) and per-pool meters with billing-cycle reset countdowns formatted client-side from resetsAt, error copy that distinguishes not-configured, sign-in-required, and refresh-failed; default-on migration for the new status-bar item.
  • Settings → Accounts (commit 4): read-only Cursor section with identity, "on this machine" provenance, pool meters, Refresh, and links to Cursor's docs and spending page. Settings search entries for both surfaces.
  • Mobile (commit 5): read-only Cursor card on the paired-host Accounts screen; the decoder tolerates hosts without the cursor slot.
  • Locale catalogs (en, es, ja, ko, zh) for every new renderer string. No RPC method, no RUNTIME_PROTOCOL_VERSION change.

Why

Cursor billing has two monthly pools that are easy to exhaust during long agent runs, and today the only way to check is cursor.com/dashboard. Orca already shows live usage for every other agent it launches; #15516 asks for Cursor to join that set, read-only against the existing login, in the status bar and Accounts pane only. The pools are modelled as buckets rather than the single optional monthly window the issue mentions: Cursor Models and Other Models are two independent monthly quotas that cannot be expressed as one window. They are never averaged, no 0% is fabricated when a pool is absent, and a failure of the optional Grok Bot request never discards the billing pools.

Linked Issue

Fixes #15516

Visual Proof

Surface Before After
Status bar, detailed mode (light)
Status bar, compact mode (light)
Status bar, detailed mode (dark)
Status bar, compact mode (dark)
Usage roster (light)
Cursor details menu (light) (absent)
Cursor details menu (dark) (absent)
Settings → Accounts → Cursor (light) (absent)
Settings → Accounts → Cursor (dark) (absent)

Captured on Linux with the repository's Playwright Electron fixture against a live Cursor Ultra login (cursor-agent auth.json); the account email is masked. Mobile is covered by tests only (no paired device available for capture).

macOS live proof (2026-09-21)

Rebased onto current main and exercised on a Mac against a live Cursor Ultra desktop login (~/Library/Application Support/Cursor/User/globalStorage/state.vscdb). No cursor-agent on PATH. Account email is masked. Opt-in replay: ORCA_CURSOR_USAGE_PROOF_DIR=... ORCA_BACKGROUND_LAUNCH=1 SKIP_BUILD=1 pnpm exec playwright test tests/e2e/cursor-usage-macos-desktop-login.spec.ts --config tests/playwright.config.ts --project electron-headless --workers=1.

Surface After (macOS, desktop state.vscdb)
Status bar, detailed mode (light)
Status bar, compact mode (light)
Status bar, detailed mode (dark)
Status bar, compact mode (dark)
Usage roster (light)
Cursor details menu (light)
Cursor details menu (dark)
Settings → Accounts → Cursor (light)
Settings → Accounts → Cursor (dark)

Testing

Linux (Ubuntu, Node 24, pnpm 12). pnpm typecheck, pnpm lint, pnpm test, pnpm build pass locally, plus the cross-version wire suites and the mobile typecheck/lint/format/test checks. macOS desktop state.vscdb was exercised live on this machine (Ultra login, no cursor-agent on PATH); Windows credential-path resolution remains unit-tested (process.platform, APPDATA). WSL: Cursor auth is read from the host that runs the rate-limit service; if the login lives inside a WSL distro it is reported as not available (same as Grok today).

Reviewer steps:

  1. Be signed in to Cursor desktop or cursor-agent on the host, open Orca.
  2. Status bar → Usage: the Cursor row shows the pools; hover shows email, plan, and reset dates. Toggle it under Settings → Appearance → Status bar.
  3. Settings → Accounts → Cursor shows the same identity and pools with Refresh.
  4. Sign out of Cursor (or rename state.vscdb / auth.json): the section shows sign-in guidance, nothing crashes or prompts.
  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

Tests: auth-path resolution per platform, JWT/cookie construction, desktop-vs-CLI precedence, read-only SQLite, absent vs corrupt/locked/unreadable/malformed stores, network/server/401 failures, usage-summary and sand mapping, absent pools, Grok Bot failure isolation, 401 without token leak, cancellation, service policy, default-on migration, status-bar visibility/gating/tooltip/error copy, Accounts section states, mobile old-host decoding and read-only route.

AI Disclosure

The port onto current main was written by OpenAI Codex CLI (gpt-5.6-sol) from a design and audit produced with Claude (Anthropic), then independently re-validated (gates re-run, code review) by Claude Fable 5.1 and reviewed by me. Linux screenshots were taken with the repository's Playwright Electron fixture. macOS screenshots were captured the same way on 2026-09-21 against a live Cursor desktop login. The rebase onto current main and the macOS proof were done with Grok (xAI).

Review

Cross-platform: credential roots selected behind process.platform and built with path.join; XDG affects Linux only; no child processes, no shell. Linux verified locally; macOS desktop state.vscdb verified live; Windows path logic unit-tested, packaging via CI.

SSH / remote / local: usage is fetched by the execution host's rate-limit service, so local, SSH, and paired-phone views report the host that owns the Cursor login; without a readable login the provider reports not available. Folder workspaces unaffected.

Supported agents and integrations: adds the Cursor provider only, gated like the other providers; nothing in Stats or Chat; no change to Claude/Codex/Gemini/Kimi/MiniMax/Grok/Antigravity paths.

Performance: shares the provider poll cycle and abort path; SQLite opened read-only in place with a 250 ms busy timeout (the database can be multi-GB, it is never copied); two HTTPS requests per poll with 10 s timeouts.

UI quality: compact and verbose status-bar modes, visibility toggle, tooltip states, Accounts section, search entries, five locale catalogs, existing tokens and shadcn primitives; mobile reuses the existing host-usage card pattern.

Security: the token stays on the execution host, is read from Cursor's own stores, and is sent only to Cursor's two HTTPS endpoints in their expected cookie/Bearer schemes. Errors never echo the token; 401/403 become sign-in guidance; mobile receives usage metadata only. The endpoints are the ones Cursor's own dashboard uses; there is no public per-user usage API for Pro/Ultra plans.

Agent skill upstream boundary

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

Notes

Size: roughly half of the additions are tests and the five locale catalogs; the prep refactor commit is behaviour-neutral. Shared with Grok/MiniMax: one providerResultFromSettled helper and one request-timeout helper replace the previously copied per-provider blocks. No baseline/ratchet files touched, no lint suppressions added. Known wire nuance shared with the earlier Grok toggle: a new client's default-on migration writes the cursor status-bar item, which an older host's ui.update enum rejects for that payload; no protocol bump, same shape upstream accepted for Grok.

Checklist

  • This PR is small and focused
  • I explained what changed and why (including ELI5)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

Author

X (Twitter): none

🤖 Generated with Claude Code

@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 Cursor segment is gated behind cursor-agent CLI detection, but Cursor auth is desktop-primary — desktop-only users will never see the bar.

Reviewed changes

  • cursor rate-limit provider — reads the desktop state.vscdb token read-only (cursor-agent auth.json as fallback), fetches cursor.com/api/usage-summary + api2.cursor.sh sand usage, and maps Cursor Models / Other Models / On-demand / Grok Bot buckets into the shared buckets model.
  • Status bar — Cursor segment, visibility toggle, tooltip identity (email / plan / subscription) and per-pool meters, plus a default-on migration refactor (ui-status-bar-default-migration.ts) that also adds cursor.
  • Settings → Accounts — read-only CursorAccountsSection with identity, pool meters, Refresh, and docs/spending links, plus search entries.
  • Mobile — read-only Cursor card on the paired-host Accounts screen; snapshot decoder tolerates an absent cursor slot.
  • Shared — cursor added to provider union, RateLimitState, status-bar items/defaults, RPC StatusBarItem enum, and RateLimitBucket.windowMinutes made optional.

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

@coderabbitai

coderabbitai Bot commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

Understand this PR’s impact

Explore downstream dependencies and potential security impact with Blast Radius.

View 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: 87ecc90e-9b63-4b11-bd7c-6dde205ccd13

📥 Commits

Reviewing files that changed from the base of the PR and between 4042ed2a251e92b19c15e00b23d048119f5efd80 and 7e3c6f4.

📒 Files selected for processing (3)
  • src/main/rate-limits/cursor-auth.test.ts
  • src/main/rate-limits/cursor-auth.ts
  • tests/e2e/cursor-usage-macos-desktop-login.spec.ts

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


📝 Walkthrough

Walkthrough

This change adds Cursor as a rate-limit provider. It reads desktop and CLI authentication, fetches and maps Cursor usage pools, and integrates Cursor into rate-limit service state. Desktop settings, status-bar views, mobile accounts, localization, persistence migration, runtime capability filtering, mock data, and tests now support Cursor usage. Shared rate-limit types also support named buckets without required cycle durations. A timeout helper is shared with the Grok fetcher.

Priority: ➖ Normal

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 6.45% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 62 functions across 59 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely identifies the main change: adding Cursor subscription usage to the status bar and Accounts surfaces.
Description check ✅ Passed The description covers all required template sections, including the user-facing summary, implementation details, rationale, linked issue, visual proof, testing, AI disclosure, review considerations, …
Linked Issues check ✅ Passed Issue [#15516] requires read-only Cursor usage in Accounts and the status bar. The PR adds platform-specific desktop and cursor-agent credential discovery, read-only SQLite and JSON access, usage fetc…
Out of Scope Changes check ✅ Passed The changes remain connected to [#15516]. Shared provider types, timeout handling, service orchestration, status-bar migration, localization, web capability filtering, mobile selectors, and test fixtu…
  • 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.

@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: 5

🧹 Nitpick comments (3)
src/renderer/src/components/settings/accounts-search.ts (1)

217-220: 📐 Maintainability & Code Quality | 🔵 Trivial | 🏗️ Heavy lift

Use intent-named IDs for the new search strings.

The new translate calls use hash-based IDs. Use intent-named IDs and matching locale entries for this new catalog entry.

Based on learnings: For newly added user-facing strings in stablyai/orca TypeScript and TSX files, follow config/i18n-translation-source.md: use intent-named localization IDs with named interpolation placeholders. Treat existing hash-based IDs as grandfathered, and do not require SHA-1-derived IDs for new strings.

Also applies to: 223-228

Source: Learnings

mobile/src/accounts/cursor-host-usage-section.tsx (1)

39-46: 🎯 Functional Correctness | 🔵 Trivial | 🏗️ Heavy lift

Localize the new Cursor account strings.

Host Cursor login, Uses Cursor on the host, and the Resets ... prefix are hardcoded. Non-English users will see English text in the new section. Use intent-named translation IDs and a named interpolation placeholder for bucket.resetDescription.

Based on learnings: For newly added user-facing strings in stablyai/orca TypeScript and TSX files, follow config/i18n-translation-source.md: use intent-named localization IDs with named interpolation placeholders. Treat existing hash-based IDs as grandfathered, and do not require SHA-1-derived IDs for new strings.

Also applies to: 60-60

Source: Learnings

src/renderer/src/components/settings/appearance-status-bar-cursor-toggle-search.ts (1)

14-16: 📐 Maintainability & Code Quality | 🔵 Trivial | 🏗️ Heavy lift

Use intent-named localization IDs for new Cursor strings. The new Cursor strings in both files use hash-based IDs, but the current renderer localization workflow requires intent-named IDs for new user-facing TypeScript and TSX strings.

  • src/renderer/src/components/settings/appearance-status-bar-cursor-toggle-search.ts#L14-L16: rename the Cursor title key and update locale catalogs.
  • src/renderer/src/components/settings/appearance-status-bar-cursor-toggle-search.ts#L18-L20: rename the Cursor description key and update locale catalogs.
  • src/renderer/src/components/settings/appearance-status-bar-cursor-toggle-search.ts#L40-L42: rename the Cursor toggle-description key and update locale catalogs.
  • src/renderer/src/components/status-bar/StatusBarVisibilityMenu.tsx#L145-L147: rename the Cursor menu-label key and update locale catalogs.

Based on learnings: “For newly added user-facing strings in TypeScript and TSX files, use intent-named localization IDs. Treat existing hash-based IDs as grandfathered.”

Source: Learnings


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: 05e2791e-8741-4b4c-a608-a1829e196ad9

📥 Commits

Reviewing files that changed from the base of the PR and between 4bc20cb and a396835be9bc8ae18229faa8ee34cdb43ef96f9a.

📒 Files selected for processing (75)
  • mobile/app/h/[hostId]/accounts.tsx
  • mobile/scripts/mock-server-account-state.ts
  • mobile/scripts/mock-server-cursor-state.ts
  • mobile/src/accounts-route-cursor.test.ts
  • mobile/src/accounts-route-reset-credit.test.ts
  • mobile/src/accounts/cursor-host-usage-section.tsx
  • mobile/src/components/AccountUsage.tsx
  • mobile/src/components/account-usage-state.test.ts
  • mobile/src/components/account-usage-state.ts
  • mobile/src/components/accounts-snapshot.test.ts
  • mobile/src/components/accounts-snapshot.ts
  • mobile/src/mock-server-account-state.test.ts
  • src/main/codex-accounts/service-reset-credit-test-fixtures.ts
  • src/main/rate-limits/cursor-auth.test.ts
  • src/main/rate-limits/cursor-auth.ts
  • src/main/rate-limits/cursor-fetcher.test.ts
  • src/main/rate-limits/cursor-fetcher.ts
  • src/main/rate-limits/cursor-usage-mapping.ts
  • src/main/rate-limits/gemini-bucket-formatting.ts
  • src/main/rate-limits/grok-fetcher.ts
  • src/main/rate-limits/rate-limit-request-timeout.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-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-settled-provider-result.ts
  • src/main/rate-limits/service/service-state.ts
  • src/main/rate-limits/service/service-types.ts
  • src/main/runtime/rpc/methods/client-ui-schemas.ts
  • src/renderer/src/components/settings/AccountsPane.tsx
  • src/renderer/src/components/settings/CursorAccountsSection.test.tsx
  • src/renderer/src/components/settings/CursorAccountsSection.tsx
  • src/renderer/src/components/settings/accounts-search.test.ts
  • 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/stats/GrokUsagePane.test.tsx
  • src/renderer/src/components/status-bar/StatusBarProviderSegment.tsx
  • src/renderer/src/components/status-bar/StatusBarVisibilityMenu.tsx
  • src/renderer/src/components/status-bar/provider-segment-monthly-window.test.tsx
  • src/renderer/src/components/status-bar/status-bar-agent-gating.test.ts
  • src/renderer/src/components/status-bar/status-bar-agent-gating.ts
  • 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.test.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.test.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/i18n/locales/es.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/zh.json
  • src/renderer/src/store/slices/rate-limits.ts
  • 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-status-bar-default-migration.ts
  • src/renderer/src/web/preload-api/web-rate-limits-api.ts
  • src/shared/persisted-ui-state-types.ts
  • src/shared/rate-limit-types.test.ts
  • src/shared/rate-limit-types.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; 8 remain after this review.

Comment thread mobile/src/components/AccountUsage.tsx Resolved
@Mivr

Mivr commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

Addressed the three nitpicks from the CodeRabbit review as well: every new renderer string on this PR now uses an intent-named ID (fix(i18n): use intent-named localization IDs for new Cursor strings), covering the accounts-search and appearance-toggle-search entries and the visibility-menu label. The mobile Cursor card strings stay hardcoded English because mobile/ has no localization layer today; every other mobile string follows the same convention, and they can move to translation IDs together when mobile gets i18n.

@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 (delta against the prior pullfrog review at a396835)

  • Ungated the Cursor segment from CLI detection — removed cursor from CLI_GATED_ITEMS and switched the segment, Appearance toggle, and visibility-menu item to credential/usage-driven gating via a new isCursorStatusBarAvailable(provider, cursorAuthConfigured) in status-bar-provider-visibility.ts. This resolves the prior IMPORTANT finding: a desktop-only Cursor login now renders the bar/toggle without cursor-agent on PATH.
  • Added remote-wire capability negotiation — introduced status-bar.cursor-item.v1 (STATUS_BAR_CURSOR_ITEM_RUNTIME_CAPABILITY) and had the paired web client (web-ui-api.ts prepareHostUiUpdates) strip cursor from ui.set status-bar payloads sent to hosts that don't advertise it, so an older host's StatusBarItem enum never sees the new value. Only the web client negotiates; native desktop renderer/main stay in lockstep.
  • Renamed locale IDs to intent-named — replaced the hash-based Cursor string IDs (dd3e96043c, 5d095e229c, …) with intent-named IDs across all five catalogs and their call sites, addressing the localization-ID feedback.
  • Fixed mobile meter alignment — AccountUsage.tsx now aligns the reset countdown to a custom labelWidth via effectiveLabelWidth, with a new layout test.
  • Made the cursor-auth EACCES test portable — swapped chmod(0) for a readFileSync mock throwing EACCES, which behaves correctly on Windows.

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

@Mivr
Mivr force-pushed the feat/cursor-usage branch from 05e8db1 to 4bbf650 Compare September 7, 2026 18:13
@coderabbitai

coderabbitai Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@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 — this run reviewed the branch after a rebase onto the latest main (base moved 28214e1 → 83b1558). The PR's own seven commits are unchanged in content (same commit subjects, new SHAs); the only delta is main's concurrent edits to files the PR also touches.

  • Rebased onto latest main — the rebase pulled in main's concurrent changes to shared rate-limit and status-bar files (MiniMax fetcher split, ports segment rework, clipboard thumbnail, markdown-file opens), which merged cleanly with no conflict markers (working tree clean, no <<<<<<</======= markers).
  • Verified the cursor integration survives the rebase — confirmed the merged state of every shared file both sides modified still wires cursor correctly: service-types.ts (InternalRateLimitState.cursor), service-configuration.ts (cursorAuthConfigured), rate-limit-types.ts / rate-limit-state-factory.ts (provider union + empty state), status-bar-provider-visibility.ts (isCursorStatusBarAvailable), use-status-bar-controller.ts / use-available-status-bar-toggles.ts (credential-driven gating), usage-error-copy.ts (sign-in copy), protocol-version.ts (status-bar.cursor-item.v1), and web-ui-api.ts (prepareHostUiUpdates). A diff of the old head 05e8db14ff vs the new head 4bbf650acd restricted to Cursor-specific files is empty apart from unrelated web-ui-api.ts clipboard/markdown additions pulled from main.

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

@jairuspace

Copy link
Copy Markdown
Contributor

Thanks for landing this — exactly the gap I’m hitting as a daily Cursor + Orca user on macOS.

Happy to help get it over the line:

  • macOS verification against a live Cursor desktop / cursor-agent login (your notes say Linux was exercised live; I’m set up to cover the macOS state.vscdb path + status bar / Accounts UX).
  • Rebase assist if useful — #18119 currently shows as conflicting with main. From a quick look, main has moved a lot (~860 commits), but the overlap with this PR’s shared files looks relatively contained (mostly locale catalogs + a few shared UI/protocol types); the Cursor-specific rate-limit modules themselves look quiet.

No pressure either way — just wanted to offer hands if a macOS smoke pass or a fresh rebase would unblock review/merge. Happy to report back with before/after notes once there’s a rebased head to try.

@Mivr
Mivr force-pushed the feat/cursor-usage branch 2 times, most recently from 4bbf650 to 4042ed2 Compare September 21, 2026 11:54
@Mivr

Mivr commented Sep 21, 2026

Copy link
Copy Markdown
Contributor Author

@jairuspace thanks — this was exactly the gap. Rebased onto current main (conflicts were in the moved StatusBarItem schema and Accounts search tests) and proved it on macOS against a live Cursor Ultra desktop login (state.vscdb under Application Support). No cursor-agent on PATH.

macOS screenshots are in the PR description under macOS live proof. The desktop path now has an isolated unit test plus an opt-in Electron spec (tests/e2e/cursor-usage-macos-desktop-login.spec.ts) so this doesn't leak the host login into CI.

Happy to take another pass if you hit anything on your machine.

@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: 3


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: a74d9716-7bbb-40c4-a439-5bcfb385b2c9

📥 Commits

Reviewing files that changed from the base of the PR and between 4bbf650acde70ba74245592041e908d5e9a52766 and 4042ed2a251e92b19c15e00b23d048119f5efd80.

📒 Files selected for processing (18)
  • src/main/rate-limits/cursor-auth.test.ts
  • src/main/rate-limits/cursor-auth.ts
  • src/main/rate-limits/service-account-target-selection.test.ts
  • src/main/runtime/rpc/methods/client-ui.test.ts
  • src/renderer/src/components/settings/CursorAccountsSection.tsx
  • src/renderer/src/components/settings/accounts-search.test.ts
  • src/renderer/src/components/settings/accounts-search.ts
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/zh.json
  • src/renderer/src/store/slices/ui-hydration-workspace-preferences.test.ts
  • src/renderer/src/store/slices/ui/ui-slice-hydration-actions.ts
  • src/shared/persisted-ui-state-types.ts
  • src/shared/protocol-version.ts
  • src/shared/rpc-contract/client-ui-params.ts
  • tests/e2e/cursor-usage-macos-desktop-login.spec.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/renderer/src/store/slices/ui-hydration-workspace-preferences.test.ts
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json

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

Comment on lines +197 to +199
if (desktopRead.status === 'error') {
return desktopRead
}

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.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Try Cursor Agent auth after a desktop-read failure.

If state.vscdb is locked or corrupt, this return prevents reading a valid Cursor Agent auth.json. The provider then reports a desktop auth error instead of available usage from its other supported credential source. Try CLI auth before returning the desktop error, and preserve the desktop error only if no usable CLI session exists.

Comment on lines +8 to +28
async function maskCursorEmail(page: Page): Promise<void> {
await page.evaluate(() => {
const current = window.__store!.getState().rateLimits
const cursor = current.cursor
if (!cursor?.usageMetadata?.accountEmail) {
return
}
window.__store!.setState({
rateLimits: {
...current,
cursor: {
...cursor,
usageMetadata: {
...cursor.usageMetadata,
accountEmail: 'user@******.com'
}
}
}
})
})
}

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.

🔒 Security & Privacy | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

sed -n '1,180p' tests/e2e/cursor-usage-macos-desktop-login.spec.ts
rg -n -C 3 'rateLimits|cursorAuthConfigured|setState|poll|refreshRateLimits|email' tests/e2e src/renderer/src src/main/rate-limits

Repository: stablyai/orca

Length of output: 45546


🏁 Script executed:

set -o pipefail
printf '%s\n' '--- target test ---'
cat -n tests/e2e/cursor-usage-macos-desktop-login.spec.ts
printf '%s\n' '--- candidate rate-limit files ---'
rg --files src/main/rate-limits src/renderer/src tests/e2e | rg -i '(rate.limit|cursor|usage|screenshot|proof)'
printf '%s\n' '--- narrow symbol search ---'
rg -n -C 4 --glob '!**/*.test.*' --glob '!**/node_modules/**' \
  'refreshRateLimits|rateLimits|cursorAuthConfigured|usageMetadata|accountEmail|captureScreenshot|screenshot' \
  src/main/rate-limits src/renderer/src tests/e2e/cursor-usage-macos-desktop-login.spec.ts

Repository: stablyai/orca

Length of output: 43050


🏁 Script executed:

set -o pipefail
printf '%s\n' '--- renderer rate-limit slice ---'
cat -n src/renderer/src/store/slices/rate-limits.ts | sed -n '19,42p;130,140p'
printf '%s\n' '--- polling and service update symbols ---'
rg -n -C 5 --glob '!**/*.test.*' \
  'setRateLimitsFromPush|rateLimits.*push|push.*rateLimits|emit.*rate|on.*rate|poll|setInterval|refresh\(' \
  src/main/rate-limits/service src/main/rate-limits/service.ts \
  src/renderer/src/hooks/ipc-events/rate-limit-ipc-bridge.ts \
  src/main | head -n 320
printf '%s\n' '--- bridge ---'
cat -n src/renderer/src/hooks/ipc-events/rate-limit-ipc-bridge.ts
printf '%s\n' '--- polling implementation ---'
cat -n src/main/rate-limits/service/service-polling.ts

Repository: stablyai/orca

Length of output: 38809


🏁 Script executed:

set -o pipefail
printf '%s\n' '--- service lifecycle and publication ---'
cat -n src/main/rate-limits/service/service-state.ts | sed -n '1,190p'
printf '%s\n' '--- fetch cycle state application ---'
rg -n -C 5 --glob '!**/*.test.*' \
  'updateState\(|fetchAll\(|this\.state|publish|webContents\.send' \
  src/main/rate-limits/service/service-fetch-queue.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-provider-cycles.ts \
  src/main/rate-limits/service/service-configuration.ts
printf '%s\n' '--- Cursor successful result ---'
cat -n src/main/rate-limits/cursor-fetcher.ts | sed -n '55,170p'
printf '%s\n' '--- Cursor mapping metadata ---'
cat -n src/main/rate-limits/cursor-usage-mapping.ts | sed -n '1,220p'

Repository: stablyai/orca

Length of output: 36288


Keep the Cursor email masked for the entire screenshot capture. maskCursorEmail changes only the renderer snapshot. A later focused-window rate-limit poll replaces that snapshot with a fresh Cursor result containing the real session.email. A subsequent proof screenshot can then expose the email. Apply the mask to every pushed snapshot, or pause polling until all screenshots complete.

Comment on lines +65 to +73
return {
auth: window.__store!.getState().rateLimits.cursorAuthConfigured,
status: cursor?.status ?? null,
bucketCount: cursor?.buckets?.length ?? 0
}
}),
{ timeout: 30_000 }
)
.toEqual(expect.objectContaining({ auth: true, status: 'ok' }))

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Assert bucketCount, or remove it from the polled payload.

The poll builds bucketCount, but expect.objectContaining({ auth: true, status: 'ok' }) never checks it. A provider result with status: 'ok' and zero buckets passes the gate. The spec then captures proof screenshots of an empty usage chip, which defeats the purpose of the proof run.

♻️ Assert a non-empty bucket list before capturing proof
-      .toEqual(expect.objectContaining({ auth: true, status: 'ok' }))
+      .toEqual(expect.objectContaining({ auth: true, status: 'ok' }))
+    const bucketCount = await orcaPage.evaluate(
+      () => window.__store!.getState().rateLimits.cursor?.buckets?.length ?? 0
+    )
+    expect(bucketCount).toBeGreaterThan(0)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
return {
auth: window.__store!.getState().rateLimits.cursorAuthConfigured,
status: cursor?.status ?? null,
bucketCount: cursor?.buckets?.length ?? 0
}
}),
{ timeout: 30_000 }
)
.toEqual(expect.objectContaining({ auth: true, status: 'ok' }))
return {
auth: window.__store!.getState().rateLimits.cursorAuthConfigured,
status: cursor?.status ?? null,
bucketCount: cursor?.buckets?.length ?? 0
}
}),
{ timeout: 30_000 }
)
.toEqual(expect.objectContaining({ auth: true, status: 'ok' }))
const bucketCount = await orcaPage.evaluate(
() => window.__store!.getState().rateLimits.cursor?.buckets?.length ?? 0
)
expect(bucketCount).toBeGreaterThan(0)

@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 (delta against the prior pullfrog review at 4bbf650)

  • Restored the Cursor default-on marker on the wire — re-added _cursorStatusBarDefaultAdded to the shared client-ui-params.ts UiUpdateFields after main moved the status-bar schema out of client-ui-schemas.ts. This fixes the persisted-key parity assertion that the rebase broke, and keeps the default-on migration able to send the marker.
  • Isolated the auth tests from a live macOS login — new isolateLinuxCursorConfig / isolateDarwinCursorHome helpers mock process.platform and os.homedir; cursor-auth.ts now imports the os namespace instead of the named homedir, so the unit tests no longer read the developer's real state.vscdb.
  • Covered the macOS desktop store — added a unit test that builds a ~/Library/Application Support/Cursor/.../state.vscdb, points os.homedir at it, and asserts the desktop-primary session read.
  • Added an opt-in macOS Electron proof spec — tests/e2e/cursor-usage-macos-desktop-login.spec.ts is skipped unless darwin, ORCA_CURSOR_USAGE_PROOF_DIR, and a real desktop DB are all present; it masks the account email before capture.
  • Two small CursorAccountsSection style fixes — moved tabular-nums from the Badge class onto an inner span and dropped a redundant button gap-1.

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

…y provider

Move the existing MiniMax search entry and default-on migration into focused modules.

This keeps later provider additions below the max-lines ratchet without changing behavior.
Read existing Cursor desktop or CLI credentials without copying state.

Fetch billing and Grok Bot pools with abort-aware polling and stale-state handling.
Add default-on, CLI-gated Cursor usage to the consolidated status bar.

Render all named pools and signed-in account metadata with localized controls.
Show read-only Cursor sign-in identity, plan, and named usage pools.

Register localized Accounts search entries and cover signed-out, pool, and error states.
Decode optional Cursor snapshots from mixed-version hosts and render named pools read-only.

Add bucket helpers, a Cursor-only route test, and an extracted mock fixture.
Gate Cursor surfaces by credential or usage state and filter unsupported web UI writes by host capability. Align mobile reset labels with custom widths and make unreadable-auth coverage deterministic.
Rename every Cursor renderer key introduced by this branch while preserving all five translated catalog values.
Keep search metadata and status-bar copy aligned with the maintainer naming policy.
Main moved the status-bar schema into shared UI params, so add the Cursor
default-on marker there. Isolate auth tests from a live macOS desktop
login, cover Application Support state.vscdb, and add an opt-in Electron
proof spec for that path.
Keep a usable CLI session when state.vscdb is locked or corrupt, hold the
masked Cursor email across proof screenshots, and require a non-empty
usage bucket list before capturing those screenshots.
@Mivr
Mivr force-pushed the feat/cursor-usage branch from 4042ed2 to 7e3c6f4 Compare September 21, 2026 12:34

@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 (delta against the prior pullfrog review at 4042ed2)

  • Added a CLI fallback when the desktop read fails — readCursorAuthSession() now runs the Cursor Agent auth.json path when readDesktopProfile() errors, returning the CLI session when it is usable and still surfacing the desktop error otherwise.
  • Extracted readCliSession() — shared by the desktop-missing and desktop-error paths, so the token-to-session mapping is no longer duplicated.
  • Covered the new fallback — the added test builds a corrupt state.vscdb alongside a valid auth.json and asserts the CLI session with an exact toEqual; the existing corrupt-DB test still asserts the desktop error when no CLI file exists, so the branch is genuinely exercised.
  • Hardened the macOS proof spec's email mask — installPersistentCursorEmailMask subscribes to the store so snapshots taken after a later host refresh stay masked, and the spec now asserts at least one usage bucket was fetched.

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

@jairuspace

Copy link
Copy Markdown
Contributor

Thanks — confirmed on my machine as well.

Setup: pr-18119 @ 7e3c6f41, pnpm install + pnpm dev on macOS (Apple Silicon). Live Cursor desktop login via ~/Library/Application Support/Cursor/.../state.vscdb (Pro / active).

Results:

  • Unit tests: cursor-auth + cursor-fetcher — 22/22 pass
  • Live store after refreshRateLimits(): cursorAuthConfigured: true, status: ok, credential source desktop
  • Pools rendered: Cursor Models / Other Models / On-demand / Grok Bot (status-bar Usage roster + Accounts)
  • No crashes or keychain prompts during read

Looks good from here — happy to re-check once this lands or if you want another pass after further review feedback.

@jairuspace

Copy link
Copy Markdown
Contributor

Small naming nit from trying this against a live Cursor Pro login:

Cursor’s own /usage UI labels the three billing pools Auto, API, and On-Demand. The API payload already uses that vocabulary (individualUsage.plan.autoPercentUsed / apiPercentUsed, plus onDemand), but this PR surfaces them as Cursor Models / Other Models / On-demand (docs-style wording).

Would it be better to match /usage exactly?

  • autoPercentUsed → Auto (today: Cursor Models)
  • apiPercentUsed → API (today: Other Models)
  • onDemand → On-Demand (today: On-demand)

That way Orca and cursor.com/dashboard/usage use the same words when you’re comparing remaining allowance. Happy either way — just noticed the mismatch while smoke-testing.

(Unrelated to this: Grok Bot as a fourth optional pool still seems right; /usage doesn’t fold that into the three billing labels.)

@Mivr

Mivr commented Sep 21, 2026

Copy link
Copy Markdown
Contributor Author
  • autoPercentUsed → Auto (today: Cursor Models)
  • apiPercentUsed → API (today: Other Models)
  • onDemand → On-Demand (today: On-demand)

I used Cursor models as their auto is not really auto in practice, it's their Composer or Grok models from xAI.

So I followed their own UI:
image

@nwparker

Copy link
Copy Markdown
Contributor

Heads up — I've opened #22633, which brings Cursor usage tracking together from this PR and the other open attempts (#8669, #11780, #13837, #16815, #18119, #20469, #21833). You're credited as a co-author on the commit; your work is in there.

The one thing I changed structurally: none of the open PRs read the macOS Keychain, and that's where cursor-agent 2026.06+ actually stores the session. On an up-to-date macOS install there's no ~/.cursor/auth.json at all, so the auth.json PRs find nothing, and the state.vscdb PRs find nothing for CLI-only users. #22633 reads keychain → auth.json → Cursor IDE in order, so it works either way.

Could you try it on your account and tell me if the numbers are right? There's an installable build here:

https://github.com/stablyai/orca-adhoc/releases/tag/v1.4.211-adhoc.20260924221219

macOS is signed and notarized, so it installs through Orca's updater. Windows is unsigned — grab orca-windows-setup.exe and run it once (SmartScreen will warn), and every switch after that works in-app. To go back, switch channels in Settings → Updates.

What I'd love checked, since I couldn't: the live numbers on a working paid plan. The only Cursor account on this machine has an expired token, so I verified the credential discovery and every error path end-to-end, but never saw real percentages render. If the pools (Cursor Models / Other Models / On-demand) and the plan total match what cursor.com/dashboard shows you, that's the confirmation I'm missing. If they don't, tell me what you see versus the dashboard and I'll fix it.

Also useful if you're on a plan shape I couldn't test: unlimited/Ultra, on-demand enabled, teams, or the older request-quota billing.

@nwparker

Copy link
Copy Markdown
Contributor

Update: new build, please use this one instead —

https://github.com/stablyai/orca-adhoc/releases/tag/v1.4.211-adhoc.20260924232116

The build I linked earlier has been deleted, because review found three bugs in it that would have hit you directly:

  • An expired CLI token hid a valid Cursor IDE session. If you ever ran cursor-agent login and now work mainly in the IDE, the old build told you "sign-in expired" forever while a perfectly good session sat unused. A live session now wins regardless of where it's stored.
  • A null field in the response threw away the whole reading, so some accounts would have shown no usage at all.
  • Cursor's pools rendered with no number — icon and an empty bar. That one only showed up on a healthy account, which is exactly what I couldn't test.

Same ask as before, and the same one thing I still can't verify myself: do the numbers match your cursor.com dashboard? Install instructions are unchanged — macOS through Orca's updater, Windows via orca-windows-setup.exe once past SmartScreen, Settings → Updates to go back.

@Mivr

Mivr commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor Author

@nwparker
Tested locally this build you provided:

Orca app:
image

Cursor webpage:
image

@Mivr Mivr closed this Sep 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Add Cursor usage tracking (status-bar rate limits + Accounts pane)

3 participants