Archilyzer · Source

archilyzer

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

commit 9ae432d440e35a18fdef9b70fb4172fd481c8e93
parent 3baa1daef3a3794de6e37b143925f5cb0f590148
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Thu,  5 Nov 2026 11:14:27 -0500

Merge lane/post-media-wave: the post bench's attachment lanes on the take-only bench too -- one lane per video or GIF, the attachment's waveform (a flat bar for a GIF or a silent video) with draggable in/out handles that edit the bench's draft and save into the take's patch, the plays-span dashed, the clock following a dragged edge, [ ] , . and arrow nudges (operator, 5 Nov: "it seems like the visual waveform/bar clip/video adjusters are gone? They would've been useful"; "I could have sworn post bench had a draggable bar for this even without a waveform before, but nonetheless I want it added")

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

Diffstat:
Meditor/CHANGELOG.md | 1+
Mumtool/app/api/report/post-narration/route.ts | 10++++++----
Aumtool/components/projects/PostAttachmentLane.tsx | 150+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mumtool/components/projects/PostBench.tsx | 1+
Mumtool/components/projects/PostNarrationPanel.tsx | 199++++++++++++++++++++++++++++++++++++-------------------------------------------
Mumtool/docs/knobs.md | 8+++++---
Mumtool/e2e/post-items.spec.ts | 73++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
7 files changed, 326 insertions(+), 116 deletions(-)

diff --git a/editor/CHANGELOG.md b/editor/CHANGELOG.md @@ -1,6 +1,7 @@ # Changelog ## [Unreleased] +- **umtool: the post bench's attachment lanes are back on the take-only bench, and a GIF has one.** On `?inTake=<t>` (the only bench of an item a take carries and the cut does not) the bench showed a note where the lanes were, so a video's in and out could only be typed; and the lane covered the first video only. Now every video and GIF of the item has a lane under the player: its whole length as a waveform (a flat line for a GIF or a silent video, which still drags), the in and out as its two handles (never closer than 0.5 s, never past the file), the part the item plays dashed and the playhead, with the bench's clock following a moving edge so the player shows its frame. A handle moves the same draft the **in / out** fields do (they follow at once, as the plan's seconds do) and **Save** writes it -- into the take's patch on a take-only bench, the project's manifest untouched; focused, `[ ]` and `, .` nudge the in and out (Shift coarser) and `← →` the edge last moved. The read's lane (its lead dragged) and **Re-pick best** write the take there too (`/api/report/post-narration` takes `inTake` for set and fit); recording, re-takes and the mix stay on the cut's bench. umtool/docs/knobs.md. - **A reply that is only a picture is drawn as its message, and a long post on a card alone keeps large text.** A post whose words are only @mentions and links with an attachment (an "@ObviousRises" and a GIF, a reply that is a screenshot of another post) is now picture-only in a report video: its picture is drawn inside its own card where its words would be, at the card's width, with the mention drawn small as a reply-to line, never in the side slot. The GIF that showed beside Mr. Obvious's reply while he was being read now has its own beat first: shown alone in its card for its own length (an image for 2 s, between 1.5 and 4 s), then the read. The read's start moves and the take is not re-made, so word zooms, captions, slams and beeps stay on their words. The render plays the GIF over its place in the card, Play plays it in the card, and the post bench has a **picture-only** block with an auto, on or off setting for the item and for each post it answers or quotes (`umtool posts set-item <p> <item> pictureOnly=on|off|auto`, `parent.<i>.pictureOnly=`, `quoted.pictureOnly=`). `render.posts.pictureReply` sets the beat's length or turns the rule off. A long post on a card alone is now drawn at a reading size and scrolled with the read, where it used to shrink to read-follow's minimum to fit (operator, 5 Nov: "bigger text for the novel"). Posts that are not picture-only, and posts whose words fit their card, render exactly as before. - **umtool: a pause can be put in after words of an approved read, without reading it again.** A countdown read as "20 10 4 0" in one breath could only be spaced by synthesizing a new read, losing a delivery that was liked. `umtool posts reread <p> <item> --pause "20=0.45,10=0.45,4=0.45"` now cuts the picked take just after each word named (found in its word timings as a word zoom finds one: case and punctuation aside, `#2` its second time, `--target linked:0` one piece's words) and puts that much silence in (0.05–3 s), moving everything after it on -- its words, its parts and its length, so zooms, captions, slams, beeps and the read-follow stay on their words. It is a new take, picked in one undoable write; on a paused take it re-cuts from the take before (`=0` takes a pause away), `--dry-run` shows each cut and the new length, `--in-take <t>` puts it in a take's read, and a take with no word timings is refused naming `umtool posts narrate <p> <item> --words`. The post bench's Options → Re-join the read has **pause after** with Preview and Apply, on the take-only bench too. umtool/docs/cli.md, knobs.md. - **A post's @handles typed inside the message are read.** A read dropped every @handle, so "its good advice @grok don't you agree?" lost "@grok" and the lexicon's `@grok` -> "at grok" never applied. Only the run of handles a reply OPENS with (X adds those) is dropped now; a handle inside the sentence stays in the script and is said "at <handle>" (`sayHandles`), the lexicon's own spelling first. Existing takes are untouched; a re-read picks it up. 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 @@ -418,6 +418,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&apos;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&apos;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/docs/knobs.md b/umtool/docs/knobs.md @@ -662,7 +662,7 @@ its knobs are one writer, `updatePostItem` (`lib/report/manifest.mjs`), refused | `mediaLayout` — `grid`: its 2-4 images at once (one picture of the read); absent: one after another, cycling | post bench, **images** | `layout=grid` (`layout=sequence`) | same, `patch: {mediaLayout}` | | `redact` — other authors (the posts it answers, the one it quotes, a repost's original): absent, the privacy rule (blurred unless a subject or gold/grey verified); `false` shows them (judged public); `true` blurs even the verified | post bench, **other authors** | `redact=off` · `redact=on` · `redact=auto` | same, `patch: {redact}` | | `quoted.paraphrase`, `parents[i].paraphrase` — your short retelling (≤ 600 characters) of a long context post (the post it quotes, the posts it answers, nearest first): the card (render, Play, the bench, the recording page) draws it in place of that post's words, in the same style, with a small **paraphrased** label beside its date; its read counts the paraphrase's words; the author stays under the blur rule; its `text` is never touched. Absent or empty: its own words | post bench, the context block's **Paraphrase** (its words shown above it; **clear**), then **Save** | `quoted.paraphrase="He reviewed three of the videos."` · `parent.0.paraphrase="…"` (`=off`) | same, `patch: {quoted: {paraphrase}, parents: {"0": {paraphrase}}}` | -| `media[i].start`, `media[i].end` — a video's or a GIF's in and out, its own seconds (at least 0.5 s apart) | post bench, **in / out**, **In at playhead**, **Out at playhead**, **Whole** | `media.0.start=1.5 media.0.end=6` · `media.0.trim=off` | same, `patch: {media: {"0": {start, end}}}` | +| `media[i].start`, `media[i].end` — a video's or a GIF's in and out, its own seconds (at least 0.5 s apart) | post bench, **in / out**, **In at playhead**, **Out at playhead**, **Whole**; or the attachment's LANE (one per video or GIF, under the player): its whole length as a waveform (a flat line for a GIF or a silent video), the in and out its two handles (drag one, or click near it; never closer than 0.5 s, never past the file), the part the item plays dashed, the playhead; the bench's clock follows a moving edge, so the player shows its frame. Focused: `[` `]` the in, `,` `.` the out (0.05 s; Shift 0.5 s), `←` `→` the edge last moved (0.1 s; Shift 1 s). The number fields follow at once; **Save** writes them (the take's patch on `?inTake=<t>`) | `media.0.start=1.5 media.0.end=6` · `media.0.trim=off` | same, `patch: {media: {"0": {start, end}}}` | | `media[i].mute` — `true`: the video plays silent | post bench, **its sound** | `media.0.mute=on` (`=off`) | same | | `media[i].crop` — `[x, y, w, h]`, fractions of the picture: what of it is shown | post bench, **crop** (none, centre 80%, top half, bottom half) | `media.0.crop=0,0.1,1,0.8` (`=off`) | same | | `media[i].push` — an image's slow push-in (6% over its span) | post bench, **slow push-in** | `media.0.push=on` | same | @@ -700,7 +700,7 @@ the shape, the mix, recordings, parts, the best part). One writer for a post's n | `narration.off` — keep it all, play un-narrated | post bench, **narrated** | `--off` · `--on` | `patch: {off: true \| null}` | | `lead`, `tail`, `ramp`, `linger`, `wet`, `lowpassHz`, `duck`, `short` (`hold`\|`loop`), `clip` (`read`\|`full`), `attach` (`under`\|`after`), `lufs`, `rate` — this post's mix | post bench, **the mix** (`rate`: **read rate**); the read lane's voice block dragged sets `lead` | `umtool posts narrate <p> <item> lead=0.6 wet=0.25 short=loop rate=1.1 …` (`k=` back to the cut's) · `umtool posts set-item <p> <item> narration.rate=1.1` (any mix knob as `narration.<k>=`) | `patch: {…}` | | `rate` — the READ's speed, 0.8–1.5 (default 1): the voice sped up, its pitch kept (the build's `atempo`; Play's `playbackRate` with `preservesPitch`), the attachment untouched; the item's length, the muffle and the parts follow the faster read (take ÷ rate), and so does a video's out point `posts fit` chose (its `window`); one set by hand stays | post bench, **the mix**, **read rate**; the read lane says `read in <s> at <r>×` | the cut's: `umtool posts narrate <p> --cut rate=1.08` · a post's: `… <item> rate=1.1` or `posts set-item <p> <item> narration.rate=1.1` | `patch: {rate}` | -| the attachment's window — its in and out for the read; why it was chosen (`narration.window`) | post bench, the attachment lane's handles; **Re-pick best**; **Play whole attachment** | `umtool posts fit <p> --all \| <item>… [--linger s]` · `posts set-item <p> <item> fit=read[:<linger>]` | `op: "fit", linger?` · the handles: `POST /api/report/post-item {op: "set", patch: {media}}` | +| the attachment's window — its in and out for the read; why it was chosen (`narration.window`) | post bench, the attachment lane's handles (the bench's draft, then **Save**); **Re-pick best**; **Play whole attachment**; on the take-only bench too | `umtool posts fit <p> --all \| <item>… [--linger s]` · `posts set-item <p> <item> fit=read[:<linger>]` | `op: "fit", linger?, inTake?` · the handles: `POST /api/report/post-item {op: "set", patch: {media}, inTake?}` | | `render.postNarration` — the cut's mix (every key above but `attach`, and `engine`, `voice`) | the Cut tab's Options → **Reads and voices** → **The cut's narration mix** (a knob, a value, **Set for the cut**) | `umtool posts narrate <p> --cut wet=0.25 clip=full rate=1.08 …` | — | | undo the last write | post bench, **Undo last change** | `umtool timeline <p> undo` | `op: "undo"` | | the hand-made batch | — | `umtool posts narrate <p> --import` (`narration/posts/index.json`, a take's `take-<n>.parts.json`) | — | @@ -1227,7 +1227,9 @@ has the recipe. **New draft from this take** (the next free `<take>-d<n>`) and **Add items from another project** (the project, the items, by date or after/before an entry; **Preview** is `--dry-run`, then **Import into <take>**); New take has **Save as a draft**. The post bench's **edits go to: take <t> only** scopes its set-item, fx and combo writes to the take -(`--in-take`); a read for the take is still the terminal's. A clip into a take only is the take walk's **+ Add a clip to +(`--in-take`), and its lanes: an attachment's in and out (the lane's handles, saved with **Save**), the read's lead +(dragged) and **Re-pick best** (`POST /api/report/post-narration {op: "set" | "fit" | "reread", inTake}`); recording a +read, a re-take and the mix are still the cut's bench's, and a read for the take is still the terminal's. A clip into a take only is the take walk's **+ Add a clip to <take> only** (`umtool timeline <p> --take <t> insert <spec> --after <id>`). Each edit is an undo point of the take's (`takes/<t>/revisions/`). An edit that changes nothing 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"));