Repository navigation
feat(rate-limits): add Cursor usage tracking - #13837
dominikzabcik wants to merge 3 commits into
Conversation
47bda5e to
b649eba
Compare
📝 WalkthroughWalkthroughAdded Cursor authentication from platform-specific session databases, authenticated rate-limit fetching, and service refresh orchestration. Exposed account and refresh APIs through IPC and preload layers. Added Cursor account settings, usage analytics, status-bar usage, search metadata, localization, web fallbacks, persisted status-bar migration, tests, and reference documentation. Merge Risk: 🟡 Moderate · up to The PR adds Cursor usage tracking across authentication, API fetching, status bar, Stats, and Accounts. Merge readiness is currently moderate because full typecheck, test, and build checks are still unchecked, while locale catalog entries and database-read error handling need correction or explicit acceptance to avoid misleading setup guidance and incomplete validation. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
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 |
There was a problem hiding this comment.
Actionable comments posted: 8
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 364a119d-1d99-4b36-9759-d001e05c38f8
📥 Commits
Reviewing files that changed from the base of the PR and between a0a654c and b649eba98de21baf37f017283b274883937e796b.
📒 Files selected for processing (47)
.gitignoredocs/reference/cursor-usage-tracking.mdsrc/main/cursor-accounts/status.test.tssrc/main/cursor-accounts/status.tssrc/main/ipc/cursor-accounts.tssrc/main/ipc/rate-limits.tssrc/main/ipc/register-core-handlers.tssrc/main/rate-limits/cursor-auth.test.tssrc/main/rate-limits/cursor-auth.tssrc/main/rate-limits/cursor-fetcher.test.tssrc/main/rate-limits/cursor-fetcher.tssrc/main/rate-limits/service.test.tssrc/main/rate-limits/service.tssrc/preload/api-types.tssrc/preload/index.tssrc/renderer/src/components/settings/AccountsPane.tsxsrc/renderer/src/components/settings/AppearanceWindowSidebarSection.tsxsrc/renderer/src/components/settings/CursorAccountsSection.test.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-search.tssrc/renderer/src/components/settings/appearance-status-bar-ssh-toggle-search.tssrc/renderer/src/components/stats/CursorUsagePane.test.tsxsrc/renderer/src/components/stats/CursorUsagePane.tsxsrc/renderer/src/components/stats/StatsPane.tsxsrc/renderer/src/components/stats/stats-search.tssrc/renderer/src/components/status-bar/StatusBar.tsxsrc/renderer/src/components/status-bar/provider-segment-monthly-window.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.test.tssrc/renderer/src/components/status-bar/tooltip.tsxsrc/renderer/src/components/status-bar/usage-error-copy.test.tssrc/renderer/src/components/status-bar/usage-error-copy.tssrc/renderer/src/components/status-bar/usage-provider-settings-target.test.tssrc/renderer/src/components/status-bar/usage-provider-settings-target.tssrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/store/slices/rate-limits.tssrc/renderer/src/store/slices/ui.tssrc/renderer/src/web/web-preload-api.tssrc/shared/cursor-session-paths.test.tssrc/shared/cursor-session-paths.tssrc/shared/rate-limit-types.test.tssrc/shared/rate-limit-types.tssrc/shared/status-bar-defaults.tssrc/shared/types.ts
| function readItemFromStateDb(dbPath: string, key: string): string | null { | ||
| let db: SyncDatabase.Database | null = null | ||
| try { | ||
| db = new SyncDatabase(dbPath, { readonly: true, fileMustExist: true }) | ||
| const row = db.prepare('SELECT value FROM ItemTable WHERE key = ?').get(key) as | ||
| | { value?: string } | ||
| | undefined | ||
| const value = row?.value | ||
| return typeof value === 'string' && value.trim().length > 0 ? value.trim() : null | ||
| } catch { | ||
| return null | ||
| } finally { | ||
| db?.close() | ||
| } | ||
| } | ||
|
|
||
| export function readCursorAuthSession(): CursorAuthReadResult { | ||
| const dbPath = resolveCursorGlobalStateDbPath() | ||
| if (!existsSync(dbPath)) { | ||
| return { status: 'missing' } | ||
| } | ||
| const accessToken = readItemFromStateDb(dbPath, CURSOR_ACCESS_TOKEN_KEY) | ||
| if (!accessToken) { | ||
| return { status: 'missing' } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Do not map database read failures to missing authentication.
Line 109 converts every database open and query failure to null. Lines 121-123 then report the state as missing. A locked, corrupt, or permission-denied existing database therefore appears as a signed-out user.
Return a read-error result from readItemFromStateDb, map it to CursorAuthReadResult.status: 'error', and add a regression test.
| "CursorAccountsSection": { | ||
| "a1b2c3d4e5": "Cursor", | ||
| "f6e5d4c3b2": "Shows plan usage from your Cursor IDE sign-in (globalStorage state database).", | ||
| "0d8e77bc40": "Cursor docs", | ||
| "ad47a33f72": "Loading…", | ||
| "b2c3d4e5f6": "Signed in", | ||
| "b36fa2c908": "Signed in. Orca reads the Cursor IDE session stored on disk.", | ||
| "f08c41de73": "Session expired — sign in to Cursor on the computer running Orca, then click Refresh usage.", | ||
| "e5f6a7b8c9": "Not signed in to Cursor", | ||
| "f6a7b8c9d0": "Open Cursor and sign in, then click Refresh usage here.", | ||
| "3325d996cb": "Refresh usage", | ||
| "a8f3e2c1b4": "Plan usage", | ||
| "b7e2d9f0a3": "Same plan usage % as the Cursor dashboard.", | ||
| "c6d1a8f4e2": "Resets {{when}}", | ||
| "d5e0b7c3a1": "Plan {{pct}}%", | ||
| "e4f1c8d2b0": "Auto {{pct}}%", | ||
| "f3a2d9e1c7": "API {{pct}}%" | ||
| }, |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Sync the CursorAccountsSection description with the component's current fallback text.
b7e2d9f0a3 in en.json still reads "Same plan usage % as the Cursor dashboard.". src/renderer/src/components/settings/CursorAccountsSection.tsx (Line 165) passes the fallback "Same plan / Auto / API % as the Cursor dashboard." for this same key. Because the catalog value overrides the inline fallback at runtime, users see the stale, less accurate description that omits the Auto/API breakdown shown by the new badges.
Update this catalog entry to match the component's current text, or run the locale sync tooling so the key and text stay aligned.
📝 Proposed fix
- "b7e2d9f0a3": "Same plan usage % as the Cursor dashboard.",
+ "b7e2d9f0a3": "Same plan / Auto / API % as the Cursor dashboard.",📝 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.
| "CursorAccountsSection": { | |
| "a1b2c3d4e5": "Cursor", | |
| "f6e5d4c3b2": "Shows plan usage from your Cursor IDE sign-in (globalStorage state database).", | |
| "0d8e77bc40": "Cursor docs", | |
| "ad47a33f72": "Loading…", | |
| "b2c3d4e5f6": "Signed in", | |
| "b36fa2c908": "Signed in. Orca reads the Cursor IDE session stored on disk.", | |
| "f08c41de73": "Session expired — sign in to Cursor on the computer running Orca, then click Refresh usage.", | |
| "e5f6a7b8c9": "Not signed in to Cursor", | |
| "f6a7b8c9d0": "Open Cursor and sign in, then click Refresh usage here.", | |
| "3325d996cb": "Refresh usage", | |
| "a8f3e2c1b4": "Plan usage", | |
| "b7e2d9f0a3": "Same plan usage % as the Cursor dashboard.", | |
| "c6d1a8f4e2": "Resets {{when}}", | |
| "d5e0b7c3a1": "Plan {{pct}}%", | |
| "e4f1c8d2b0": "Auto {{pct}}%", | |
| "f3a2d9e1c7": "API {{pct}}%" | |
| }, | |
| "CursorAccountsSection": { | |
| "a1b2c3d4e5": "Cursor", | |
| "f6e5d4c3b2": "Shows plan usage from your Cursor IDE sign-in (globalStorage state database).", | |
| "0d8e77bc40": "Cursor docs", | |
| "ad47a33f72": "Loading…", | |
| "b2c3d4e5f6": "Signed in", | |
| "b36fa2c908": "Signed in. Orca reads the Cursor IDE session stored on disk.", | |
| "f08c41de73": "Session expired — sign in to Cursor on the computer running Orca, then click Refresh usage.", | |
| "e5f6a7b8c9": "Not signed in to Cursor", | |
| "f6a7b8c9d0": "Open Cursor and sign in, then click Refresh usage here.", | |
| "3325d996cb": "Refresh usage", | |
| "a8f3e2c1b4": "Plan usage", | |
| "b7e2d9f0a3": "Same plan / Auto / API % as the Cursor dashboard.", | |
| "c6d1a8f4e2": "Resets {{when}}", | |
| "d5e0b7c3a1": "Plan {{pct}}%", | |
| "e4f1c8d2b0": "Auto {{pct}}%", | |
| "f3a2d9e1c7": "API {{pct}}%" | |
| }, |
Source: Learnings
| const previous = process.platform | ||
| Object.defineProperty(process, 'platform', { value: 'darwin' }) | ||
| expect(resolveCursorGlobalStateDbPath({}, '/Users/dev')).toBe( | ||
| '/Users/dev/Library/Application Support/Cursor/User/globalStorage/state.vscdb' | ||
| ) | ||
| Object.defineProperty(process, 'platform', { value: previous }) |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -eu
file="$(fd -t f 'cursor-session-paths\.test\.ts$' . | head -n 1)"
printf '%s\n' "FILE: $file"
cat -n "$file"
printf '\n--- related platform mutations ---\n'
rg -n -C 3 'process\.platform|resolveCursorGlobalStateDbPath|afterEach|beforeEach' "$file"
printf '\n--- test configuration references ---\n'
rg -n '"(test|test:|vitest|jest|mocha)|vitest|jest' package.json pnpm-lock.yaml yarn.lock package-lock.json 2>/dev/null | head -80 || trueRepository: stablyai/orca
Length of output: 10603
🏁 Script executed:
#!/bin/bash
set -eu
printf '%s\n' '--- Vitest configuration ---'
config="$(fd -t f 'vitest\.config\.ts$' config . | head -n 1)"
printf 'FILE: %s\n' "$config"
cat -n "$config" | sed -n '1,220p'
printf '\n--- suite-level isolation/concurrency settings ---\n'
rg -n -C 2 'sequence|concurrent|pool|isolate|fileParallelism|maxWorkers|minWorkers|restoreMocks|setupFiles' config src package.json
printf '\n--- standalone control-flow probe ---\n'
node - <<'JS'
let platform = 'linux'
function run(assertionThrows) {
const previous = platform
platform = 'darwin'
try {
if (assertionThrows) throw new Error('assertion failure')
} finally {
// This models the proposed safe cleanup.
platform = previous
}
}
try {
const previous = platform
platform = 'darwin'
throw new Error('assertion failure')
platform = previous
} catch {}
console.log(JSON.stringify({withoutFinally: platform}))
run(false)
console.log(JSON.stringify({withFinally: platform}))
JSRepository: stablyai/orca
Length of output: 50370
🏁 Script executed:
#!/bin/bash
set -eu
printf '%s\n' '--- config/vitest.config.ts ---'
cat -n config/vitest.config.ts | sed -n '1,220p'
printf '\n--- relevant test-runner settings only ---\n'
rg -n 'sequence|concurrent|pool|isolate|fileParallelism|maxWorkers|minWorkers|restoreMocks|setupFiles|test:' config/vitest.config.ts package.json
printf '\n--- standalone control-flow probe ---\n'
node - <<'JS'
let platform = 'linux'
try {
const previous = platform
platform = 'darwin'
throw new Error('assertion failure')
platform = previous
} catch {}
const withoutFinally = platform
const run = (throws) => {
const previous = platform
platform = 'win32'
try {
if (throws) throw new Error('assertion failure')
} finally {
platform = previous
}
}
run(true)
console.log(JSON.stringify({ withoutFinally, afterFinally: platform }))
JSRepository: stablyai/orca
Length of output: 6992
🏁 Script executed:
#!/bin/bash
set -eu
node - <<'JS'
const descriptorBefore = Object.getOwnPropertyDescriptor(process, 'platform')
const previous = process.platform
let withoutFinally
try {
Object.defineProperty(process, 'platform', { value: 'darwin' })
try {
throw new Error('assertion failure')
} catch {}
withoutFinally = process.platform
} finally {
Object.defineProperty(process, 'platform', {
value: previous,
configurable: descriptorBefore?.configurable,
enumerable: descriptorBefore?.enumerable,
writable: descriptorBefore?.writable
})
}
let restoredByFinally
try {
Object.defineProperty(process, 'platform', { value: 'win32' })
try {
throw new Error('assertion failure')
} finally {
Object.defineProperty(process, 'platform', {
value: previous,
configurable: descriptorBefore?.configurable,
enumerable: descriptorBefore?.enumerable,
writable: descriptorBefore?.writable
})
}
} catch (error) {
console.error(error)
process.exitCode = 1
}
restoredByFinally = process.platform
console.log(JSON.stringify({ withoutFinally, restoredByFinally }))
JSRepository: stablyai/orca
Length of output: 721
Restore process.platform in a finally block.
If an assertion fails, the restore statement is skipped. Later tests can then run with the simulated platform. Apply the same protection to lines 16–26 and 30–35.
| @@ -0,0 +1,33 @@ | |||
| import { homedir } from 'node:os' | |||
| import { join } from 'node:path' | |||
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🌐 Web query:
Does the XDG Base Directory Specification require XDG_CONFIG_HOME to be an absolute path?
💡 Result:
Yes, the XDG Base Directory Specification requires XDG_CONFIG_HOME to be an absolute path [1][2]. The specification explicitly states that all paths set in the environment variables defined by the spec (which includes XDG_CONFIG_HOME) must be absolute [1][3]. Furthermore, it directs that if an implementation encounters a relative path in any of these variables, it should consider the path invalid and ignore it [1][4][5].
Citations:
- 1: https://specifications.freedesktop.org/basedir-spec/latest/
- 2: https://specifications.freedesktop.org/basedir/latest/
- 3: https://xdg-specs-razzeee-a1dec53d4dde6f1df1b4b4e5aedd619a0802ae9768a5f.pages.freedesktop.org/basedir-spec/basedir-spec-latest.html
- 4: https://xdg-specs-technobaboo-f55ac9d85e73073a0c8831695ba0fb110849811c0.pages.freedesktop.org/basedir-spec/latest/ar01s02.html
- 5: https://web.archive.org/web/20221029151712/https:/specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
🏁 Script executed:
#!/bin/sh
set -eu
file=$(git ls-files | grep -Fx 'src/shared/cursor-session-paths.ts')
cat -n "$file"
printf '\nPath API availability:\n'
node - <<'JS'
const path = require('node:path')
for (const value of ['config', '~/.config', '/home/user/.config', '']) {
console.log(JSON.stringify({ value, isAbsolute: path.isAbsolute(value), joined: path.join(value || '/fallback/.config', 'Cursor', 'User', 'globalStorage', 'state.vscdb') }))
}
JSRepository: stablyai/orca
Length of output: 1851
Reject relative XDG_CONFIG_HOME values.
Line 29 accepts relative values such as config. Use the fallback path unless XDG_CONFIG_HOME is absolute.
b649eba to
2807426
Compare
|
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. |
Read Cursor IDE session from state.vscdb and surface plan, Auto, and API usage in the status bar, Stats, and Accounts settings. Co-authored-by: Cursor <[email protected]>
Match Claude's explicit unused-case breaks so type-aware oxlint passes. Co-authored-by: Cursor <[email protected]>
Add missing en.json entries required by localization-catalog verify. Co-authored-by: Cursor <[email protected]>
2807426 to
a3dfbc0
Compare
|
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. |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 37d3116a-09cc-477e-962e-7d89d3df837b
📒 Files selected for processing (56)
.gitignoredocs/reference/cursor-usage-tracking.mdsrc/main/cursor-accounts/status.test.tssrc/main/cursor-accounts/status.tssrc/main/ipc/cursor-accounts.tssrc/main/ipc/rate-limits.tssrc/main/ipc/register-core-handlers.tssrc/main/rate-limits/cursor-auth.test.tssrc/main/rate-limits/cursor-auth.tssrc/main/rate-limits/cursor-fetcher.test.tssrc/main/rate-limits/cursor-fetcher.tssrc/main/rate-limits/rate-limit-service-test-harness.tssrc/main/rate-limits/service-account-target-selection.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.tssrc/preload/api-types.tssrc/preload/api/agent-account-api.tssrc/preload/api/agent-usage-api.tssrc/preload/index.tssrc/renderer/src/components/settings/AccountsPane.tsxsrc/renderer/src/components/settings/AppearanceWindowSidebarSection.tsxsrc/renderer/src/components/settings/CursorAccountsSection.test.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-search.tssrc/renderer/src/components/settings/appearance-status-bar-ssh-toggle-search.tssrc/renderer/src/components/stats/CursorUsagePane.test.tsxsrc/renderer/src/components/stats/CursorUsagePane.tsxsrc/renderer/src/components/stats/StatsPane.tsxsrc/renderer/src/components/stats/stats-search.tssrc/renderer/src/components/status-bar/StatusBar.tsxsrc/renderer/src/components/status-bar/provider-segment-monthly-window.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.test.tssrc/renderer/src/components/status-bar/tooltip.tsxsrc/renderer/src/components/status-bar/usage-error-copy.test.tssrc/renderer/src/components/status-bar/usage-error-copy.tssrc/renderer/src/components/status-bar/usage-provider-settings-target.test.tssrc/renderer/src/components/status-bar/usage-provider-settings-target.tssrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/store/slices/rate-limits.tssrc/renderer/src/store/slices/ui.tssrc/renderer/src/web/web-preload-api.tssrc/shared/cursor-session-paths.test.tssrc/shared/cursor-session-paths.tssrc/shared/persisted-ui-state-types.tssrc/shared/rate-limit-types.test.tssrc/shared/rate-limit-types.tssrc/shared/status-bar-defaults.tssrc/shared/ui-chrome-types.ts
🚧 Files skipped from review as they are similar to previous changes (53)
- src/main/rate-limits/service-window-activation.test.ts
- src/main/rate-limits/service-live-claude-usage.test.ts
- src/shared/rate-limit-types.test.ts
- src/renderer/src/components/settings/AppearanceWindowSidebarSection.tsx
- src/shared/ui-chrome-types.ts
- src/renderer/src/components/status-bar/tooltip.tsx
- src/renderer/src/store/slices/rate-limits.ts
- src/main/ipc/cursor-accounts.ts
- src/main/rate-limits/service-account-target-selection.test.ts
- src/renderer/src/components/status-bar/usage-provider-settings-target.test.ts
- src/shared/status-bar-defaults.ts
- src/preload/api/agent-usage-api.ts
- src/renderer/src/components/status-bar/tooltip.test.ts
- src/main/rate-limits/rate-limit-service-test-harness.ts
- src/preload/api-types.ts
- .gitignore
- src/renderer/src/components/settings/accounts-search.ts
- src/main/rate-limits/service-inactive-account-previews.test.ts
- src/main/rate-limits/service-minimax-usage.test.ts
- src/renderer/src/components/status-bar/provider-segment-monthly-window.test.tsx
- src/main/ipc/register-core-handlers.ts
- src/preload/api/agent-account-api.ts
- src/renderer/src/components/settings/appearance-status-bar-search.ts
- src/main/rate-limits/service-refresh-orchestration.test.ts
- src/renderer/src/components/stats/StatsPane.tsx
- src/shared/rate-limit-types.ts
- src/main/cursor-accounts/status.ts
- src/main/rate-limits/cursor-fetcher.test.ts
- src/renderer/src/web/web-preload-api.ts
- src/renderer/src/components/status-bar/usage-error-copy.ts
- src/shared/cursor-session-paths.test.ts
- docs/reference/cursor-usage-tracking.md
- src/renderer/src/store/slices/ui.ts
- src/renderer/src/components/status-bar/status-bar-provider-visibility.test.ts
- src/renderer/src/components/status-bar/usage-error-copy.test.ts
- src/renderer/src/components/settings/appearance-status-bar-ssh-toggle-search.ts
- src/renderer/src/components/status-bar/StatusBar.tsx
- src/renderer/src/components/status-bar/status-bar-provider-visibility.ts
- src/main/ipc/rate-limits.ts
- src/renderer/src/components/stats/CursorUsagePane.test.tsx
- src/main/rate-limits/cursor-fetcher.ts
- src/shared/persisted-ui-state-types.ts
- src/renderer/src/components/settings/AccountsPane.tsx
- src/shared/cursor-session-paths.ts
- src/renderer/src/i18n/locales/en.json
- src/renderer/src/components/stats/stats-search.ts
- src/main/cursor-accounts/status.test.ts
- src/renderer/src/components/stats/CursorUsagePane.tsx
- src/renderer/src/components/settings/appearance-status-bar-cursor-toggle-search.ts
- src/main/rate-limits/cursor-auth.test.ts
- src/renderer/src/components/settings/CursorAccountsSection.test.tsx
- src/preload/index.ts
- src/renderer/src/components/status-bar/usage-provider-settings-target.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
| {translate('auto.components.settings.CursorAccountsSection.a1b2c3d4e5', 'Cursor')} | ||
| </h3> | ||
| <p className="text-xs text-muted-foreground"> | ||
| {translate( | ||
| 'auto.components.settings.CursorAccountsSection.f6e5d4c3b2', | ||
| 'Shows plan usage from your Cursor IDE sign-in (globalStorage state database).' |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Generate the required locale keys.
The locale keys use placeholder-like values such as a1b2c3d4e5. Generate each key from the first 10 SHA-1 characters of <filePath>:<text>. Add the generated entries to src/renderer/src/i18n/locales/en.json. Then run pnpm bootstrap:locale-catalog to propagate translations.
Based on learnings: “generate locale keys as the first 10 characters of the SHA-1 hash of <filePath>:<text>” and add keys to en.json before running pnpm bootstrap:locale-catalog.
Also applies to: 80-80, 100-100, 106-120, 126-134, 153-153, 159-165, 172-203
Source: Learnings
|
I prepared three follow-up commits based exactly on this PR's current head
Verification:
Cherry-pick in order:
|
|
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 Could you try it on your account and tell me if the numbers are right? There's an installable build here: macOS is signed and notarized, so it installs through Orca's updater. Windows is unsigned — grab 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. |
|
Update: new build, please use this one instead — The build I linked earlier has been deleted, because review found three bugs in it that would have hit you directly:
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 |

Summary
Shows Cursor plan usage in the status bar, usage roster, Stats, and Accounts when the machine running Orca is signed into Cursor IDE.
Auth matches CodexBar: read
cursorAuth/accessToken(and optionalcachedEmail) from Cursor’sstate.vscdb, callcursor.com/api/usage-summary+/api/auth/me, map:totalPercentUsedautoPercentUsed/apiPercentUsed)Toggle lives under Appearance → status bar, same pattern as Grok.
Screenshots
Please attach screenshots from a signed-in Cursor IDE session before marking ready for review.
Testing
pnpm lintpnpm typecheckpnpm testpnpm buildCovered: auth/JWT parsing, fetcher mapping (monthly + Auto/API), service refresh, session DB paths (macOS/Linux/Windows), status-bar verbose buckets, tooltip sections, Stats pane, Accounts section, stale-token copy, localization catalog keys, exhaustive
failureKindswitches.Focused suite used during development:
pnpm test \ src/main/rate-limits/cursor-auth.test.ts \ src/main/rate-limits/cursor-fetcher.test.ts \ src/main/cursor-accounts/status.test.ts \ src/main/rate-limits/service.test.ts \ src/shared/cursor-session-paths.test.ts \ src/renderer/src/components/stats/CursorUsagePane.test.tsx \ src/renderer/src/components/settings/CursorAccountsSection.test.tsx \ src/renderer/src/components/status-bar/tooltip.test.ts \ src/renderer/src/components/status-bar/provider-segment-monthly-window.test.tsx \ src/renderer/src/components/status-bar/usage-error-copy.test.tsManual: signed-in Cursor IDE on macOS → status bar + detail + Stats + Accounts refresh.
Note
Full
pnpm typecheck/pnpm test/pnpm buildshould be confirmed green before marking ready; lint + localization catalog verify already passed after follow-up fixes.AI Review Report
Reviewed against Grok/Gemini usage providers and Orca contribution rules (cross-platform paths, provider-neutral status bar, no
.d.tstypes, STYLEGUIDE/shadcn for UI).Checked:
state.vscdbpath resolution (path.join,APPDATA,XDG_CONFIG_HOME)fetchCursorOnlyalongside existing provider cyclesfailureKindswitchesen.jsonFixed during review: dropped fake Weekly lane; restored Auto/API buckets; verbose-bar allowlist + monthly fallback; Accounts/Stats locale keys; exhaustive switches; catalog sync.
SSH / remote: usage is read from Cursor’s local IDE session on the host running Orca (same class as Grok CLI auth). It does not read Cursor state from an SSH remote.
Security Audit
accessToken,cachedEmail) from the local SQLite DB; no write pathcursor.comAPI calls; token is not loggedNotes
docs/reference/cursor-usage-tracking.mdMade with Cursor