derive codex window labels from api

This commit is contained in:
2026-03-13 13:40:08 +00:00
parent 3d314d944b
commit 58dd9d8c2b
+9 -2
View File
@@ -165,11 +165,18 @@ function modelToProvider(modelProvider?: string): ProviderName | undefined {
return undefined; return undefined;
} }
function pushCodexWindow(windows: RateWindow[], label: string, window?: CodexRateWindow): void { function codexWindowLabel(window: CodexRateWindow | undefined, fallback: string): string {
if (!window || typeof window.limit_window_seconds !== "number" || window.limit_window_seconds <= 0) {
return fallback;
}
return formatDuration(window.limit_window_seconds) ?? fallback;
}
function pushCodexWindow(windows: RateWindow[], fallbackLabel: string, window?: CodexRateWindow): void {
if (!window) return; if (!window) return;
const resetIso = typeof window.reset_at === "number" ? new Date(window.reset_at * 1000).toISOString() : undefined; const resetIso = typeof window.reset_at === "number" ? new Date(window.reset_at * 1000).toISOString() : undefined;
windows.push({ windows.push({
label, label: codexWindowLabel(window, fallbackLabel),
usedPercent: clampPercent(window.used_percent), usedPercent: clampPercent(window.used_percent),
resetAt: resetIso, resetAt: resetIso,
}); });