The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 21:00 UTC
fix(cursor): hide duplicate pooled usage limits (#34421)
Yash Singh committed
Nov 11, 2026 at 22:00 UTC
489fa8c052d984e7b840b891c9c83d6f2375d860
6 files changed
+87
-27
apps/mobile/src/features/usage/UsageLimitsPooled.tsx
+5
-3
@@ -171,7 +171,7 @@ function PoolWindowCard({
171
readonly color: string;
172
readonly now: number;
173
readonly environmentIds: readonly string[] | null;
174
- readonly label?: string;
174
+ readonly label?: string | null;
175
readonly description?: string;
176
readonly wide: boolean;
177
}) {
@@ -195,7 +195,9 @@ function PoolWindowCard({
195
<>
196
<View className={wide ? "gap-1" : "flex-row items-start justify-between gap-3"}>
197
<View className="gap-1">
198
- <Text className="text-sm font-t3-medium text-foreground">{label ?? pool.label}</Text>
198
+ {label !== null ? (
199
+ <Text className="text-sm font-t3-medium text-foreground">{label ?? pool.label}</Text>
200
+ ) : null}
201
<View className="flex-row items-baseline gap-1.5">
202
<Text className="text-3xl font-t3-bold tabular-nums text-foreground">
203
{pool.remainingPercent}%
@@ -444,7 +446,7 @@ export function UsageLimitsSection({
446
</View>
447
{windows.map((window) => {
448
const details =
447
- pool.driver === "cursor" ? cursorUsageWindowDetails(window.id) : undefined;
449
+ pool.driver === "cursor" ? cursorUsageWindowDetails(window.id, pool) : undefined;
450
return (
451
<PoolWindowCard
452
key={`${window.kind}:${window.id}`}
apps/web/src/components/usage/UsageLimitsPooled.tsx
+6
-3
@@ -540,14 +540,16 @@ function PoolWindowCard({
540
readonly pool: LimitPoolWindow;
541
readonly color: string;
542
readonly now: number;
543
- readonly label?: string | undefined;
543
+ readonly label?: string | null | undefined;
544
readonly description?: string | undefined;
545
}) {
546
const nextRefill = pool.resets.find((reset) => reset.restoresPercent > 0);
547
return (
548
<div className="grid items-center gap-x-6 gap-y-3 rounded-lg border border-border/60 p-4 md:grid-cols-[11rem_minmax(0,1fr)]">
549
<div className="flex flex-col gap-1">
550
- <span className="text-sm font-medium text-foreground">{label ?? pool.label}</span>
550
+ {label !== null ? (
551
+ <span className="text-sm font-medium text-foreground">{label ?? pool.label}</span>
552
+ ) : null}
553
<span className="flex items-baseline gap-2">
554
<span className="text-3xl font-semibold text-foreground tabular-nums">
555
{pool.remainingPercent}%
@@ -588,7 +590,8 @@ function PoolSection({ pool, now }: { readonly pool: LimitPool; readonly now: nu
590
{label}
591
</h2>
592
{windows.map((window) => {
591
- const details = pool.driver === "cursor" ? cursorUsageWindowDetails(window.id) : undefined;
593
+ const details =
594
+ pool.driver === "cursor" ? cursorUsageWindowDetails(window.id, pool) : undefined;
595
return (
596
<PoolWindowCard
597
key={`${window.kind}:${window.id}`}
packages/provider-cursor/src/server/usageLimits.test.ts
+2
-3
@@ -76,13 +76,12 @@ describe("Cursor usage limits", () => {
76
}
77
});
78
79
- it("shows a unified allowance once, not as a total plus a pool", () => {
80
- // A unified plan reports only the total and the auto bucket, at the same value.
79
+ it("retains unified totals for account aggregation", () => {
80
const windows = cursorUsageResponseToLimits(
81
{ planUsage: { totalPercentUsed: 1.77, autoPercentUsed: 1.77 } },
82
checkedAt,
83
).windows;
85
- expect(windows.map((window) => window.id)).toEqual(["autoPercentUsed"]);
84
+ expect(windows.map((window) => window.id)).toEqual(["autoPercentUsed", "totalPercentUsed"]);
85
expect(
86
cursorUsageResponseToLimits(
87
{ planUsage: { totalPercentUsed: 100, apiPercentUsed: 100 } },
packages/provider-cursor/src/server/usageLimits.ts
+2
-13
@@ -57,19 +57,8 @@ export function cursorUsageResponseToLimits(
57
});
58
}
59
}
60
- const total = windows.find((window) => window.id === "totalPercentUsed");
61
- const pools = windows.filter((window) => window !== total);
62
- // Unified plans report their one allowance as both the total and the auto pool. Keep the pool:
63
- // it pools with split-plan accounts, and exhaustedUsageWindow reads the pools.
64
- const visibleWindows =
65
- total &&
66
- pools.length === 1 &&
67
- pools[0]?.id === "autoPercentUsed" &&
68
- pools[0].usedPercent === total.usedPercent
69
- ? pools
70
- : windows;
71
- return visibleWindows.length > 0
72
- ? makeUsageLimits({ checkedAt, windows: visibleWindows })
60
+ return windows.length > 0
61
+ ? makeUsageLimits({ checkedAt, windows })
62
: makeUnavailableUsageLimits({ checkedAt, reason: "unsupported" });
63
}
64
packages/shared/src/usageLimits.test.ts
+43
@@ -10,6 +10,8 @@ import { describe, expect, it } from "vite-plus/test";
10
11
import {
12
type LimitAccount,
13
+ displayLimitWindows,
14
+ cursorUsageWindowDetails,
15
collectProviderUsageLimits,
16
sameUsageLimitCommandCoverage,
17
withUsageLimitsCommands,
@@ -954,6 +956,47 @@ describe("pooled account columns", () => {
956
row.columns.map((member) => (member.window ? member.account.key : null)),
957
);
958
959
+ it.each([
960
+ {
961
+ reports: [
962
+ [14, 14],
963
+ [14, 14],
964
+ ],
965
+ ids: ["autoPercentUsed"],
966
+ remaining: [86],
967
+ label: null,
968
+ },
969
+ {
970
+ reports: [
971
+ [14, 14],
972
+ [80, 70],
973
+ ],
974
+ ids: ["totalPercentUsed", "autoPercentUsed"],
975
+ remaining: [53, 58],
976
+ label: "Cursor Models",
977
+ },
978
+ {
979
+ reports: [[undefined, 14]],
980
+ ids: ["autoPercentUsed"],
981
+ remaining: [86],
982
+ label: "Cursor Models",
983
+ },
984
+ { reports: [[14, undefined]], ids: ["totalPercentUsed"], remaining: [86], label: null },
985
+ ])("preserves Cursor totals and scope for $reports", ({ reports, ids, remaining, label }) => {
986
+ const accounts = reports.map(([total, auto], index) => ({
987
+ ...account(String(index), [
988
+ ...(total === undefined ? [] : [{ ...weekly, id: "totalPercentUsed", usedPercent: total }]),
989
+ ...(auto === undefined ? [] : [{ ...weekly, id: "autoPercentUsed", usedPercent: auto }]),
990
+ ]),
991
+ driver: ProviderDriverKind.make("cursor"),
992
+ }));
993
+ const pool = collectLimitPools(accounts, now)[0]!;
994
+ const visible = displayLimitWindows(pool);
995
+ expect(visible.map((window) => window.id)).toEqual(ids);
996
+ expect(visible.map((window) => window.remainingPercent)).toEqual(remaining);
997
+ expect(cursorUsageWindowDetails(ids.at(-1)!, pool)?.label).toBe(label);
998
+ });
999
+
1000
// regression: #20349 sessions stay visible while the weekly quota is exhausted
1001
it.each([
1002
["claudeAgent", "13:00", 40, "14:00", 100],
packages/shared/src/usageLimits.ts
+29
-5
@@ -137,12 +137,16 @@ export const CURSOR_USAGE_WINDOWS = [
137
{
138
id: "apiPercentUsed",
139
label: "Other Models",
140
- description: "Claude, GPT, and Gemini use this pool. Grok and Composer fall back here.",
140
+ description: "Usage allowance for third-party models such as Claude, GPT, and Gemini.",
141
},
142
] as const;
143
144
-export function cursorUsageWindowDetails(id: string) {
145
- return CURSOR_USAGE_WINDOWS.find((window) => window.id === id);
144
+export function cursorUsageWindowDetails(id: string, pool: LimitPool) {
145
+ const details = CURSOR_USAGE_WINDOWS.find((window) => window.id === id);
146
+ return details &&
147
+ ((pool.windows.length === 1 && id === "totalPercentUsed") || hasDuplicateCursorTotal(pool))
148
+ ? { ...details, label: null, description: undefined }
149
+ : details;
150
}
151
152
function cursorUsageWindowRank(id: string): number {
@@ -451,6 +455,26 @@ export interface LimitPool {
455
readonly windows: readonly LimitPoolWindow[];
456
}
457
458
+function hasDuplicateCursorTotal(pool: LimitPool): boolean {
459
+ if (pool.windows.length !== 2) return false;
460
+ const total = pool.windows.find((window) => window.id === "totalPercentUsed");
461
+ const auto = pool.windows.find((window) => window.id === "autoPercentUsed");
462
+ return (
463
+ total !== undefined &&
464
+ auto !== undefined &&
465
+ total.members.length === auto.members.length &&
466
+ total.members.every(({ account, window }) =>
467
+ account.limits.windows.some(
468
+ (candidate) =>
469
+ candidate.id === auto.id &&
470
+ candidate.kind === auto.kind &&
471
+ candidate.usedPercent === window.usedPercent &&
472
+ candidate.resetsAt === window.resetsAt,
473
+ ),
474
+ )
475
+ );
476
+}
477
+
478
export function displayLimitWindows(pool: LimitPool) {
479
if (pool.driver === "antigravity") {
480
return [...pool.windows].sort(
@@ -465,9 +489,9 @@ export function displayLimitWindows(pool: LimitPool) {
489
if (pool.driver !== "cursor") return pool.windows;
490
const hasAuto = pool.windows.some((window) => window.id === "autoPercentUsed");
491
const hasApi = pool.windows.some((window) => window.id === "apiPercentUsed");
468
- const hasBothPools = hasAuto && hasApi;
492
+ const hideTotal = (hasAuto && hasApi) || hasDuplicateCursorTotal(pool);
493
return pool.windows
470
- .filter((window) => !hasBothPools || window.id !== "totalPercentUsed")
494
+ .filter((window) => !hideTotal || window.id !== "totalPercentUsed")
495
.sort((left, right) => cursorUsageWindowRank(left.id) - cursorUsageWindowRank(right.id));
496
}
497