feat(FN-1176): synthesize fallback resetAt for Claude usage windows

- Update Claude usage window normalization to set resetAt when API omits reset timestamps
- Derive fallback resetAt as now plus the computed window duration while preserving existing resetMs/resetText behavior
- Expand usage tests to assert fallback resetAt is present and approximately 5 hours in the future in both affected scenarios
This commit is contained in:
gsxdsm
2026-04-08 01:06:20 -07:00
parent 0c55b9edfc
commit 9118fdb16f
2 changed files with 10 additions and 4 deletions

View File

@@ -837,7 +837,7 @@ async function fetchClaudeUsage(): Promise<ProviderUsage> {
let resetText: string | null = null;
let resetMs: number | undefined;
const resetAtValue = w.resets_at || w.reset_at || w.resetAt;
let resetAtValue = w.resets_at || w.reset_at || w.resetAt;
if (resetAtValue) {
const msLeft = new Date(resetAtValue).getTime() - Date.now();
resetMs = msLeft > 0 ? msLeft : 0;
@@ -849,6 +849,7 @@ async function fetchClaudeUsage(): Promise<ProviderUsage> {
// the API omits resets_at / reset_at / resetAt fields.
resetMs = windowDurationMs;
resetText = "resets in 5h";
resetAtValue = new Date(Date.now() + windowDurationMs).toISOString();
}
return {