mirror of
https://github.com/nomadkaraoke/karaoke-gen.git
synced 2026-12-02 09:58:08 +09:00
## Summary - Fix misleading "No audio sources found" message that appeared when audio search failed (timeout, network error, 5xx) instead of showing an error - Replace scattered boolean/string state with explicit `SearchStatus` state machine so the no-results message can only appear after a confirmed successful search - Add automatic retry (up to 3 attempts with backoff) for transient failures ## Changes - **State machine:** Replace `isSearching`, `error`, `isCreditError` with single `SearchStatus` discriminated union (`searching | succeeded | failed`) - **Retry logic:** Auto-retry network errors, timeouts, and 5xx up to 3 times with 2s/4s backoff delays. 4xx errors (auth, credits) fail immediately - **Spinner feedback:** Show "Retry 1 of 2" / "Retry 2 of 2" during retries - **Fuzzy accept:** Route through `doSearch` via useEffect instead of inline API call, so corrected searches also get retry protection - **Tests:** 5 new tests covering the core bug fix, retry behavior, and error classification - **Docs:** Added lesson learned about state conflation pattern ## Testing - [x] 20/20 unit tests pass (15 existing + 5 new) - [x] 712/712 full suite tests pass - [x] TypeScript compiles cleanly - [x] Production flacfetch verified healthy (v0.19.5, all providers up) ## Review - [x] Local CodeRabbit review completed (no findings) - [x] Two-stage review (spec compliance + code quality) during implementation @coderabbitai ignore --- 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>