Files
Andrew Beveridge ☄️andClaude Opus 4.8 b6dcf6602d feat: match-judge improvements — parallel tidy + hard gate, two-way toggle, weak-tier AI verify, preview perf (#841)
## Summary

Four follow-ups to the artist/title **match judge** (shipped in
v0.184.1), per
`docs/archive/2026-06-16-match-judge-improvements-prompt.md`:

### 1. Race fix — parallel tidy + hard gate
The judge previously ran only *after* the audio search resolved, leaving
a window where a user could select audio with un-tidied metadata (or
have a late verdict clobber their pick).
- Split into a **`fast`** catalog-only pass (fired on mount, parallel
with the audio search) and a **`full`** pass (with the tier, may use
AI). New `stage` field + `needs_ai` marker on
`/api/catalog/match-judge`.
- **Hard-gate** all audio-selection buttons until the judge settles,
with a subtle "Checking song details…" indicator. A 12s safety timeout
guarantees release. Impossible to reach Step 3 with un-tidied metadata
in the normal flow.

### 2. Two-way tidy/correction toggle
The notice now switches **both directions** — canonical ⇄ what-you-typed
— instead of a one-way undo. The current value is always clear.

### 3. Title-screen preview performance
`TitleCardPreview` + `KaraokeBackgroundPreview` rendered a 3840×2160
(4K) canvas and loaded a 2.7 MB 4K PNG for a small thumbnail.
- Render at preview resolution (960×540, dpr-aware) via a scale
transform.
- Low-res background assets (~540 KB) for the preview; 4K stays for the
real render path.
- Preload backgrounds at Step 2; show a loading spinner.

### 4. Catalog-match trust — verify weak matches with AI
A confident catalog match could land on a junk/misspelled Spotify entry
(prod: `Queen / Bohemian Rapsody` → wrongly "already canonical"). Now,
when audio results are weak (tier 3), the AI judge verifies the catalog
match and can override. Extra cost (~$0.0003/call) only on weak-result
cases.

## Testing
- **Backend:** new unit tests for `fast`/`full` staging, `needs_ai`,
weak-tier AI override + keep-catalog-on-unconfident/failure/disabled;
route tests for `stage` forwarding. Full suite green (3510 passed).
- **Frontend:** Jest coverage for fast-on-mount, gate disable→enable,
12s timeout release, full-pass-only-when-needed, two-way toggle;
`TitleCardPreview` preview-resolution canvas + low-res bg + spinner.
Full unit suite green (1024 passed).
- `make test` green; `tsc` introduces zero net-new errors; ESLint clean.

## i18n
6 new keys (`matchUsingTyped`, `matchUseTidied`, `matchUseCorrection`,
`matchChecking`, `titleCardPreview.loading`,
`karaokeBackgroundPreview.loading`) translated to all 32 locales.

## Notes
Preserves all "constraints from history": no Step-1 autocomplete,
cosmetic never restarts the audio search, deferred job creation, public
brand rule, audio-before-customize ordering.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

@coderabbitai ignore

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-16 02:15:43 -04:00
..