Files
Andrew Beveridge ☄️andClaude Opus 5.5 a8f9618a07 feat(review): admin "perfectly synced" mark for the word-timing reference set (v0.290.0) (#1242)
## Summary
Andrew's review depth varies: Thursday live-event jobs often get only a
quick review. Treating every admin review as perfect sync truth
therefore poisons aligner training and evaluation (full-auto v2). This
adds an explicit, admin-only **"perfectly synced"** mark in the lyrics
review. Ticked jobs join the word-timing reference set; unticked means
unverified. Andrew's definition: a confident spot-check (anchors +
waveforms), not necessarily a full listen.

## Changes
- **Backend:** new `POST /api/review/{job_id}/sync-reference`
(`require_admin`).
  - Stores `state_data.sync_reference = {verified, by, at, notes}`.
- `verified: true` needs saved review output: the `file_urls` pointer,
or the direct GCS path for older jobs. Otherwise it returns 409.
Revoking is always allowed.
- **`correction-data`** returns `sync_reference`, so a re-review shows
the existing mark and can revoke it.
- **Frontend:**
- The review modal shows the checkbox plus an optional notes field, to
admins only.
- The modal passes the mark to `onSubmit`. `LyricsAnalyzer` saves it
**after** `submitCorrections` succeeds, so a mark can't sit on unsaved
timing. A failure shows a toast and never blocks the review.
- Once the box is touched, its current state is always sent, so it can
be revoked.
- **i18n:** 4 new strings × 33 locales.
- **Docs:** API.md. Version 0.290.0.

## Testing
- Backend: `test_review_sync_reference.py` (admin store, notes trim,
404, 422, 403 non-admin, 409 without review, direct-path fallback).
Related review suites pass (29).
- Frontend: `ReviewChangesModal.syncReference.test.tsx` (hidden for
non-admin, tick passes the mark, untick sends nothing, saved mark
pre-ticks and revokes, touched-then-unticked sends `false`). The modal
suites pass (29). tsc shows no new errors (21 pre-existing test-file
errors, the same on main).
- **CodeRabbit:** ran locally for 3 cycles and fixed 6 findings. One was
left by design: a pre-ticked mark on an edited re-review is visible in
the modal Andrew confirms, so submitting re-affirms it. The only user is
Andrew.

@coderabbitai ignore

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

https://claude.ai/code/session_012RYLVVVPsvPbXFhRYY5VSJ

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 20:17:41 +00:00
..

Karaoke Generator Frontend

Next.js frontend for the Karaoke Generator application.

Quick Start

# Install dependencies
npm install

# Run development server
npm run dev

The app will be available at http://localhost:3000

Development Setup

Connecting to the Cloud Backend

In development, the frontend proxies API requests to the cloud backend (api.nomadkaraoke.com) via Next.js rewrites. This avoids CORS issues and allows local development without running a local backend.

The proxy is configured in next.config.mjs:

  • All /api/* requests are forwarded to the cloud backend
  • You can override the backend URL with BACKEND_URL environment variable

Authentication

The backend requires authentication. To authenticate:

  1. Create a .env.local file in the frontend directory:

    KARAOKE_ACCESS_TOKEN=your-token-here
    
  2. The token is automatically loaded by Playwright tests

  3. In the browser, the token is stored in localStorage as karaoke_access_token

Testing

Unit Tests (Jest)

# Run tests in watch mode
npm test

# Run tests with coverage
npm run test:coverage

# Run tests in CI mode
npm run test:ci

E2E Tests (Playwright)

E2E tests run against the local dev server connected to the real cloud backend.

# Run all E2E tests
npm run test:e2e

# Run with UI (interactive mode)
npm run test:e2e:ui

# Run in headed mode (see the browser)
npm run test:e2e:headed

# Run in debug mode
npm run test:e2e:debug

Authentication for E2E Tests

E2E tests require a valid access token. Set it in .env.local:

KARAOKE_ACCESS_TOKEN=your-token-here

The Playwright config (playwright.config.ts) automatically loads this file.

Test Structure

Tests are located in e2e/:

  • karaoke-generation.spec.ts - Main test suite covering:
    • Homepage loading and form display
    • Search tab functionality
    • Audio search submission
    • Audio selection dialog flow
    • API health checks

Test Architecture

┌─────────────────┐     ┌──────────────────┐     ┌─────────────────────┐
│   Playwright    │────▶│  Next.js Dev     │────▶│  Cloud Backend      │
│   Browser       │     │  Server (:3000)  │     │  api.nomadkaraoke   │
└─────────────────┘     └──────────────────┘     └─────────────────────┘
                              │
                              ▼
                        API Proxy
                        /api/* → backend

Debugging Test Failures

  1. Screenshots: Failed tests save screenshots to test-results/
  2. Videos: First retry captures video (when retries enabled)
  3. Traces: View detailed traces with npx playwright show-trace <trace.zip>
  4. HTML Report: After running tests, view npx playwright show-report

Common Issues

  • 401 Unauthorized: Token missing or invalid - check .env.local
  • Socket hang up: Backend operation taking too long - some operations (like audio download) can take minutes
  • Element outside viewport: Dialog scrolling issues - tests use JavaScript click to handle this

Project Structure

frontend/
├── app/                    # Next.js app router pages
├── components/             # React components
│   ├── ui/                 # shadcn/ui components
│   └── audio-search/       # Audio search feature components
├── lib/                    # Utilities and API client
│   └── api.ts              # Backend API client
├── e2e/                    # Playwright E2E tests
├── playwright.config.ts    # Playwright configuration
└── next.config.mjs         # Next.js configuration

Scripts

Script Description
npm run dev Start development server
npm run build Build for production
npm run start Start production server
npm run lint Run ESLint
npm test Run unit tests (watch mode)
npm run test:ci Run unit tests (CI mode with coverage)
npm run test:e2e Run E2E tests
npm run test:e2e:ui Run E2E tests with interactive UI