commit ed7b4ee170d6843cd72ea79b8f2fe9b885420c0a
parent 481b09d179b9269558e2ca9905eeed7e23c87855
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Thu, 5 Nov 2026 11:03:17 -0500
umtool: the post bench's attachment lanes on the take-only bench, one per video or GIF -- the in/out handles move the bench's draft (the number fields and the plan follow; Save writes the take's patch on ?inTake=), the bench's clock follows a moving edge, [ ] , . and the arrows nudge a focused lane; the read's lead and Re-pick best post inTake (post-narration takes set and fit in a take's scope)
The take-only bench (lane/ui-simplify) returned a note where the lanes were, so an item a take carries and the
cut does not -- whose only bench is ?inTake -- had no draggable bar; and the lane drew the first video only, its
handles writing the project's manifest with no inTake. PostAttachmentLane.tsx is one lane (Waveform over the
peaks route; a flat line that still drags for a GIF or a silent video).
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
5 files changed, 320 insertions(+), 113 deletions(-)
diff --git a/umtool/app/api/report/post-narration/route.ts b/umtool/app/api/report/post-narration/route.ts
@@ -49,7 +49,7 @@ const benchVoice = (red: { slurs?: { voice?: string } | null } | null) => (red?.
// POST {project, op: "reread", id, pause: "20=0.45,10=0.45", target?, dryRun?} SILENCE PUT IN after the words
// named (postPause.mjs); dryRun: the plan only, nothing written
// (postReread.mjs: no TTS; a new take, picked, one undo point)
-// any reread + inTake: <take> the same, scoped to the take's patch (takeScope.mjs, the CLI's
+// a reread, set or fit + inTake: <take> the same, scoped to the take's patch (takeScope.mjs, the CLI's
// --in-take); every other op refuses inTake
// POST {project, op: "undo"} the last structural write undone
@@ -153,8 +153,10 @@ export async function GET(request: Request) {
// "Edit this take only" (the bench's ?inTake=): a JSON reread naming `inTake` runs under takeScope.mjs withTakeScope --
// the take's manifest read, the new take picked in its patch, the project's manifest untouched (the CLI's `--in-take`).
-// The token is then the take's, so a client's project token is not checked. Only a reread: a TTS take is kept by a GET
-// later (unscoped), so it is made on the cut's bench.
+// The token is then the take's, so a client's project token is not checked. A reread, a set (the lanes' lead, the
+// knobs) and a fit (Re-pick best) are each one write; a TTS take is kept by a GET later (unscoped), and a recording
+// is a multipart upload, so those are made on the cut's bench.
+const TAKE_OPS = new Set(["reread", "set", "fit"]);
export async function POST(request: Request) {
if ((request.headers.get("content-type") ?? "").startsWith("multipart/form-data")) return postHere(request);
const text = await request.text();
@@ -168,7 +170,7 @@ export async function POST(request: Request) {
const again = (body: string) => new Request(request.url, { method: "POST", headers: request.headers, body });
if (!take || !parsed) return postHere(again(text));
if (!isTakeId(take)) return Response.json({ error: "inTake must be a take id" }, { status: 400 });
- if (parsed.op !== "reread") return Response.json({ error: `inTake: only a reread runs on a take's read here (${String(parsed.op ?? "no op")} is the cut bench's)` }, { status: 400 });
+ if (!TAKE_OPS.has(String(parsed.op))) return Response.json({ error: `inTake: only ${[...TAKE_OPS].join(", ")} run on a take here (${String(parsed.op ?? "no op")} is the cut bench's)` }, { status: 400 });
const rr = await resolveReport(String(parsed.project ?? ""));
if ("error" in rr) return Response.json({ error: rr.error }, { status: rr.status });
return withTakeScope(rr.project.dir, take, () => postHere(again(JSON.stringify({ ...parsed, token: null }))));
diff --git a/umtool/components/projects/PostAttachmentLane.tsx b/umtool/components/projects/PostAttachmentLane.tsx
@@ -0,0 +1,150 @@
+"use client";
+
+import { useMemo, useRef, useState } from "react";
+import Waveform from "@/components/Waveform";
+import { POST_MEDIA_MIN_SPAN } from "umtool-report-to-video/post-item";
+import { projectFileMedia } from "./bench/benchMedia";
+import { usePeaks } from "./bench/usePeaks";
+import type { PostPlan } from "./review/PostItemPlayer";
+
+// ---------------------------------------------------------------------------
+// ONE ATTACHMENT'S LANE on the post bench (PostNarrationPanel's lanes): a video's
+// or a GIF's whole length as a waveform -- its sound's envelope (the peaks route,
+// "use a file"), or a flat line for a GIF or a silent video -- with its in and out
+// as the waveform's two handles, the part the item plays dashed, and the playhead.
+//
+// The handles move `media[i].start` / `.end` as the number fields do (the bench's
+// draft, saved by its Save -- the take's patch on ?inTake=), never closer than
+// POST_MEDIA_MIN_SPAN and never past the file. While a handle moves, the bench's
+// clock follows the edge, so the player shows its frame. Keys, with the lane
+// focused: [ ] the in, , . the out (0.05 s; Shift 0.5 s, the clip bench's), and
+// ← → the edge last moved (0.1 s; Shift 1 s).
+// ---------------------------------------------------------------------------
+
+type Media = Record<string, unknown> & { src: string; kind: string; seconds?: number; start?: number; end?: number; audio?: boolean };
+type Edge = "start" | "end";
+type Step = PostPlan["steps"][number];
+
+const r2 = (v: number) => Math.round(v * 100) / 100;
+
+/** The trim `{start, end}` an edge at `t` makes, inside the file and at least POST_MEDIA_MIN_SPAN long. */
+export function trimEdge(sel: { from: number; to: number }, edge: Edge, t: number, len: number) {
+ const span = Math.min(POST_MEDIA_MIN_SPAN, len);
+ if (edge === "start") return { from: r2(Math.max(0, Math.min(t, sel.to - span))), to: sel.to };
+ return { from: sel.from, to: r2(Math.min(len, Math.max(t, sel.from + span))) };
+}
+
+export default function PostAttachmentLane({
+ project,
+ media: m,
+ index: i,
+ step,
+ s,
+ setS,
+ window: chosen = null,
+ onTrim,
+ children,
+}: {
+ project: string;
+ media: Media;
+ index: number;
+ /** Its step in the item's plan: where it comes in, the source seconds it plays. */
+ step: Step | null;
+ s: number;
+ setS: (s: number) => void;
+ /** The narration's chosen window (posts fit), drawn as the reference. */
+ window?: { start: number; end: number } | null;
+ /** An edge moved: the attachment's start / end (undefined: the file's own). */
+ onTrim: (i: number, patch: { start?: number; end?: number }) => void;
+ /** The lane's own buttons (Re-pick best …), beside its title. */
+ children?: React.ReactNode;
+}) {
+ const len = Number(m.seconds ?? 0) || 1;
+ const sel = { from: Number(m.start ?? 0), to: Number(m.end ?? len) };
+ const played = step ? { from: step.srcFrom ?? 0, to: (step.srcFrom ?? 0) + step.seconds } : sel;
+ // Its sound's envelope: none for a GIF or a video without sound (the bar still draws and drags).
+ const sounded = m.kind === "video" && m.audio !== false;
+ const fm = useMemo(() => projectFileMedia({ project, path: m.src, seconds: len }), [project, m.src, len]);
+ const peaks = usePeaks(sounded ? fm : { ...fm, peaksUrl: null });
+ const [last, setLast] = useState<Edge>("end");
+ const [showWhole, setShowWhole] = useState(false);
+ const whole = useRef<HTMLVideoElement | null>(null);
+
+ const apply = (next: { from: number; to: number }, edge: Edge) => {
+ onTrim(i, { start: next.from > 0.02 ? next.from : undefined, end: next.to < len - 0.02 ? next.to : undefined });
+ setLast(edge);
+ // The player shows the edge's frame: the bench's clock at it, inside the attachment's step.
+ const t = edge === "start" ? next.from : next.to;
+ if (step) setS(Math.max(0, step.at + Math.max(0, Math.min(t - next.from, Math.max(0, next.to - next.from - 0.05)))));
+ const v = whole.current;
+ if (v) {
+ try {
+ v.currentTime = t;
+ } catch {
+ /* not seekable yet */
+ }
+ }
+ };
+ const nudge = (edge: Edge, by: number) => apply(trimEdge(sel, edge, (edge === "start" ? sel.from : sel.to) + by, len), edge);
+ const playhead = step && s >= step.at ? (step.srcFrom ?? 0) + Math.min(step.seconds, s - step.at) : null;
+
+ return (
+ <div
+ data-post-lane="attachment"
+ data-post-lane-media={i}
+ data-post-lane-kind={m.kind}
+ data-post-lane-sel={`${sel.from.toFixed(2)}-${sel.to.toFixed(2)}`}
+ data-post-lane-peaks={peaks ? "on" : "none"}
+ tabIndex={0}
+ aria-label={`attachment ${i + 1}: its in and out`}
+ className="rounded outline-none focus-visible:ring-1 focus-visible:ring-[var(--color-sel)]"
+ onKeyDown={(e) => {
+ if (e.metaKey || e.ctrlKey || e.altKey) return;
+ const fine = e.shiftKey ? 0.5 : 0.05;
+ const by: Record<string, [Edge, number]> = {
+ "[": ["start", -fine], "{": ["start", -fine], "]": ["start", fine], "}": ["start", fine],
+ ",": ["end", -fine], "<": ["end", -fine], ".": ["end", fine], ">": ["end", fine],
+ ArrowLeft: [last, e.shiftKey ? -1 : -0.1], ArrowRight: [last, e.shiftKey ? 1 : 0.1],
+ };
+ const hit = by[e.key];
+ if (!hit) return;
+ e.preventDefault();
+ e.stopPropagation();
+ nudge(hit[0], hit[1]);
+ }}
+ >
+ <div className="mb-1 flex flex-wrap items-center gap-2">
+ <span className="micro">
+ attachment {i + 1} · {m.kind} · {len.toFixed(1)} s · in {sel.from.toFixed(2)} · out {sel.to.toFixed(2)} ·{" "}
+ <span data-post-lane-plays="">plays {played.from.toFixed(1)}–{played.to.toFixed(1)} s</span>
+ {!sounded ? " · no sound" : ""}
+ </span>
+ {children}
+ <button type="button" className="ink-link text-[11.5px]" onClick={() => setShowWhole((x) => !x)} data-post-play-whole={i}>
+ {showWhole ? "Hide whole attachment" : "Play whole attachment"}
+ </button>
+ </div>
+ <Waveform
+ view={{ from: 0, to: len }}
+ sel={sel}
+ cand={chosen ? { from: chosen.start, to: chosen.end } : played}
+ words={[]}
+ peaks={peaks}
+ playhead={playhead}
+ onSel={(next, _dragging, edge) => {
+ const e2: Edge = edge === "start" ? "start" : "end";
+ apply(trimEdge(sel, e2, e2 === "start" ? next.from : next.to, len), e2);
+ }}
+ onReachEdge={() => {}}
+ height={72}
+ />
+ <p className="m-0 mt-0.5 text-[11px] text-muted">
+ drag a handle (or click near it) · focused: [ ] the in, , . the out, ← → the last moved (Shift: coarser) · the dashed lines: what the item plays
+ </p>
+ {showWhole && (
+ // eslint-disable-next-line jsx-a11y/media-has-caption
+ <video ref={whole} src={fm.src ?? undefined} controls className="mt-1 max-h-48" data-post-whole-video={i} />
+ )}
+ </div>
+ );
+}
diff --git a/umtool/components/projects/PostBench.tsx b/umtool/components/projects/PostBench.tsx
@@ -409,6 +409,7 @@ export default function PostBench({
setSaved(e);
setToken(t);
}}
+ onTrim={(i, patch) => setMedia(i, patch)}
s={s}
setS={setS}
setPlaying={setPlaying}
diff --git a/umtool/components/projects/PostNarrationPanel.tsx b/umtool/components/projects/PostNarrationPanel.tsx
@@ -15,15 +15,18 @@ import { useNotes } from "@/lib/annotations/useNotes";
import { MIC_KEY, ls, useMic } from "./useMic";
import type { PostPlan } from "./review/PostItemPlayer";
import { wordZoomTimes, zoomSpan } from "umtool-report-to-video/word-zoom";
+import PostAttachmentLane from "./PostAttachmentLane";
// ---------------------------------------------------------------------------
// A POST's NARRATION ON THE BENCH (report-to-video/post-narration.mjs;
// knobs.md, "A narrated post item"), beside the post bench's player:
//
-// the lanes the attachment's whole waveform with its window (the in/out
-// handles; Re-pick best: posts fit's scan), and the read on the
+// the lanes each video's or GIF's whole waveform with its window (the in/out
+// handles, PostAttachmentLane: the bench's draft, as its number
+// fields; Re-pick best: posts fit's scan), and the read on the
// item's clock -- the take's waveform from its lead (drag it),
-// the muffle under it, the ramp back to clean
+// the muffle under it, the ramp back to clean. On the take-only
+// bench (?inTake) too, every write the take's
// record THE RECORDING SESSION (operator, 2 Nov: "I think I'll record my
// voice"): the mic, a level meter, a 3-2-1 count-in, the script as
// a teleprompter PART BY PART (Record / Stop / Redo part / Next
@@ -46,7 +49,7 @@ const fileUrl = (project: string, rel: string) => `/api/report/file?project=${en
const LABEL_KEY = "umtool.post-narration.label";
export default function PostNarrationPanel({
- project, entry, token, plan, render, onEntry, s, setS, setPlaying, prev, next, fromPlay,
+ project, entry, token, plan, render, onEntry, onTrim, s, setS, setPlaying, prev, next, fromPlay,
}: {
project: string;
entry: Entry;
@@ -55,6 +58,8 @@ export default function PostNarrationPanel({
render: Record<string, unknown>;
/** The writer's answer: the entry as it is now, and the manifest's token. */
onEntry: (e: Entry, token: string | null) => void;
+ /** An attachment lane's handle moved: its start / end in the bench's draft (undefined: the file's own). */
+ onTrim: (i: number, patch: { start?: number; end?: number }) => void;
s: number;
setS: (s: number) => void;
setPlaying: (p: boolean) => void;
@@ -280,16 +285,12 @@ export default function PostNarrationPanel({
const [deriveDraft, setDeriveDraft] = useState<{ op: string; engine: string; voice: string }>({ op: "enhance", engine: "", voice: "" });
// ---- the lanes ------------------------------------------------------------------
+ // One lane per timed attachment (a video, a GIF), its in and out the bench's draft (onTrim).
+ const timed = (entry.media ?? []).map((m, i) => ({ m, i })).filter(({ m }) => m.kind === "video" || m.kind === "gif");
const vi = (entry.media ?? []).findIndex((m) => m.kind === "video");
- const video = vi >= 0 ? entry.media![vi] : null;
- const vSecs = Number(video?.seconds ?? 0);
- const step = vi >= 0 ? plan.steps.find((st) => st.items.some((m) => m.i === vi)) ?? null : null;
- const win = step ? { from: step.srcFrom ?? 0, to: (step.srcFrom ?? 0) + step.seconds } : { from: 0, to: vSecs };
- const vMedia = useMemo(() => projectFileMedia({ project, path: video?.src ?? "", seconds: vSecs || 1 }), [project, video?.src, vSecs]);
- const vPeaks = usePeaks(video ? vMedia : { ...vMedia, peaksUrl: null });
+ const stepOf = (i: number) => plan.steps.find((st) => st.items.some((m) => m.i === i)) ?? null;
const tMedia = useMemo(() => projectFileMedia({ project, path: picked?.file ?? "", seconds: picked?.seconds || 1 }), [project, picked?.file, picked?.seconds]);
const tPeaks = usePeaks(picked ? tMedia : { ...tMedia, peaksUrl: null });
- const [showWhole, setShowWhole] = useState(false);
// The word zooms on the read (word-zoom.mjs): worked out once per change, not per frame.
const zoomSpans = useMemo(
() =>
@@ -335,14 +336,91 @@ export default function PostNarrationPanel({
</label>
);
+ // THE LANES: each attachment's window, the read on the item's clock -- on the take-only bench too (every write
+ // through the take: the trim is the bench's draft, saved with inTake; the lead and Re-pick best post inTake).
+ const lanes =
+ timed.length || (sch && picked) ? (
+ <section className="space-y-1.5 rounded border border-[var(--color-line)] bg-[var(--color-panel)] p-3" data-post-lanes="">
+ {timed.map(({ m, i }) => (
+ <PostAttachmentLane key={i} project={project} media={m} index={i} step={stepOf(i)} s={s} setS={setS} window={n.window && n.window.media === i ? n.window : null} onTrim={onTrim}>
+ {i === vi && (
+ <button type="button" className={btn} onClick={() => void post({ op: "fit" }).then((j) => j && setStatus(j.untouched ? `nothing to fit: ${j.why}` : `best part: ${j.window?.start}–${j.window?.end} s`))} data-post-repick="">
+ Re-pick best
+ </button>
+ )}
+ {i === vi && n.window?.reason && (
+ <span className="text-[11.5px] text-text-2" data-post-window-reason="">
+ chosen: {n.window.reason}
+ </span>
+ )}
+ </PostAttachmentLane>
+ ))}
+ {sch && picked && (
+ <div data-post-lane="read">
+ <div className="micro mb-1">
+ the read · {picked.file.split("/").pop()} · {picked.seconds.toFixed(1)} s{(sch.rate ?? 1) !== 1 ? ` read in ${sch.seconds.toFixed(1)} s at ${sch.rate}×` : ""} from {lead.toFixed(2)} s · muffled to {sch.voiceEnd.toFixed(1)} s, clean from {sch.rampEnd.toFixed(1)} s · {mixPhaseAt(sch, s)}
+ </div>
+ <div
+ className="relative h-16 w-full overflow-hidden rounded bg-black/30"
+ onPointerMove={(e) => {
+ if (!drag.current) return;
+ const dt = ((e.clientX - drag.current.x) / drag.current.w) * total;
+ setLeadDraft(Math.max(0, Math.min(5, Math.round((drag.current.lead + dt) * 20) / 20)));
+ }}
+ onPointerUp={() => {
+ if (!drag.current) return;
+ drag.current = null;
+ if (leadDraft !== null && leadDraft !== Number(k.lead)) void set({ lead: leadDraft }).then(() => setLeadDraft(null));
+ else setLeadDraft(null);
+ }}
+ onClick={(e) => {
+ const r = e.currentTarget.getBoundingClientRect();
+ setS(((e.clientX - r.left) / r.width) * total);
+ }}
+ >
+ {/* The muffle under the read, the ramp back to clean. */}
+ {sch.duck && <div className="absolute inset-y-0 left-0 bg-sky-500/15" style={{ width: pct(sch.voiceEnd) }} data-post-lane-muffle="" />}
+ {sch.duck && <div className="absolute inset-y-0 bg-gradient-to-r from-sky-500/15 to-transparent" style={{ left: pct(sch.voiceEnd), width: pct(sch.rampEnd - sch.voiceEnd) }} data-post-lane-ramp="" />}
+ {plan.steps.map((st, j) => (
+ <div key={j} className="absolute bottom-0 h-2 border-l border-black/50 bg-[var(--color-sel)]/40" style={{ left: pct(st.at), width: pct(st.seconds) }} title={`${st.kind} ${st.seconds.toFixed(1)} s`} />
+ ))}
+ <div
+ className="absolute inset-y-1 cursor-grab rounded bg-amber-400/20 ring-1 ring-amber-400/60"
+ style={{ left: pct(lead), width: pct(sch.seconds) }}
+ onPointerDown={(e) => {
+ e.stopPropagation();
+ (e.currentTarget.parentElement as HTMLElement).setPointerCapture(e.pointerId);
+ drag.current = { x: e.clientX, lead, w: (e.currentTarget.parentElement as HTMLElement).getBoundingClientRect().width };
+ }}
+ data-post-lane-voice=""
+ >
+ {tPeaks && (
+ <Waveform view={{ from: 0, to: picked.seconds }} sel={{ from: 0, to: 0 }} cand={{ from: 0, to: 0 }} words={[]} peaks={tPeaks} playhead={null} onSel={() => {}} onReachEdge={() => {}} height={52} />
+ )}
+ {(picked.parts ?? []).map((p) => (
+ <span key={p.n} className="absolute inset-y-0 w-px bg-amber-200/70" style={{ left: `${(p.start / picked.seconds) * 100}%` }} title={`part ${p.n}`} />
+ ))}
+ </div>
+ {/* The word zooms on the read: from the lead-in to back out (word-zoom.mjs). */}
+ {zoomSpans.map((sp) => (
+ <div key={`z${sp.i}`} className="pointer-events-none absolute inset-y-0 border-x-2 border-amber-300 bg-amber-300/10" style={{ left: pct(sp.t0), width: pct(sp.t3 - sp.t0) }} title={`word zoom ${sp.i + 1}`} data-post-lane-zoom={sp.i} />
+ ))}
+ <div className="absolute inset-y-0 w-px bg-[var(--color-signal,#e33)]" style={{ left: pct(s) }} />
+ </div>
+ </div>
+ )}
+ </section>
+ ) : null;
+
// A take-scoped bench (?inTake): a read is made for the cut here; a take's own read is \`umtool posts narrate … --in-take <t>\`.
// Pauses in the picked read (postPause.mjs) are no TTS, so they are made here too, on the take's own read.
if (inTake)
return (
<div className="space-y-2 text-[12.5px]" data-post-narration-in-take={inTake}>
<p className="m-0 text-[12px] text-muted" data-post-bench-in-take-note="">
- Narration is edited on the cut's bench (edits go to: the cut); take {inTake} keeps the reads it has.
+ Recording, re-takes and the mix are made on the cut's bench (edits go to: the cut); take {inTake} keeps the reads it has. The lanes and the pauses here edit the take.
</p>
+ {lanes}
{picked && (
<Options id="post-reread" label="Re-join the read (no TTS)" hint="pauses after words">
<PauseAfter post={post} hasWords={!!picked.words?.length} setStatus={setStatus} />
@@ -412,102 +490,7 @@ export default function PostNarrationPanel({
</div>
</section>
- {/* THE LANES: the attachment's window, the read on the item's clock. */}
- <section className="space-y-1.5 rounded border border-[var(--color-line)] bg-[var(--color-panel)] p-3" data-post-lanes="">
- {video && (
- <div data-post-lane="attachment">
- <div className="mb-1 flex flex-wrap items-center gap-2">
- <span className="micro">attachment · {vSecs.toFixed(1)} s · plays {win.from.toFixed(1)}–{win.to.toFixed(1)} s</span>
- <button type="button" className={btn} onClick={() => void post({ op: "fit" }).then((j) => j && setStatus(j.untouched ? `nothing to fit: ${j.why}` : `best part: ${j.window?.start}–${j.window?.end} s`))} data-post-repick="">
- Re-pick best
- </button>
- <button type="button" className={btn} onClick={() => setShowWhole((x) => !x)} data-post-play-whole="">
- {showWhole ? "Hide whole attachment" : "Play whole attachment"}
- </button>
- </div>
- <Waveform
- view={{ from: 0, to: vSecs || 1 }}
- sel={win}
- cand={n.window ? { from: n.window.start, to: n.window.end } : win}
- words={[]}
- peaks={vPeaks}
- playhead={step && s >= step.at ? (step.srcFrom ?? 0) + Math.min(step.seconds, s - step.at) : null}
- onSel={(next2, dragging) => {
- if (dragging) return;
- const media = { [vi]: { start: next2.from > 0.02 ? Math.round(next2.from * 100) / 100 : null, end: next2.to < vSecs - 0.02 ? Math.round(next2.to * 100) / 100 : null } };
- void fetch("/api/report/post-item", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ project, op: "set", id: entry.id, patch: { media }, token }) })
- .then((r) => r.json())
- .then((j: { entry?: Entry; token?: string; error?: string }) => (j.entry ? onEntry(j.entry, j.token ?? null) : setError(j.error ?? "not saved")));
- }}
- onReachEdge={() => {}}
- height={72}
- />
- {n.window?.reason && (
- <p className="m-0 mt-1 text-text-2" data-post-window-reason="">
- chosen: {n.window.reason}
- </p>
- )}
- {showWhole && (
- // eslint-disable-next-line jsx-a11y/media-has-caption
- <video src={fileUrl(project, video.src)} controls className="mt-1 max-h-48" data-post-whole-video="" />
- )}
- </div>
- )}
- {sch && picked && (
- <div data-post-lane="read">
- <div className="micro mb-1">
- the read · {picked.file.split("/").pop()} · {picked.seconds.toFixed(1)} s{(sch.rate ?? 1) !== 1 ? ` read in ${sch.seconds.toFixed(1)} s at ${sch.rate}×` : ""} from {lead.toFixed(2)} s · muffled to {sch.voiceEnd.toFixed(1)} s, clean from {sch.rampEnd.toFixed(1)} s · {mixPhaseAt(sch, s)}
- </div>
- <div
- className="relative h-16 w-full overflow-hidden rounded bg-black/30"
- onPointerMove={(e) => {
- if (!drag.current) return;
- const dt = ((e.clientX - drag.current.x) / drag.current.w) * total;
- setLeadDraft(Math.max(0, Math.min(5, Math.round((drag.current.lead + dt) * 20) / 20)));
- }}
- onPointerUp={() => {
- if (!drag.current) return;
- drag.current = null;
- if (leadDraft !== null && leadDraft !== Number(k.lead)) void set({ lead: leadDraft }).then(() => setLeadDraft(null));
- else setLeadDraft(null);
- }}
- onClick={(e) => {
- const r = e.currentTarget.getBoundingClientRect();
- setS(((e.clientX - r.left) / r.width) * total);
- }}
- >
- {/* The muffle under the read, the ramp back to clean. */}
- {sch.duck && <div className="absolute inset-y-0 left-0 bg-sky-500/15" style={{ width: pct(sch.voiceEnd) }} data-post-lane-muffle="" />}
- {sch.duck && <div className="absolute inset-y-0 bg-gradient-to-r from-sky-500/15 to-transparent" style={{ left: pct(sch.voiceEnd), width: pct(sch.rampEnd - sch.voiceEnd) }} data-post-lane-ramp="" />}
- {plan.steps.map((st, j) => (
- <div key={j} className="absolute bottom-0 h-2 border-l border-black/50 bg-[var(--color-sel)]/40" style={{ left: pct(st.at), width: pct(st.seconds) }} title={`${st.kind} ${st.seconds.toFixed(1)} s`} />
- ))}
- <div
- className="absolute inset-y-1 cursor-grab rounded bg-amber-400/20 ring-1 ring-amber-400/60"
- style={{ left: pct(lead), width: pct(sch.seconds) }}
- onPointerDown={(e) => {
- e.stopPropagation();
- (e.currentTarget.parentElement as HTMLElement).setPointerCapture(e.pointerId);
- drag.current = { x: e.clientX, lead, w: (e.currentTarget.parentElement as HTMLElement).getBoundingClientRect().width };
- }}
- data-post-lane-voice=""
- >
- {tPeaks && (
- <Waveform view={{ from: 0, to: picked.seconds }} sel={{ from: 0, to: 0 }} cand={{ from: 0, to: 0 }} words={[]} peaks={tPeaks} playhead={null} onSel={() => {}} onReachEdge={() => {}} height={52} />
- )}
- {(picked.parts ?? []).map((p) => (
- <span key={p.n} className="absolute inset-y-0 w-px bg-amber-200/70" style={{ left: `${(p.start / picked.seconds) * 100}%` }} title={`part ${p.n}`} />
- ))}
- </div>
- {/* The word zooms on the read: from the lead-in to back out (word-zoom.mjs). */}
- {zoomSpans.map((sp) => (
- <div key={`z${sp.i}`} className="pointer-events-none absolute inset-y-0 border-x-2 border-amber-300 bg-amber-300/10" style={{ left: pct(sp.t0), width: pct(sp.t3 - sp.t0) }} title={`word zoom ${sp.i + 1}`} data-post-lane-zoom={sp.i} />
- ))}
- <div className="absolute inset-y-0 w-px bg-[var(--color-signal,#e33)]" style={{ left: pct(s) }} />
- </div>
- </div>
- )}
- </section>
+ {lanes}
{/* THE RECORDING SESSION. */}
<section className="space-y-2 rounded border border-[var(--color-line)] bg-[var(--color-panel)] p-3" data-post-record="" data-post-record-phase={phase}>
diff --git a/umtool/e2e/post-items.spec.ts b/umtool/e2e/post-items.spec.ts
@@ -1,6 +1,7 @@
import { test, expect, type Page } from "@playwright/test";
import { execFileSync } from "node:child_process";
-import { copyFileSync, existsSync, readFileSync, rmSync } from "node:fs";
+import { createHash } from "node:crypto";
+import { copyFileSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";
import * as urls from "./urls";
@@ -214,6 +215,76 @@ test("the post bench trims the video attachment and saves it; the cut's seconds
await expect(page.locator('[data-entry="p-vid"] [data-post-seconds]')).toHaveText("4.7s");
});
+test("the take-only bench draws the attachment's lane: its out edge dragged into the take's patch, the field and the plan following, the project untouched; a GIF's lane has no sound and still drags", async ({ page }) => {
+ // A draft take of the cut (no patch yet: the project's timeline until its first edit), written here alone.
+ const takes = path.join(DIR, "takes");
+ rmSync(takes, { recursive: true, force: true });
+ const projectText = readFileSync(MANIFEST, "utf8");
+ mkdirSync(path.join(takes, "t1"), { recursive: true });
+ writeFileSync(path.join(takes, "t1", "take.json"), JSON.stringify({
+ id: "t1", group: "takes", order: 1, label: "Take one", kind: "different", summary: "", changes: [], preview: "preview.mp4", seconds: null, builtAt: null,
+ style: null, patch: null, window: null, draft: true, draftedAt: "2026-11-05T00:00:00.000Z", baseHash: createHash("sha256").update(projectText).digest("hex"),
+ }, null, 2) + "\n");
+ try {
+ await page.setViewportSize({ width: 1366, height: 1000 });
+ await page.goto(`${urls.postBenchHref(PROJECT, "p-vid")}?inTake=t1`);
+ await expect(page.locator('[data-post-bench-scope="t1"]')).toBeVisible();
+ await expect(page.locator("[data-post-narration-in-take=t1] [data-post-bench-in-take-note]")).toBeVisible();
+ const lane = page.locator('[data-post-lane="attachment"][data-post-lane-media="0"]');
+ await expect(lane).toBeVisible();
+ await expect(lane).toHaveAttribute("data-post-lane-kind", "video");
+ await expect(lane).toHaveAttribute("data-post-lane-sel", "0.00-4.00");
+ // Its sound's envelope arrives (the peaks route over the project file).
+ await expect(lane).toHaveAttribute("data-post-lane-peaks", "on");
+ // Drag the out handle from the file's end to half way: 2 s.
+ await lane.scrollIntoViewIfNeeded();
+ const box = (await lane.locator('[data-testid="waveform"]').boundingBox())!;
+ const y = box.y + box.height / 2;
+ await page.mouse.move(box.x + box.width - 2, y);
+ await page.mouse.down();
+ await page.mouse.move(box.x + box.width * 0.75, y, { steps: 4 });
+ await page.mouse.move(box.x + box.width * 0.5, y, { steps: 4 });
+ await page.mouse.up();
+ const end = async () => Number(await page.locator('[data-post-bench-end="0"]').inputValue());
+ await expect.poll(end).toBeGreaterThan(1.9);
+ expect(await end()).toBeLessThan(2.1);
+ const dragged = await end();
+ // The plan's video step plays what the trim leaves.
+ await expect(page.locator('[data-post-bench-step="video"]')).toContainText(`video ${dragged.toFixed(1)} s`);
+ // Focused, → moves the edge last moved by 0.1 s.
+ await lane.focus();
+ await page.keyboard.press("ArrowRight");
+ await expect.poll(end).toBeCloseTo(dragged + 0.1, 2);
+ await expect(lane).toHaveAttribute("data-post-lane-sel", `0.00-${(dragged + 0.1).toFixed(2)}`);
+ if (SHOTS) {
+ await lane.evaluate((el) => el.scrollIntoView({ block: "center" }));
+ await page.screenshot({ path: path.join(SHOTS, "bench.png") });
+ }
+ await page.locator("[data-post-bench-save]").click();
+ await expect(page.locator("[data-post-bench-status]")).toHaveText("saved");
+ const take = JSON.parse(readFileSync(path.join(takes, "t1", "take.json"), "utf8")) as { patch?: { timeline?: Entry[] } };
+ const vid = (take.patch?.timeline ?? []).find((e) => e.id === "p-vid");
+ expect(vid?.media?.[0]?.end).toBeCloseTo(dragged + 0.1, 2);
+ expect(vid?.media?.[0]?.start).toBeUndefined();
+ // The project's manifest byte for byte the same.
+ expect(readFileSync(MANIFEST, "utf8")).toBe(projectText);
+ } finally {
+ rmSync(takes, { recursive: true, force: true });
+ }
+ // A GIF (the combo fixture's p-c1, 2 s, no sound): the lane draws a flat line and its in handle still drags.
+ await page.goto(urls.postBenchHref("reports/post-combo-fixture", "p-c1"));
+ const gif = page.locator('[data-post-lane="attachment"][data-post-lane-media="0"]');
+ await expect(gif).toHaveAttribute("data-post-lane-kind", "gif");
+ await expect(gif).toHaveAttribute("data-post-lane-peaks", "none");
+ await gif.scrollIntoViewIfNeeded();
+ const gb = (await gif.locator('[data-testid="waveform"]').boundingBox())!;
+ await page.mouse.move(gb.x + 2, gb.y + gb.height / 2);
+ await page.mouse.down();
+ await page.mouse.move(gb.x + gb.width * 0.25, gb.y + gb.height / 2, { steps: 4 });
+ await page.mouse.up();
+ await expect.poll(async () => Number(await page.locator('[data-post-bench-start="0"]').inputValue())).toBeCloseTo(0.5, 1);
+});
+
test("the post bench paraphrases a context post: the card draws it labelled, the read counts it, the original kept", async ({ page }) => {
await page.setViewportSize({ width: 1366, height: 1000 });
await page.goto(urls.postBenchHref(PROJECT, "p-txt"));