Skip to content

feat(ui): shorts in clip ui, and export every short - #86

Merged
yultyyev merged 4 commits into
feat/shortsfrom
feat/ui-shorts
Nov 16, 2026
Merged

yultyyev merged 4 commits into
feat/shortsfrom
feat/ui-shorts

Conversation

@yultyyev

Copy link
Copy Markdown
Collaborator

Slice 4 of 4 toward v0.5.2 (long recording → vertical shorts). Targets the integration branch feat/shorts; merging it releases nothing. Layout B from the mock: tabs above the timeline.

Docs: README before · after (one command line and one paragraph at the end of the section); SKILL.md before · after (the "To cut vertical shorts" paragraph); llms.txt (the shorts bullet).

What

Server (src/ui/server.ts)

  • Every /api/timeline* route reads ?timeline= (default main).
    • A middleware refuses a malformed id with 400.
    • A short that doesn't exist answers 404 through app.onError. The per-route catch blocks pass NoTimelineError and TimelineIdError on to it instead of turning them into 500 or 503.
    • Any other error is answered the way Hono does by default.
  • GET /api/timelines lists main and every short with its size, length and rev.
  • DELETE /api/timelines/:id removes a short and its undo history. Main gives 400, a missing short 404.
  • POST /api/timelines/export renders every short into shorts-<hex>/<id>.mp4 in the workspace. Each one is logged to the session, so it shows in Outputs. A short that can't render is reported with its error, and the rest still render. With no shorts it answers 422.
  • The verbs route now returns warnings (make_short's mid-sentence and no-pause edges).
  • The single-timeline export logs timeline in its op args.

Core and CLI

  • exportTimelines(ids, dir) in src/timeline/run-plan.ts (exported from the package):
    • compiles and runs each timeline one at a time, to <dir>/<id>.mp4;
    • returns each result with its rev and loudness, or the error;
    • names intermediates per run, so a concurrent export or frame preview can't overwrite them.
  • clip timeline export --all <dir> renders every short except main.
    • It prints { exported: [...] } and exits 1 if any short failed.
    • It refuses --timeline and project formats, which export one timeline.
    • It refuses a workspace with no shorts.

Web app (src/ui/web/src/)

  • TimelineTabs: a tab per timeline with its shape (16:9, 9:16…), shown once a short exists.

    • A short's ✕ deletes it after a confirm.
    • "Export all shorts (N)" renders them all and lists each with its LUFS, or why it failed.
  • The open timeline is kept in the page URL (?timeline=best-1), so a reload keeps it. Every fetch passes it:

    • the document poll, the verbs, the viewer frame and exportable check;
    • the history, undo and redo, the mp4 and project exports;
    • the transcript.

    useTimeline only returns a document that belongs to the open timeline, and the viewer remounts per timeline, so a switch never shows or renders the last timeline's clips.

  • If the open short is deleted elsewhere (the agent, the CLI), the 404 sends the page back to main.

  • Make short in the transcript panel appears once words are selected. It has:

    • a name, offering the first free short-N and checked against the id rule;
    • the left–right position (x).

    It runs make_short on the new timeline with the open one as its source, opens the short and shows its warnings under the tabs. Errors such as "already holds a short" show in the inspector.

  • Slider is now exported from FramingSection for reuse.

Why

The finish line includes the UI: picking a moment from the transcript, seeing the 9:16 short with its captions, and exporting every short, without the CLI.

How to test

clip ui
  1. Add a talking-head recording, select its clip, then press "Show transcript" (needs whisper.cpp).
  2. Click a word, then shift-click a later one. Name the short in the box below the actions, then press "Make short from N words".
  3. The new tab opens: the viewer shows 9:16 with captions above the bottom quarter.
  4. Press "Export all shorts". The note lists each short with its LUFS, and the files show in Outputs.
  5. Press ↶ once on a short's tab: the short is empty again, and main is unchanged.

Checks

  • pnpm lint: no errors. The 7 warnings are in tests/speed.test.ts and tests/transition.test.ts, which this PR doesn't touch.

  • pnpm type-check: clean.

  • pnpm test: 965 passed, 34 skipped.

  • pnpm build: OK.

  • New unit tests:

    • tests/ui-timelines.test.ts (8): ?timeline= reads, edits, undoes and reports history per timeline; 400 and 404 on every route; list, delete and export-all through the real server, with no FFmpeg; export-all refuses a short whose media was swapped for a link out of the workspace.
    • tests/timeline-export-all.test.ts (4): exportTimelines reports a failure and goes on; --all usage and refusals; exit code 1.
  • New integration test, tests/integration/timeline-export-all.test.ts: two shorts (9:16 and 1:1) render at their own sizes, ~2 s each, and between -15 and -13 LUFS. An empty short is reported and sets exit code 1.

  • CI=true run of the export-all, shorts, caption safe zone and frame window integration tests: 5 passed.

  • Browser check (Vite dev against a scratch API server, synthetic 83 s recording, whisper base.en):

    • A badly formed name ("Best 1") shows the inline error.
    • Making best-1 from 10 selected words opened its tab (?timeline=best-1). The viewer showed a 720×1280 frame with the caption above the bottom quarter.
    • A second short with the default name short-1 worked too.
    • Export all saved both at -14.0 LUFS, 720×1280, and logged both to Outputs. In best-1.mp4 at 1 s, the caption box ends at y≈960 of 1280.
    • One undo on short-1 emptied it, with redo enabled. Main stayed at rev 2 throughout.
    • Deleting short-1 asked first and fell back to main.
    • A reload kept ?timeline=best-1.
    • Deleting best-1 from the CLI sent the page back to main on the next poll.
    • Found and fixed during the check: right after a switch, the first frame request used the old playhead and the old timeline's doc (a 422). Now the first request is at 0 s on the new timeline.
  • Codex review (codex exec, high effort, inline diff), 2 findings, both fixed in 4bb87a6:

    • P1, fixed. Export-all passed the registry's paths to FFmpeg unchecked. A registered file swapped for a symlink out of the workspace would have been rendered. The UI route now passes confinedMediaMap, so that short is reported with the boundary error and the rest still render. The new test fails without the fix.
    • P2, fixed. useTimeline's missing leaked across switches. Opening another short right after a fallback to main could bounce back to main. It's now tied to the timeline that answered 404. There's no automated test, because the web app has no React test setup.
    • A second Codex pass on the fix commit found the fixes hold, with no new issue.

Notes

  • Backlog: docs/backlog/confine-render-media.md. The older single-timeline mp4 export, the frame preview and the MCP mp4 export also take the registry's paths unchecked, as they did before this PR. This PR confines only the new route.
  • Backlog: docs/backlog/ui-inspector-height.md. On a 1000 px tall window the clip inspector gets 0 px, because the viewer fills .main. That was so before this PR; the tabs bar takes about 30 px more once a short exists.

yultyyev and others added 4 commits November 15, 2026 19:25
… all shorts

Every /api/timeline route reads ?timeline= (default main): a malformed id
answers 400 and a short that doesn't exist 404. GET /api/timelines lists
them, DELETE /api/timelines/:id removes a short (main is refused), and
POST /api/timelines/export renders every short through exportTimelines,
which `clip timeline export --all <dir>` shares. The verbs route now
returns make_short's warnings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ll shorts

Tabs above the timeline list main and every short with its shape; the
open one lives in the page URL and every fetch names it. A short's tab
deletes it after a confirm, and a short deleted elsewhere falls back to
main. Selecting words in a clip's transcript offers Make short (a name
and the left-right position), which opens the new short and shows
make_short's warnings. Export all shorts renders every one and lists
each with its loudness.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Also logs the clip inspector getting no height on a short window as a
backlog note; it predates the tabs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…o its timeline

The export-all route now resolves each short's files through
confinedMediaMap, so a registered file swapped for a link out of the
workspace is refused instead of rendered. useTimeline remembers which
timeline answered 404, so switching to another short right after a
fallback doesn't bounce back to main.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@yultyyev
yultyyev merged commit bfd0839 into feat/shorts Nov 16, 2026
1 check passed
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 0.5.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant