Skip to content

Commit e16d051

Browse files
Sid-Qincursoragent
andauthored
fix: label Codex weekly usage window as "Week" instead of "Day" (openclaw#26267)
The secondary window label logic treated any window >= 24h as "Day", but Codex plans can have a weekly (604800s / 168h) quota window. The reset timer showed "resets 2d 4h" while the label said "Day", which was confusing. Now windows >= 168h are labeled "Week", >= 24h remain "Day", and shorter windows show the hour count. Closes openclaw#25812 Co-authored-by: Cursor <[email protected]>
1 parent f16ecd1 commit e16d051

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

src/infra/provider-usage.fetch.codex.test.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,29 @@ describe("fetchCodexUsage", () => {
5454
{ label: "Day", usedPercent: 75, resetAt: 1_700_050_000_000 },
5555
]);
5656
});
57+
58+
it("labels weekly secondary window as Week", async () => {
59+
const mockFetch = createProviderUsageFetch(async () =>
60+
makeResponse(200, {
61+
rate_limit: {
62+
primary_window: {
63+
limit_window_seconds: 10_800,
64+
used_percent: 7,
65+
reset_at: 1_700_000_000,
66+
},
67+
secondary_window: {
68+
limit_window_seconds: 604_800,
69+
used_percent: 10,
70+
reset_at: 1_700_500_000,
71+
},
72+
},
73+
}),
74+
);
75+
76+
const result = await fetchCodexUsage("token", undefined, 5000, mockFetch);
77+
expect(result.windows).toEqual([
78+
{ label: "3h", usedPercent: 7, resetAt: 1_700_000_000_000 },
79+
{ label: "Week", usedPercent: 10, resetAt: 1_700_500_000_000 },
80+
]);
81+
});
5782
});

src/infra/provider-usage.fetch.codex.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export async function fetchCodexUsage(
6565
if (data.rate_limit?.secondary_window) {
6666
const sw = data.rate_limit.secondary_window;
6767
const windowHours = Math.round((sw.limit_window_seconds || 86400) / 3600);
68-
const label = windowHours >= 24 ? "Day" : `${windowHours}h`;
68+
const label = windowHours >= 168 ? "Week" : windowHours >= 24 ? "Day" : `${windowHours}h`;
6969
windows.push({
7070
label,
7171
usedPercent: clampPercent(sw.used_percent || 0),

0 commit comments

Comments
 (0)