Skip to content

refactor(usage): Cursor account usage comes from provider-cursor - #17578

Merged
juliusmarminge merged 1 commit into
t3/usage-opencode-readerfrom
t3/usage-cursor-reader
Oct 9, 2026
Merged

juliusmarminge merged 1 commit into
t3/usage-opencode-readerfrom
t3/usage-cursor-reader

Conversation

@juliusmarminge

@juliusmarminge juliusmarminge commented Oct 9, 2026 •

Copy link
Copy Markdown
Member

UsageService owned Cursor's account usage: the dashboard reader, the in-memory and persisted account cache, TTL, failure memo, in-flight refresh dedupe, and the login/Keychain gating. Separately, keychainToken.ts in provider-cursor kept module-level memo state and threw a plain Error.

  • These move into a CursorUsageAccounts service in provider-cursor, behind a scan reader on CursorDriver.usage. It persists to the same usage-cursor-account-cache-v1.json under ProviderHost.paths.stateDir, so existing caches survive.
  • cursorKeychainUsageEnabled is read through ProviderHost.settings.
  • keychainToken.ts becomes a CursorKeychain service; its errors are Schema.TaggedErrors.

User-visible messages are unchanged.

Review note: CursorKeychain.layer is provided both in the adapter infrastructure and under layerUsage. Effect memoizes by layer reference, so this should build one instance (one Keychain prompt for usage limits and usage history), but that hasn't been verified at runtime on macOS.

🤖 Generated with Claude Code (Claude Opus 5.5, Claude Code harness)

@juliusmarminge
juliusmarminge added this pull request to stack #17580 October 9, 2026 19:20
@github-actions github-actions Bot added the vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. label Oct 9, 2026
@juliusmarminge juliusmarminge added the macroscope-review Opt PRs made by unvouched contributors in for Macroscope review. Vouched contributors auto-reviews label Oct 9, 2026
@github-actions github-actions Bot added the size:XL 500-999 changed lines (additions + deletions). label Oct 9, 2026
Comment thread packages/provider-cursor/src/server/CursorUsageAccounts.ts Outdated
@github-actions

github-actions Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Thread transfer impact

✅ Thread transfer remains within every enforced ceiling.

ℹ️ No successful main baseline artifact is available yet. This run establishes the initial measurement.

Provider Metric Main baseline This PR Impact PR ceiling
Codex Total thread wire — 5.0 KiB — 6.8 KiB ✅
Codex Thread snapshot wire — 3.8 KiB — 4.9 KiB ✅
Codex Live turn WebSocket wire — 1.2 KiB — 2.0 KiB ✅
Codex Live turn WebSocket decoded — 20.9 KiB — 29.3 KiB ✅
Codex Live turn messages — 2 — 8 ✅
Claude Total thread wire — 5.0 KiB — 6.8 KiB ✅
Claude Thread snapshot wire — 3.8 KiB — 4.9 KiB ✅
Claude Live turn WebSocket wire — 1.2 KiB — 2.0 KiB ✅
Claude Live turn WebSocket decoded — 21.2 KiB — 29.3 KiB ✅
Claude Live turn messages — 2 — 8 ✅

Baseline: unavailable · PR result: aec4a9f · Source CI: success

Scenario and decoded snapshot size

10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

  • Codex decoded thread snapshot: 108.5 KiB
  • Claude decoded thread snapshot: 108.8 KiB

Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

@macroscopeapp

macroscopeapp Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Not approved

Macroscope's review found this PR not approvable — This production refactor introduces substantial new Cursor usage and Keychain service wiring across the provider runtime, with cache, refresh, and credential behavior spanning multiple packages. It also adds a static-analysis suppression directive, so the change warrants direct human review.

You can add or adjust custom eligibility rules. Learn more.

@juliusmarminge
juliusmarminge force-pushed the t3/usage-cursor-reader branch from e57935a to 6c5f9b7 Compare October 9, 2026 19:25
@coderabbitai

