Archilyzer · Source

archilyzer

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

commit a4fef285a528ce8158d8fe982d027bf970fddab8
parent e4d40c3df4cab1d88799bf3b8b1591ec40179451
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Mon,  9 Nov 2026 23:40:33 -0500

umtool: the take walk's bench code retired -- ClipBench and benchData read the draft's clip only (L3 owed)

Since L3 a take's clip is never benched: its old address (/takes/<t>/clip/<id>) is the Open in draft page,
and nothing in the UI links a take walk. What could no longer be reached goes: benchData.ts's `take` option
(walkOf over a take, the take's links, trail, back, "Take walk" kind, its segment rule), the bench route's
`walkTake`, CutApp's take bench address and ClipBenchPage's `take` prop, and in ClipBench the `take` data,
every `&take=` / `take:` its routes were asked with, the take's Undo record and address, the "edits go to take"
notes, the take-no-rerender block and the take's sibling links. A take Play was on (`?take=` with from=play)
still rides Back, and the bench still says its edits go to the cut. An Undo record a take walk left in
session storage is ignored, not replayed.

Test: take-walk.spec asks the bench route for the take's clip with walkTake (now 404) and for the draft's
clip with a take named (the draft's, kind "Clip bench", Back keeping the take).

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

Diffstat:
Mumtool/app/api/report/bench/route.ts | 5+++--
Mumtool/components/projects/ClipBench.tsx | 167+++++++++++++++++++++++++------------------------------------------------------
Mumtool/components/projects/ClipBenchPage.tsx | 9+--------
Mumtool/components/projects/cutApp/CutApp.tsx | 22+++++-----------------
Mumtool/e2e/take-walk.spec.ts | 14++++++++++++++
Mumtool/lib/report/benchData.ts | 73+++++++++++++++++++++++++------------------------------------------------
6 files changed, 101 insertions(+), 189 deletions(-)

diff --git a/umtool/app/api/report/bench/route.ts b/umtool/app/api/report/bench/route.ts @@ -4,7 +4,8 @@ import { clipBenchData } from "@/lib/report/benchData"; export const dynamic = "force-dynamic"; // THE CLIP BENCH'S DATA as JSON, for Play's in-place bench (components/projects/cutApp/CutApp.tsx): -// GET ?project=<id>&clip=<id>[&take=<id>][&from=play&at=<s>][&order=cut] +// GET ?project=<id>&clip=<id>[&take=<id>][&from=play&at=<s>][&order=cut] (`take`: the take Play was on, for +// Back; the clip is always the draft's -- a take's clip is never benched, L3) // // The same function the bench's own page renders from (lib/report/benchData.ts), // so the bench inside Play and the one on its own page cannot disagree. A clip @@ -15,7 +16,7 @@ export async function GET(request: Request) { if (!project) return Response.json({ error: "no such project" }, { status: 404 }); const clip = q.get("clip") ?? ""; const search = Object.fromEntries([...q.entries()].filter(([k]) => k !== "project" && k !== "clip")); - const r = await clipBenchData(project, clip, { search, take: q.get("walkTake") || null, order: q.get("order") === "cut" ? "cut" : "walk" }); + const r = await clipBenchData(project, clip, { search, order: q.get("order") === "cut" ? "cut" : "walk" }); if (!r) return Response.json({ error: `${clip} is not a clip of the cut` }, { status: 404 }); return Response.json(r, { headers: { "cache-control": "no-store" } }); } diff --git a/umtool/components/projects/ClipBench.tsx b/umtool/components/projects/ClipBench.tsx @@ -328,37 +328,11 @@ export type ClipBenchData = { * returns -- the project's cut at this clip -- and the take that was playing, * if one was (its render does not change when this manifest does). */ - /** Opened from Play: where Back lands; the take that was playing; `editsTake`: this bench edits that take (its own timeline). */ - fromPlay?: { href: string; take: string | null; editsTake?: boolean } | null; - /** Walk → Play: the cut from this clip (the bench opened on its own, not from Play, not a take's). */ + fromPlay?: { href: string; take: string | null } | null; + /** Walk → Play: the cut from this clip (the bench opened on its own, not from Play). */ playHere?: string | null; /** The working cut's name (lib/report/workingCut.mjs): the latest whole-cut take and the edits since it. */ working?: WorkingCut; - /** - * WALKING A TAKE (/projects/<p>/takes/<take>/clip/<id>): the clip is the - * take's -- the project's manifest with the take's patch applied -- and - * every save goes into the take's patch (takes/<id>/take.json), never the - * project's manifest. Every route this bench calls is asked with `take`. - * `all`: the walk visits every fetched clip, judged or not. - */ - take?: { - id: string; - label: string; - draft: boolean; - /** take.json exists, so there is somewhere for an edit to land (a recipe-only take is read only). */ - editable: boolean; - all: boolean; - /** The Takes page, and this walk's own start (with `all` as it is). */ - takesHref: string; - walkHref: string; - /** The same clip on the walk of every clip / of the unjudged ones. */ - toggleAllHref: string; - /** Clip id -> its bench address on this take's walk (siblings link through it). */ - clipHref: Record<string, string>; - /** This clip's index in the take's timeline, and the timeline's length (the strip's moves). */ - at: number; - entries: number; - } | null; }; const hms = (t: number) => { @@ -407,8 +381,6 @@ type UndoRec = { before: Record<string, unknown>; /** The Confirm carried a moved window, so Undo puts the edges back too. */ moved: boolean; - /** Walking a take: the take the Confirm was written into. */ - take?: string | null; }; const readUndo = (): UndoRec | null => { try { @@ -555,13 +527,9 @@ export default function ClipBench({ // The project's notes: this clip's row notes, and the edit notes a save on a // generated manifest leaves (the save says so, and they are re-read). const notes = useSharedNotes({ project: data.project }); - // Walking a take: every route is asked about the TAKE's clip, and every - // save lands in the take's patch (see ClipBenchData.take). - const takeId = data.take?.id ?? null; - const tq = takeId ? `&take=${encodeURIComponent(takeId)}` : ""; - const takeBody = takeId ? { take: takeId } : {}; - // Export clip (ClipExport.tsx): this clip, clean, into the project's exports/ -- the take's clip on a take's walk. - const clipExport = useClipExport(data.project, takeId); + // The DRAFT's clip, always (L3): a take's clip is never benched -- its old address is Open in draft. + // Export clip (ClipExport.tsx): this clip, clean, into the project's exports/. + const clipExport = useClipExport(data.project, null); const [clip, setClip] = useState<Clip>(data.clip); // Export ▾'s full exchange starts from the clip's saved extent. const clipAround = useMemo(() => ({ start: clip.start, end: clip.end }), [clip.start, clip.end]); @@ -581,7 +549,7 @@ export default function ClipBench({ const after = edgesAfter(clip, sel, mode); // Where the render will actually cut the drafted selection (bench/RenderGhosts.tsx): the // desk's waveform and the phone's edge strip both draw it. - const renderEdges = useRenderEdges(data.project, clip, { from: after.start, to: after.end }, takeId, { cutStart: after.cutStart, cutEnd: after.cutEnd }); + const renderEdges = useRenderEdges(data.project, clip, { from: after.start, to: after.end }, null, { cutStart: after.cutStart, cutEnd: after.cutEnd }); /** The patch that writes a span as the handles' (no mute mark): edgesAfter, as keys. */ const edgePatch = useCallback( (span: { from: number; to: number }): WindowPatch => { @@ -759,10 +727,11 @@ export default function ClipBench({ } catch { /* nothing to clear */ } - if (u.project !== data.project || (u.take ?? null) !== takeId || (u.next !== data.clip.id && u.clip !== data.clip.id)) return; + // A record a take's walk left (`take` set, before L3) is not this bench's to undo. + if (u.project !== data.project || (u as { take?: unknown }).take || (u.next !== data.clip.id && u.clip !== data.clip.id)) return; if (Date.now() - u.at >= UNDO_MS) return; setUndo(u); - }, [data.project, data.clip.id, takeId]); + }, [data.project, data.clip.id]); useEffect(() => { if (!undo) return; const id = window.setTimeout(() => setUndo(null), Math.max(0, undo.at + UNDO_MS - Date.now())); @@ -790,10 +759,10 @@ export default function ClipBench({ // What plays (bench/benchMedia.ts): the widest cached window, on the source clock. const media = useMemo( - () => sourceWindowMedia({ project: data.project, clip: clip.id, take: takeId, win: cached }), + () => sourceWindowMedia({ project: data.project, clip: clip.id, take: null, win: cached }), // The window by its name and the version of its bytes: a refresh returning the same one is the same media. // eslint-disable-next-line react-hooks/exhaustive-deps - [data.project, clip.id, takeId, cached?.name, cached?.v, cached?.from, cached?.to], + [data.project, clip.id, cached?.name, cached?.v, cached?.from, cached?.to], ); // Read by play() at the moment it schedules, so a mark moved since the last // render is the one you hear -- without re-creating play() on every nudge. @@ -842,7 +811,7 @@ export default function ClipBench({ void (async () => { const r = await fetch( `/api/report/cues?project=${encodeURIComponent(data.project)}&clip=${encodeURIComponent(clip.id)}` + - `&from=${(view.from - peekPad).toFixed(2)}&to=${(view.to + peekPad).toFixed(2)}${tq}`, + `&from=${(view.from - peekPad).toFixed(2)}&to=${(view.to + peekPad).toFixed(2)}`, { cache: "no-store" }, ); if (!r.ok || !live) return; @@ -852,7 +821,7 @@ export default function ClipBench({ return () => { live = false; }; - }, [data.project, clip.id, view.from, view.to, peekPad, tq]); + }, [data.project, clip.id, view.from, view.to, peekPad]); // ---- playback preferences ------------------------------------------------ useEffect(() => setPlayback(readPlayback()), []); @@ -1033,7 +1002,7 @@ export default function ClipBench({ const r = await fetch("/api/report/window", { method: "PUT", headers: { "content-type": "application/json" }, - body: JSON.stringify({ project: data.project, clip: clip.id, ...takeBody, token: token.current, ...patch }), + body: JSON.stringify({ project: data.project, clip: clip.id, token: token.current, ...patch }), }); const j = (await r.json()) as Record<string, unknown>; lastSaved.current = j; @@ -1238,7 +1207,7 @@ export default function ClipBench({ // A verdict is a state change, and a thumb lands where it did not mean to. const before = (lastSaved.current?.before ?? null) as Record<string, unknown> | null; if (before) { - const rec: UndoRec = { project: data.project, clip: clip.id, next: data.next, at: Date.now(), before, moved: !!win, take: takeId }; + const rec: UndoRec = { project: data.project, clip: clip.id, next: data.next, at: Date.now(), before, moved: !!win }; try { sessionStorage.setItem(UNDO_KEY, JSON.stringify(rec)); } catch { @@ -1260,8 +1229,7 @@ export default function ClipBench({ async (u: UndoRec) => { setUndo(null); const b = u.before; - const uq = u.take ? `&take=${encodeURIComponent(u.take)}` : ""; - const r = await fetch(`/api/report/clip?project=${encodeURIComponent(u.project)}&clip=${encodeURIComponent(u.clip)}${uq}`, { + const r = await fetch(`/api/report/clip?project=${encodeURIComponent(u.project)}&clip=${encodeURIComponent(u.clip)}`, { cache: "no-store", }); if (!r.ok) { @@ -1280,11 +1248,11 @@ export default function ClipBench({ const w = await fetch("/api/report/window", { method: "PUT", headers: { "content-type": "application/json" }, - body: JSON.stringify({ project: u.project, clip: u.clip, ...(u.take ? { take: u.take } : {}), token: tok, ...patch }), + body: JSON.stringify({ project: u.project, clip: u.clip, token: tok, ...patch }), }); const j = (await w.json()) as Record<string, unknown>; if (!w.ok) { - setNote(j.stale ? `could not undo: the ${u.take ? "take" : "manifest"} changed since — reload` : `could not undo: ${String(j.error ?? w.status)}`); + setNote(j.stale ? "could not undo: the manifest changed since — reload" : `could not undo: ${String(j.error ?? w.status)}`); return; } if (wroteNotes(j)) void notes.reload(); @@ -1304,11 +1272,7 @@ export default function ClipBench({ const q = new URLSearchParams(window.location.search); q.delete("at"); const qs = q.toString(); - router.push( - u.take - ? `/projects/${u.project}/takes/${encodeURIComponent(u.take)}/clip/${encodeURIComponent(u.clip)}${qs ? `?${qs}` : ""}` - : `/projects/${u.project}/clip/${encodeURIComponent(u.clip)}${qs ? `?${qs}` : ""}`, - ); + router.push(`/projects/${u.project}/clip/${encodeURIComponent(u.clip)}${qs ? `?${qs}` : ""}`); }, // `notes.reload` is the stable part of `notes`. // eslint-disable-next-line react-hooks/exhaustive-deps @@ -1744,7 +1708,7 @@ export default function ClipBench({ const refresh = useCallback(async (): Promise<ClipBenchData | null> => { const r = await fetch( - `/api/report/clip?project=${encodeURIComponent(data.project)}&clip=${encodeURIComponent(clip.id)}${tq}`, + `/api/report/clip?project=${encodeURIComponent(data.project)}&clip=${encodeURIComponent(clip.id)}`, { cache: "no-store" }, ); if (!r.ok) return null; @@ -1787,7 +1751,6 @@ export default function ClipBench({ body: JSON.stringify({ project: data.project, clip: clip.id, - ...takeBody, padBefore: round2(pads.padBefore), padAfter: round2(pads.padAfter), ...storedAsk, @@ -1858,7 +1821,7 @@ export default function ClipBench({ const r = await fetch("/api/report/fetch", { method: "POST", headers: { "content-type": "application/json" }, - body: JSON.stringify({ project: data.project, clip: clip.id, ...takeBody, full: true }), + body: JSON.stringify({ project: data.project, clip: clip.id, full: true }), }); if (!r.ok) { const j = (await r.json()) as { error?: string }; @@ -1945,7 +1908,7 @@ export default function ClipBench({ const r = await fetch("/api/report/cut", { method: "POST", headers: { "content-type": "application/json" }, - body: JSON.stringify({ project: data.project, clip: clip.id, ...takeBody, token: token.current }), + body: JSON.stringify({ project: data.project, clip: clip.id, token: token.current }), }); const j = (await r.json()) as { ok?: boolean; @@ -2132,8 +2095,7 @@ export default function ClipBench({ const padLabelForCue = (c: Cue) => c.end > view.to ? `+${padsForCue(c).padAfter} s` : `−${padsForCue(c).padBefore} s`; - // A take's clip has no segment of the project's (ClipBenchPage passes none). - const segSrc = segment && !takeId + const segSrc = segment ? `/api/report/segment?project=${encodeURIComponent(data.project)}&clip=${encodeURIComponent(clip.id)}&v=${segmentMtime ?? 0}` : null; @@ -2177,7 +2139,7 @@ export default function ClipBench({ const ok = () => !returnState.current.busy && returnState.current.clean; if (!ok()) return; const r = await fetch( - `/api/report/clip?project=${encodeURIComponent(data.project)}&clip=${encodeURIComponent(clip.id)}${tq}`, + `/api/report/clip?project=${encodeURIComponent(data.project)}&clip=${encodeURIComponent(clip.id)}`, { cache: "no-store" }, ).catch(() => null); if (!r?.ok) return; @@ -2203,7 +2165,7 @@ export default function ClipBench({ setDraft(emptyDraft(next)); setOs(osDraftOf(next.onscreen)); } - }, [data.project, clip.id, tq]); + }, [data.project, clip.id]); const resyncRef = useRef(resync); resyncRef.current = resync; useEffect(() => { @@ -2661,19 +2623,12 @@ export default function ClipBench({ <p data-walk-quote="" className="m-0 font-serif text-[18px] leading-snug text-text"> {draft.quote.trim() ? `“${draft.quote.trim()}”` : <span className="text-muted">no quote on this entry</span>} </p> - {data.fromPlay?.take && - (data.fromPlay.editsTake ? ( - <p data-walk-take-note={data.fromPlay.take} data-walk-take-edits="take" className="m-0 text-[12.5px] leading-snug text-text-2"> - Opened from take <span className="font-mono">{data.fromPlay.take}</span>, which has its own timeline. Edits here go to the - take (<code className="font-mono">takes/{data.fromPlay.take}/take.json</code>), never the project&rsquo;s cut; Back plays - the take. - </p> - ) : ( - <p data-walk-take-note={data.fromPlay.take} className="m-0 text-[12.5px] leading-snug text-text-2"> - Opened from take <span className="font-mono">{data.fromPlay.take}</span>. Edits here go to the project&rsquo;s cut, not - to the take&rsquo;s render, so Back plays the project&rsquo;s cut. - </p> - ))} + {data.fromPlay?.take && ( + <p data-walk-take-note={data.fromPlay.take} className="m-0 text-[12.5px] leading-snug text-text-2"> + Opened from take <span className="font-mono">{data.fromPlay.take}</span>. Edits here go to the project&rsquo;s cut, not + to the take&rsquo;s render, so Back plays the project&rsquo;s cut. + </p> + )} </div> {cached && ( <EdgeStrip @@ -2770,12 +2725,12 @@ export default function ClipBench({ /** * Reject ▾ (RejectClip) on this clip: the bench's own writer for a keep in * place (its token, its state), the project's structural write for a - * removal -- and on a take's walk, a keep only (a take's timeline is a patch). + * removal. */ const rejectPanel = (className: string, opened = false) => ( <RejectClip project={data.project} - take={takeId ?? null} + take={null} hotkey={opened ? false : "digits"} control={opened ? undefined : rejectCtl} initialOpen={opened} @@ -2930,10 +2885,8 @@ export default function ClipBench({ {unsaved ? "Save and back to the cut" : "‹ Back to the cut"} </button> {data.fromPlay.take && ( - <span data-back-take={data.fromPlay.take} data-back-take-edits={data.fromPlay.editsTake ? "take" : "cut"} className="ml-2 text-[11.5px] text-muted-2"> - {data.fromPlay.editsTake - ? `edits go to take ${data.fromPlay.take}, not the project’s cut` - : <>edits go to the project&rsquo;s cut, not take {data.fromPlay.take}</>} + <span data-back-take={data.fromPlay.take} data-back-take-edits="cut" className="ml-2 text-[11.5px] text-muted-2"> + edits go to the project&rsquo;s cut, not take {data.fromPlay.take} </span> )} </>, @@ -2961,12 +2914,11 @@ export default function ClipBench({ {/* On a phone the banner is one muted line under Notes (phoneNotesHead). The wrapper only when there is a banner: an empty one would be a flex item, and a gap, on the desk. */} - {data.generatedBy && !data.take && ( + {data.generatedBy && ( <div className="max-md:hidden"> <GeneratedBanner generatedBy={data.generatedBy} /> </div> )} - {/* A take's clip is never benched from the UI now (L3: Open in draft first); `umtool window --take` edits one. */} {/* ---- where you are, where you can go, and what will be burned in ---- */} <div className="flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] max-md:contents"> {/* On a phone both counts are the place bar's `50/51` and its hairline. */} @@ -2979,7 +2931,7 @@ export default function ClipBench({ ready {data.ready} of {data.needing} needing judgement </span> {/* The working cut's name: what this bench edits, and the latest take it was made into. */} - {data.working && !data.take && <LatestLine project={data.project} working={data.working} className="max-md:hidden" />} + {data.working && <LatestLine project={data.project} working={data.working} className="max-md:hidden" />} {!data.fetched && ( <span className={cn(badgeVariants({ variant: "state", size: "sm" }), "max-md:order-[21] max-md:self-start")} data-clip-unfetched=""> not fetched yet @@ -3540,7 +3492,7 @@ export default function ClipBench({ Fetch whole source via editor </button> {/* A window known bad, evicted and fetched again: a queue step (lane/ui-simplify). */} - <RefetchButton project={data.project} clip={clip.id} take={takeId} disabled={!!busy} /> + <RefetchButton project={data.project} clip={clip.id} take={null} disabled={!!busy} /> {storedOffered && ( <StoredUrlCheckbox checked={fromStored} onChange={setFromStored} disabled={!!busy} compact /> )} @@ -3841,33 +3793,20 @@ export default function ClipBench({ nothing rendered for this clip yet </div> )} - {data.take ? ( - // The one-clip render builds the PROJECT's segment; a take is rendered whole. - <p data-take-no-rerender="" className="text-[11px] leading-snug text-[var(--color-dim)]"> - A take is rendered as a whole, from its own patch:{" "} - <Link href={data.take.takesHref} className="ink-link"> - Render on the Takes page - </Link>{" "} - or <code className="font-mono">umtool take {data.project} --id {data.take.id} --full</code>. - </p> - ) : ( - <> - <button - type="button" - data-rerender="" - className={buttonVariants({ variant: "outline", size: "sm" })} - disabled={!!busy} - onClick={() => void rerender()} - > - Re-render this clip - </button> - <p className="text-[11px] leading-snug text-[var(--color-dim)]"> - One clip, no crossfade, no chapters — it overwrites this clip&rsquo;s segment and - nothing else. The header is drawn by ffmpeg from a text file, so this is the only - place the line above can be checked rather than believed. - </p> - </> - )} + <button + type="button" + data-rerender="" + className={buttonVariants({ variant: "outline", size: "sm" })} + disabled={!!busy} + onClick={() => void rerender()} + > + Re-render this clip + </button> + <p className="text-[11px] leading-snug text-[var(--color-dim)]"> + One clip, no crossfade, no chapters — it overwrites this clip&rsquo;s segment and + nothing else. The header is drawn by ffmpeg from a text file, so this is the only + place the line above can be checked rather than believed. + </p> </div> {/* ---- lock, explained rather than labelled ---- */} @@ -3961,7 +3900,7 @@ export default function ClipBench({ {siblings.map((sb) => ( <li key={sb.id} data-sibling={sb.id} className="leading-snug"> <Link - href={data.take?.clipHref[sb.id] ?? `/projects/${data.project}/clip/${sb.id}`} + href={`/projects/${data.project}/clip/${sb.id}`} className="font-mono ink-link" > {sb.id} diff --git a/umtool/components/projects/ClipBenchPage.tsx b/umtool/components/projects/ClipBenchPage.tsx @@ -11,19 +11,12 @@ export default async function ClipBenchPage({ project, clipId, search = {}, - take = null, }: { project: ProjectRef; clipId: string; search?: Record<string, string | undefined>; - /** - * WALKING A TAKE (`/projects/<p>/takes/<take>/clip/<id>`): the clip is the - * take's -- the project's manifest with the take's patch applied - * (lib/report/walkData.mjs) -- and the bench's saves go into the take. - */ - take?: string | null; }) { - const { data, top } = await clipBenchDataOr404(project, clipId, { search, take, order: search.order === "cut" ? "cut" : "walk" }); + const { data, top } = await clipBenchDataOr404(project, clipId, { search, order: search.order === "cut" ? "cut" : "walk" }); return ( // The bench shell (P4b): its top bar here, the body -- the work, the // verdict bar, the reader -- in ClipBench, which owns their state. diff --git a/umtool/components/projects/cutApp/CutApp.tsx b/umtool/components/projects/cutApp/CutApp.tsx @@ -28,9 +28,8 @@ import type { BenchTopSpec } from "@/lib/report/benchData"; // the view is read again (router.refresh: the bench may have saved), and // Play recomposes only when the manifest's token moved. // -// A TAKE WITH ITS OWN TIMELINE is edited on its own bench (PlayCut's Edit: -// `/takes/<take>/clip/<id>?from=play`) -- in place too, the bench's data asked -// with `walkTake`, so its saves go into the take's patch and Back plays it. +// A take's clip is not benched here (L3): its old address +// (`/takes/<take>/clip/<id>`) is the Open in draft page, a navigation of its own. // --------------------------------------------------------------------------- type View = { kind: "play" } | { kind: "clip"; id: string; href: string }; @@ -47,21 +46,13 @@ const Ctx = createContext<CutAppApi | null>(null); /** Play's handle on the app: null when Play is drawn on its own (a test page, an old build). */ export const useCutApp = () => useContext(Ctx); -/** - * The clip id in a bench address of this project, or null: the cut's - * (`/clip/<id>`) or a take's (`/takes/<take>/clip/<id>`, `take` set). - */ -function benchOf(pathname: string, project: string): { id: string; take: string | null } | null { +/** The clip id in a bench address of this project (`/clip/<id>`), or null. */ +function clipOf(pathname: string, project: string): string | null { const root = `/projects/${project.split("/").map(encodeURIComponent).join("/")}/`; if (!pathname.startsWith(root)) return null; const rest = pathname.slice(root.length).split("/"); - if (rest.length === 2 && rest[0] === "clip" && rest[1]) return { id: decodeURIComponent(rest[1]), take: null }; - if (rest.length === 4 && rest[0] === "takes" && rest[1] && rest[2] === "clip" && rest[3]) { - return { id: decodeURIComponent(rest[3]), take: decodeURIComponent(rest[1]) }; - } - return null; + return rest.length === 2 && rest[0] === "clip" && rest[1] ? decodeURIComponent(rest[1]) : null; } -const clipOf = (pathname: string, project: string): string | null => benchOf(pathname, project)?.id ?? null; const isPlay = (pathname: string, project: string) => pathname === `/projects/${project.split("/").map(encodeURIComponent).join("/")}/play`; export default function CutApp({ project, playTop, children }: { project: string; playTop: React.ReactNode; children: React.ReactNode }) { @@ -92,9 +83,6 @@ export default function CutApp({ project, playTop, children }: { project: string q.set("project", project); q.set("clip", id); q.set("order", "cut"); - // A take's bench (its own timeline): the take's clip, its saves into the take's patch. - const walkTake = benchOf(u.pathname, project)?.take; - if (walkTake) q.set("walkTake", walkTake); return fetch(`/api/report/bench?${q.toString()}`, { cache: "no-store" }).then(async (r) => ({ ok: r.ok, status: r.status, body: (await r.json().catch(() => ({}))) as Bench & { error?: string } })); }, [project], diff --git a/umtool/e2e/take-walk.spec.ts b/umtool/e2e/take-walk.spec.ts @@ -58,6 +58,20 @@ test("the Takes page: the draft take and the saved version each Play and Open in await expect(page.locator('[data-take="v1"] [data-take-draft="v1"]')).toContainText("saved version — not rendered"); }); +test("the bench's data is the draft's whatever a take is named: a take's clip is not benched (its take paths are gone, E1)", async ({ request }) => { + // t01a is the take's, not the draft's: once the bench walked the take with `walkTake`; now it is a 404. + const theirs = await request.get(`/api/report/bench?project=${encodeURIComponent(PROJECT)}&clip=t01a&walkTake=${TAKE}`); + expect(theirs.status()).toBe(404); + const ours = await request.get(`/api/report/bench?project=${encodeURIComponent(PROJECT)}&clip=w01&walkTake=${TAKE}&take=${TAKE}&from=play`); + expect(ours.status()).toBe(200); + const j = (await ours.json()) as { data: { take?: unknown; fromPlay: { take: string } }; top: { kind: string } }; + expect(j.data.take).toBeUndefined(); + expect(j.top.kind).toBe("Clip bench"); + // `take` with from=play is only the take Play was on: Back keeps it, edits go to the draft. + expect(j.data.fromPlay.take).toBe(TAKE); + expect(manifestText()).toBe(masterBefore); +}); + test("the walk's old address asks to open the take in the draft; the walk's data route still reads the take", async ({ page, request }) => { await page.goto(urls.takeWalkHref(PROJECT, TAKE)); const ask = page.locator(`[data-open-draft="${TAKE}"]`); diff --git a/umtool/lib/report/benchData.ts b/umtool/lib/report/benchData.ts @@ -1,5 +1,5 @@ import { notFound } from "next/navigation"; -import { projectsHref, clipBenchHref, ingredientHref, playHref, takeClipHref, takeWalkHref, takesHref } from "@/lib/hrefs"; +import { projectsHref, clipBenchHref, ingredientHref, playHref } from "@/lib/hrefs"; import type { ClipBenchData } from "@/components/projects/ClipBench"; import type { BenchKey, BenchLink } from "@/components/projects/bench/BenchShell"; import { @@ -27,6 +27,10 @@ import type { ProjectRef } from "@/lib/project-types"; // `order: "cut"` (the bench opened inside Play): p / n step along the CUT -- // the reel strip's neighbours, every clip judged or not -- not the walk's // recording order; the walk is a different journey. +// +// The DRAFT's clips only (L3): a take's clip is never benched -- its old +// address (`…/takes/<t>/clip/<id>`) is the Open in draft page -- so there is +// no take here (the take walk's paths went with E1, 9 Nov). /** BenchTop's props, as data (the server page and the app both draw it). */ export type BenchTopSpec = { @@ -46,18 +50,18 @@ export type BenchTopSpec = { }; /** - * @returns null when the clip is not a clip of the cut (or the take) -- the page's 404 + * @returns null when the clip is not a clip of the cut -- the page's 404 */ export async function clipBenchData( project: ProjectRef, clipId: string, - { search = {}, take = null, order = "walk" }: { search?: Record<string, string | undefined>; take?: string | null; order?: "walk" | "cut" } = {}, + { search = {}, order = "walk" }: { search?: Record<string, string | undefined>; order?: "walk" | "cut" } = {}, ): Promise<{ data: ClipBenchData; top: BenchTopSpec } | null> { // `?all=1`: the walk visits every fetched clip, judged or not. const all = search.all === "1"; let walk: Awaited<ReturnType<typeof walkOf>>; try { - walk = await walkOf(project, { take, all }); + walk = await walkOf(project, { all }); } catch { return null; } @@ -95,9 +99,8 @@ export async function clipBenchData( const windows = await windowsFor(project, entry, await projectCache(project, manifest)); // The mtime rides along so a re-render busts the browser's cache: the segment // is written back to the SAME path, and without it the player would keep - // showing the cut from before the edit. A take's clip has none: the - // project's segments are the project's cut. - const seg = take ? null : await segmentFor(project, clipId); + // showing the cut from before the edit. + const seg = await segmentFor(project, clipId); const widest = windows[0] ?? null; const view = widest ? { from: widest.from, to: widest.to } @@ -176,7 +179,7 @@ export async function clipBenchData( endsSentence: entry.endsSentence ?? null, noPunctuation: !!entry.noPunctuation, sourceDuration: entry.duration ?? null, - segment: take ? null : (seg?.rel ?? entry.segment ?? null), + segment: seg?.rel ?? entry.segment ?? null, segmentMtime: seg?.mtimeMs ?? null, // What the header would say with no overrides. Shown beside the fields that // replace it, because "the archive says 2019" is the whole reason `date` @@ -200,7 +203,7 @@ export async function clipBenchData( ).length, cues: cues?.cues ?? [], siblings: siblingsOf(manifest, clipId), - // The project's manifest token, or -- walking a take -- the take's. + // The project's manifest token. token: walk.token, fetchPad: manifest.render?.fetchPad ?? 3, // The widest the fetch route will go. The BUTTON has to know it: it names @@ -225,67 +228,41 @@ export async function clipBenchData( }; // The piece this view belongs to: the article's when an article claims the project (P4a-2). - // Walking a take, Back is the take's walk (its overview), on the Takes page's side. - const back = take ? takeWalkHref(project.id, take, { all }) : await pieceHrefOfProject(project.id, { tab: "cut" }); + const back = await pieceHrefOfProject(project.id, { tab: "cut" }); // ---- opened from Play the cut ("Edit this clip") -------------------------- // // `?from=play` rides every walk link from here (p / n / Confirm's advance), // so "Back to the cut" survives walking on; `at` is only ever the clip Play // was on. Back lands on the PROJECT's cut, positioned by clip id plus the // offset into it -- never by raw cut seconds, which the edit just moved for - // everything after this clip. A take without a timeline of its own plays - // the project's cut, so its Edit lands here and its Back is the project's - // cut too, and the bench says so (`take`). A take WITH its own timeline is - // walked on its own bench (`take`: `…/takes/<take>/clip/<id>?from=play`): - // its saves go into the take's patch, and Back plays that take. + // everything after this clip. An address that names the take Play was on + // (`?take=`) keeps it on Back, and the bench says its edits go to the cut. const fromPlay = search.from === "play"; const withOrder = (h: string) => (order === "cut" ? `${h}${h.includes("?") ? "&" : "?"}order=cut` : h); - const playTake = take && fromPlay ? take : fromPlay && search.take ? search.take : null; + const playTake = fromPlay && search.take ? search.take : null; const atRaw = Number(search.at); const at = fromPlay && Number.isFinite(atRaw) && atRaw > 0 ? atRaw : 0; - const href = (id: string) => - take - ? withOrder(takeClipHref(project.id, take, id, { all, play: fromPlay ? {} : null })) - : withOrder(clipBenchHref(project.id, id, fromPlay ? { play: { take: playTake } } : {})); + const href = (id: string) => withOrder(clipBenchHref(project.id, id, fromPlay ? { play: { take: playTake } } : {})); data.walkHrefs = { prev: prev ? href(prev) : null, next: next ? href(next) : null, back, - backLabel: take ? `take ${take}` : project.name, + backLabel: project.name, }; - if (take && walk.take) { - const timeline = (manifest.timeline ?? []) as { id: string }[]; - data.take = { - id: take, - label: walk.take.label, - draft: walk.take.draft, - editable: walk.take.editable, - all, - takesHref: takesHref(project.id), - walkHref: takeWalkHref(project.id, take, { all }), - toggleAllHref: takeClipHref(project.id, take, clipId, { all: !all }), - clipHref: Object.fromEntries(data.siblings.map((sb: { id: string }) => [sb.id, takeClipHref(project.id, take, sb.id, { all, play: fromPlay ? {} : null })])), - at: timeline.findIndex((e) => e.id === clipId), - entries: timeline.length, - }; - } - // `editsTake`: this bench writes the take Play was playing (its own timeline), not the project's cut. - data.fromPlay = fromPlay ? { href: playHref(project.id, { take: playTake, clip: clipId, at }), take: playTake, editsTake: !!take } : null; + data.fromPlay = fromPlay ? { href: playHref(project.id, { take: playTake, clip: clipId, at }), take: playTake } : null; // Walk → Play (the audit's "no way back"): the cut, from this clip. - data.playHere = take || fromPlay ? null : playHref(project.id, { clip: clipId }); + data.playHere = fromPlay ? null : playHref(project.id, { clip: clipId }); // The working cut's name: the bench edits the project's manifest, the latest take is what it was made into. - data.working = take - ? null - : await readWorkingCut(project.dir).catch(() => null); + data.working = await readWorkingCut(project.dir).catch(() => null); const top: BenchTopSpec = { - trail: take ? [{ href: projectsHref(), label: "Projects" }, { href: takesHref(project.id), label: `${project.name} · takes` }] : [{ href: projectsHref(), label: "Projects" }], - back: { href: back, label: take ? `take ${take}` : project.name }, - kind: take ? "Take walk" : order === "cut" ? "Clip bench · the cut's order" : "Clip bench", + trail: [{ href: projectsHref(), label: "Projects" }], + back: { href: back, label: project.name }, + kind: order === "cut" ? "Clip bench · the cut's order" : "Clip bench", here: clipId, // The walk on a phone draws its own place bar (ClipBench). phone: "hidden", // The head's slot: Back to the cut (from Play), or Play from here. - slot: fromPlay || !take, + slot: true, pos: { index: order === "cut" ? ci + 1 : i + 1, total: order === "cut" ? cutClips.length : clips.length }, prev: prev ? { href: href(prev), label: prev, attrs: { "data-clip-nav": "prev" } } : null, next: next ? { href: href(next), label: next, attrs: { "data-clip-nav": "next" } } : null,