Open-Generative-AI/app/api
Anuragp22 4cf0d503b8 feat(batch): batch detail page with progress, controls, retry, CSV export
Slice 5 of the batch feature. Marketing team can now click into a
batch from the list, watch a live progress dashboard, drive it with
Start/Pause/Resume/Cancel, retry individual failed jobs, and pull a
results CSV when it's done.

Includes a stakeholder-demo helper that simulates worker progress
(slice 4 hasn't shipped yet) so non-technical viewers see a realistic
running state without needing real MuAPI generations.

Backend
-------
- POST /api/batches/[id]/start: draft|paused -> running, requeues
  any cancelled jobs.
- POST /api/batches/[id]/pause: running -> paused.
- POST /api/batches/[id]/resume: paused -> running.
- POST /api/batches/[id]/cancel: any -> cancelled, marks queued/draft
  jobs as cancelled (in-flight ones complete naturally).
- POST /api/batches/[id]/simulate: demo-only. Picks ~10% of queued
  jobs, marks ~90% of those done with a placeholder video URL and
  ~10% failed. Updates batch counters atomically.
- GET /api/batches/[id]/export: streams a CSV with row-index,
  practice, trainer, studio, status, video URL, error, retries.
  Properly quotes cells, slugifies the filename.
- POST /api/jobs/[id]/retry: resets a failed job to queued so the
  worker re-attempts it.

UI
--
- app/batch/[id]/page.js: leaf route mounting BatchDetailShell.
- components/batch/BatchDetailShell.jsx: same MuAPI-key gate as
  BatchShell so opening a deep link works in a fresh browser.
- components/batch/BatchDetail.jsx: full progress dashboard.
  - Top header: back link, batch name, live status pill, CSV
    download button.
  - Progress card: done/total numbers, breakdown line
    (failed / running / queued), animated yellow bar, "auto-refresh
    every 3s" indicator while the batch is running or paused.
  - Settings strip: model / duration / quality / aspect / concurrency.
  - Filter pills: All | Pending | Done | Failed.
  - Demo button: " Simulate progress (demo)".
  - Jobs table: row index, practice (with inline error message),
    trainer, studio, status pill, ▶ Play (opens video preview modal),
    Retry (only on failed rows).
  - 3s polling driven by the running/paused state.
- components/batch/BatchesTab.jsx: rows are now clickable, the
  wizard navigates straight to the new batch's detail page after
  saving so the demo flow is one continuous click-through.

Verification
------------
- Created a 5-row batch via the API.
- start -> status went to running.
- simulate -> 1 done with placeholder URL, 0 failed (10% of 5 = 0
  failed by design).
- GET detail returned the batch with jobs joined to trainer/studio.
- /batch/[id] page returned 200.
- CSV export returned text/csv with the right columns and rows.
2026-04-23 08:48:42 +05:30
..
agents/[[...path]] feat: integrate AI agent studio with minimal UI and upgrade Tailwind v4 2026-04-22 15:22:26 +05:30
api/v1/[[...path]] feat: integrate AI agent studio with minimal UI and upgrade Tailwind v4 2026-04-22 15:22:26 +05:30
app/[[...path]] feat: implement workflow identity persistence, unify api auth, and upgrade tailwind to v4 2026-04-21 19:38:34 +05:30
batches feat(batch): batch detail page with progress, controls, retry, CSV export 2026-04-23 08:48:42 +05:30
jobs/[id]/retry feat(batch): batch detail page with progress, controls, retry, CSV export 2026-04-23 08:48:42 +05:30
studios feat(batch): degrade to local-only uploads when MuAPI is unreachable 2026-04-23 08:34:57 +05:30
trainers feat(batch): degrade to local-only uploads when MuAPI is unreachable 2026-04-23 08:34:57 +05:30
upload-binary feat: implement workflow identity persistence, unify api auth, and upgrade tailwind to v4 2026-04-21 19:38:34 +05:30
uploads/[kind]/[name] feat(batch): degrade to local-only uploads when MuAPI is unreachable 2026-04-23 08:34:57 +05:30
workflow/[[...path]] feat: implement workflow identity persistence, unify api auth, and upgrade tailwind to v4 2026-04-21 19:38:34 +05:30