From ccce4c38c5d659d834659b05178a7142fc69d857 Mon Sep 17 00:00:00 2001 From: vladikkuzn Date: Sun, 1 Nov 2026 03:38:14 +0200 Subject: [PATCH 1/7] fix(cursor): link enterprise accounts to Cursor usage instead of hiding them MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cursor Enterprise (token-based contract) accounts get a 200 from GetCurrentPeriodUsage with no planUsage, so the limits reader returned a bare `unsupported` and the account vanished from Usage → Limits with no notice. Cursor's own CLI shows only spend for these accounts. Map a response without plan percentages to `unsupported` with a message and a "Cursor usage" dashboard link, the same external-usage path ChatGPT uses, so web and mobile show the account with a Manage usage link. Signed-off-by: vladikkuzn --- .../provider-cursor/src/server/usageLimits.test.ts | 8 ++++++++ packages/provider-cursor/src/server/usageLimits.ts | 13 ++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/packages/provider-cursor/src/server/usageLimits.test.ts b/packages/provider-cursor/src/server/usageLimits.test.ts index e969106812e6e..21f5656d03936 100644 --- a/packages/provider-cursor/src/server/usageLimits.test.ts +++ b/packages/provider-cursor/src/server/usageLimits.test.ts @@ -94,6 +94,14 @@ describe("Cursor usage limits", () => { expect(cursorUsageResponseToLimits({ planUsage: {} }, checkedAt).unavailable?.reason).toBe( "unsupported", ); + // Real Enterprise (token-based contract) response: no planUsage at all. + expect( + cursorUsageResponseToLimits({ billingCycleEnd: "1793495876373" }, checkedAt), + ).toMatchObject({ + windows: [], + unavailable: { reason: "unsupported", message: expect.any(String) }, + externalUsage: { label: "Cursor usage", url: "https://cursor.com/dashboard?tab=usage" }, + }); expect( cursorUsageResponseToLimits({ planUsage: { totalPercentUsed: 0 } }, checkedAt).windows, ).toEqual([{ id: "totalPercentUsed", kind: "monthly", label: "Overall", usedPercent: 0 }]); diff --git a/packages/provider-cursor/src/server/usageLimits.ts b/packages/provider-cursor/src/server/usageLimits.ts index 48ab708554206..9af6c38e72b96 100644 --- a/packages/provider-cursor/src/server/usageLimits.ts +++ b/packages/provider-cursor/src/server/usageLimits.ts @@ -57,9 +57,16 @@ export function cursorUsageResponseToLimits( }); } } - return windows.length > 0 - ? makeUsageLimits({ checkedAt, windows }) - : makeUnavailableUsageLimits({ checkedAt, reason: "unsupported" }); + if (windows.length > 0) return makeUsageLimits({ checkedAt, windows }); + // Usage-based plans such as Enterprise report no plan allowance; Cursor's CLI shows only spend. + return { + ...makeUnavailableUsageLimits({ + checkedAt, + reason: "unsupported", + message: "Cursor reports no plan allowance for this account. View its spend on Cursor.", + }), + externalUsage: { label: "Cursor usage", url: "https://cursor.com/dashboard?tab=usage" }, + }; } export const readCursorUsageLimits = Effect.fn("readCursorUsageLimits")(function* ( From ff4702ea65a6096a9383f589e7cf74d4bc17c088 Mon Sep 17 00:00:00 2001 From: vladikkuzn Date: Sun, 1 Nov 2026 03:48:57 +0200 Subject: [PATCH 2/7] fix(cursor): clarify the link-only usage message and document it Say Cursor doesn't report limits rather than that the account has no allowance, and warn that the dashboard shows whichever account the browser is signed in to. Pin the exact message and link for both no-percentage responses, pin that link-only accounts keep /usage-limits and appear in its report, and note the dashboard link in the Cursor limits docs. Signed-off-by: vladikkuzn --- docs/user/usage.md | 3 ++- .../src/server/usageLimits.test.ts | 22 +++++++++++-------- .../provider-cursor/src/server/usageLimits.ts | 10 ++++----- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/docs/user/usage.md b/docs/user/usage.md index 5160becc21567..103124ce2d17b 100644 --- a/docs/user/usage.md +++ b/docs/user/usage.md @@ -166,7 +166,8 @@ refresh provider status. Cursor reports its monthly allowance, including separate Auto and API usage, for `CURSOR_AUTH_TOKEN` when it is set, otherwise for the account you signed in with in T3 or set as `CURSOR_API_KEY`. Sign-in and API keys report limits only with Cursor's default API endpoint. If you configure a custom -Cursor endpoint, use an explicit `CURSOR_AUTH_TOKEN` for limits. +Cursor endpoint, use an explicit `CURSOR_AUTH_TOKEN` for limits. Accounts without a monthly +allowance, such as Enterprise, show a link to Cursor's usage dashboard instead. Grok reports the remaining subscription allowance and reset time for its current billing period after signing in with `grok login`. Explicit `XAI_API_KEY` connections and custom authentication diff --git a/packages/provider-cursor/src/server/usageLimits.test.ts b/packages/provider-cursor/src/server/usageLimits.test.ts index 21f5656d03936..e77848bc8d150 100644 --- a/packages/provider-cursor/src/server/usageLimits.test.ts +++ b/packages/provider-cursor/src/server/usageLimits.test.ts @@ -91,17 +91,21 @@ describe("Cursor usage limits", () => { }); it("does not invent unused allowance for absent buckets", () => { - expect(cursorUsageResponseToLimits({ planUsage: {} }, checkedAt).unavailable?.reason).toBe( - "unsupported", - ); - // Real Enterprise (token-based contract) response: no planUsage at all. - expect( - cursorUsageResponseToLimits({ billingCycleEnd: "1793495876373" }, checkedAt), - ).toMatchObject({ + const linkOnly = { + checkedAt, windows: [], - unavailable: { reason: "unsupported", message: expect.any(String) }, + unavailable: { + reason: "unsupported", + message: + "Cursor doesn't report usage limits for this account. Open Cursor's dashboard with the same account to see its spend.", + }, externalUsage: { label: "Cursor usage", url: "https://cursor.com/dashboard?tab=usage" }, - }); + }; + expect(cursorUsageResponseToLimits({ planUsage: {} }, checkedAt)).toEqual(linkOnly); + // Real Enterprise (token-based contract) response: no planUsage at all. + expect(cursorUsageResponseToLimits({ billingCycleEnd: "1793495876373" }, checkedAt)).toEqual( + linkOnly, + ); expect( cursorUsageResponseToLimits({ planUsage: { totalPercentUsed: 0 } }, checkedAt).windows, ).toEqual([{ id: "totalPercentUsed", kind: "monthly", label: "Overall", usedPercent: 0 }]); diff --git a/packages/provider-cursor/src/server/usageLimits.ts b/packages/provider-cursor/src/server/usageLimits.ts index 9af6c38e72b96..60892b8dd71c1 100644 --- a/packages/provider-cursor/src/server/usageLimits.ts +++ b/packages/provider-cursor/src/server/usageLimits.ts @@ -15,6 +15,8 @@ import { } from "@t3tools/provider-core/server/usageLimits"; import { DEFAULT_CURSOR_API_ENDPOINT, exchangeCursorApiKey } from "./apiKey.ts"; +const NO_LIMITS_MESSAGE = + "Cursor doesn't report usage limits for this account. Open Cursor's dashboard with the same account to see its spend."; const CursorUsageResponse = Schema.Struct({ billingCycleStart: Schema.optional(Schema.Union([Schema.String, Schema.Number])), billingCycleEnd: Schema.optional(Schema.Union([Schema.String, Schema.Number])), @@ -58,13 +60,9 @@ export function cursorUsageResponseToLimits( } } if (windows.length > 0) return makeUsageLimits({ checkedAt, windows }); - // Usage-based plans such as Enterprise report no plan allowance; Cursor's CLI shows only spend. + // Usage-based plans such as Enterprise report no percentages; Cursor's CLI shows only spend. return { - ...makeUnavailableUsageLimits({ - checkedAt, - reason: "unsupported", - message: "Cursor reports no plan allowance for this account. View its spend on Cursor.", - }), + ...makeUnavailableUsageLimits({ checkedAt, reason: "unsupported", message: NO_LIMITS_MESSAGE }), externalUsage: { label: "Cursor usage", url: "https://cursor.com/dashboard?tab=usage" }, }; } From 6575d1c23418cc0f9ba2a31748a182f87c6e4fb3 Mon Sep 17 00:00:00 2001 From: vladikkuzn Date: Sun, 1 Nov 2026 03:58:49 +0200 Subject: [PATCH 3/7] fix(cursor): word the link-only usage message for every plan Signed-off-by: vladikkuzn --- packages/provider-cursor/src/server/usageLimits.test.ts | 2 +- packages/provider-cursor/src/server/usageLimits.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/provider-cursor/src/server/usageLimits.test.ts b/packages/provider-cursor/src/server/usageLimits.test.ts index e77848bc8d150..f2594ab446cb4 100644 --- a/packages/provider-cursor/src/server/usageLimits.test.ts +++ b/packages/provider-cursor/src/server/usageLimits.test.ts @@ -97,7 +97,7 @@ describe("Cursor usage limits", () => { unavailable: { reason: "unsupported", message: - "Cursor doesn't report usage limits for this account. Open Cursor's dashboard with the same account to see its spend.", + "Cursor doesn't report usage limits for this account. Open Cursor's dashboard with the same account to see its usage.", }, externalUsage: { label: "Cursor usage", url: "https://cursor.com/dashboard?tab=usage" }, }; diff --git a/packages/provider-cursor/src/server/usageLimits.ts b/packages/provider-cursor/src/server/usageLimits.ts index 60892b8dd71c1..c126ccf8326c2 100644 --- a/packages/provider-cursor/src/server/usageLimits.ts +++ b/packages/provider-cursor/src/server/usageLimits.ts @@ -16,7 +16,7 @@ import { import { DEFAULT_CURSOR_API_ENDPOINT, exchangeCursorApiKey } from "./apiKey.ts"; const NO_LIMITS_MESSAGE = - "Cursor doesn't report usage limits for this account. Open Cursor's dashboard with the same account to see its spend."; + "Cursor doesn't report usage limits for this account. Open Cursor's dashboard with the same account to see its usage."; const CursorUsageResponse = Schema.Struct({ billingCycleStart: Schema.optional(Schema.Union([Schema.String, Schema.Number])), billingCycleEnd: Schema.optional(Schema.Union([Schema.String, Schema.Number])), From 85f617ee0029173927168f978028fe003137b82b Mon Sep 17 00:00:00 2001 From: vladikkuzn Date: Sun, 1 Nov 2026 04:27:01 +0200 Subject: [PATCH 4/7] fix(cursor): show Enterprise spend against the personal spend limit Signed-off-by: vladikkuzn --- docs/user/usage.md | 3 +- .../src/server/usageLimits.test.ts | 87 ++++++++++++++++++- .../provider-cursor/src/server/usageLimits.ts | 55 +++++++++--- packages/shared/src/usageLimits.test.ts | 1 + packages/shared/src/usageLimits.ts | 7 ++ 5 files changed, 137 insertions(+), 16 deletions(-) diff --git a/docs/user/usage.md b/docs/user/usage.md index 103124ce2d17b..0fb69d3452019 100644 --- a/docs/user/usage.md +++ b/docs/user/usage.md @@ -167,7 +167,8 @@ its monthly allowance, including separate Auto and API usage, for `CURSOR_AUTH_T otherwise for the account you signed in with in T3 or set as `CURSOR_API_KEY`. Sign-in and API keys report limits only with Cursor's default API endpoint. If you configure a custom Cursor endpoint, use an explicit `CURSOR_AUTH_TOKEN` for limits. Accounts without a monthly -allowance, such as Enterprise, show a link to Cursor's usage dashboard instead. +allowance, such as Enterprise, show a **Spend** bar for this billing cycle against your personal +spend limit. If Cursor reports no personal limit, Usage links to Cursor's usage dashboard instead. Grok reports the remaining subscription allowance and reset time for its current billing period after signing in with `grok login`. Explicit `XAI_API_KEY` connections and custom authentication diff --git a/packages/provider-cursor/src/server/usageLimits.test.ts b/packages/provider-cursor/src/server/usageLimits.test.ts index f2594ab446cb4..2a188be59544a 100644 --- a/packages/provider-cursor/src/server/usageLimits.test.ts +++ b/packages/provider-cursor/src/server/usageLimits.test.ts @@ -40,6 +40,15 @@ describe("Cursor usage limits", () => { }, ]), ); + const withSpendLimit = cursorUsageResponseToLimits( + { + billingCycleEnd: "1789876386000", + planUsage: { totalPercentUsed: 72.4, autoPercentUsed: 69.5, apiPercentUsed: 100 }, + spendLimitUsage: { individualLimit: 5000, individualUsed: 100 }, + }, + checkedAt, + ); + expect(withSpendLimit.windows).toEqual(limits.windows); }); it("reports the billing-cycle length so pace can be computed", () => { @@ -54,7 +63,7 @@ describe("Cursor usage limits", () => { }); it("omits the cycle length when the start is missing or invalid", () => { - for (const billingCycleStart of [undefined, "", "0", "not-a-number", "1796637847072"]) { + for (const billingCycleStart of [undefined, "", "0", "not-a-number"]) { expect( cursorUsageResponseToLimits( { @@ -97,7 +106,7 @@ describe("Cursor usage limits", () => { unavailable: { reason: "unsupported", message: - "Cursor doesn't report usage limits for this account. Open Cursor's dashboard with the same account to see its usage.", + "Cursor doesn't report a personal spend limit for this account. Open Cursor's dashboard with the same account to see its usage.", }, externalUsage: { label: "Cursor usage", url: "https://cursor.com/dashboard?tab=usage" }, }; @@ -106,6 +115,18 @@ describe("Cursor usage limits", () => { expect(cursorUsageResponseToLimits({ billingCycleEnd: "1793495876373" }, checkedAt)).toEqual( linkOnly, ); + // Enterprise seat with only the team pool: zeroed percentages and no personal limit. + expect( + cursorUsageResponseToLimits( + { + billingCycleStart: "1793491200000", + billingCycleEnd: "1796083200000", + planUsage: { totalPercentUsed: 0, autoPercentUsed: 0, apiPercentUsed: 0 }, + spendLimitUsage: {}, + }, + checkedAt, + ), + ).toEqual(linkOnly); expect( cursorUsageResponseToLimits({ planUsage: { totalPercentUsed: 0 } }, checkedAt).windows, ).toEqual([{ id: "totalPercentUsed", kind: "monthly", label: "Overall", usedPercent: 0 }]); @@ -114,6 +135,68 @@ describe("Cursor usage limits", () => { ).toEqual([{ id: "totalPercentUsed", kind: "monthly", label: "Overall", usedPercent: 100 }]); }); + it.effect("shows Enterprise spend against the personal spend limit", () => + Effect.gen(function* () { + const limits = yield* readCursorUsageLimits( + { apiEndpoint: "" }, + { CURSOR_AUTH_TOKEN: "token" }, + ).pipe( + Effect.provideService( + HttpClient.HttpClient, + HttpClient.make((request) => { + expect( + request.body._tag === "Uint8Array" && new TextDecoder().decode(request.body.body), + ).toBe('{"includePooledUsage":true}'); + return Effect.succeed( + HttpClientResponse.fromWeb( + request, + Response.json({ + billingCycleStart: "1793491200000", + billingCycleEnd: "1796083200000", + displayThreshold: 50, + planUsage: { totalPercentUsed: 0, autoPercentUsed: 0, apiPercentUsed: 0 }, + spendLimitUsage: { + limitType: "team", + overallLimit: 50000, + overallUsed: 3211, + overallRemaining: 46789, + pooledLimit: "3000000", + pooledUsed: 0, + pooledRemaining: "3000000", + }, + displayMessage: "You've used 6% of your included usage", + }), + ), + ); + }), + ), + ); + expect(limits).toEqual({ + checkedAt: expect.any(String), + windows: [ + { + id: "spendLimit", + kind: "monthly", + label: "Spend", + usedPercent: 6.422, + resetsAt: "2026-12-01T00:00:00.000Z", + }, + ], + }); + // Without includePooledUsage, Cursor reports start = end = now instead of the cycle. + expect( + cursorUsageResponseToLimits( + { + billingCycleStart: "1793491200000", + billingCycleEnd: "1793491200000", + spendLimitUsage: { individualLimit: "2000", individualUsed: "500" }, + }, + checkedAt, + ).windows, + ).toEqual([{ id: "spendLimit", kind: "monthly", label: "Spend", usedPercent: 25 }]); + }), + ); + it.effect("requires explicit credentials and accepts an auth token", () => Effect.gen(function* () { for (const token of [undefined, "explicit-token"]) { diff --git a/packages/provider-cursor/src/server/usageLimits.ts b/packages/provider-cursor/src/server/usageLimits.ts index c126ccf8326c2..8d041562f35df 100644 --- a/packages/provider-cursor/src/server/usageLimits.ts +++ b/packages/provider-cursor/src/server/usageLimits.ts @@ -16,17 +16,27 @@ import { import { DEFAULT_CURSOR_API_ENDPOINT, exchangeCursorApiKey } from "./apiKey.ts"; const NO_LIMITS_MESSAGE = - "Cursor doesn't report usage limits for this account. Open Cursor's dashboard with the same account to see its usage."; + "Cursor doesn't report a personal spend limit for this account. Open Cursor's dashboard with the same account to see its usage."; +const CursorInt64 = Schema.Union([Schema.String, Schema.Number]); const CursorUsageResponse = Schema.Struct({ - billingCycleStart: Schema.optional(Schema.Union([Schema.String, Schema.Number])), - billingCycleEnd: Schema.optional(Schema.Union([Schema.String, Schema.Number])), + billingCycleStart: Schema.optional(CursorInt64), + billingCycleEnd: Schema.optional(CursorInt64), planUsage: Schema.optional( Schema.Struct({ + limit: Schema.optional(CursorInt64), totalPercentUsed: Schema.optional(Schema.Number), autoPercentUsed: Schema.optional(Schema.Number), apiPercentUsed: Schema.optional(Schema.Number), }), ), + spendLimitUsage: Schema.optional( + Schema.Struct({ + overallLimit: Schema.optional(CursorInt64), + overallUsed: Schema.optional(CursorInt64), + individualLimit: Schema.optional(CursorInt64), + individualUsed: Schema.optional(CursorInt64), + }), + ), }); /** Cursor's dashboard percentages include bonus usage; spend / limit does not. */ @@ -34,20 +44,29 @@ export function cursorUsageResponseToLimits( response: typeof CursorUsageResponse.Type, checkedAt: string, ) { - const reset = DateTime.make(Number(response.billingCycleEnd)); + const end = Number(response.billingCycleEnd); + const cycleStart = Number(response.billingCycleStart); + const reset = DateTime.make(end); + // Without includePooledUsage, Cursor reports start = end = now instead of the cycle. const resetsAt = - Number(response.billingCycleEnd) > 0 && Option.isSome(reset) + end > 0 && !(cycleStart >= end) && Option.isSome(reset) ? DateTime.formatIso(reset.value) : undefined; - const cycleStart = Number(response.billingCycleStart); + const { planUsage, spendLimitUsage: spend } = response; + // Usage-based plans such as Enterprise send zeroed percentages without an allowance. + const usageBased = + spend !== undefined && + planUsage?.limit === undefined && + !planUsage?.totalPercentUsed && + !planUsage?.autoPercentUsed && + !planUsage?.apiPercentUsed; const windowDurationMins = - resetsAt && cycleStart > 0 - ? Math.round((Number(response.billingCycleEnd) - cycleStart) / 60_000) - : 0; + resetsAt && cycleStart > 0 ? Math.round((end - cycleStart) / 60_000) : 0; const windows: ServerProviderUsageWindow[] = []; - if (response.planUsage) { + if (planUsage && !usageBased) { for (const { id, label } of CURSOR_USAGE_WINDOWS) { - const usedPercent = response.planUsage[id]; + if (id === "spendLimit") continue; + const usedPercent = planUsage[id]; if (usedPercent === undefined || !Number.isFinite(usedPercent)) continue; windows.push({ id, @@ -59,8 +78,18 @@ export function cursorUsageResponseToLimits( }); } } + const spendLimit = Number(spend?.overallLimit ?? spend?.individualLimit); + const spent = Number(spend?.overallUsed ?? spend?.individualUsed ?? 0); + if (windows.length === 0 && spendLimit > 0 && Number.isFinite(spent)) { + windows.push({ + id: "spendLimit", + kind: "monthly", + label: "Spend", + usedPercent: clampPercent((spent / spendLimit) * 100), + ...(resetsAt ? { resetsAt } : {}), + }); + } if (windows.length > 0) return makeUsageLimits({ checkedAt, windows }); - // Usage-based plans such as Enterprise report no percentages; Cursor's CLI shows only spend. return { ...makeUnavailableUsageLimits({ checkedAt, reason: "unsupported", message: NO_LIMITS_MESSAGE }), externalUsage: { label: "Cursor usage", url: "https://cursor.com/dashboard?tab=usage" }, @@ -99,7 +128,7 @@ export const readCursorUsageLimits = Effect.fn("readCursorUsageLimits")(function "connect-protocol-version": "1", "x-cursor-client-type": "cli", }), - HttpClientRequest.bodyJsonUnsafe({}), + HttpClientRequest.bodyJsonUnsafe({ includePooledUsage: true }), ), ); const body = yield* HttpClientResponse.schemaBodyJson(CursorUsageResponse)( diff --git a/packages/shared/src/usageLimits.test.ts b/packages/shared/src/usageLimits.test.ts index 0078c21b566b7..ee7f3143f24ea 100644 --- a/packages/shared/src/usageLimits.test.ts +++ b/packages/shared/src/usageLimits.test.ts @@ -129,6 +129,7 @@ describe("new thread model fallback", () => { ["cursor", ["autoPercentUsed"], "claude-opus-5-5", false, undefined, undefined], ["cursor", ["autoPercentUsed"], "composer-2.5", false, undefined, undefined], ["cursor", ["autoPercentUsed", "apiPercentUsed"], "composer-2.5", true, undefined, undefined], + ["cursor", ["spendLimit"], "composer-2.5", true, undefined, undefined], ["antigravity", ["gemini-weekly"], "claude-opus-5-5", false, undefined, undefined], ["antigravity", ["3p-weekly"], "claude-opus-5-5", true, undefined, undefined], ["antigravity", ["gemini-weekly"], "antigravity-default", true, undefined, undefined], diff --git a/packages/shared/src/usageLimits.ts b/packages/shared/src/usageLimits.ts index 693d82b956971..5254a11b539ee 100644 --- a/packages/shared/src/usageLimits.ts +++ b/packages/shared/src/usageLimits.ts @@ -43,6 +43,8 @@ export function exhaustedUsageWindow( if (model === undefined) return exhausted[0]; switch (provider?.driver) { case "cursor": { + const spend = exhausted.find((window) => window.id === "spendLimit"); + if (spend) return spend; const api = exhausted.find((window) => window.id === "apiPercentUsed"); const auto = exhausted.find((window) => window.id === "autoPercentUsed"); return /^(auto|default|grok|composer)/.test(model) ? auto && api : api; @@ -143,6 +145,11 @@ export const CURSOR_USAGE_WINDOWS = [ label: "Other Models", description: "Usage allowance for third-party models such as Claude, GPT, and Gemini.", }, + { + id: "spendLimit", + label: "Spend", + description: "Spending this billing cycle against your Cursor spend limit.", + }, ] as const; export function cursorUsageWindowDetails(id: string, pool: LimitPool) { From 45281cb2ada1d92899f6646295e04de540a24a3d Mon Sep 17 00:00:00 2001 From: vladikkuzn Date: Sun, 1 Nov 2026 04:43:52 +0200 Subject: [PATCH 5/7] fix(cursor): pair spend limits with their usage and gate Enterprise on the team pool Signed-off-by: vladikkuzn --- .../src/server/usageLimits.test.ts | 38 ++++++++++++++++++- .../provider-cursor/src/server/usageLimits.ts | 28 ++++++++++---- 2 files changed, 57 insertions(+), 9 deletions(-) diff --git a/packages/provider-cursor/src/server/usageLimits.test.ts b/packages/provider-cursor/src/server/usageLimits.test.ts index 2a188be59544a..b87e594749303 100644 --- a/packages/provider-cursor/src/server/usageLimits.test.ts +++ b/packages/provider-cursor/src/server/usageLimits.test.ts @@ -122,11 +122,36 @@ describe("Cursor usage limits", () => { billingCycleStart: "1793491200000", billingCycleEnd: "1796083200000", planUsage: { totalPercentUsed: 0, autoPercentUsed: 0, apiPercentUsed: 0 }, - spendLimitUsage: {}, + spendLimitUsage: { pooledLimit: "3000000" }, }, checkedAt, ), ).toEqual(linkOnly); + const zeroPercents = { totalPercentUsed: 0, autoPercentUsed: 0, apiPercentUsed: 0 }; + const zeroPlanWindows = [ + { id: "apiPercentUsed", kind: "monthly", label: "Other Models", usedPercent: 0 }, + { id: "autoPercentUsed", kind: "monthly", label: "Cursor Models", usedPercent: 0 }, + { id: "totalPercentUsed", kind: "monthly", label: "Overall", usedPercent: 0 }, + ]; + // Fresh-cycle Pro: an included allowance, or no pool marker, keeps the plan bars. + for (const response of [ + { + planUsage: { ...zeroPercents, limit: "2000" }, + spendLimitUsage: { individualLimit: 5000, individualUsed: 0 }, + }, + { planUsage: zeroPercents, spendLimitUsage: { individualLimit: 5000 } }, + ]) { + expect(cursorUsageResponseToLimits(response, checkedAt).windows).toEqual(zeroPlanWindows); + } + expect( + cursorUsageResponseToLimits( + { + planUsage: { ...zeroPercents, limit: "0" }, + spendLimitUsage: { pooledLimit: "3000000", overallLimit: 50000, overallUsed: 3211 }, + }, + checkedAt, + ).windows.map((window) => window.id), + ).toEqual(["spendLimit"]); expect( cursorUsageResponseToLimits({ planUsage: { totalPercentUsed: 0 } }, checkedAt).windows, ).toEqual([{ id: "totalPercentUsed", kind: "monthly", label: "Overall", usedPercent: 0 }]); @@ -194,6 +219,17 @@ describe("Cursor usage limits", () => { checkedAt, ).windows, ).toEqual([{ id: "spendLimit", kind: "monthly", label: "Spend", usedPercent: 25 }]); + // Limit and used come from the same pair; protobuf JSON omits a zero used. + for (const [spendLimitUsage, usedPercent] of [ + [{ overallLimit: 50000, individualUsed: 3211 }, 0], + [{ overallLimit: 0, individualLimit: "2000", individualUsed: "500" }, 25], + ] as const) { + expect( + cursorUsageResponseToLimits({ spendLimitUsage }, checkedAt).windows.map( + (window) => window.usedPercent, + ), + ).toEqual([usedPercent]); + } }), ); diff --git a/packages/provider-cursor/src/server/usageLimits.ts b/packages/provider-cursor/src/server/usageLimits.ts index 8d041562f35df..72c671ff98340 100644 --- a/packages/provider-cursor/src/server/usageLimits.ts +++ b/packages/provider-cursor/src/server/usageLimits.ts @@ -35,11 +35,22 @@ const CursorUsageResponse = Schema.Struct({ overallUsed: Schema.optional(CursorInt64), individualLimit: Schema.optional(CursorInt64), individualUsed: Schema.optional(CursorInt64), + pooledLimit: Schema.optional(CursorInt64), }), ), }); -/** Cursor's dashboard percentages include bonus usage; spend / limit does not. */ +function spendPair( + limit: typeof CursorInt64.Type | undefined, + used: typeof CursorInt64.Type | undefined, +) { + const cents = Number(limit); + return Number.isFinite(cents) && cents > 0 + ? { limit: cents, used: Number(used ?? 0) } + : undefined; +} + +/** Plan bars use Cursor's own percentages; the Spend bar is computed from cents. */ export function cursorUsageResponseToLimits( response: typeof CursorUsageResponse.Type, checkedAt: string, @@ -53,10 +64,10 @@ export function cursorUsageResponseToLimits( ? DateTime.formatIso(reset.value) : undefined; const { planUsage, spendLimitUsage: spend } = response; - // Usage-based plans such as Enterprise send zeroed percentages without an allowance. + // Enterprise sends a team pool and zeroed percentages without an included allowance. const usageBased = - spend !== undefined && - planUsage?.limit === undefined && + spend?.pooledLimit !== undefined && + !(Number(planUsage?.limit) > 0) && !planUsage?.totalPercentUsed && !planUsage?.autoPercentUsed && !planUsage?.apiPercentUsed; @@ -78,14 +89,15 @@ export function cursorUsageResponseToLimits( }); } } - const spendLimit = Number(spend?.overallLimit ?? spend?.individualLimit); - const spent = Number(spend?.overallUsed ?? spend?.individualUsed ?? 0); - if (windows.length === 0 && spendLimit > 0 && Number.isFinite(spent)) { + const personal = + spendPair(spend?.overallLimit, spend?.overallUsed) ?? + spendPair(spend?.individualLimit, spend?.individualUsed); + if (windows.length === 0 && personal && Number.isFinite(personal.used)) { windows.push({ id: "spendLimit", kind: "monthly", label: "Spend", - usedPercent: clampPercent((spent / spendLimit) * 100), + usedPercent: clampPercent((personal.used / personal.limit) * 100), ...(resetsAt ? { resetsAt } : {}), }); } From 69a978e6c0934e670c27cd145ac6bde9a0b0a09e Mon Sep 17 00:00:00 2001 From: vladikkuzn Date: Sun, 1 Nov 2026 04:59:29 +0200 Subject: [PATCH 6/7] test(cursor): pin plan-bar gating with pooled responses Signed-off-by: vladikkuzn --- .../src/server/usageLimits.test.ts | 200 +++++++++--------- 1 file changed, 104 insertions(+), 96 deletions(-) diff --git a/packages/provider-cursor/src/server/usageLimits.test.ts b/packages/provider-cursor/src/server/usageLimits.test.ts index b87e594749303..9fc32f4878105 100644 --- a/packages/provider-cursor/src/server/usageLimits.test.ts +++ b/packages/provider-cursor/src/server/usageLimits.test.ts @@ -7,7 +7,7 @@ import { cursorUsageResponseToLimits, readCursorUsageLimits } from "./usageLimit describe("Cursor usage limits", () => { const checkedAt = "2026-09-16T00:00:00.000Z"; - it("uses the advertised percentages and billing-cycle reset", () => { + it("uses the advertised percentages and reset, or Spend when no allowance is included", () => { const limits = cursorUsageResponseToLimits( { billingCycleEnd: "1789876386000", @@ -49,6 +49,59 @@ describe("Cursor usage limits", () => { checkedAt, ); expect(withSpendLimit.windows).toEqual(limits.windows); + const zeroPercents = { totalPercentUsed: 0, autoPercentUsed: 0, apiPercentUsed: 0 }; + const zeroPlanWindows = [ + { id: "apiPercentUsed", kind: "monthly", label: "Other Models", usedPercent: 0 }, + { id: "autoPercentUsed", kind: "monthly", label: "Cursor Models", usedPercent: 0 }, + { id: "totalPercentUsed", kind: "monthly", label: "Overall", usedPercent: 0 }, + ]; + const windowIds = (response: Parameters[0]) => + cursorUsageResponseToLimits(response, checkedAt).windows.map((window) => window.id); + // Usage already counted against a pooled plan keeps the plan bars. + expect( + windowIds({ + planUsage: { totalPercentUsed: 6, autoPercentUsed: 6, apiPercentUsed: 0 }, + spendLimitUsage: { pooledLimit: "3000000", overallLimit: 50000, overallUsed: 3211 }, + }), + ).toEqual(["apiPercentUsed", "autoPercentUsed", "totalPercentUsed"]); + // Fresh-cycle Pro: an included allowance, or no pool marker, keeps the plan bars. + for (const response of [ + { + planUsage: { ...zeroPercents, limit: "2000" }, + spendLimitUsage: { individualLimit: 5000, individualUsed: 0, pooledLimit: "3000000" }, + }, + { planUsage: zeroPercents, spendLimitUsage: { individualLimit: 5000 } }, + ]) { + expect(cursorUsageResponseToLimits(response, checkedAt).windows).toEqual(zeroPlanWindows); + } + expect( + windowIds({ + planUsage: { ...zeroPercents, limit: "0" }, + spendLimitUsage: { pooledLimit: "3000000", overallLimit: 50000, overallUsed: 3211 }, + }), + ).toEqual(["spendLimit"]); + // Without includePooledUsage, Cursor reports start = end = now instead of the cycle. + expect( + cursorUsageResponseToLimits( + { + billingCycleStart: "1793491200000", + billingCycleEnd: "1793491200000", + spendLimitUsage: { individualLimit: "2000", individualUsed: "500" }, + }, + checkedAt, + ).windows, + ).toEqual([{ id: "spendLimit", kind: "monthly", label: "Spend", usedPercent: 25 }]); + // Limit and used come from the same pair; protobuf JSON omits a zero used. + for (const [spendLimitUsage, usedPercent] of [ + [{ overallLimit: 50000, individualUsed: 3211 }, 0], + [{ overallLimit: 0, individualLimit: "2000", individualUsed: "500" }, 25], + ] as const) { + expect( + cursorUsageResponseToLimits({ spendLimitUsage }, checkedAt).windows.map( + (window) => window.usedPercent, + ), + ).toEqual([usedPercent]); + } }); it("reports the billing-cycle length so pace can be computed", () => { @@ -127,31 +180,6 @@ describe("Cursor usage limits", () => { checkedAt, ), ).toEqual(linkOnly); - const zeroPercents = { totalPercentUsed: 0, autoPercentUsed: 0, apiPercentUsed: 0 }; - const zeroPlanWindows = [ - { id: "apiPercentUsed", kind: "monthly", label: "Other Models", usedPercent: 0 }, - { id: "autoPercentUsed", kind: "monthly", label: "Cursor Models", usedPercent: 0 }, - { id: "totalPercentUsed", kind: "monthly", label: "Overall", usedPercent: 0 }, - ]; - // Fresh-cycle Pro: an included allowance, or no pool marker, keeps the plan bars. - for (const response of [ - { - planUsage: { ...zeroPercents, limit: "2000" }, - spendLimitUsage: { individualLimit: 5000, individualUsed: 0 }, - }, - { planUsage: zeroPercents, spendLimitUsage: { individualLimit: 5000 } }, - ]) { - expect(cursorUsageResponseToLimits(response, checkedAt).windows).toEqual(zeroPlanWindows); - } - expect( - cursorUsageResponseToLimits( - { - planUsage: { ...zeroPercents, limit: "0" }, - spendLimitUsage: { pooledLimit: "3000000", overallLimit: 50000, overallUsed: 3211 }, - }, - checkedAt, - ).windows.map((window) => window.id), - ).toEqual(["spendLimit"]); expect( cursorUsageResponseToLimits({ planUsage: { totalPercentUsed: 0 } }, checkedAt).windows, ).toEqual([{ id: "totalPercentUsed", kind: "monthly", label: "Overall", usedPercent: 0 }]); @@ -160,77 +188,57 @@ describe("Cursor usage limits", () => { ).toEqual([{ id: "totalPercentUsed", kind: "monthly", label: "Overall", usedPercent: 100 }]); }); - it.effect("shows Enterprise spend against the personal spend limit", () => - Effect.gen(function* () { - const limits = yield* readCursorUsageLimits( - { apiEndpoint: "" }, - { CURSOR_AUTH_TOKEN: "token" }, - ).pipe( - Effect.provideService( - HttpClient.HttpClient, - HttpClient.make((request) => { - expect( - request.body._tag === "Uint8Array" && new TextDecoder().decode(request.body.body), - ).toBe('{"includePooledUsage":true}'); - return Effect.succeed( - HttpClientResponse.fromWeb( - request, - Response.json({ - billingCycleStart: "1793491200000", - billingCycleEnd: "1796083200000", - displayThreshold: 50, - planUsage: { totalPercentUsed: 0, autoPercentUsed: 0, apiPercentUsed: 0 }, - spendLimitUsage: { - limitType: "team", - overallLimit: 50000, - overallUsed: 3211, - overallRemaining: 46789, - pooledLimit: "3000000", - pooledUsed: 0, - pooledRemaining: "3000000", - }, - displayMessage: "You've used 6% of your included usage", - }), - ), - ); - }), - ), - ); - expect(limits).toEqual({ - checkedAt: expect.any(String), - windows: [ - { - id: "spendLimit", - kind: "monthly", - label: "Spend", - usedPercent: 6.422, - resetsAt: "2026-12-01T00:00:00.000Z", - }, - ], - }); - // Without includePooledUsage, Cursor reports start = end = now instead of the cycle. - expect( - cursorUsageResponseToLimits( - { - billingCycleStart: "1793491200000", - billingCycleEnd: "1793491200000", - spendLimitUsage: { individualLimit: "2000", individualUsed: "500" }, - }, - checkedAt, - ).windows, - ).toEqual([{ id: "spendLimit", kind: "monthly", label: "Spend", usedPercent: 25 }]); - // Limit and used come from the same pair; protobuf JSON omits a zero used. - for (const [spendLimitUsage, usedPercent] of [ - [{ overallLimit: 50000, individualUsed: 3211 }, 0], - [{ overallLimit: 0, individualLimit: "2000", individualUsed: "500" }, 25], - ] as const) { - expect( - cursorUsageResponseToLimits({ spendLimitUsage }, checkedAt).windows.map( - (window) => window.usedPercent, + it.effect( + "requests pooled usage and shows Enterprise spend against the personal spend limit", + () => + Effect.gen(function* () { + const limits = yield* readCursorUsageLimits( + { apiEndpoint: "" }, + { CURSOR_AUTH_TOKEN: "token" }, + ).pipe( + Effect.provideService( + HttpClient.HttpClient, + HttpClient.make((request) => { + expect( + request.body._tag === "Uint8Array" && new TextDecoder().decode(request.body.body), + ).toBe('{"includePooledUsage":true}'); + return Effect.succeed( + HttpClientResponse.fromWeb( + request, + Response.json({ + billingCycleStart: "1793491200000", + billingCycleEnd: "1796083200000", + displayThreshold: 50, + planUsage: { totalPercentUsed: 0, autoPercentUsed: 0, apiPercentUsed: 0 }, + spendLimitUsage: { + limitType: "team", + overallLimit: 50000, + overallUsed: 3211, + overallRemaining: 46789, + pooledLimit: "3000000", + pooledUsed: 0, + pooledRemaining: "3000000", + }, + displayMessage: "You've used 6% of your included usage", + }), + ), + ); + }), ), - ).toEqual([usedPercent]); - } - }), + ); + expect(limits).toEqual({ + checkedAt: expect.any(String), + windows: [ + { + id: "spendLimit", + kind: "monthly", + label: "Spend", + usedPercent: 6.422, + resetsAt: "2026-12-01T00:00:00.000Z", + }, + ], + }); + }), ); it.effect("requires explicit credentials and accepts an auth token", () => From ad72749f849b71de54e2fa2734fe0b9296f6ad47 Mon Sep 17 00:00:00 2001 From: vladikkuzn Date: Fri, 20 Nov 2026 01:14:09 +0200 Subject: [PATCH 7/7] fix(cursor): translate spend limit copy Signed-off-by: vladikkuzn --- packages/shared/src/usageLimitsCopy.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/shared/src/usageLimitsCopy.ts b/packages/shared/src/usageLimitsCopy.ts index d772c48b29aac..ce0dfb5d739cd 100644 --- a/packages/shared/src/usageLimitsCopy.ts +++ b/packages/shared/src/usageLimitsCopy.ts @@ -36,6 +36,10 @@ const CURSOR_USAGE_WINDOW_COPY: Readonly< label: msg("Other Models"), description: msg("Usage allowance for third-party models such as Claude, GPT, and Gemini."), }, + spendLimit: { + label: msg("Spend"), + description: msg("Spending this billing cycle against your Cursor spend limit."), + }, }; /** @public */