29 Commits
Author SHA1 Message Date
Andrew Beveridge ☄️andClaude Opus 5.5 c277bc8ee3 feat: local E2E stack (fake workers + test API) + email-code sign-in (v0.275.0) (#1165)
## Summary
- **Local stack:** `scripts/local-stack.sh up --frontend` runs the
**real** backend on the Firestore + GCS emulators with `FAKE_WORKERS=1`.
In-process fake workers move jobs through their real states in seconds,
using tiny real media, so web Playwright and mobile Maestro full-journey
tests can run offline against the same endpoints.
- **Email-code sign-in** (nomad-mobile spec §4.1): `POST
/api/users/auth/send-code` + `verify-code`. The code logic is shared
with kjbox via `LoginCodeStore`, and sends are throttled per email and
per IP.
- **Bug fix found by the new suite:** `confirm-duration` moved jobs to
`separating_stage1`, from which they can never reach review. It now
resumes at `downloading`. No prod job had taken this path yet.

## Changes
- `backend/services/fake_workers/`: dispatch seam in
`WorkerService.trigger_*`, plus fake search, download, checkout and
outbox, scenarios, and per-user config. The real stem upload, transcode,
backing-vocals analysis and preview render are reused. Every check is
strict (`is True`), so a MagicMock settings object never enables the
fakes, and startup **refuses FAKE_WORKERS in production**.
- `/api/test/*` router (mounted only in that mode): `status`,
`scenario`, `fake-config`, `emails`, `reset`, plus the fake Stripe
checkout page. Paying it runs the real webhook handler.
- `frontend/e2e/local-stack/` (9 specs, ~50s):
  - sign-up → make → review → instrumental → download
  - buy and cancel credits
  - duration confirm, failed, complete and review states
  - code sign-in and lockout
- New required CI job `local-stack-e2e`.
- Docs: TESTING.md § Local stack, DEVELOPMENT.md, API.md, README,
LESSONS-LEARNED.
- `MAX_SIGNUPS_PER_IP` can now be set by env. Only the local stack
raises it; production keeps the default of 2.

## Testing
- [x] Backend unit: 6175 passed
- [x] Emulator: 152 passed
- [x] Frontend Jest: 1706 passed
- [x] Local-stack Playwright: 9/9 passed (CI mode)

## Review
- [x] CodeRabbit CLI review completed locally. 1 minor finding declined:
it suggested swallowing infrastructure errors in send-code as fake
"sent" responses, which would hide real outages from users.

@coderabbitai ignore

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

https://claude.ai/code/session_01AGuxtgoscF6RJGtpjHPg3W

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-15 16:00:24 -04:00
Andrew Beveridge ☄️ 7729d30937 build: build frontend into the wheel in CI instead of committing out/ to git (supersedes #892) (#926)
Build the Next.js frontend into the wheel in CI instead of committing the generated out/ to git (fixes #876; supersedes #892). Validated: package-build-test green (npm ci → make build-frontend → poetry build → verify_wheel_frontend guard → install). Thanks @netux for surfacing it.
2026-08-23 01:19:11 -04:00
Andrew Beveridge ☄️andClaude Opus 4.7 7268dfd830 feat(duet): multi-singer karaoke support + local CLI review fixes (#730)
## Summary

- **New feature:** Multi-singer / duet support. Review UI gains a "Duet
Mode" toggle and a per-segment chip to assign Singer 1 / Singer 2 /
Both. Rendered MP4 shows each singer in their signature color (blue /
pink / yellow), sweeping to a near-white tint of the same hue as each
word is sung.
- **Unplanned but necessary:** ~15 local CLI regression fixes that
landed alongside. The i18n work on `main` (LocaleRedirect, static-export
locale prefixes) silently broke the local `karaoke-gen` CLI review flow;
shipped-with-package `ReviewServer` was also missing several
`/api/review/{jobId}/*` endpoint aliases that the unified frontend
expects. This branch closes all of that so the local flow works
end-to-end again.

Full design spec:
[`docs/archive/2026-04-21-multi-singer-duets-design.md`](./docs/archive/2026-04-21-multi-singer-duets-design.md).
Implementation plan:
[`docs/archive/2026-04-21-multi-singer-duets-plan.md`](./docs/archive/2026-04-21-multi-singer-duets-plan.md).

## Changes — Duet Feature

**Backend**
- `Word.singer` / `LyricsSegment.singer` optional fields (`SingerId =
Literal[0,1,2]`, 0=Both)
- `DEFAULT_KARAOKE_STYLE` gains a `singers` block with per-singer colors
(unhighlighted = signature color, highlighted = near-white hue tint)
- `CDG_DUET_SINGERS` palette constant (+ `build_cdg_lyrics` helper —
wired into the render flow but not yet fed into `CDGGenerator`'s TOML
builder; follow-up tracked in `docs/LESSONS-LEARNED.md`)
- `ass/style.py` gains `build_karaoke_styles` factory that emits one ASS
style per singer in use
- `LyricsLine` / `LyricsScreen` / `SubtitlesGenerator` /
`SegmentResizer` all forward segment + word singer fields through the
render chain (several bugs where rebuilds silently dropped the field
were fixed)
- `is_duet` flag persisted in review-session `state_data` (cloud) and
captured by the local `ReviewServer` with a latch-up-only semantic on
`complete_review` so InstrumentalSelector can't accidentally downgrade
it
- `CorrectionOperations.generate_preview_video` threads `is_duet` into
the inner `preview_config`
- `render_video_worker` reads `is_duet` from state_data and propagates
through `OutputGenerator` → `SubtitlesGenerator` (both local + GCE
paths)

**Frontend (`frontend/`, sources only — bundle at
`karaoke_gen/nextjs_frontend/out/` also rebuilt)**
- `SingerId` type + optional `singer` on `Word` / `LyricsSegment` /
`CorrectionData.is_duet`
- `duet.ts` helpers: `cycleSinger`, `resolveSegmentSinger`,
`collectSingersInUse`, `hasMultipleSingers`, `hasWordOverrides`
- `SingerChip` component (click to cycle 1 → 2 → Both, shows `*` when
words have overrides)
- `Header` "Duet Mode" toggle (opt-in, hides chip column when off)
- `TranscriptionView` renders chip + subtle row-tint gradient when duet
is on
- `LyricsAnalyzer` manages `isDuet` state, includes it in save payloads
- `segmentOperations.ts` extends split/merge/addBefore/delete with
singer-inheritance rules (including the tricky implicit-vs-explicit
singer case)
- Keyboard shortcuts `1` / `2` / `B` on a focused segment
- `InstrumentalSelector` falls back to `hasMultipleSingers(segments)`
when `correctionData.is_duet` is missing
- Auto-enable duet on session-restore when restored data shows
multi-singer evidence
- `lyricsReview.duet.*` namespace added to `frontend/messages/en.json`
and auto-translated to all 32 other locales

**i18n**
- Every new user-visible string goes through `next-intl`; the
translation pipeline ran for each en.json change
- Backend new error strings added to
`backend/translations/{en,es,de}.json` and tracked via
`.en-snapshot.json`

## Changes — Local CLI Review Regression Fixes

These were uncovered while trying to manually validate the duet feature
end-to-end. They land in this PR because blocking validation would have
blocked the feature.

- `ReviewServer` now serves the `/{locale}/app/jobs/local/review` (and
broader `/{locale}/app/...`) paths that `LocaleRedirect` unconditionally
bounces to — discovers valid locales from the frontend build
- Added missing `/api/review/{jobId}/...` aliases: `search-lyrics` (new
handler using `CorrectionOperations.search_lyrics_sources`),
`add-lyrics`, `handlers` (POST, matching cloud), `audio/{stem-or-hash}`
(dispatches stems vs audio-by-hash), `instrumental-analysis`,
`waveform-data`, `v1/annotations`, `sessions` stubs
- Review-session history persistence added (external session)
- `job-router-routes.ts` now parses locale-prefixed pathnames so
`/en/app/jobs/local/instrumental` renders the InstrumentalSelector
instead of the lyrics review fallback
- Test-mock signatures updated for the `run_combined_review` 3-tuple
return

## Testing

- [x] Unit tests pass: **1606 package tests + 3002 backend tests + 848
frontend tests**, all green. Coverage: 69.29% (≥69% gate)
- [x] Integration tests pass (including new end-to-end multi-singer
fixture tests)
- [x] Playwright production E2E spec compiles
(`frontend/e2e/production/duet-review.spec.ts`)
- [x] Manual validation done end-to-end on Lady Gaga × Bradley Cooper —
"Shallow (145s duet clip)" — full pipeline produces a proper
duet-rendered MP4 with three per-singer ASS styles tagged correctly
against dialogue lines (6 Singer 1, 16 Singer 2, 4 Both across this
clip). Checked-in fixture at `tests/data/Shallow-Duet-145.ogg`.
- [ ] Manual validation against a second track with dense
call-and-response (spec listed Eminem × Rihanna "Love the Way You Lie")
— not done this PR; can follow up after merge if anything surprising
surfaces
- [ ] End-to-end CDG duet output — still deferred (see Known Follow-Ups)

## Review

- [x] Local code-review done via `feature-dev:code-reviewer` agent
(CodeRabbit CLI fell over on the 3605-file bundle rebuild commit)
- [x] Two findings addressed in commit `da3004ea`: handlers HTTP method,
mergeSegment implicit-singer case

@coderabbitai ignore

## Known Follow-Ups

- `build_cdg_lyrics` helper is implemented and unit-tested but
`CDGGenerator` still constructs its TOML config directly rather than via
`SettingsLyric`. CDG output from duet jobs renders in solo colors today.
Documented in `docs/LESSONS-LEARNED.md`; not required for the MP4/ASS
path which is the feature's primary surface.
- Cloud `complete_review` overwrites `is_duet` in state_data
unconditionally (local server has latch-only semantics). In practice the
frontend's `hasMultipleSingers` fallback in `InstrumentalSelector` keeps
this consistent, but the cloud could gain the same latch for parity.

## Version

Bumped `pyproject.toml` from `0.171.0` → `0.171.1`.

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

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-22 23:27:21 -04:00
Andrew Beveridge ☄️andClaude Opus 4.6 591c050545 feat: Reference lyrics search with relevance filtering (#632)
## Summary

- Add relevance filtering to the correction pipeline — automatically
rejects wrong-song reference lyrics (below 30% word match threshold,
validated against 168 prod source pairs)
- New `POST /api/review/{job_id}/search-lyrics` endpoint lets users
search with alternate artist/title from the review UI, with force-add
override for edge cases
- Redesigned Add Reference Lyrics modal with Search (default) and Paste
tabs, plus inline empty state when no valid sources exist

## Changes

### Backend
- **Relevance filtering** (`correction/relevance.py`): Per-source
scoring based on anchor sequence word coverage. Integrated into
`LyricsCorrector.run()` after anchor finding — sources below threshold
removed before corrections computed
- **Search endpoint** (`routes/review.py`): Queries all providers
(Genius, Spotify, Musixmatch, LRCLIB) with user-supplied artist/title,
auto-filters results, returns added/rejected/not-found breakdown
- **Provider factory** (`operations.py`): `create_lyrics_providers()`
reads env vars, `search_lyrics_sources()` orchestrates
fetch+filter+correct
- **Force override**: `add-lyrics` and `search-lyrics` support `force`
flag to bypass threshold

### Frontend
- **Tabbed modal**: `AddLyricsModal` rewritten with Search (default) and
Paste tabs
- **SearchLyricsTab**: Artist/title inputs, provider search, rejected
source cards with force-add checkboxes
- **ReferenceEmptyState**: Inline search/paste UI when no valid
reference sources exist
- **API client**: New `searchLyrics()` method with
`SearchLyricsResponse` types

### Analysis
- Empirical threshold analysis script
(`scripts/analyze_reference_relevance.py`) + visual review tool
- 168 source pairs from 81 prod jobs: wrong-song max 3.5%, correct-song
min 26.8% → 30% threshold

## Testing
- 35 new backend tests (relevance scoring, filtering, corrector
integration, search operation, API endpoint)
- 717 existing frontend tests passing (no regressions)
- Edge case: all sources filtered out handled gracefully

## Review
- [x] Local CodeRabbit review completed (3 issues fixed: response
contract, force param coercion, null checks)

@coderabbitai ignore

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

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-30 00:25:47 +00:00
Andrew Beveridge ☄️andClaude Opus 4.5 29be83cb56 Combined review flow: lyrics + instrumental selection in one session (#351)
## Summary

Merges the two-step human review process (lyrics review → instrumental
selection) into a single unified flow. Users now review lyrics AND
select instrumental track in one session.

**Benefits:**
- Better UX (one interaction vs two)
- Reduced drop-off between steps
- Single email notification instead of two
- Simpler workflow

## Changes

### Backend
- `complete_review` endpoint now accepts optional
`instrumental_selection` in request body
- Backing vocals analysis moved from `render_video_worker` to
`screens_worker` (runs before review)
- Removed standalone instrumental selection endpoints (now part of
combined review)
- Added `CompleteReviewRequest` model with validation

### Frontend
- New `InstrumentalSelectorEmbedded` component for combined review UI
- `LyricsAnalyzer` updated to proceed to instrumental review
- `ReviewChangesModal` shows "Proceed to Instrumental Review" button
- Mock data updated in E2E tests

### Local CLI
- `gen_cli.py` refactored to use `run_combined_review()` instead of
separate `run_instrumental_review()`
- `ReviewServer` extended with instrumental options and analysis
- Deleted standalone `InstrumentalReviewServer`

### Documentation
- Updated `docs/README.md` with recent changes entry
- Updated `docs/ARCHITECTURE.md` with new pipeline diagram
- Updated `docs/API.md` with endpoint changes
- Added lesson to `docs/LESSONS-LEARNED.md`

## Test plan

- [x] Backend unit tests: 1742 passed
- [x] Frontend unit tests: 234 passed
- [x] New integration tests: 5 tests for combined flow
- [x] New backend tests: 7 tests for CompleteReviewRequest and
state_data
- [x] New frontend E2E tests: 6 tests for combined flow UI

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

@coderabbitai ignore

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 11:49:51 -08:00
Andrew Beveridge ☄️andClaude Opus 4.5 082d36a3c9 fix(pwa): Add service worker file that was gitignored (#276)
## Summary
- Adds the service worker file that was previously gitignored
- Updates gitignore to allow sw.js (hand-written) while still ignoring
auto-generated PWA files

## Context
The sw.js service worker file was created in PR #274 but was blocked
from being tracked by a gitignore rule meant for auto-generated PWA
files. Without this file, push notifications cannot work because the
browser has no service worker to receive push events.

## Test plan
- [ ] CI passes
- [ ] `curl https://gen.nomadkaraoke.com/sw.js` returns JavaScript after
deploy

@coderabbitai ignore

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-10 18:14:51 -05:00
Andrew Beveridge a6ca766a87 Merge branch 'main' into feature/payment-flow 2025-12-28 15:30:44 -05:00
Andrew BeveridgeandClaude Opus 4.5 a897ac8cbd chore: add frontend/e2e/screenshots/ to .gitignore
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-28 15:11:31 -05:00
Andrew BeveridgeandClaude Opus 4.5 c51b0126a7 feat: Add beta tester program with free credit for feedback
Implements a low-friction beta tester promo that grants users free credits
in exchange for their promise to provide feedback after using the tool.

Backend:
- Add BetaTesterStatus enum and beta fields to User model
- Add BetaTesterFeedback model for collecting user feedback
- Add POST /users/beta/enroll endpoint for beta signup
- Add POST /users/beta/feedback endpoint for feedback submission
- Add GET /users/beta/feedback-form for checking feedback status
- Add admin endpoints: /admin/beta/feedback, /admin/beta/stats
- Add email templates: beta_welcome, feedback_request

Frontend (buy-site):
- Add beta tester signup section with purple gradient styling
- Require checkbox acceptance of correction work
- Require promise text (min 10 chars) for feedback commitment
- Auto-redirect to main app after successful enrollment
- Add enrollBetaTester API method

Features:
- 1 free credit granted on beta enrollment
- Bonus credit for detailed feedback (50+ chars)
- Feedback includes ratings (1-5) for ease, accuracy, correction UX
- Admin dashboard shows aggregate beta stats and ratings

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-28 04:03:55 -05:00
Andrew Beveridge 12a62db7f8 Remove test files and add to gitignore 2025-12-28 00:48:13 -05:00
Andrew BeveridgeandClaude Opus 4.5 3cbfbd14d1 Fix: Pass theme configuration from JobCreate to Job
The create_job() function was not passing theme_id, color_overrides,
style_params_gcs_path, or style_assets from JobCreate to the Job
constructor. This caused jobs created via audio search to have null
theme_id even when a theme was specified.

Also enables video recording for all Playwright tests.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-27 20:17:42 -05:00
Andrew BeveridgeandClaude Opus 4.5 050f86a280 Add Playwright E2E testing and fix frontend API issues
- Set up Playwright for E2E testing against real cloud backend
- Add Next.js API proxy rewrites to avoid CORS in development
- Fix AudioSearchDialog: useState -> useEffect for loading results
- Add auth headers to all API methods that were missing them
- Fix selectAudioResult to use correct field name (selection_index)
- Add .env.local support for storing access token
- Create E2E tests for job listing, search, and audio selection flows

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-26 01:05:52 -05:00
Andrew Beveridge 6d81ad804a chore: remove accidentally committed flacfetch submodule reference
The flacfetch directory was a cloned repo that got tracked as a submodule
when running git add. Remove it from tracking and add to .gitignore.
2025-12-25 12:07:03 -05:00
Andrew Beveridge ☄️ 91f51d6a8c feat: Match frontend styling to instrumental review UI and add authentication
- Updated color scheme to match instrumental review UI (neutral dark theme with blue accents)
- Replaced Geist fonts with system font stack for faster loading
- Fixed API URL from gen.nomadkaraoke.com to api.nomadkaraoke.com
- Added authentication support with token management (localStorage)
- Created AuthBanner component for token input
- All API requests now include Authorization header when authenticated

This resolves frontend API 404 errors and provides consistent styling across all karaoke-gen UIs.
2025-12-22 11:41:25 -05:00
Andrew Beveridge fa1fed414b Fix gitignore excluding lyrics_transcriber output subpackage
The .gitignore pattern `output/` was too broad and matched directories
anywhere in the repo, causing lyrics_transcriber_temp/lyrics_transcriber/output/
to be ignored.

Changes:
- Make gitignore patterns root-specific (/output/, /input/)
- Add previously-ignored output module files (ass/, cdgmaker/, fonts/, generators)

Tested locally - all backend imports succeed.
2025-12-08 21:43:47 -05:00
Andrew Beveridge 72385e3a77 Fix gitignore excluding lyrics_transcriber subpackages
The .gitignore pattern `lyrics/` was too broad and matched directories
anywhere in the repo, causing lyrics_transcriber_temp/lyrics_transcriber/lyrics/
and related subpackages to be ignored.

Changes:
- Make gitignore patterns root-specific (/audio/, /lyrics/, /karaoke/)
- Add missing __init__.py files for correction, lyrics, transcribers, utils
- Include previously-ignored lyrics provider modules and tests
2025-12-08 21:18:12 -05:00
Andrew Beveridge 79e6c60a61 Temporarily added lyrics transcriber codebase to this repo so we can iterate faster 2025-12-08 20:35:09 -05:00
Andrew Beveridge 45a94ef7c7 Replaced frontend with next.js/react version from vercel v0 2025-12-08 05:00:02 -05:00
Andrew Beveridge 4fe9a98698 Added karaoke-gen-remote CLI to submit remote jobs 2025-12-08 03:53:32 -05:00
Andrew Beveridge a08fa5cc5b Added more finalization logic, improved logging, added tests for nvenc to try and speed up video rendering 2025-07-07 00:58:05 -04:00
Andrew Beveridge c9ed433bf4 Improve management of cookies for youtube download, artist/title etc. 2025-07-04 22:34:32 -04:00
Andrew Beveridge 2b6e34395d Made progress towards phase 2 working with modal app 2025-07-03 05:05:20 -04:00
Andrew Beveridge 48875ebeff Got initial part of the modal-backend web UI flow working with frontend submitting jobs to modal with live tail logs, job history management admin tools etc. Actual generation runs half of the job but gets stuck at review stage right now. Prompt written to work on that next. 2025-07-03 01:37:38 -04:00
Andrew Beveridge cc76db0c04 Hopefully fix CI, upgrade to latest version of lyrics-transcriber 2025-06-29 20:59:04 -04:00
Andrew Beveridge 586763ae5f Updated bulk CLI 2025-02-03 00:47:01 -05:00
Andrew Beveridge 6092a67ef4 Updated to use latest lyrics transcriber. Added full auto and bulk processing modes. Added ability to pass in existing lyrics input file. 2025-02-02 22:35:16 -05:00
Andrew Beveridge ddb70a9c31 Updated to include fixed region and extra text logic, additional font, test for intro and end screen rendering 2024-12-24 00:34:28 -05:00
Andrew Beveridge ad9492d7e3 Attempt to get pyinstaller building windows executable from github actions 2023-12-20 22:45:26 -06:00
Andrew Beveridge 9479153338 Initial version of the code, mostly copied from karaokenerds prep 2023-10-05 00:27:43 -05:00