fix(FN-1014): add fallback reset time for Claude session window when API omits resets_at

- When the Claude usage API omits resets_at for the 5-hour session window, fall back to using the full window duration as resetMs
- This enables pace calculation and reset text display even without an explicit reset timestamp
- Update existing test to verify fallback behavior (resetMs = 5h, resetText = 'resets in 5h')
- Add new test for pace calculation with fallback reset time
This commit is contained in:
gsxdsm
2026-04-05 19:45:17 -07:00
parent 9e499df124
commit fb6db73a89
2 changed files with 43 additions and 3 deletions

View File

@@ -842,6 +842,13 @@ async function fetchClaudeUsage(): Promise<ProviderUsage> {
const msLeft = new Date(resetAtValue).getTime() - Date.now();
resetMs = msLeft > 0 ? msLeft : 0;
resetText = msLeft > 0 ? `resets in ${formatDuration(msLeft)}` : "resetting now";
} else if (windowDurationMs === FIVE_HOURS_MS) {
// Fallback for session window: when the API doesn't provide reset time,
// use the full window duration as a best-effort estimate. This enables
// pace calculation and reset text for the session (5h) window even when
// the API omits resets_at / reset_at / resetAt fields.
resetMs = windowDurationMs;
resetText = "resets in 5h";
}
return {