Skip to content

Commit 98b19c5

Browse files
fix(cursor): keep the API pool so automatic fallback still triggers
Only fold the total into one meter when the single pool is the auto pool. Dropping apiPercentUsed removed the window exhaustedUsageWindow reads to switch Claude, GPT, and Gemini selections to a fallback provider. AI-assisted; verified with the tests and tools listed above.
1 parent d8a8a65 commit 98b19c5

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

‎packages/provider-cursor/src/server/usageLimits.test.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,12 @@ describe("Cursor usage limits", () => {
8383
checkedAt,
8484
).windows;
8585
expect(windows).toHaveLength(1);
86+
expect(
87+
cursorUsageResponseToLimits(
88+
{ planUsage: { totalPercentUsed: 100, apiPercentUsed: 100 } },
89+
checkedAt,
90+
).windows.map((window) => window.id),
91+
).toEqual(["apiPercentUsed", "totalPercentUsed"]);
8692
});
8793

8894
it("does not invent unused allowance for absent buckets", () => {

‎packages/provider-cursor/src/server/usageLimits.ts‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,15 @@ export function cursorUsageResponseToLimits(
5959
}
6060
const total = windows.find((window) => window.id === "totalPercentUsed");
6161
const pools = windows.filter((window) => window !== total);
62-
// Unified plans report their one allowance as both the total and a pool.
62+
// Unified plans report their one allowance as both the total and the auto pool. Never drop
63+
// the API pool: exhaustedUsageWindow reads it to fall back from Claude, GPT, and Gemini.
6364
const visibleWindows =
64-
total && pools.length === 1 && pools[0]?.usedPercent === total.usedPercent ? [total] : windows;
65+
total &&
66+
pools.length === 1 &&
67+
pools[0]?.id === "autoPercentUsed" &&
68+
pools[0].usedPercent === total.usedPercent
69+
? [total]
70+
: windows;
6571
return visibleWindows.length > 0
6672
? makeUsageLimits({ checkedAt, windows: visibleWindows })
6773
: makeUnavailableUsageLimits({ checkedAt, reason: "unsupported" });

0 commit comments

Comments
 (0)