Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(usage): Cursor limits show again after signing in through T3 #19578

Closedpenson-yo(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/19578/headopened View on GitHub

Problem

Signing in to Cursor through T3 hides Cursor from Usage → Limits even when a CLI login exists. The SDK sign-in key stops the reader before it tries that login.

Change

Pass the instance environment to the reader without injecting the SDK key. Require the CLI account returned by GetMe to match the SDK-verified instance email, so another account's limits cannot be attributed to the instance. Keep reader messages used by the existing /usage-limits composer UI.

Scope and approval

Fixes #19008. Related: #15906, maintainer root-cause reply. Limits only; account-history aggregation stays out of scope, and pooled unsupported notices are a possible follow-up requiring maintainer approval.

Verification

vp test run packages/provider-cursor/src/server/usageLimits.test.ts packages/provider-cursor/src/server/driver.test.ts
vp run --filter @t3tools/provider-cursor typecheck
vp lint packages/provider-cursor/src/server/driver.ts packages/provider-cursor/src/server/driver.test.ts packages/provider-cursor/src/server/usageLimits.ts packages/provider-cursor/src/server/usageLimits.test.ts

All 14 tests passed; the Cursor package typecheck passed with existing suggestions, and lint passed for the four remaining files. The regression failed against the original code; earlier GetMe and usage endpoint probes returned HTTP 200 using a desktop session, which does not verify CLI/Keychain access. Not checked end to end: the T3 sign-in → Keychain → Limits flow in a running app, and the native clients.

Model and harness: GPT-6.1 Sol, Codex via T3 Code. Reviewed and filed by Claude Opus 5.5 (Claude Code).

🤖 Generated with Claude Code

    1. chatgpt-codex-connector[bot](GitHub profile, opens in a new tab)commented

      Codex Review Summary

      This comment shows the latest Codex review activity on this pull request.

      ReviewStatusCommitReview trigger
      📝 Code Review✅ Completed 2026-10-14T20:28:25.319312Zc43eefcPR opened
      ℹ️ About Codex in GitHub

      Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

      • Open a pull request for review
      • Mark a draft as ready
      • Comment "@codex review" or "@codex security review".

      Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

    3. Approvability

      Verdict: Not approved

      Macroscope's review found this PR not approvable — This production change alters Cursor credential selection, account matching, and usage-limit publication by adding an identity-verification request before showing limits. Because it affects authentication-adjacent account attribution and metering behavior, the change warrants human review despite its focused scope and test coverage.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    4. 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: Advanced
      • Run ID: 5dc9d6a8-eaeb-4f6c-98e7-5fb66fc63f75
      📥 Commits

      Reviewing files that changed from the base of the PR and between bf8ffe81a63c82d3de5fbaa9991fd5f30034a452 and c43eefc0db4f2fba12d6dcfb1cc62e55dea5e832.

      📒 Files selected for processing: 4
      • packages/provider-cursor/src/server/driver.test.ts
      • packages/provider-cursor/src/server/driver.ts
      • packages/provider-cursor/src/server/usageLimits.test.ts
      • packages/provider-cursor/src/server/usageLimits.ts

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

      📝 Walkthrough

      Cursor usage-limit reads now reject API-key-only access and verify that the CLI login matches the authenticated provider account before fetching usage. The driver passes the authenticated email to the usage-limit reader.

      Changes: Cursor usage-limit verification

      Layer / File(s)Summary
      Verify CLI identity before reading limits
      packages/provider-cursor/src/server/usageLimits.ts, packages/provider-cursor/src/server/usageLimits.test.ts
      The usage-limit reader rejects API-key-only access and checks the CLI account email against the provider email before requesting usage. Tests cover failed requests, missing or mismatched identities, and API-key and Keychain cases.
      Pass provider identity into usage reads
      packages/provider-cursor/src/server/driver.ts, packages/provider-cursor/src/server/driver.test.ts
      The driver passes the process environment and authenticated snapshot email to the usage-limit reader. A driver test checks the returned usage limits and the GetMe and GetCurrentPeriodUsage requests.

      Priority: ➖ Normal

      Estimated code review effort: 3 (Moderate) | ~20 minutes

      Change: Bug fix · Severity of issue fixed: Medium

      Suggested reviewers: juliusmarminge

      Merge Risk: ⚪ Minimal · up to c43ee

      The change is mergeable after normal checks. A live CLI sign-in check would confirm that Cursor returns the email field expected by the limits reader.

      Security architecture risk: 🟡 Moderate · up to c43ee

      The account-matching check improves attribution, but restored CLI login discovery can send a locally stored Cursor token to a custom endpoint before checking its account. The Keychain path restricts this destination; file-based logins do not. Exposure requires a custom endpoint to be configured or compromised and a readable CLI login.

      Retained concerns

      • Medium · security · observed: Restored automatic file-login discovery can disclose a host CLI bearer token to a custom endpoint before account verification. For a browser-authenticated instance without an explicit auth token or API key in its environment, the base's injected SDK key prevented file fallback; the head now permits it. Unlike the Keychain branch, auth.json credentials have no default-endpoint restriction. A malicious or compromised configured endpoint receives the token in GetMe even if it subsequently returns a mismatched account. The prerequisite is custom endpoint configuration or compromise, not established anonymous remote access.
      Security review details

      Security Blast Radius

      • inferred — The credential-destination concern exposes the selected host user's CLI bearer token, which may belong to a different account from the SDK instance because matching happens after transmission. Environment overrides can isolate credential files, but otherwise discovery uses host configuration directories. Broader account privileges or cross-tenant access were not established.

      Security Findings and Attack Paths

      • inferred — With a readable file-store login and a non-Cursor endpoint selected through configuration or environment, an SDK-authenticated refresh now automatically sends that login's token to the endpoint. An endpoint operator or an attacker compromising it can receive the credential without returning a matching email or valid usage response. The newly introduced exposure is automatic file fallback, not the pre-existing explicit-token route.

      Trust Boundaries and Controls

      • observed — Keychain discovery still requires explicit enablement and the exact default Cursor endpoint before reading the token. File discovery has no equivalent destination restriction. Independently, unknown or mismatched account identities block fresh usage data, and errors return a fixed message rather than credential or response content.

      Resilience and Maintainability Implications

      • observed — The reader has a ten-second timeout. The existing Keychain service shares one in-flight read and caches successful tokens for five minutes; a detached read can complete after its usage caller times out. Every subsequent limits read still performs account matching, so a cached different-account token is rejected rather than publishing fresh limits for that account.

      Hardening Proposals

      • proposed — Apply the trusted default-endpoint restriction to all automatically discovered CLI credentials before reading or transmitting them. If custom backends must remain supported, require an explicitly supplied backend-specific credential instead of silently falling back to the host login.
      Pre-merge checks: Passed 3 · Failed 1
      Failed Failed checks: 1 warning
      Check nameStatusExplanationResolution
      Linked Issues checkWarningIssue [#19008] requires Cursor Limits to appear when T3 stores an API key and a matching CLI login exists. The driver now passes the process environment and the instance email. readCursorUsageLimits…Update the /usage-limits composition path to display the actionable message from this Cursor unsupported result, or use a displayed notice reason for this case while preserving intentional suppression of other unsupported accounts. Add a …
      Passed Passed checks: 3 passed
      Check nameStatusExplanation
      Title checkPassedThe title is concise, uses the conventional format, and clearly describes restoring Cursor usage limits after T3 sign-in.
      Description checkPassedThe description includes all required sections, explains the problem and fix, links related issues and maintainer context, defines scope, and reports focused verification results and limitations.
      Out of Scope Changes checkPassedThe changes stay within Cursor Limits handling. They update the usage reader, the provider driver call, and focused usage-limit tests. They do not change Cursor spend-history aggregation, unrelated pr…
      Full details: Linked Issues check

      Explanation

      Issue [#19008] requires Cursor Limits to appear when T3 stores an API key and a matching CLI login exists. The driver now passes the process environment and the instance email. readCursorUsageLimits verifies GetMe before it reads GetCurrentPeriodUsage. The existing conversion tests cover Cursor Models, Other Models, Overall, and the billing-cycle reset. The new tests cover matching identity, failed requests, and explicit API-key handling. However, the issue also requires an explanatory Limits notice when the API key cannot read the endpoint. The new messages use reason: "unsupported". The linked issue evidence states that the composer skips unsupported snapshots in both account and notice collection. No composer change is included. The UI can therefore still show no row and no notice.

      Resolution

      Update the /usage-limits composition path to display the actionable message from this Cursor unsupported result, or use a displayed notice reason for this case while preserving intentional suppression of other unsupported accounts. Add a test that verifies the API-key or missing-CLI-login case produces a visible Limits notice.

      • Fix all pre-merge checks with AI
      ✨ Finishing Touches
      🧪 Generate unit tests (beta)
      • 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.
    5. Gentle bump: this one's ready for a look whenever someone has a moment. It fixes Cursor limits not showing in Usage after signing in through T3 (#19008, #15906). Checks are green and it merges cleanly. Happy to change anything.

    6. Thanks for working on this. One case still ends up silent. The new unsupported results ("requires a CLI login", "could not be matched", "API keys cannot read subscription limits") never reach the UI. collectLimitAccounts skips any account with a notice (https://github.com/pingdotgg/t3code/blob/c43eefc0db4f2fba12d6dcfb1cc62e55dea5e832/packages/shared/src/usageLimits.ts#L276 and #L301), and collectLimitNotices skips every unsupported reason (https://github.com/pingdotgg/t3code/blob/c43eefc0db4f2fba12d6dcfb1cc62e55dea5e832/packages/shared/src/usageLimits.ts#L345). So Cursor vanishes from Usage > Limits with no message, the gap CodeRabbit's linked-issue check also flags for #19008.

      Two minimal options: surface these unsupported messages as notices, at least for Cursor, or narrow the PR description so it does not promise a visible notice.

    7. Thanks @penson-yo for tracing the stored-key guard and adding account-matching checks. Closing this unclaimed duplicate in favor of @fcgith’s #21228, which I have taken over and rebuilt. That approach exchanges the selected T3 browser login’s own key, so it also covers browser-only accounts without borrowing a host CLI login. Your account-attribution work helped clarify that requirement. The survivor has focused tests and controlled browser proof; real Cursor account verification and human approval are still explicitly outstanding.

    8. juliusmarminge closed this

Sign in to join this conversation.