Skip to content

Batch conversion queue for multi-file drops - #74

Draft
liladas wants to merge 1 commit into
mainfrom
batch-queue
Draft

liladas wants to merge 1 commit into
mainfrom
batch-queue

Conversation

@liladas

@liladas liladas commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Implements #73. Draft for test-driving, not for merge.

What this does

Drop any number of karaoke zips and/or loose .cdg+.mp3 files. Loose files pair by case-insensitive basename; each zip is its own item. Items convert sequentially through the existing shared ffmpeg.wasm worker and appear in a queue with per-item state (queued / converting with progress + ETA / saved / failed with reason / cancelled / skipped duplicate). Dropping more files mid-run appends. One item keeps today's single-file UI exactly.

Outputs auto-download as each finishes; on Chromium a "Save to folder" button streams them to a picked directory instead. Only the latest finished item's blob is retained (for the preview), so memory stays flat regardless of batch size.

Design decisions (details in #73)

  • Sequential only. Two parallel ffmpeg instances would give ~1.9x but cost 1GB+ of never-shrinking wasm heap and a pool refactor; deliberately out of scope.
  • Duplicate skip is session-scoped, keyed on output basename + input size, always visible as a row with "Convert anyway", and never applies to a lone deliberate re-drop (found and fixed during the browser test drive: a single re-drop used to silently no-op).
  • Two cancel verbs: Skip (current item) and Stop batch. A skip terminates the worker; the next item reloads it from the SW cache.
  • The worker is recycled every 10 conversions to reset the wasm heap high-water mark.
  • Wake lock + beforeunload guard while a batch is active. The service-worker auto-update hold now wraps the whole batch.
  • classifyBatch replaces selectInput; one deliberate behavior change: a zip dropped together with a loose pair converts both (the zip used to silently win).

Test evidence

  • 123 unit tests pass (41 new: classifier matrix, reducer transition table, runner sequencing/cancel/retry/recycle, save targets).
  • 7 Playwright e2e pass, including two new real-conversion batch scenarios (zip + renamed pair sequential with download assertions; duplicate re-drop skipped).
  • Scripted browser test drive against the production build: 11 screenshots across idle → batch running with leftover notice → mid-batch → finished → clear → re-drop → stop batch → retry → finished. Zero console errors; downloads fired in order.

Known limitations (v1, by design)

  • Safari: gestureless auto-download is unreliable; a retained-blob manual mode is a follow-up if Safari batch usage appears (current batch users are Chromium desktop).
  • No queue persistence across reload (beforeunload guard instead).
  • No fuzzy basename matching; unmatched files get a notice.

Drop any number of karaoke zips and loose cdg+mp3 files at once; they
pair by basename and convert sequentially through the shared ffmpeg.wasm
worker. Outputs auto-download as each finishes (Save to folder via the
File System Access API on Chromium), so memory stays flat at any batch
size; only the latest finished item is retained for preview.

- classifyBatch replaces selectInput (single input is the degenerate
  case; a zip dropped with a loose pair now converts both)
- pure queue reducer + module-scope sequential runner (converting.ts
  idiom), consumed via useSyncExternalStore
- session-scoped duplicate skip (basename + size, visible row with
  Convert anyway; never applies to a lone deliberate re-drop)
- Skip / Stop batch cancel verbs, per-item Retry, continue-on-error
- worker recycled every 10 conversions to reset the wasm heap
- wake lock + beforeunload guard while a batch runs
- batch_* analytics events; conversion_* gain batch_id/index/size
- single-file flow unchanged, including hold-for-partner
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant