Skip to content

fix(cursor): accept percent-only free usage payloads#269

Open
davidarny wants to merge 2 commits intomainfrom
fix/cursor-free-percent-usage
Open

fix(cursor): accept percent-only free usage payloads#269
davidarny wants to merge 2 commits intomainfrom
fix/cursor-free-percent-usage

Conversation

@davidarny
Copy link
Collaborator

@davidarny davidarny commented Mar 6, 2026

Summary

  • accept percent-only Cursor Free usage payloads when planUsage.limit is absent but totalPercentUsed is present
  • preserve the strict dollar-limit requirement for team accounts
  • add regression coverage and document the updated Cursor API shape

Testing

  • bun run test:coverage

Screenshots

Before

CleanShot 2026-03-06 at 09 22 21@2x

After

CleanShot 2026-03-06 at 09 24 58@2x

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 3 files

@davidarny
Copy link
Collaborator Author

@codex review

@augmentcode
Copy link

augmentcode bot commented Mar 6, 2026

🤖 Augment PR Summary

Summary: Updates the Cursor provider to tolerate Free/individual “percent-only” usage payloads where planUsage.limit is omitted but totalPercentUsed is present.

Changes:

  • Determines team vs individual usage earlier using planName and spendLimitUsage signals.
  • Keeps the strict dollar-based limit requirement for team accounts (still throws when missing).
  • For non-team accounts, accepts finite totalPercentUsed even when limit is absent (and logs the fallback).
  • Adds regression tests for both the new Free path and the unchanged Team failure path.
  • Documents the updated Cursor API shape in docs/providers/cursor.md.

Technical Notes: The fallback is scoped to non-team accounts; if neither a finite limit nor a finite totalPercentUsed is available, the plugin continues to fail fast.

🤖 Was this summary useful? React with 👍 or 👎

Copy link

@augmentcode augmentcode bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. 1 suggestions posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

@davidarny
Copy link
Collaborator Author

augment review

@chatgpt-codex-connector
Copy link

Codex Review: Didn't find any major issues. Chef's kiss.

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link

@augmentcode augmentcode bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. No suggestions at this time.

Comment augment review to trigger a new review at any time.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the Cursor provider plugin to tolerate a newly observed “percent-only” free/individual usage payload shape (missing planUsage.limit but including totalPercentUsed), while keeping team accounts strict about needing a dollar limit.

Changes:

  • Allow non-team Cursor accounts to render “Total usage” from planUsage.totalPercentUsed even when planUsage.limit is absent.
  • Add regression tests covering (a) percent-only free payloads and (b) team payloads still failing without limit.
  • Document the updated/observed Cursor API shape for Total usage.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
plugins/cursor/plugin.js Adds team-vs-individual gating so percent-only payloads are accepted for non-team accounts while team still requires limit.
plugins/cursor/plugin.test.js Adds regression tests for percent-only free payload acceptance and team payload rejection without limit.
docs/providers/cursor.md Updates provider docs to mention observed percent-only payloads and team limit requirements.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

|---|---|---|---|---|
| Credits | `GetCreditGrantsBalance` + `/api/auth/stripe.customerBalance` | overview | dollars | Combined total: active grant total + Stripe prepaid balance (negative `customerBalance`). Used stays based on grant usage. |
| Total usage | `planUsage.totalPercentUsed` | overview | percent (individual) / dollars (team) | Falls back to computed `(limit - remaining) / limit * 100` when `totalPercentUsed` is not finite. Team accounts use dollars format. |
| Total usage | `planUsage.totalPercentUsed` | overview | percent (individual) / dollars (team) | Falls back to computed `(limit - remaining) / limit * 100` when `totalPercentUsed` is not finite. Free/individual payloads observed on 2026-03-06 may omit `limit`; plugin uses `totalPercentUsed` directly in that case. Team accounts use dollars format and still require `limit`. |
Copy link

Copilot AI Mar 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docs note about the computed fallback percent is a bit too specific: in the plugin, when totalPercentUsed is not finite the fallback percent is computed from totalSpend / limit * 100 when totalSpend is present, and only uses (limit - remaining) / limit * 100 when totalSpend is absent. Please update the note so it matches the actual fallback logic.

Suggested change
| Total usage | `planUsage.totalPercentUsed` | overview | percent (individual) / dollars (team) | Falls back to computed `(limit - remaining) / limit * 100` when `totalPercentUsed` is not finite. Free/individual payloads observed on 2026-03-06 may omit `limit`; plugin uses `totalPercentUsed` directly in that case. Team accounts use dollars format and still require `limit`. |
| Total usage | `planUsage.totalPercentUsed` | overview | percent (individual) / dollars (team) | When `totalPercentUsed` is not finite, falls back to `totalSpend / limit * 100` when `totalSpend` is present, otherwise `(limit - remaining) / limit * 100`. Free/individual payloads observed on 2026-03-06 may omit `limit`; plugin uses `totalPercentUsed` directly in that case. Team accounts use dollars format and still require `limit`. |

Copilot uses AI. Check for mistakes.
Comment on lines +226 to +229
const ctx = makeCtx()
ctx.host.sqlite.query.mockReturnValue(JSON.stringify([{ value: "token" }]))
ctx.host.http.request.mockImplementation((opts) => {
if (String(opts.url).includes("GetCurrentPeriodUsage")) {
Copy link

Copilot AI Mar 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test uses a non-JWT access token ("token"), which makes needsRefresh() treat it as expiring and triggers an implicit /oauth/token refresh call that isn’t explicitly mocked here. To keep the test focused and avoid coupling it to refresh behavior, consider using makeJwt({ sub: ..., exp: ... }) (or explicitly mocking the refresh endpoint).

Copilot uses AI. Check for mistakes.
Comment on lines +286 to +289
const ctx = makeCtx()
ctx.host.sqlite.query.mockReturnValue(JSON.stringify([{ value: "token" }]))
ctx.host.http.request.mockImplementation((opts) => {
if (String(opts.url).includes("GetCurrentPeriodUsage")) {
Copy link

Copilot AI Mar 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above: using a non-JWT token here causes an implicit refresh attempt via /oauth/token that isn’t mocked, so the test relies on refresh failing gracefully. Using makeJwt(...) (or mocking the refresh response) would make the regression test less brittle.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants