refactor(auth-profiles): reuse cooldown timestamp resolver

This commit is contained in:
Peter Steinberger
2026-02-18 17:13:47 +00:00
parent 818419b4c4
commit 28d49b8d44
3 changed files with 25 additions and 16 deletions

View File

@@ -3,7 +3,9 @@ import { normalizeProviderId } from "../model-selection.js";
import { saveAuthProfileStore, updateAuthProfileStoreWithLock } from "./store.js";
import type { AuthProfileFailureReason, AuthProfileStore, ProfileUsageStats } from "./types.js";
function resolveProfileUnusableUntil(stats: ProfileUsageStats): number | null {
export function resolveProfileUnusableUntil(
stats: Pick<ProfileUsageStats, "cooldownUntil" | "disabledUntil">,
): number | null {
const values = [stats.cooldownUntil, stats.disabledUntil]
.filter((value): value is number => typeof value === "number")
.filter((value) => Number.isFinite(value) && value > 0);