@devries-cameron20 / t3code Mirror · read-only / commits / 350753afac
Fork 0

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, 17:15 UTC

fix(usage): Claude accounts with a $0 monthly cap no longer leave a blank cell (#35341)

Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>

Nei Cardoso de Oliveira Neto committed Nov 13, 2026 at 14:35 UTC 350753aface93da09325ddcafbda0ecffb9ad3f0
6 files changed +39 -3
apps/server/src/provider/claudeUsageLimits.test.ts
+16
@@ -199,6 +199,22 @@ describe("claudeUsageResponseToLimits", () => {
199 ).toEqual([monthlyWindow]);
200 });
201
202 + it("flags a $0 cap instead of reporting a monthly window", () => {
203 + const response = {
204 + rate_limits_available: true,
205 + rate_limits: {
206 + five_hour: null,
207 + seven_day: null,
208 + extra_usage: { is_enabled: true, used_credits: 0, monthly_limit: 0, utilization: null },
209 + },
210 + };
211 + expect(claudeUsageResponseToLimits({ checkedAt, response }).limits).toEqual({
212 + checkedAt,
213 + windows: [],
214 + zeroSpendCap: true,
215 + });
216 + });
217 +
218 it("omits disabled budgets and refuses invalid money without an enabled fallback", () => {
219 const rateLimits = enterpriseResponse.rate_limits;
220 const response = {
apps/server/src/provider/claudeUsageLimits.ts
+5 -1
@@ -202,6 +202,7 @@ export function claudeUsageResponseToLimits(input: {
202 overageIncluded ??= entry.display_name;
203 }
204 const spendPercent = readSpendPercent(response.rate_limits);
205 + const extra = response.rate_limits.extra_usage;
206 if (spendPercent !== undefined) {
207 windows.push({
208 id: "monthly_spend",
@@ -211,7 +212,10 @@ export function claudeUsageResponseToLimits(input: {
212 });
213 }
214 return {
214 - limits: makeUsageLimits({ checkedAt, windows }),
215 + limits: {
216 + ...makeUsageLimits({ checkedAt, windows }),
217 + ...(extra?.is_enabled && extra.monthly_limit === 0 ? { zeroSpendCap: true } : {}),
218 + },
219 names: { overageIncluded },
220 };
221 }
apps/web/src/components/usage/UsageLimitsPooled.tsx
+12
@@ -523,6 +523,18 @@ function PoolBar({
523 index={position + 1}
524 showAccountName={pool.columns.length > 1}
525 />
526 + ) : pool.kind === "monthly" && member.account.limits.zeroSpendCap ? (
527 + <div
528 + key={member.account.key}
529 + style={{ gridColumn: position + 1, gridRow: 1 }}
530 + className="flex h-5 min-w-0 items-center justify-center gap-1.5 overflow-hidden rounded-md border border-dashed border-border text-3xs whitespace-nowrap text-muted-foreground @2xl/pool:h-8 @2xl/pool:justify-start @2xl/pool:px-2 @2xl/pool:text-xs"
531 + >
532 + <AccountName
533 + account={member.account}
534 + className="hidden min-w-0 truncate @2xl/pool:inline-flex"
535 + />
536 + $0 cap
537 + </div>
538 ) : null,
539 )}
540 </div>
packages/contracts/src/providerUsageLimits.ts
+2
@@ -47,6 +47,8 @@ export type ServerProviderResetCredits = typeof ServerProviderResetCredits.Type;
47 export const ServerProviderUsageLimits = Schema.Struct({
48 checkedAt: IsoDateTime,
49 windows: ForwardCompatibleArray(ServerProviderUsageWindow),
50 + /** A $0 monthly spend cap has no percentage, so it cannot be a window. */
51 + zeroSpendCap: Schema.optional(Schema.Boolean),
52 credentialFingerprint: Schema.optional(TrimmedNonEmptyString),
53 resetCredits: Schema.optional(ServerProviderResetCredits),
54 externalUsage: Schema.optional(
packages/provider-core/src/server/usageLimits.test.ts
+3 -2
@@ -89,10 +89,10 @@ describe("applyUsageLimitsUpdate", () => {
89 ).toEqual({ checkedAt, windows: [weekly], unavailable: { reason: "probeFailed" } });
90 });
91
92 - it("preserves reset credits when a streamed window update changes usage", () => {
92 + it("preserves reset credits and a $0 cap when a streamed window update changes usage", () => {
93 const resetCredits = { availableCount: 2, nextExpiresAt: "2026-10-01T00:00:00.000Z" };
94 const next = applyUsageLimitsUpdate({
95 - previous: { ...published, resetCredits },
95 + previous: { ...published, resetCredits, zeroSpendCap: true },
96 checkedAt: "2026-09-03T12:00:05.000Z",
97 update: { windows: [{ ...session, usedPercent: 55 }] },
98 });
@@ -101,6 +101,7 @@ describe("applyUsageLimitsUpdate", () => {
101 checkedAt: "2026-09-03T12:00:05.000Z",
102 windows: [{ ...session, usedPercent: 55 }, weekly],
103 resetCredits,
104 + zeroSpendCap: true,
105 });
106 });
107 });
packages/provider-core/src/server/usageLimits.ts
+1
@@ -84,6 +84,7 @@ export function applyUsageLimitsUpdate(input: {
84 return {
85 ...makeUsageLimits({ checkedAt: input.checkedAt, windows: merged.values() }),
86 ...(previous?.resetCredits !== undefined ? { resetCredits: previous.resetCredits } : {}),
87 + ...(previous?.zeroSpendCap ? { zeroSpendCap: true } : {}),
88 ...(unavailable !== undefined ? { unavailable } : {}),
89 };
90 }