coderabbitai Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Path: .coderabbit.config.ts
  • Review profile: CHILL
  • Plan: Team
  • Run ID: 6a2aab68-d981-45f7-b46c-bf90a467c0c7

📥 Commits

Reviewing files that changed from the base of the PR and between 6c5f9b7 and aec4a9f.


📒 Files selected for processing (4)
  • apps/server/src/usage/UsageService.ts
  • packages/provider-core/src/server/usage.ts
  • packages/provider-cursor/src/server/CursorUsageAccounts.ts
  • packages/provider-cursor/src/server/driver.ts

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



📝 Walkthrough

Walkthrough

Cursor account-usage reading, Keychain access, and persisted scan caching now reside in the provider package. The server registers Cursor as a built-in usage driver. UsageService removes its dedicated Cursor account-refresh and cache path.

Changes

Cursor provider usage

Layer / File(s) Summary
Keychain access and account reading
packages/provider-cursor/src/server/CursorKeychain.ts, packages/provider-cursor/src/server/CursorAccountReader.ts, packages/provider-cursor/src/server/accountUsage.ts, packages/provider-cursor/src/server/usageLimits.ts, packages/provider-cursor/package.json, packages/provider-cursor/src/server.ts, packages/provider-cursor/src/server/*test.ts
Adds a Keychain service that shares in-flight reads, caches non-null tokens for five minutes, and reports timeout or read errors. Adds CursorAccountReader and uses the Keychain service for usage-limit reads. Account-usage tests cover pagination, response validation, and failure paths. The package exports the new server modules.
Cached Cursor usage scans
packages/provider-cursor/src/server/CursorUsageAccounts.ts, packages/provider-cursor/src/server/accountCache.ts, packages/provider-cursor/src/server/accountCache.test.ts
Adds per-credential persisted usage caches, refresh coordination, failure handling, and filtered scan results.
Provider and server wiring
packages/provider-cursor/src/server/driver.ts, packages/provider-cursor/src/server/driver.test.ts, apps/server/src/provider/*, apps/server/src/provider/builtInDrivers.ts, apps/server/src/server.ts
CursorDriver delegates usage scans to CursorUsageAccounts and includes CursorKeychain in its environment. The server registers Cursor in its built-in drivers and provides the provider usage layers.
UsageService migration and tests
packages/provider-core/src/server/usage.ts, apps/server/src/usage/UsageService.ts, apps/server/src/usage/UsageService.test.ts, apps/server/src/usage/*test.ts
ProviderUsageScanInput now includes a settings snapshot. UsageService removes Cursor-specific account-cache persistence and refresh logic. Usage-service tests use the provider account layer; Cursor account-history tests are removed from the server usage tests.

Priority: ⬇️ Low

Estimated code review effort: 4 (Complex) | ~45 minutes

Change: Refactor

Sequence Diagram(s)

sequenceDiagram
  participant CursorDriver
  participant CursorUsageAccounts
  participant CursorAccountReader
  participant CursorKeychain
  participant readCursorAccountUsage
  CursorDriver->>CursorUsageAccounts: scan window and refresh options
  CursorUsageAccounts->>CursorAccountReader: read account history
  CursorAccountReader->>CursorKeychain: retrieve token for Keychain credentials
  CursorAccountReader->>readCursorAccountUsage: read usage for the requested time range
  readCursorAccountUsage-->>CursorUsageAccounts: account usage result
  CursorUsageAccounts-->>CursorDriver: filtered usage scan
Loading

Merge Risk: ⚪ Minimal · up to aec4a

Cursor usage tracking moves into the Cursor provider package, and existing caches are preserved. No concrete defects were identified, so the change appears ready to merge. Someone with a Mac should confirm that the Keychain prompt appears only once.

Pre-merge checks | Passed 3 | Failed 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check Warning The description explains the problem and the planned change, but it does not include the required Scope and approval or Verification sections. It also does not state focused test results or manual che… Add the required Problem, Change, Scope and approval, and Verification sections. Include the triaged issue or maintainer approval, focused test commands with observed results, and any checks not performed, including the unverified macOS lay…
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Title check Passed The title clearly and concisely describes the main change: moving Cursor account usage handling into provider-cursor.

Full details: Description check

Explanation

The description explains the problem and the planned change, but it does not include the required Scope and approval or Verification sections. It also does not state focused test results or manual checks.

Resolution

Add the required Problem, Change, Scope and approval, and Verification sections. Include the triaged issue or maintainer approval, focused test commands with observed results, and any checks not performed, including the unverified macOS layer-memoization behavior.



  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR

📝 Generate docstrings
  • Commit to this branch
  • Create a new PR

🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR


  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

The dashboard reader, account cache, and the account caches' state (TTL,
failure memo, refresh dedupe, persistence under the same
usage-cursor-account-cache-v1.json) move into a CursorUsageAccounts service
in provider-cursor, behind a scan reader on CursorDriver.usage. The login and
Keychain gating moves with it and reads cursorKeychainUsageEnabled through
ProviderHost.settings.

keychainToken's module-level memo becomes a CursorKeychain service shared by
usage history and usage limits, and its timeout error is a
Schema.TaggedError. User-visible messages are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@juliusmarminge
juliusmarminge force-pushed the t3/usage-cursor-reader branch from 6c5f9b7 to aec4a9f Compare October 9, 2026 20:28
@juliusmarminge
juliusmarminge merged commit 5a9c664 into main Oct 9, 2026
57 of 77 checks passed
@juliusmarminge
juliusmarminge deleted the t3/usage-cursor-reader branch October 9, 2026 22:26
github-actions Bot added a commit to omarcresp/t3code-flake that referenced this pull request Oct 10, 2026
## What's Changed
* chore(deps): upgrade Effect to 4.0.2 by @juliusmarminge in pingdotgg/t3code#17571
* fix(devices): recover stalled video without losing simulator input by @juliusmarminge in pingdotgg/t3code#17566
* fix(web): keep checkout stable while pr actions load by @maria-rcks in pingdotgg/t3code#16625
* fix(mobile): show waiting thread status by @maria-rcks in pingdotgg/t3code#16693
* feat(web): add parent thread breadcrumb navigation by @maria-rcks in pingdotgg/t3code#16666
* fix(server): restart inactivity after snoozed threads wake by @maria-rcks in pingdotgg/t3code#16674
* feat(desktop): passkeys in the in-app browser on macOS by @juliusmarminge in pingdotgg/t3code#16952
* fix(client): load earlier turns works for MCP threads over T3 Connect by @juliusmarminge in pingdotgg/t3code#17599
* refactor(client): sign relay request URLs built from the HttpApi contract by @juliusmarminge in pingdotgg/t3code#17602
* refactor(source-control): add @t3tools/source-control-core by @juliusmarminge in pingdotgg/t3code#17573
* refactor(source-control): Forgejo lives in @t3tools/source-control-forgejo by @juliusmarminge in pingdotgg/t3code#17581
* refactor(source-control): Azure DevOps lives in @t3tools/source-control-azure-devops by @juliusmarminge in pingdotgg/t3code#17592
* refactor(source-control): GitLab lives in @t3tools/source-control-gitlab by @juliusmarminge in pingdotgg/t3code#17594
* refactor(source-control): Bitbucket lives in @t3tools/source-control-bitbucket by @juliusmarminge in pingdotgg/t3code#17597
* refactor(source-control): GitHub lives in @t3tools/source-control-github by @juliusmarminge in pingdotgg/t3code#17607
* refactor(usage): transcript readers come from their drivers by @juliusmarminge in pingdotgg/t3code#17576
* refactor(usage): OpenCode usage comes from provider-opencode by @juliusmarminge in pingdotgg/t3code#17577
* refactor(usage): Cursor account usage comes from provider-cursor by @juliusmarminge in pingdotgg/t3code#17578
* refactor(usage): Antigravity usage is a reader on its driver by @juliusmarminge in pingdotgg/t3code#17579
* refactor(usage): usage readers use Effect FileSystem and SqlClient by @juliusmarminge in pingdotgg/t3code#17615
* fix(web): composer context strip pads both edges evenly by @limineol in pingdotgg/t3code#17562
* test(usage): v4 cache upgrade test waits for the migrated cache write by @Mnigos in pingdotgg/t3code#17553
* feat(mobile): support Duo in the shared iOS app by @juliusmarminge in pingdotgg/t3code#12648
* refactor(source-control): GitManager reads provider resolvers, not host kinds by @juliusmarminge in pingdotgg/t3code#17617
* refactor(source-control): PullRequestService reads GitHub resolvers, not its kind by @juliusmarminge in pingdotgg/t3code#17619
* refactor(source-control): Forgejo identity and Azure DevOps addressing move into their packages by @juliusmarminge in pingdotgg/t3code#17624
* refactor: home directory comes from a HostProcessHomeDirectory reference by @juliusmarminge in pingdotgg/t3code#17628
* refactor(shared): host process references live in a HostProcess module by @juliusmarminge in pingdotgg/t3code#17641
* feat(web): filter PR comments by bots and resolved threads by @juliusmarminge in pingdotgg/t3code#17645
* fix(clients): remove redundant prefix from PR watch status by @extoci in pingdotgg/t3code#17635
* fix(web): pending requests wait until you stop typing by @maria-rcks in pingdotgg/t3code#17637
* fix(models): remove new badges from Claude Opus and Sonnet 5.5 by @extoci in pingdotgg/t3code#17646
* fix(ui): keep focus and selection borders visible across the app by @maria-rcks in pingdotgg/t3code#16675
* fix(mobile): prevent row presses during native back swipes by @juliusmarminge in pingdotgg/t3code#17648
* fix(server): Codex shadow homes replace stray sqlite maintenance locks by @juliusmarminge in pingdotgg/t3code#17663
* feat(desktop): T3 Code can be your default web browser on macOS by @juliusmarminge in pingdotgg/t3code#17587
* test(server): the ACP process-tree test no longer collides with the runner's own pid by @yordis in pingdotgg/t3code#17647
* fix(web): keep branch restore action inline in narrow composers by @Saikrishna1876 in pingdotgg/t3code#14811
* fix(web): composer banner actions stay inline whenever they fit by @maria-rcks in pingdotgg/t3code#17640


**Full Changelog**: pingdotgg/t3code@v0.0.46-nightly.20261009.2886...v0.0.46-nightly.20261010.2908

Upstream release: https://github.com/pingdotgg/t3code/releases/tag/v0.0.46-nightly.20261010.2908
github-actions Bot added a commit to davidvanderklay/t3code-flake that referenced this pull request Oct 10, 2026
## What's Changed
* chore(deps): upgrade Effect to 4.0.2 by @juliusmarminge in pingdotgg/t3code#17571
* fix(devices): recover stalled video without losing simulator input by @juliusmarminge in pingdotgg/t3code#17566
* fix(web): keep checkout stable while pr actions load by @maria-rcks in pingdotgg/t3code#16625
* fix(mobile): show waiting thread status by @maria-rcks in pingdotgg/t3code#16693
* feat(web): add parent thread breadcrumb navigation by @maria-rcks in pingdotgg/t3code#16666
* fix(server): restart inactivity after snoozed threads wake by @maria-rcks in pingdotgg/t3code#16674
* feat(desktop): passkeys in the in-app browser on macOS by @juliusmarminge in pingdotgg/t3code#16952
* fix(client): load earlier turns works for MCP threads over T3 Connect by @juliusmarminge in pingdotgg/t3code#17599
* refactor(client): sign relay request URLs built from the HttpApi contract by @juliusmarminge in pingdotgg/t3code#17602
* refactor(source-control): add @t3tools/source-control-core by @juliusmarminge in pingdotgg/t3code#17573
* refactor(source-control): Forgejo lives in @t3tools/source-control-forgejo by @juliusmarminge in pingdotgg/t3code#17581
* refactor(source-control): Azure DevOps lives in @t3tools/source-control-azure-devops by @juliusmarminge in pingdotgg/t3code#17592
* refactor(source-control): GitLab lives in @t3tools/source-control-gitlab by @juliusmarminge in pingdotgg/t3code#17594
* refactor(source-control): Bitbucket lives in @t3tools/source-control-bitbucket by @juliusmarminge in pingdotgg/t3code#17597
* refactor(source-control): GitHub lives in @t3tools/source-control-github by @juliusmarminge in pingdotgg/t3code#17607
* refactor(usage): transcript readers come from their drivers by @juliusmarminge in pingdotgg/t3code#17576
* refactor(usage): OpenCode usage comes from provider-opencode by @juliusmarminge in pingdotgg/t3code#17577
* refactor(usage): Cursor account usage comes from provider-cursor by @juliusmarminge in pingdotgg/t3code#17578
* refactor(usage): Antigravity usage is a reader on its driver by @juliusmarminge in pingdotgg/t3code#17579
* refactor(usage): usage readers use Effect FileSystem and SqlClient by @juliusmarminge in pingdotgg/t3code#17615
* fix(web): composer context strip pads both edges evenly by @limineol in pingdotgg/t3code#17562
* test(usage): v4 cache upgrade test waits for the migrated cache write by @Mnigos in pingdotgg/t3code#17553
* feat(mobile): support Duo in the shared iOS app by @juliusmarminge in pingdotgg/t3code#12648
* refactor(source-control): GitManager reads provider resolvers, not host kinds by @juliusmarminge in pingdotgg/t3code#17617
* refactor(source-control): PullRequestService reads GitHub resolvers, not its kind by @juliusmarminge in pingdotgg/t3code#17619
* refactor(source-control): Forgejo identity and Azure DevOps addressing move into their packages by @juliusmarminge in pingdotgg/t3code#17624
* refactor: home directory comes from a HostProcessHomeDirectory reference by @juliusmarminge in pingdotgg/t3code#17628
* refactor(shared): host process references live in a HostProcess module by @juliusmarminge in pingdotgg/t3code#17641
* feat(web): filter PR comments by bots and resolved threads by @juliusmarminge in pingdotgg/t3code#17645
* fix(clients): remove redundant prefix from PR watch status by @extoci in pingdotgg/t3code#17635
* fix(web): pending requests wait until you stop typing by @maria-rcks in pingdotgg/t3code#17637
* fix(models): remove new badges from Claude Opus and Sonnet 5.5 by @extoci in pingdotgg/t3code#17646
* fix(ui): keep focus and selection borders visible across the app by @maria-rcks in pingdotgg/t3code#16675
* fix(mobile): prevent row presses during native back swipes by @juliusmarminge in pingdotgg/t3code#17648
* fix(server): Codex shadow homes replace stray sqlite maintenance locks by @juliusmarminge in pingdotgg/t3code#17663
* feat(desktop): T3 Code can be your default web browser on macOS by @juliusmarminge in pingdotgg/t3code#17587
* test(server): the ACP process-tree test no longer collides with the runner's own pid by @yordis in pingdotgg/t3code#17647
* fix(web): keep branch restore action inline in narrow composers by @Saikrishna1876 in pingdotgg/t3code#14811
* fix(web): composer banner actions stay inline whenever they fit by @maria-rcks in pingdotgg/t3code#17640


**Full Changelog**: pingdotgg/t3code@v0.0.46-nightly.20261009.2886...v0.0.46-nightly.20261010.2908

Upstream release: https://github.com/pingdotgg/t3code/releases/tag/v0.0.46-nightly.20261010.2908
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

macroscope-review Opt PRs made by unvouched contributors in for Macroscope review. Vouched contributors auto-reviews size:XL 500-999 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant