From 4866f1804d4a3af6060f898ad045d151db893f9a Mon Sep 17 00:00:00 2001 From: stevejkang Date: Tue, 2 Jun 2026 09:55:14 +0900 Subject: [PATCH] Fix monthly window label showing raw minutes instead of "Monthly" Codex RPC returns windowDurationMins=43200 for monthly usage limits, but formatWindowLabel had no case for it. The fallback dumped the raw number with an "m" suffix, producing "43200m" in the sidebar. Add the Monthly (43200) mapping and reorder existing cases by ascending duration. Improve the fallback to convert unknown durations into human-readable day/hour units instead of raw minutes. --- src/__tests__/format.test.ts | 14 ++++++++++++++ src/format.ts | 10 ++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/__tests__/format.test.ts b/src/__tests__/format.test.ts index 0ca2a06..a0fc903 100644 --- a/src/__tests__/format.test.ts +++ b/src/__tests__/format.test.ts @@ -114,6 +114,20 @@ describe("formatWindowLabel", () => { it("returns Daily for 1440", () => { expect(formatWindowLabel(1440)).toBe("Daily") }) + + it("returns Monthly for 43200", () => { + expect(formatWindowLabel(43200)).toBe("Monthly") + }) + + it("returns Hourly for 60", () => { + expect(formatWindowLabel(60)).toBe("Hourly") + }) + + it("returns human-readable fallback for unknown durations", () => { + expect(formatWindowLabel(720)).toBe("12h") + expect(formatWindowLabel(2880)).toBe("2d") + expect(formatWindowLabel(30)).toBe("30m") + }) }) describe("getPercentColor", () => { diff --git a/src/format.ts b/src/format.ts index de8edb2..ea423a6 100644 --- a/src/format.ts +++ b/src/format.ts @@ -43,10 +43,16 @@ export function formatBar( export function formatWindowLabel(windowDurationMins: number | null | undefined): string { if (windowDurationMins == null) return "Unknown" + if (windowDurationMins === 60) return "Hourly" if (windowDurationMins === 300) return "Session" - if (windowDurationMins === 10080) return "Weekly" if (windowDurationMins === 1440) return "Daily" - if (windowDurationMins === 60) return "Hourly" + if (windowDurationMins === 10080) return "Weekly" + if (windowDurationMins === 43200) return "Monthly" + + const totalHours = Math.floor(windowDurationMins / 60) + const days = Math.floor(totalHours / 24) + if (days > 0) return `${days}d` + if (totalHours > 0) return `${totalHours}h` return `${windowDurationMins}m` }