Files
karaoke-gen/frontend
Andrew Beveridge ☄️andClaude Opus 5.5 f4f0f6af77 feat(review): only show the review button once the job is fully prepared (v0.298.0) (#1273)
## Summary

The review button now appears only once a job is fully prepared: stems
separated, auto-approval re-scored with them, AI lyric corrections
generated and applied on the server, and review audio + waveforms
cached. The browser no longer applies AI corrections by itself, so there
is one code path.

Prompted by job ae995697 (a Made For You order): the review button
showed at 18:29, but the stems, backing verdict and vocal waveform only
existed from 18:32, and the server pre-apply had aborted on a
duplicate-word check, leaving the browser to apply corrections on load.

## Changes

- **Hold every job until stems land**
(`review_gate.route_after_scoring`). Before, only jobs whose lyrics
would auto-ship were held, so Made For You and lyrics-gated jobs opened
review early. Same kill switch (`AUTO_APPROVAL_AUDIO_HOLD_ENABLED`) and
20-minute backstop.
- **Generate AI suggestions on the API service before parking.** The
hold is released inside the audio-separation job, which has no LLM
credentials, so that job only applies an existing cache.
- **`enter_human_review` prepares everything before AWAITING_REVIEW**:
pre-apply (generating on a cache miss), then
`review_assets.prepare_review_assets` (OGG transcodes, backing waveform,
vocal peak envelope), then the transition.
- **Non-strict pre-apply for human review**
(`build_applied_segments(strict=False)`): what "Accept All" produces.
Stale/duplicate signals are recorded as `warnings`. The auto-ship path
stays strict.
- **Removed the browser's on-load auto-run/auto-apply** from
`useAutoCorrect`.
- **Job card shows "[5/10] Preparing review"** while held (new summary
field + 33 locales).
- Docs: ARCHITECTURE review-gate step,
`docs/archive/2026-11-19-review-ready-gate.md`.

Trade-off: Made For You and lyrics-gated jobs reach review (and send the
review-ready notification) ~3 minutes later.

## Testing

- Backend unit suite: 7294 passed. Locally failing: 8
emulator-integration tests (something unrelated listens on :8080 so they
don't skip; CI runs them against real emulators) and 1 locale test that
tripped on a gitignored translation snapshot (passes once removed).
- New/updated tests: review gate (review-verdict jobs held, kill switch,
prepare-before-transition order, suggestions generated before parking,
no double wait, missing job), non-strict apply, duplicate-word pre-apply
(ae995697 case), review_assets.
- Frontend Jest: 1834 passed; no type errors in touched files.
- Local CodeRabbit: 2 minor findings fixed, re-review clean.

@coderabbitai ignore

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

https://claude.ai/code/session_012RYLVVdAxGitbw1FhYP4e4

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 16:12:58 -05: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