derive codex window labels from api
This commit is contained in:
@@ -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,
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user