Archilyzer · Source

archilyzer

Archilyzer
git clone https://archilyzer.pages.dev/source/archilyzer.git
Log | Files | Refs | README | LICENSE

commit 989e054925ae3933b5a4faea7f8cb91d4d6c93b1
parent d74e4b9f944097a6ea4bd6e5a7451c889627631c
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Thu, 22 Oct 2026 10:18:44 -0400

knobs: e2e (Count & stamp, Markers, Make variants with a stub encoder), docs/knobs.md, the record

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

Diffstat:
MAGENTS.md | 4+++-
Aplans/video-knobs-ui.md | 73+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mumtool/docs/cli.md | 6+++++-
Aumtool/docs/knobs.md | 61+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mumtool/docs/notes.md | 4++++
Mumtool/docs/report-video.md | 3+++
Aumtool/e2e/fixtures/knobs-fixture.mjs | 48++++++++++++++++++++++++++++++++++++++++++++++++
Mumtool/e2e/fixtures/make-fixture.mjs | 3+++
Aumtool/e2e/knobs.spec.ts | 160+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mumtool/playwright.config.ts | 6++++++
10 files changed, 366 insertions(+), 2 deletions(-)

diff --git a/AGENTS.md b/AGENTS.md @@ -196,7 +196,9 @@ beside the report's `report.json` (never published) or beside the project's anchor resolved and the **source** file to edit — a draft, not the generated `report.json` or manifest. Act, regenerate, then `umtool notes reply <id> "<what changed>" --resolve`. Never hand-edit `notes.json`. See -[umtool/docs/notes.md](umtool/docs/notes.md). +[umtool/docs/notes.md](umtool/docs/notes.md). Every report-video knob a person sets in umtool (a stamp's moment and +count, a clip's sync, markers, the encode ladder) an agent sets with `umtool set` / `umtool look` / `umtool variants`: +[umtool/docs/knobs.md](umtool/docs/knobs.md). # The runtime container diff --git a/plans/video-knobs-ui.md b/plans/video-knobs-ui.md @@ -0,0 +1,73 @@ +# Video knobs — the surfaces (lane `lane/knobs-ui`, K2) + +Asked by the operator on 2026-10-22 on the Huck seizure video: "Do we have the ability to adjust the point where +the count increments / the stamp appears per clip?", "Make quality variants … I'll want to share higher quality +ones elsewhere", and "Add any knobs you can think of, I want to allow for deep human involvement as well as AI +control for these videos." The plan (both lanes): the job's `video-knobs-plan.md`. The renderer side is +`lane/knobs-core` (K1, `plans/video-knobs-core.md`); this lane is the writers, routes, UI, CLI and agent control. +Merge order K1 then K2. + +## What shipped + +Every knob is a field or button in umtool and a `umtool` command, through one writer each. Absent keys are the +defaults; a knob set to its default is removed. The reference for people and agents is `umtool/docs/knobs.md`. + +| Knob | UI | CLI | Route | Writer | +|---|---|---|---|---| +| `claim.at` | clip editor, Count & stamp: **Set at playhead** (Shift+S) | `umtool set <p> <clip> claim.at=S` | `POST /api/report/clip-editor {op: "claim"}` | `updateClaimKnobs` | +| `claim.hold` / `stamp` / `count` / `label` | Count & stamp fields, Clear | `claim.hold=` … | same | same | +| `audio.offset` / `gain` / `fadeIn` / `fadeOut` | clip editor, Audio (nudges ±10/±40 ms, **listen** = 3 s around the playhead), Clear all | `umtool set <p> <clip> audio.offset=-40` | `POST /api/report/clip-editor {op: "audio"}` | `updateClip` (`audio`) | +| `factcheck.stamp.scale` / `motion` / `opacity` | Structure → fact-check labels | `umtool look <p> factcheck.stamp.scale=1.3` | `POST /api/report/timeline {op: "factcheck"}` | `updateFactcheck` | +| `factcheck.verdicts[V].stampLabel` | fact-check labels, third column | `factcheck.verdicts.V.stampLabel=…` | same | same | +| `deck.markers[]` (`align`), `deck.markerLayout` | On-screen → **markers** (add, clip picker, label ≤ 24, colour, align, ↑ ↓, remove, layout; ≤ 12) | `umtool look <p> deck.markers=<json> deck.markerLayout=…` | `PUT /api/report/chrome {markers, markerLayout}` | `updateDeckMarkers` (structural: snapshotted) | +| `render.variants` | Deliver → Variants and sync: Edit / Save ladder / Use the default | `umtool look <p> variants=<json>` | `PUT /api/report/render {variants}` | `updateVariants` | +| Make variants | Deliver → **Make variants** (project build or a take's) | `umtool variants <p> [--take t]` | `POST /api/report/deliver {action: "variants", take?}` (a job) | driver `variantsSteps` → `node report-to-video/variants.mjs <out>` | +| variants list, Sync table | Deliver: the list (size, frame, kb/s, open), sync rows (lag, flagged > 1 frame, link to the clip's Audio box) | `umtool variants <p> --list [--json]` | `GET /api/report/variants?project[&take][&file=<name>]` | `variantsView.mjs` | +| all of the above, read | — | `umtool show <p>` (**knobs** block; `--json`: `knobs`) | — | `knobsCli.mjs knobsOf` | + +Rulings: + +- Every manifest-write route (`build`, `chrome`, `claim`, `clip-editor`, `cut`, `deliver`, `drafts`, `hand-fill`, + `narration`, `onscreen`, `posts`, `render`, `timeline`, `video-assist`, `window`) takes the page (no header) or + `Bearer <WORKER_TOKEN>`; any other header is 401 (`lib/report/caller.ts`, routeCaller's rule). +- The Count & stamp key is **Shift+S**: S alone stays Split here. +- `claim.at` must lie in the clip's window (`start`–`end`); a window save that would leave it outside is refused. + The box warns when it is outside the cut. +- A claim's knobs are read from the clip that stamps it (the last carrying the id); the box on another clip names it. +- The On-screen table's claim rows keep the knobs while the claim id is unchanged; a row naming knobs replaces them. +- `audio`: merged per key, a 0 or null removes a key, nothing left removes `audio`; offset rounded to the ms, + gain to 0.1 dB, fades to 0.01 s. +- `render.variants`: ≤ 8 rungs, unique names `[a-z0-9-]{1,24}`; `master` takes no setting; a `maxMiB` rung takes no + height or crf; any other rung needs a height (even, 240–2160) or a maxMiB. +- Sync: a lag past one frame (1000 / fps ms) is flagged; the file is the build's `<out>/sourced/sync.json`. + +## Until K1 merges (resolve at merge) + +- **Shims** (K1's files win): `umtool/report-to-video/clip-audio.mjs` (`validateClipAudio`, `CLIP_AUDIO_LIMITS`), + `umtool/report-to-video/variants.mjs` (`encodeVariants(outDir, {slug, variants, onLog})` + the CLI + `node variants.mjs <out dir>`, reading `<out>/../video.manifest.json`, in the heavy slot), and their two lines in + `umtool/report-to-video/package.json` exports (`./clip-audio`, `./variants`). +- `lib/report/knobs.mjs` checks every knob itself and probes the renderer's validators (`normalizeClaim`, + `validateFactcheck`, `validateChrome` markers) once: a validator that refuses a knob is handed the value without + it (`claimsForRenderer`, `chromeForRenderer`); one that accepts it gets the whole value. After K1 merges the probes + are true and those helpers pass values through unchanged. +- The claim knobs' limits here (hold 0.5–10, count 1–99, label ≤ 20, `at` inside `start`–`end`) and the stamp's + (scale 0.5–2, motion slam|pop|fade|none, opacity 0.3–1, stampLabel ≤ 24) are the plan's; if K1's differ, K1's + validators also run after the merge and the stricter rule refuses. + +## Files + +- `umtool/lib/report/knobs.mjs` (+ `knobs.test.mjs`), `knobsCli.mjs` (+ `knobsCli.test.mjs`), `variantsView.mjs`, + `caller.ts`; `manifest.mjs` (`updateClaimKnobs`, `updateDeckMarkers`, `updateVariants`, `normalizeMarkers`, + `updateClip` audio and the `claim.at` window rule, `updateOnscreen` knob carry, knob-aware validation); + `clipEditor.mjs` (ops `claim`, `audio`; the view's `claim`, `stampsOn`, `audio`, `knobs`), `clipEditorTypes.ts`; + `driver.mjs` (`variantsSteps`). +- Routes: `app/api/report/variants/route.ts` (new); `chrome`, `render`, `deliver`, `timeline`, `clip-editor`, + `still`, `chrome/preview` and the guard on every write route above. +- UI: `components/projects/review/ClipKnobs.tsx` (Count & stamp, Audio) in `ClipEditor.tsx`; + `components/projects/MarkersEditor.tsx` in `OnscreenSection.tsx`; `StructureEditors.tsx` (FactcheckEditor); + `components/projects/report/VariantsPanel.tsx` in `DeliverTab.tsx`. +- CLI: `umtool/bin/umtool.mjs` (`set`, `look`, `variants`, `show`'s knobs). +- e2e: `e2e/knobs.spec.ts`, `e2e/fixtures/knobs-fixture.mjs`, `e2e/fixtures/variants.e2e.mjs` + (`E2E_UMTOOL_VARIANTS_SCRIPT` in `playwright.config.ts`). +- Docs: `umtool/docs/knobs.md` (new); pointers in `notes.md`, `report-video.md`, `cli.md`, `AGENTS.md`. diff --git a/umtool/docs/cli.md b/umtool/docs/cli.md @@ -23,6 +23,9 @@ Inbox cannot disagree about what is wrong with one. | `inbox [--all] [--json]` | the decisions grouped and ranked by piece (`a:<site>/<report>`, `p:<project>`): Your call, Review, Blocking, Notes, Open, Ready to finish, Quiet — one card per piece and kind, and how many sit hidden on parked or done pieces (`--all` lists them). Every decision, songs' and articles' included; runs `bin/inbox.ts` through tsx | | `folders [--json]` · `kinds [--json]` | the tree, the registry | | `window <project> <clip> [--start S] [--end E] [--lock] [--lock-end] [--no-lock-end] [--note …]` | edit a window | +| `set <project> <clip> key=value …` | a clip's **knobs**: `claim.at` `claim.hold` `claim.stamp` `claim.count` `claim.label` `audio.offset` `audio.gain` `audio.fadeIn` `audio.fadeOut`; `key=` clears one ([knobs.md](knobs.md)) | +| `look <project> key=value …` | the cut's **knobs**: `factcheck.stamp.*`, `factcheck.verdicts.<V>.stampLabel\|label\|color`, `deck.markers=<json>`, `deck.markerLayout`, `variants=<json>`, and the look's keys ([knobs.md](knobs.md)) | +| `variants <project> [--take <t>] [--list] [--json]` | **Make variants**: the encode ladder of the build (or of a take's); `--list` what was made and the build's sync report, each clip's lag (past a frame flagged) ([knobs.md](knobs.md)) | | `build <project> [--preset preview\|fast\|final] [--only ID]` | **prints** the chain | | `build <project> --run [--url URL] [--replace] [--preset P] [--only ID] [--skip-fetch]` | **runs** it as the app's build job (POST `/api/report/build` on `--url`, else `UMTOOL_URL`, else `http://localhost:3050`), prints its log as it grows, **Ctrl-C** cancels the job (twice leaves it running); `--replace` stamps a deliverable newer than the manifest aside; exit 1 unless the job is done (release 36) | | `index [--rebuild] [--prune] [--since MS] [--json]` | the cache | @@ -59,7 +62,8 @@ projects answering to one name is reported, never resolved by picking one. `UMTOOL_CACHE_DIR`, `UMTOOL_MEDIA_DIR`, `UMTOOL_PHRASE_CANDIDATES` (the phrase finder's suggestion files) — which is how it is tested against the e2e fixture (which also sets `E2E_UMTOOL_MONTAGE_STYLES`, the montage styles module `take`/`takes` read in place of -`report-to-video/montage-styles.mjs`). The path defaults +`report-to-video/montage-styles.mjs`, and `E2E_UMTOOL_VARIANTS_SCRIPT`, the encoder `variants` and Make variants +run in place of `report-to-video/variants.mjs`). The path defaults (`lib/paths.mjs`, `song/paths.mjs`): | Variable | Default | diff --git a/umtool/docs/knobs.md b/umtool/docs/knobs.md @@ -0,0 +1,61 @@ +# Knobs: every setting of a report video, by hand or by an agent + +Each knob below is a field or a button in umtool **and** a `umtool` command an agent runs, and both go through the +same writer (`lib/report/manifest.mjs`), checked by the same rules (`lib/report/knobs.mjs`, then the renderer's own +validators). An absent key is the default: the video renders as it did before the knob existed. A knob set to its +default is removed, never written. + +Every manifest-write route takes the app's page (no `Authorization` header) or an agent's +`Authorization: Bearer <umtool's WORKER_TOKEN>`; any other header is a 401. Each write carries the manifest's +token (`GET` the route first, or let the CLI read it from the file): a write over a newer manifest is a 409, never +a silent overwrite. On a generated manifest (`generatedBy`) every knob change is also an `edit` note for the agent +that generates it ([notes.md](notes.md)). + +## A clip + +| Knob | In umtool | From a terminal | Route | +|---|---|---|---| +| `claim.at` — the SOURCE second the stamp lands and the tally steps; inside the clip's window | clip editor, **Count & stamp**: **Set at playhead** (Shift+S) | `umtool set <p> <clip> claim.at=12.4` | `POST /api/report/clip-editor {op: "claim", clip, knobs: {at}}` | +| `claim.hold` — seconds the stamp stays (0.5–10; default the cut's `factcheck.stamp.seconds`) | Count & stamp, **hold** | `claim.hold=4` | same | +| `claim.stamp` — `false`: the claim counts, no stamp is drawn | Count & stamp, **draw the stamp** | `claim.stamp=false` | same | +| `claim.count` — how much the tally steps (1–99; default 1) | Count & stamp, **count** | `claim.count=2` | same | +| `claim.label` — this stamp's text (≤ 20; default the verdict's stamp word) | Count & stamp, **label** | `claim.label="2 SEIZURES"` | same | +| `audio.offset` — ms, + = the sound later (−2000…2000) | clip editor, **Audio**: **sync**, the ±10/±40 nudges, **listen** (the 3 s around the playhead) | `umtool set <p> <clip> audio.offset=-40` | `POST /api/report/clip-editor {op: "audio", clip, audio: {offset}}` | +| `audio.gain` — dB (−20…20) | Audio, **gain** | `audio.gain=-3` | same | +| `audio.fadeIn`, `audio.fadeOut` — seconds (0–5) | Audio, **fade in / fade out** | `audio.fadeIn=0.3` | same | + +`key=` (nothing after the `=`) clears a knob; in umtool, **Clear** beside a field (Audio: **Clear all**). A +claim's knobs are read from the clip that **stamps** it — the last clip carrying the claim id; the box on any other +clip says which one that is, and `umtool set` prints a NOTE. A window save that would leave `claim.at` outside the +clip's window is refused: widen the window, or clear `claim.at`. The On-screen table's claim column edits the +claim's id and verdict and keeps its knobs while the id stays the same. + +## The cut + +| Knob | In umtool | From a terminal | Route | +|---|---|---|---| +| `render.chrome.factcheck.stamp.scale` (0.5–2), `.motion` (`slam` `pop` `fade` `none`), `.opacity` (0.3–1) | Structure, **fact-check labels**: scale, motion, opacity | `umtool look <p> factcheck.stamp.scale=1.3 factcheck.stamp.motion=pop` | `POST /api/report/timeline {op: "factcheck", factcheck}` | +| `render.chrome.factcheck.verdicts.<V>.stampLabel` — the stamp's word (singular, `SEIZURE`) beside `label` (the tally's, `SEIZURES`) | fact-check labels, the third column | `factcheck.verdicts.CONTRADICTED.stampLabel=SEIZURE` | same | +| `render.chrome.deck.markers[]` — `{after, label ≤ 24, color?, align?}`, at most 12; `align` `auto` `left` `right` `center` | On-screen, **markers**: add, the clip picker, label, colour, align, ↑ ↓, remove | `umtool look <p> deck.markers='[{"after":"c03","label":"Rescue","align":"right"}]'` | `PUT /api/report/chrome {project, token, markers}` | +| `render.chrome.deck.markerLayout` — `stagger` or `truncate` when labels crowd (default: stagger only when a label would truncate) | markers, **layout** | `deck.markerLayout=truncate` | `PUT /api/report/chrome {project, token, markerLayout}` | +| `render.variants` — the ladder **Make variants** encodes: `{name, height?, crf?, maxMiB?}`; `master` is the build itself | Deliver, **Variants and sync**: Edit, Save ladder, Use the default | `umtool look <p> variants='[{"name":"master"},{"name":"720p","height":720,"crf":23}]'` | `PUT /api/report/render {project, token, variants}` | + +The default ladder: `master`, `1080p` (crf 22), `720p` (crf 23), `fit24` (at most 24 MiB). `umtool look` also sets +the look's keys (`transition=0.3`, …: [report-video.md](report-video.md#the-look-captions-loudness-shorts-release-36)). + +## Make variants, and the sync report + +| | In umtool | From a terminal | Route | +|---|---|---|---| +| encode the ladder of the build (or of a take's) | Deliver, **Make variants** (one job; the encoder takes the heavy slot) | `umtool variants <p> [--take <t>]` | `POST /api/report/deliver {action: "variants", take?}` | +| what was made: name, frame, size, bitrate, a link | Deliver, the list | `umtool variants <p> --list [--json]` | `GET /api/report/variants?project=<p>[&take=<t>]`, a file: `&file=<name>` | +| each clip's sound against its picture (`<out>/sourced/sync.json`, written by the build); past one frame flagged | Deliver, **sync**: each clip links to its Audio box | `umtool variants <p> --list` | same `GET` | + +The files: `<out>/<slug>.<name>.mp4` and `<out>/variants.json`; `<out>` is the project's `out/`, or +`takes/<t>/out/`. A flagged clip is fixed with its `audio.offset` (the sign: a clip whose sound is early, a +negative lag, needs a positive offset), then a build. + +## Reading them back + +`umtool show <p>` prints a **knobs** block — each clip's claim knobs and audio (which clip stamps), the stamp's +knobs and words, the markers and their layout, the ladder — and `umtool show <p> --json` carries it as `knobs`. diff --git a/umtool/docs/notes.md b/umtool/docs/notes.md @@ -27,6 +27,10 @@ from the working directory to the checkout. ## The agent loop +A note that asks for a different look, timing or sound is usually a **knob**: when a stamp lands and how much it +counts, a clip's sync, the markers, the encode ladder. Every knob a person sets in umtool an agent sets with +`umtool set` / `umtool look` / `umtool variants`, through the same writers ([knobs.md](knobs.md)). + 1. `umtool notes --all --open` — what is waiting. 2. `umtool notes <target>` — each open note with its anchor resolved against what is on disk now, and the **Source** line naming the file to edit. diff --git a/umtool/docs/report-video.md b/umtool/docs/report-video.md @@ -318,6 +318,9 @@ wrong place is worse than no code — so only an explicit `citeUrl` draws one. ## The on-screen deck (`render.chrome`) +Its knobs — the stamp's moment and count per clip, the stamp's look and words, the markers, a clip's sync and +level, the encode ladder — are each a field in umtool and a `umtool set` / `umtool look` command: [knobs.md](knobs.md). + Opt-in, and it **replaces** the header, the footer's progress track and the corner QR described above — a deck manifest draws none of them, because the panel carries the citation itself. The full contract (every setting, the diff --git a/umtool/e2e/fixtures/knobs-fixture.mjs b/umtool/e2e/fixtures/knobs-fixture.mjs @@ -0,0 +1,48 @@ +// What knobs.spec.ts edits (video knobs, plans/video-knobs-ui.md): +// +// knobs-fixture the clip editor's three clips (clip-editor-fixture.mjs, +// its own copy) with a claim on r002 and r003 (k1, r003 +// stamps it), a "build" in out/ (the cached window, as +// out/knobs-fixture.mp4) and the build's sync report +// (out/sourced/sync.json: r002 -469 ms, the rest in sync) +// -- the Count & stamp box, the Audio box, Make variants +// (the encoder stubbed: variants.e2e.mjs) and the Sync table +// knobs-deck-fixture the deck on (make-fixture.mjs deckManifest), two clips +// -- the Markers editor +// +// Synthetic, like every fixture. +import { copyFileSync, mkdirSync, readFileSync, writeFileSync } from "node:fs"; +import path from "node:path"; +import { makeClipEditorFixture } from "./clip-editor-fixture.mjs"; + +/** + * @param {{ reports: string, manifest: Function, deckManifest: Function, cachedWindow: string, cues: Array<[number, number, string]> }} o + */ +export function makeKnobsFixture({ reports, manifest, deckManifest, cachedWindow, cues }) { + const { dir } = makeClipEditorFixture({ reports, manifest, cachedWindow, cues, name: "knobs-fixture", title: "The Knobs Fixture" }); + const file = path.join(dir, "video.manifest.json"); + const m = JSON.parse(readFileSync(file, "utf8")); + for (const e of m.timeline) if (e.id === "r002" || e.id === "r003") e.claim = { id: "k1", verdict: "CONTRADICTED" }; + writeFileSync(file, JSON.stringify(m, null, 2) + "\n"); + mkdirSync(path.join(dir, "out", "sourced"), { recursive: true }); + copyFileSync(cachedWindow, path.join(dir, "out", "knobs-fixture.mp4")); + writeFileSync( + path.join(dir, "out", "sourced", "sync.json"), + JSON.stringify({ fps: 15, items: [{ id: "r001", start: 0, lagMs: 0, peak: 0.92 }, { id: "r002", start: 2.1, lagMs: -469, peak: 0.81 }, { id: "r003", start: 4.2, lagMs: 12, peak: 0.88 }] }, null, 2) + "\n", + ); + + const deckDir = path.join(reports, "knobs-deck-fixture"); + mkdirSync(deckDir, { recursive: true }); + writeFileSync( + path.join(deckDir, "video.manifest.json"), + JSON.stringify( + deckManifest("knobs-deck-fixture", "The Knobs Deck Fixture", [ + { type: "clip", id: "c01", video: "vid1", start: 3.0, end: 6.0, cite: 3, section: 0, lock: true, quote: "and because" }, + { type: "clip", id: "c02", video: "vid1", start: 9.0, end: 12.0, cite: 9, section: 0, lock: true, quote: "another whole sentence" }, + ]), + null, + 2, + ) + "\n", + ); + return { dir, deckDir }; +} diff --git a/umtool/e2e/fixtures/make-fixture.mjs b/umtool/e2e/fixtures/make-fixture.mjs @@ -38,6 +38,7 @@ import { makeBoardFixture, makeResearchFixture } from "./research-fixture.mjs"; import { makeRunTraceFixture } from "./run-trace-fixture.mjs"; import { makeClipsSuggestFixture } from "./clips-suggest-fixture.mjs"; import { makeVideoAssistFixture } from "./video-assist-fixture.mjs"; +import { makeKnobsFixture } from "./knobs-fixture.mjs"; const CODE = path.resolve(path.dirname(new URL(import.meta.url).pathname), "..", "..", "song"); const dest = path.resolve(process.argv[2] ?? path.join(process.cwd(), ".e2e-song")); @@ -1822,6 +1823,8 @@ makeYoutubeFixture({ reports, manifest, cachedWindow: path.join(REPORT, "out", " makeClipsSuggestFixture({ reports, manifest, cachedWindow: path.join(REPORT, "out", "clips-raw", "vid1_0.00-9.00.mp4"), cues: CUES.vid1 }); // Release 38 lane E: the video assistant's Ask box, Apply and Dismiss on the Look panel (video-assist.spec.ts). makeVideoAssistFixture({ reports, manifest, cachedWindow: path.join(REPORT, "out", "clips-raw", "vid1_0.00-9.00.mp4"), cues: CUES.vid1 }); +// Video knobs (plans/video-knobs-ui.md): Count & stamp, Audio, Make variants, Sync and the Markers editor (knobs.spec.ts). +makeKnobsFixture({ reports, manifest, deckManifest, cachedWindow: path.join(REPORT, "out", "clips-raw", "vid1_0.00-9.00.mp4"), cues: CUES.vid1 }); // TWO MORE cached windows for vid1, and they are the regression rather than // decoration. diff --git a/umtool/e2e/knobs.spec.ts b/umtool/e2e/knobs.spec.ts @@ -0,0 +1,160 @@ +import { test, expect } from "@playwright/test"; +import { existsSync, readFileSync } from "node:fs"; +import path from "node:path"; +import { fileURLToPath } from "node:url"; +import * as urls from "./urls"; + +// --------------------------------------------------------------------------- +// The video knobs (plans/video-knobs-ui.md): +// - the clip editor's Count & stamp box: Set at playhead (and Shift+S) writes +// claim.at, count / label / stamp on-off write and Clear removes; a clip +// that carries the claim but does not stamp it says where it stamps +// - the Audio box: a sync nudge, the gain, Clear all +// - an agent's token on a manifest-write route: right one writes, a wrong one is 401 +// - the On-screen Markers editor: add, label, colour, align, re-order, the +// layout -> render.chrome.deck.markers / markerLayout +// - Deliver's Make variants (the encoder stubbed: e2e/fixtures/variants.e2e.mjs) +// and the Sync table, its flagged clip linking to that clip's Audio box +// Fixture: e2e/fixtures/knobs-fixture.mjs. +// --------------------------------------------------------------------------- + +const HERE = path.dirname(fileURLToPath(import.meta.url)); +const FIXTURE = path.join(HERE, "..", ".e2e-song"); +const PROJECT = "reports/knobs-fixture"; +const DIR = path.join(FIXTURE, "reports", "knobs-fixture"); +const DECK_PROJECT = "reports/knobs-deck-fixture"; +const DECK_DIR = path.join(FIXTURE, "reports", "knobs-deck-fixture"); + +type Entry = { id: string; type: string; claim?: Record<string, unknown>; audio?: Record<string, number> }; +type Manifest = { render: Record<string, unknown> & { chrome?: { deck?: Record<string, unknown> }; variants?: unknown }; timeline: Entry[] }; +const readManifest = (dir = DIR): Manifest => JSON.parse(readFileSync(path.join(dir, "video.manifest.json"), "utf8")); +const entry = (id: string, dir = DIR) => readManifest(dir).timeline.find((e) => e.id === id) ?? null; + +test("Count & stamp and Audio in the clip editor; an agent's token on the route", async ({ page, request }) => { + test.setTimeout(150_000); + await page.setViewportSize({ width: 1366, height: 900 }); + await page.goto(urls.clipEditorHref(PROJECT, { clip: "r003", mode: "edit" })); + await expect(page.locator("[data-clip-editor]")).toHaveAttribute("data-clip-editor", "r003"); + await expect(page.locator("[data-editor-player]")).not.toHaveAttribute("data-editor-player", "looking", { timeout: 15_000 }); + + const box = page.locator('[data-count-stamp="r003"]'); + await expect(box).toBeVisible(); + // The defaults show where a key is absent: the cut's stamp seconds, a count of 1. + await expect(box.locator('[data-knob="hold"]')).toHaveAttribute("placeholder", "3"); + await expect(box.locator('[data-knob="count"]')).toHaveAttribute("placeholder", "1"); + await expect(box.locator("[data-stamps-on]")).toHaveCount(0); + + // A word puts the playhead there; Set at playhead writes the source second. + await page.locator('[data-word-t="7.2"]').click(); + await box.locator("[data-claim-at-playhead]").click(); + await expect.poll(() => entry("r003")?.claim?.at).toBe(7.2); + // Shift+S does the same (S alone is Split here). + await page.locator('[data-word-t="7.8"]').click(); + await page.keyboard.press("Shift+S"); + await expect.poll(() => entry("r003")?.claim?.at).toBe(7.8); + expect(readManifest().timeline.filter((e) => e.type === "clip").map((e) => e.id)).toEqual(["r001", "r002", "r003"]); + + const count = box.locator('[data-knob="count"]'); + await expect(async () => { + await count.fill("2"); + await count.press("Enter"); + await expect.poll(() => entry("r003")?.claim?.count, { timeout: 2000 }).toBe(2); + }).toPass({ timeout: 15_000 }); + const label = box.locator('[data-knob="label"]'); + await label.fill("2 SEIZURES"); + await label.press("Enter"); + await expect.poll(() => entry("r003")?.claim?.label).toBe("2 SEIZURES"); + await box.locator('[data-knob="stamp"]').uncheck(); + await expect.poll(() => entry("r003")?.claim?.stamp).toBe(false); + await box.locator('[data-knob-clear="count"]').click(); + await expect.poll(() => entry("r003")?.claim).toEqual({ id: "k1", verdict: "CONTRADICTED", at: 7.8, stamp: false, label: "2 SEIZURES" }); + + // Audio: a nudge, the gain, Clear all. + const audio = page.locator('[data-audio-box="r003"]'); + await audio.locator('[data-audio-nudge="-40"]').click(); + await expect.poll(() => entry("r003")?.audio).toEqual({ offset: -40 }); + const gain = audio.locator('[data-knob="gain"]'); + await gain.fill("-3"); + await gain.press("Enter"); + await expect.poll(() => entry("r003")?.audio).toEqual({ offset: -40, gain: -3 }); + await audio.locator("[data-audio-clear-all]").click(); + await expect.poll(() => entry("r003")?.audio).toBeUndefined(); + + // r002 carries the claim but r003 stamps it: the box says so; r001 has none. + await page.locator('[data-editor-row="r002"]').click(); + await expect(page.locator('[data-count-stamp="r002"] [data-stamps-on="r003"]')).toBeVisible(); + await page.locator('[data-editor-row="r001"]').click(); + await expect(page.locator("[data-count-stamp]")).toHaveCount(0); + + // An agent's token writes through the same route; a wrong one is refused. + const view = await (await request.get(`/api/report/clip-editor?project=${encodeURIComponent(PROJECT)}`)).json(); + const wrong = await request.post("/api/report/clip-editor", { headers: { authorization: "Bearer nope" }, data: { project: PROJECT, op: "claim", clip: "r003", knobs: { count: 3 }, token: view.token } }); + expect(wrong.status()).toBe(401); + const right = await request.post("/api/report/clip-editor", { headers: { authorization: "Bearer umtool-e2e-token" }, data: { project: PROJECT, op: "claim", clip: "r003", knobs: { count: 3 }, token: view.token } }); + expect(right.ok(), await right.text()).toBe(true); + expect(entry("r003")?.claim?.count).toBe(3); +}); + +test("the Markers editor: add, label, colour, align, re-order, layout", async ({ page }) => { + test.setTimeout(120_000); + test.skip(!readManifest(DECK_DIR).render.fontRegular, "the deck refuses to draw without render.fontRegular/fontBold, and make-fixture.mjs found no font on this machine"); + await page.goto(urls.section(DECK_PROJECT, "onscreen")); + const ed = page.getByTestId("markers-editor"); + await expect(ed).toBeVisible({ timeout: 30_000 }); + await ed.getByTestId("markers-add").click(); + await ed.getByTestId("markers-add").click(); + await ed.getByTestId("marker-after-0").selectOption("c01"); + await ed.getByTestId("marker-label-0").fill("Arrival"); + await ed.getByTestId("marker-align-0").selectOption("left"); + await ed.getByTestId("marker-after-1").selectOption("c02"); + await ed.getByTestId("marker-label-1").fill("Rescue"); + await ed.getByTestId("marker-color-1").fill("accent"); + await ed.getByTestId("marker-down-0").click(); + await ed.getByTestId("markers-layout").selectOption("truncate"); + await ed.getByTestId("markers-save").click(); + await expect.poll(() => readManifest(DECK_DIR).render.chrome?.deck?.markers).toEqual([ + { after: "c02", label: "Rescue", color: "accent" }, + { after: "c01", label: "Arrival", align: "left" }, + ]); + expect(readManifest(DECK_DIR).render.chrome?.deck?.markerLayout).toBe("truncate"); + + await page.reload(); + await expect(page.getByTestId("marker-label-0")).toHaveValue("Rescue", { timeout: 30_000 }); + await page.getByTestId("marker-remove-0").click(); + await page.getByTestId("markers-layout").selectOption(""); + await page.getByTestId("markers-save").click(); + await expect.poll(() => readManifest(DECK_DIR).render.chrome?.deck?.markers).toEqual([{ after: "c01", label: "Arrival", align: "left" }]); + expect(readManifest(DECK_DIR).render.chrome?.deck && "markerLayout" in readManifest(DECK_DIR).render.chrome!.deck!).toBe(false); +}); + +test("Deliver: Make variants (stub encoder) lists them; Sync flags a clip and links to its Audio box", async ({ page, request }) => { + test.setTimeout(120_000); + await page.goto(urls.section(PROJECT, "deliver")); + const panel = page.locator("[data-variants-panel]"); + await expect(panel).toBeVisible({ timeout: 30_000 }); + await expect(panel.locator('[data-variants-ladder="default"]')).toBeVisible(); + + // The ladder is a knob: one rung less, saved to render.variants. + await panel.locator("[data-variants-edit]").click(); + await panel.locator('[data-variant-field="3:name"]').locator("xpath=../..").getByRole("button", { name: "remove" }).click(); + await panel.locator("[data-variants-save]").click(); + await expect.poll(() => readManifest().render.variants).toEqual([{ name: "master" }, { name: "1080p", height: 1080, crf: 22 }, { name: "720p", height: 720, crf: 23 }]); + + await panel.locator("[data-variants-make]").click(); + await expect(panel.locator('[data-variants-job="done"]')).toBeVisible({ timeout: 60_000 }); + await expect(panel.locator("[data-variant]")).toHaveCount(3); + expect(existsSync(path.join(DIR, "out", "knobs-fixture.720p.mp4"))).toBe(true); + const href = await panel.locator('[data-variant-link="720p"]').getAttribute("href"); + const got = await request.get(href!); + expect(got.ok()).toBe(true); + expect(got.headers()["content-type"]).toBe("video/mp4"); + + // Sync: r002's sound is 469 ms early, flagged; its link opens its Audio box. + const row = panel.locator('[data-sync-row="r002"]'); + await expect(row).toHaveAttribute("data-sync-flagged", ""); + await expect(panel.locator('[data-sync-row="r001"]')).not.toHaveAttribute("data-sync-flagged", ""); + await expect(row.locator("[data-sync-link]")).toHaveAttribute("href", `${urls.clipEditorHref(PROJECT, { clip: "r002", mode: "edit" })}#clip-audio`); + await row.locator("[data-sync-link]").click(); + await expect(page.locator("[data-clip-editor]")).toHaveAttribute("data-clip-editor", "r002", { timeout: 30_000 }); + await expect(page.locator('[data-audio-box="r002"]')).toBeVisible(); +}); diff --git a/umtool/playwright.config.ts b/umtool/playwright.config.ts @@ -24,6 +24,9 @@ import { portFor } from "yt-dlp-transcript-common/lib/ports.mjs"; // worker's load of this config does not check again // E2E_UMTOOL_MONTAGE_STYLES set below on the app server: the montage styles // module the take maker reads (release 33) +// E2E_UMTOOL_VARIANTS_SCRIPT set below on the app server: the variants +// encoder Make variants runs (video knobs; +// lib/report/driver.mjs variantsSteps), stubbed // The ports are common/lib/ports.mjs's (offset per worktree by // scripts/worktree.mjs), not test-only, and keep their names. const PORT = portFor("UMTOOL_E2E_PORT"); @@ -164,6 +167,9 @@ export default defineConfig({ // report-to-video/montage-styles.mjs's shape, so takes.spec makes a take // with a style whatever the real styles do. Read by lib/report/takeMaker.mjs. `E2E_UMTOOL_MONTAGE_STYLES=${path.join(path.dirname(fileURLToPath(import.meta.url)), "e2e", "fixtures", "montage-styles.e2e.mjs")} ` + + // Make variants' encoder (video knobs): a stub of report-to-video/variants.mjs's + // command line that copies bytes instead of encoding. Read by lib/report/driver.mjs. + `E2E_UMTOOL_VARIANTS_SCRIPT=${path.join(path.dirname(fileURLToPath(import.meta.url)), "e2e", "fixtures", "variants.e2e.mjs")} ` + // Where a clip window is fetched FROM, and the shared secret it is asked // with. Set here rather than in a step's env: jobView() echoes a step's // env back to the browser, and this is a token.