Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): update all Claude unified usage windows #14441

Closednightyard(GitHub profile, opens in a new tab)wants to merge 3 commits intomain fromrefs/pull/14441/headopened View on GitHub

Showing 2 changed files with 82 additions and 11 deletions.

x
0 of 2 viewed, 2 left
59 additions and 0 deletionsapps/server/src/provider/claudeUsageLimits.test.tsModified
View file
@@ -120,6 +120,65 @@
});
​
describe("claudeRateLimitEventToUpdate", () => {
+ it("updates supported unified windows, omitting unnamed and malformed buckets", () => {
+ const info = {
+ status: "allowed" as const,
+ unifiedWindows: {
+ five_hour: { utilization: 0.25, resetsAt: 1_900_000_000 },
+ seven_day: { utilization: 0.5, resetsAt: 1_900_000_001 },
+ seven_day_overage_included: { utilization: 0.2, resetsAt: 1_900_000_002 },
+ unknown: { utilization: 1 },
+ constructor: { utilization: 1 },
+ toString: { utilization: 1 },
+ },
+ };
+ expect(
+ claudeRateLimitEventToUpdate(info, { overageIncluded: "Fable" })?.windows.map(
+ ({ id, usedPercent, resetsAt }) => ({ id, usedPercent, resetsAt }),
+ ),
+ ).toEqual([
+ { id: "five_hour", usedPercent: 25, resetsAt: "2030-03-17T17:46:40.000Z" },
+ { id: "seven_day", usedPercent: 50, resetsAt: "2030-03-17T17:46:41.000Z" },
+ { id: "seven_day_fable", usedPercent: 20, resetsAt: "2030-03-17T17:46:42.000Z" },
+ ]);
+ expect(claudeRateLimitEventToUpdate(info, noNames)?.windows.map(({ id }) => id)).toEqual([
+ "five_hour",
+ "seven_day",
+ ]);
+ const malformed = {