Archilyzer · Source

archilyzer

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

commit 94c3ff96738dbd1001e5643d58063f72396d0a5f
parent 5e72b9e58f0ff0f163b3d6b4861ef008c0d3f7e6
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Mon, 19 Oct 2026 16:01:28 -0400

umtool: room at the clips' edges -- the Look panel's Tail/Head, a clip's room override (updateClip, the clip editor's room op), the strip shades the muted head and tail; the site-less seed starts with 0.4 s blur slides and room

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

Diffstat:
Mumtool/components/projects/report/LookPanel.tsx | 24+++++++++++++++++++++++-
Mumtool/components/projects/review/ClipEditor.tsx | 58++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mumtool/e2e/clip-look.spec.ts | 26++++++++++++++++++++++----
Mumtool/e2e/create.spec.ts | 2+-
Mumtool/lib/projects/scaffold.mjs | 19++++++++++++-------
Mumtool/lib/report/clipEditor.mjs | 46++++++++++++++++++++++++++++++++++++++++++++--
Mumtool/lib/report/clipEditorTypes.ts | 5+++++
Mumtool/lib/report/look.test.mjs | 2+-
Mumtool/lib/report/manifest.mjs | 21+++++++++++++++++++--
Mumtool/lib/report/reactions-r36.test.mjs | 4++--
Aumtool/lib/report/room.test.mjs | 102+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
11 files changed, 289 insertions(+), 20 deletions(-)

diff --git a/umtool/components/projects/report/LookPanel.tsx b/umtool/components/projects/report/LookPanel.tsx @@ -7,7 +7,8 @@ import { Panel } from "@/components/ui/panel"; // THE LOOK (release 36 lane C): the render keys a person sets for a cut with // no deck -- the header, the timeline footer, the QR, the crossfade's length -// and style, the loudness target, the speaker captions -- written through +// and style, the loudness target, the speaker captions, room at the clips' +// edges (release 36 lane E) -- written through // /api/report/render (lib/report/manifest.mjs updateRender, the build's own // checks). Nothing here calls a model. A deck cut keeps its own settings // (the Media tab); a montage levels with render.montage. @@ -20,6 +21,7 @@ type Look = { transitionStyle?: string; loudness?: { target: number } | null; captions?: { style: "speakers"; labels?: { host?: string | null; subject?: string | null } | null; size?: "m" | "l" } | null; + room?: { tail?: boolean; head?: boolean; minGap?: number; maxS?: number } | null; }; type View = { look: Look; deck: boolean; montage: boolean; styles: string[]; errors: string[]; token: string | null }; @@ -37,6 +39,8 @@ type Draft = { host: string; subject: string; size: "m" | "l"; + roomTail: boolean; + roomHead: boolean; }; function draftOf(l: Look): Draft { @@ -53,6 +57,8 @@ function draftOf(l: Look): Draft { host: l.captions?.labels?.host ?? "", subject: l.captions?.labels?.subject ?? "", size: l.captions?.size ?? "m", + roomTail: l.room?.tail === true, + roomHead: l.room?.head === true, }; } @@ -74,6 +80,14 @@ function patchOf(was: Look, d: Draft, view: View): Record<string, unknown> { const next = d.captions ? { style: "speakers", ...(Object.keys(labels).length ? { labels } : {}), ...(d.size === "l" ? { size: "l" } : {}) } : null; if (JSON.stringify(next) !== JSON.stringify(was.captions ?? null)) p.captions = next; } + if (!view.montage) { + // Room at the clips' edges (release 36 lane E): its settings kept as written. + const was0 = was.room ?? null; + const on = d.roomTail || d.roomHead; + const next = on ? { ...(was0 ?? {}), tail: d.roomTail, head: d.roomHead } : null; + const same = (was0?.tail === true) === d.roomTail && (was0?.head === true) === d.roomHead; + if (!same) p.room = next; + } return p; } @@ -177,6 +191,14 @@ export default function LookPanel({ project }: { project: string }) { </Field> )} </div> + {!view.montage && ( + <div className="mt-3 flex flex-wrap items-center gap-x-5 gap-y-2" data-look-room=""> + <span className="text-[12.5px] text-text-2">Room at the clips&rsquo; edges</span> + {check("roomTail", "Tail: sound to the first silence, then muted", "data-look-room-tail", Number(draft.transition) === 0)} + {check("roomHead", "Head: muted lead-in", "data-look-room-head", Number(draft.transition) === 0)} + {Number(draft.transition) === 0 && <span className="text-[12px] text-muted">no join to make room for</span>} + </div> + )} <div className="mt-3 space-y-2"> {view.deck || view.montage ? ( <p className="m-0 text-[12px] text-muted" data-look-captions-off=""> diff --git a/umtool/components/projects/review/ClipEditor.tsx b/umtool/components/projects/review/ClipEditor.tsx @@ -11,6 +11,7 @@ import type { CitedPlay } from "@/lib/clips/types"; import { edgeClock, provenanceWords, quoteBetween, roleOf, snapCut, snapPoints } from "@/lib/report/clipEditorModel.mjs"; import type { EditorClip, EditorView, Neighbourhood, Proposal, RenderTarget, Speaker, Turn } from "@/lib/report/clipEditorTypes"; import { cn } from "@/lib/utils"; +import { ROOM, roomShade } from "umtool-report-to-video/room"; import { startTakeJob } from "../NewTakePanel"; // --------------------------------------------------------------------------- @@ -263,6 +264,13 @@ export default function ClipEditor({ const setLabel = (speaker: number, label: string) => { void write({ op: "label", speaker, label: label.trim() || null }, label.trim() ? `Speaker ${speaker} is “${label.trim()}” in the captions` : `Speaker ${speaker}'s name cleared`); }; + // Room at this clip's edges (release 36 lane E): off writes `room: false`; + // on again removes the override when the cut has room, else turns both edges on. + const setRoom = (on: boolean) => { + const cutHas = !!(view.room?.tail || view.room?.head); + const room = on ? (cutHas ? null : { tail: true, head: true }) : cutHas ? false : null; + void write({ op: "room", clip: clip.id, room }, on ? "Room at this clip's edges" : "No room at this clip's edges"); + }; const setCrop = (crop: number[] | null, aspect?: number) => { void write({ op: "vertical", clip: clip.id, crop, ...(crop && aspect ? { aspect: Math.round(aspect * 10000) / 10000 } : {}) }, crop ? "Saved the short's framing" : "The short is framed from the centre"); }; @@ -361,6 +369,18 @@ export default function ClipEditor({ const prov = provenanceWords(assist); const canRestore = !!assist?.original && (assist.original.cutStart ?? assist.original.start) !== undefined; const edits = assist?.edits ?? []; + // What the strip shades as muted: the build's rule on the cut as drawn (the + // build snaps it first). The first clip has nothing before it, so no head. + const join = view.room?.join ?? 0; + const roomEdges = clip.roomEdges ?? null; + const shade = roomShade({ + cutStart: cut.cutStart, + cutEnd: cut.cutEnd, + room: roomEdges ? { tail: roomEdges.tail, head: roomEdges.head && index > 0, minGap: view.room?.minGap ?? ROOM.minGap, maxS: view.room?.maxS ?? ROOM.maxS } : null, + D: join, + words: hoodHere?.words ?? null, + cues: hoodHere?.cues ?? null, + }); const quoteNow = hoodHere ? quoteBetween({ words: hoodHere.words, cues: hoodHere.cues }, cut.cutStart, cut.cutEnd) : null; const pickRole = speakerPick !== null ? roleOf(speakers, speakerPick) : null; @@ -436,6 +456,7 @@ export default function ClipEditor({ to={viewTo} cut={cut} hood={hoodHere} + room={shade} speakers={speakers} others={clips.filter((c) => c.id !== clip.id && c.video === clip.video && c.channel === clip.channel)} playhead={playhead} @@ -498,6 +519,26 @@ export default function ClipEditor({ ))} </div> + {/* ---- room at the edges (release 36 lane E) ---------------------- */} + {join > 0 && !clip.montage && ( + <div className="flex flex-wrap items-center gap-3 text-[12px] text-text-2" data-editor-room={roomEdges ? `${roomEdges.tail ? "tail" : ""}${roomEdges.head ? " head" : ""}`.trim() : "off"}> + <label className="inline-flex items-center gap-1.5 text-text"> + <input type="checkbox" data-clip-room="" checked={!!roomEdges} disabled={busy} onChange={(e) => setRoom(e.target.checked)} /> + Room at its edges + </label> + {shade.tail && ( + <span className="num font-mono text-[11.5px] text-muted" data-room-tail={`${shade.tail[0]}-${shade.tail[1]}`}> + sound to {edgeClock(shade.tail[0])}, muted to {edgeClock(shade.tail[1])} + </span> + )} + {shade.head && ( + <span className="num font-mono text-[11.5px] text-muted" data-room-head={`${shade.head[0]}-${shade.head[1]}`}> + muted from {edgeClock(shade.head[0])} + </span> + )} + </div> + )} + {/* ---- the decisions ----------------------------------------------- */} <div className="flex flex-wrap items-center gap-2" data-editor-actions=""> <button type="button" data-rule="keep" aria-pressed={clip.ruling === "keep"} disabled={busy} onClick={() => rule(clip.ruling === "keep" ? null : "keep")} className={buttonVariants({ variant: clip.ruling === "keep" ? "pressed" : "outline", size: "md" })}> @@ -796,6 +837,7 @@ function Strip({ to, cut, hood, + room = null, speakers, others, playhead, @@ -811,6 +853,8 @@ function Strip({ to: number; cut: Cut; hood: Neighbourhood | null; + /** Room at the edges (release 36 lane E): the muted head and tail to shade. */ + room?: { head: number[] | null; tail: number[] | null } | null; speakers: Speaker[]; others: EditorClip[]; playhead: number | null; @@ -922,6 +966,20 @@ function Strip({ })} {/* the selection to add */} {selection && <span data-selection={`${selection.cutStart}-${selection.cutEnd}`} style={{ left: pct(selection.cutStart), width: width(selection.cutStart, selection.cutEnd) }} className="pointer-events-none absolute inset-y-0 border-x border-dashed border-text bg-[color-mix(in_srgb,var(--text)_10%,transparent)]" />} + {/* room at the edges: muted picture either side of the cut */} + {(["head", "tail"] as const).map((edge) => { + const sp = room?.[edge]; + if (!sp) return null; + return ( + <span + key={edge} + data-strip-room={edge} + title={edge === "tail" ? `muted ${edgeClock(sp[0])}–${edgeClock(sp[1])}: room for the join` : `muted ${edgeClock(sp[0])}–${edgeClock(sp[1])}: room for the join before it`} + style={{ left: pct(sp[0]), width: width(sp[0], sp[1]) }} + className="pointer-events-none absolute inset-y-0 border-y border-dashed border-signal bg-[color-mix(in_srgb,var(--signal)_6%,transparent)]" + /> + ); + })} {/* the cut */} <span data-strip-cut="" style={{ left: pct(cut.cutStart), width: width(cut.cutStart, cut.cutEnd) }} className="pointer-events-none absolute inset-y-0 border-y-2 border-signal bg-[color-mix(in_srgb,var(--signal)_14%,transparent)]" /> {(["in", "out"] as const).map((edge) => ( diff --git a/umtool/e2e/clip-look.spec.ts b/umtool/e2e/clip-look.spec.ts @@ -7,7 +7,9 @@ import * as urls from "./urls"; // --------------------------------------------------------------------------- // The look of a highlights cut (release 36 lane C). The Build tab's Look // panel saves the header, the QR, the join, the loudness and the speaker -// captions into the manifest (and reads them back); the clip editor's +// captions and room at the clips' edges into the manifest (and reads them +// back); the clip editor's strip shades a clip's muted tail and its own +// toggle writes `room: false`; the clip editor's // Speakers list names a voice for the captions (reactions.json); Frame the // short drags a 9:16 box on the player (the clip's vertical.crop); Make a // short runs the job (build-video --short) and the Deliver tab's Shorts list @@ -42,7 +44,10 @@ test("the look: the panel saves and reads back; a voice named; a short framed, m await page.locator("[data-look-header]").uncheck(); await page.locator("[data-look-qr]").uncheck(); await page.locator("[data-look-transition]").fill("0.5"); - await page.locator("[data-look-style]").selectOption("fadeblack"); + await page.locator("[data-look-style]").selectOption("blurslide"); + // Room at the clips' edges (release 36 lane E). + await page.locator("[data-look-room-tail]").check(); + await page.locator("[data-look-room-head]").check(); await page.locator("[data-look-loudness]").selectOption("-16"); await page.locator("[data-look-captions]").check(); await page.locator("[data-look-label-host]").fill("The host"); @@ -53,7 +58,8 @@ test("the look: the panel saves and reads back; a voice named; a short framed, m expect(r.headerHeight).toBe(0); expect(r.qr).toBe(false); expect(r.transition).toBe(0.5); - expect(r.transitionStyle).toBe("fadeblack"); + expect(r.transitionStyle).toBe("blurslide"); + expect(r.room).toEqual({ tail: true, head: true }); expect(r.loudness).toEqual({ target: -16 }); expect(r.captions).toEqual({ style: "speakers", labels: { host: "The host" }, size: "l" }); expect(r.width).toBe(640); @@ -62,7 +68,9 @@ test("the look: the panel saves and reads back; a voice named; a short framed, m await expect(page.locator("[data-look-panel]")).toHaveAttribute("data-look-panel", ""); await expect(page.locator("[data-look-header]")).not.toBeChecked(); await expect(page.locator("[data-look-qr]")).not.toBeChecked(); - await expect(page.locator("[data-look-style]")).toHaveValue("fadeblack"); + await expect(page.locator("[data-look-style]")).toHaveValue("blurslide"); + await expect(page.locator("[data-look-room-tail]")).toBeChecked(); + await expect(page.locator("[data-look-room-head]")).toBeChecked(); await expect(page.locator("[data-look-loudness]")).toHaveValue("-16"); await expect(page.locator("[data-look-captions]")).toBeChecked(); await expect(page.locator("[data-look-label-host]")).toHaveValue("The host"); @@ -75,6 +83,16 @@ test("the look: the panel saves and reads back; a voice named; a short framed, m await subject.press("Enter"); await expect.poll(() => json("reactions.json")?.speakers?.find((s: { index: number }) => s.index === 1)?.label).toBe("The narrator"); + // Room at the edges: the strip shades the clip's muted tail; the clip's own toggle writes its override. + await expect(page.locator('[data-strip-room="tail"]')).toBeVisible(); + await expect(page.locator("[data-clip-room]")).toBeChecked(); + await page.locator("[data-clip-room]").uncheck(); + await expect.poll(() => clip("r001")?.room ?? null).toBe(false); + await expect(page.locator('[data-strip-room="tail"]')).toHaveCount(0); + await page.locator("[data-clip-room]").check(); + await expect.poll(() => clip("r001")?.room === undefined).toBe(true); + await expect(page.locator('[data-strip-room="tail"]')).toBeVisible(); + await expect(page.locator("[data-editor-player]")).toHaveAttribute("data-editor-player", /^(?!looking|none)/, { timeout: 20_000 }); await page.locator("[data-frame-short]").click(); const box = page.locator("[data-crop-box]"); diff --git a/umtool/e2e/create.spec.ts b/umtool/e2e/create.spec.ts @@ -287,7 +287,7 @@ test("Find clips from the editor (release 36): mode new with the worker token sc // A channel on no site: each clip links its YouTube page at its second; the site-less look. const m = manifestOf("p36-find"); expect(m.provenance.channel).toBe("Synth Two"); - expect(m.render).toMatchObject({ headerHeight: 0, footerHeight: 0, qr: false, transition: 0.5, transitionStyle: "fadeblack", loudness: { target: -16 } }); + expect(m.render).toMatchObject({ headerHeight: 0, footerHeight: 0, qr: false, transition: 0.4, transitionStyle: "blurslide", loudness: { target: -16 }, room: { tail: true, head: true } }); for (const c of m.timeline) expect(c.citeUrl).toBe(`https://www.youtube.com/watch?v=two001&t=${c.cite}s`); const done = async (id: string) => (await (await request.get(`/api/report/clips?job=${id}`)).json()).state; await expect.poll(() => done(made.jobId), { timeout: 60_000 }).toBe("done"); diff --git a/umtool/lib/projects/scaffold.mjs b/umtool/lib/projects/scaffold.mjs @@ -17,8 +17,14 @@ export const SLUG_RE = /^[a-z0-9][a-z0-9-]*$/; export const CHANNEL_SLUG_RE = /^[A-Za-z0-9][A-Za-z0-9._-]*$/; export const SEEDS = ["chapters", "frames", "phrase", "reactions"]; -/** The render keys a site-less, one-video reactions cut starts with (release 36: the operator's choice on the first case). */ -export const SITELESS_LOOK = Object.freeze({ headerHeight: 0, footerHeight: 0, qr: false, transition: 0.5, transitionStyle: "fadeblack", loudness: Object.freeze({ target: -16 }) }); +/** + * The render keys a site-less, one-video reactions cut starts with (release 36: the operator's choice on the first + * case; lane E: 0.4 s blur slides with room at each clip's edges, so a join never eats the end of a sentence). + */ +export const SITELESS_LOOK = Object.freeze({ + headerHeight: 0, footerHeight: 0, qr: false, transition: 0.4, transitionStyle: "blurslide", + loudness: Object.freeze({ target: -16 }), room: Object.freeze({ tail: true, head: true }), +}); /** * A manifest skeleton, and deliberately an EMPTY timeline. @@ -405,12 +411,11 @@ export async function scaffoldReportVideo({ root, slug, title, from = null, site if (pass.siteLess) { // Release 36: a channel on no site — each clip links its platform page at // its second (no QR to an archive that does not have it), and the look the - // operator chose for a one-video cut: no header, no QR, fades through black, - // even loudness (render.loudness is lane C's; until its validator lands it - // is a key the build ignores). - Object.assign(doc.render, SITELESS_LOOK, { loudness: { ...SITELESS_LOOK.loudness } }); + // operator chose for a one-video cut: no header, no QR, blur slides with + // room at each clip's edges (render.room), even loudness. + Object.assign(doc.render, SITELESS_LOOK, { loudness: { ...SITELESS_LOOK.loudness }, room: { ...SITELESS_LOOK.room } }); const platform = /^youtube/i.test(pass.rec.meta?.extractor ?? "") ? "YouTube" : pass.rec.meta?.extractor ?? "its platform"; - notes.push(`no site carries ${src.channel}: each clip links ${platform}'s page at its second (citeUrl); the look: no header, no QR, ${SITELESS_LOOK.transition} s fades through black, ${SITELESS_LOOK.loudness.target} LUFS`); + notes.push(`no site carries ${src.channel}: each clip links ${platform}'s page at its second (citeUrl); the look: no header, no QR, ${SITELESS_LOOK.transition} s blur slides with room at each clip's edges, ${SITELESS_LOOK.loudness.target} LUFS`); } else { // Hard cuts: a highlights reel. doc.render.transition = 0; diff --git a/umtool/lib/report/clipEditor.mjs b/umtool/lib/report/clipEditor.mjs @@ -42,6 +42,7 @@ import { readReactions, reproposeAvailable, REPROPOSE_UNAVAILABLE, setSpeakerLab import { readShorts } from "./shorts.mjs"; import { quoteBetween, unusedProposals, wordsOf } from "./clipEditorModel.mjs"; import { WINDOW_PAD_S } from "yt-dlp-transcript-common/lib/clips/assist.mjs"; +import { clipRoom } from "umtool-report-to-video/room"; export { StaleToken, StructureRefused }; @@ -85,7 +86,8 @@ export async function readWords(dir, reactions = null) { * @typedef {{ id: string, channel: string | null, video: string, start: number, end: number, * cutStart: number | null, cutEnd: number | null, quote: string | null, title: string | null, * assist: Record<string, unknown> | null, key: string | null, ruling: "keep" | "cut" | string | null, montage: boolean, - * vertical: { crop: number[], aspect?: number } | null }} EditorClip + * vertical: { crop: number[], aspect?: number } | null, + * room: false | { tail?: boolean, head?: boolean } | null, roomEdges: { tail: boolean, head: boolean } | null }} EditorClip */ /** The page's data: the clips, the token, the clip finder's speakers and unused proposals. */ @@ -114,6 +116,10 @@ export async function clipEditorView(project) { montage: isObj(e.montage), // A short's framing (release 36): fractions of the source picture. vertical: isObj(e.vertical) && Array.isArray(e.vertical.crop) ? { crop: e.vertical.crop, ...(fin(e.vertical.aspect) ? { aspect: e.vertical.aspect } : {}) } : null, + // Room at its edges (release 36 lane E): the clip's own override as + // written, and the edges it gets with the cut's render.room. + room: e.room === false ? false : isObj(e.room) ? e.room : null, + roomEdges: roomEdgesOf(e, manifest.render), }; }); const shorts = await readShorts(project.dir, manifest); @@ -136,6 +142,32 @@ export async function clipEditorView(project) { : null, repropose: { available: reproposeAvailable, why: reproposeAvailable ? null : REPROPOSE_UNAVAILABLE }, shorts: Object.fromEntries(shorts.filter((x) => !x.gone).map((x) => [x.clip, { mtimeMs: x.mtimeMs, size: x.size, stale: x.stale }])), + room: roomViewOf(manifest.render), + }; +} + +/** A clip's room edges (room.mjs clipRoom), or null when it has none. */ +function roomEdgesOf(entry, render) { + const r = clipRoom(entry, render); + return r ? { tail: r.tail, head: r.head } : null; +} + +/** + * The cut's room, for the strip (release 36 lane E): render.room's edges, its + * settings and the join's length -- null when the cut has no room and no + * join (a montage's, or transition 0). + */ +function roomViewOf(render) { + const r = isObj(render) ? render : {}; + // The build's join (deck.mjs transitionOf): 0.5 s unless the render says; none in a montage. + const D = r.montage !== undefined && r.montage !== null ? 0 : fin(r.transition) ? r.transition : 0.5; + const room = isObj(r.room) ? r.room : null; + return { + tail: room?.tail === true, + head: room?.head === true, + minGap: fin(room?.minGap) ? room.minGap : null, + maxS: fin(room?.maxS) ? room.maxS : null, + join: D, }; } @@ -237,6 +269,8 @@ const num = (v, what) => { * role { speaker, role | null } reactions.json, through the clip finder's writer * label { speaker, label | null } a speaker's name for the captions (reactions.json) * vertical { clip, crop | null, aspect? } the clip's 9:16 box for its short + * room { clip, room: false | {tail?, head?} | null } room at this clip's edges + * (null: the cut's render.room again) * with `token` (the manifest's, from the view) on every manifest edit. * Returns `{ op, result, carried, view }`. */ @@ -363,8 +397,16 @@ export async function runClipEditorOp(project, body, { now = null } = {}) { structural = false; break; } + case "room": { + const e = needClip(); + if (body.room !== null && body.room !== false && !isObj(body.room)) throw new OpError("room is false, {tail?, head?}, or null for the cut's"); + // A "trim" that leaves the cut where it is, as `vertical` is. + result = await updateClip(dir, e.id, { room: body.room }, { token, edit: "trim", now }); + structural = false; + break; + } default: - throw new OpError("op must be trim, restore, split, merge, add, bring-in, ruling, role, label or vertical"); + throw new OpError("op must be trim, restore, split, merge, add, bring-in, ruling, role, label, vertical or room"); } let carried = null; if (structural) { diff --git a/umtool/lib/report/clipEditorTypes.ts b/umtool/lib/report/clipEditorTypes.ts @@ -27,6 +27,9 @@ export type EditorClip = { montage: boolean; /** A short's framing (release 36): `crop` = [x, y, w, h], fractions of the source picture. */ vertical: { crop: number[]; aspect?: number } | null; + /** Room at its edges (release 36 lane E): the clip's own `room` as written (false: none), and the edges it gets. */ + room?: false | { tail?: boolean; head?: boolean } | null; + roomEdges?: { tail: boolean; head: boolean } | null; }; export type Speaker = { index: number; role?: "host" | "subject" | "other"; label?: string; seconds?: number; turns?: number; how?: "auto" | "operator"; sameAs?: number }; @@ -49,6 +52,8 @@ export type EditorView = { repropose: { available: boolean; why: string | null }; /** The shorts on disk, by clip id (release 36). */ shorts: Record<string, { mtimeMs: number; size: number; stale: boolean }>; + /** The cut's render.room and its join's length (release 36 lane E). */ + room?: { tail: boolean; head: boolean; minGap: number | null; maxS: number | null; join: number }; }; export type Turn = { start: number; end: number; speaker: number }; diff --git a/umtool/lib/report/look.test.mjs b/umtool/lib/report/look.test.mjs @@ -46,7 +46,7 @@ const read = async (dir) => JSON.parse(await readFile(path.join(dir, MANIFEST_NA test("updateRender: the look's keys only, null removes one, the build's checks refuse a bad value", async () => { const p = await project({ transition: 0.4, crf: 21 }); try { - assert.deepEqual(LOOK_KEYS, ["headerHeight", "footerHeight", "qr", "transition", "transitionStyle", "loudness", "captions"]); + assert.deepEqual(LOOK_KEYS, ["headerHeight", "footerHeight", "qr", "transition", "transitionStyle", "loudness", "captions", "room"]); const token = await manifestToken(p.dir); const r = await updateRender(p.dir, { headerHeight: 0, footerHeight: 0, qr: false, transition: 0.5, transitionStyle: "fadeblack", diff --git a/umtool/lib/report/manifest.mjs b/umtool/lib/report/manifest.mjs @@ -34,6 +34,7 @@ import { normalizeOnscreen, validateChrome, validatePosts, validateTeaser, valid import { validateThreadEntries } from "yt-dlp-transcript-common/lib/report/panels.mjs"; import { validateAssist } from "yt-dlp-transcript-common/lib/clips/assist.mjs"; import { validateLook, verticalErrors } from "umtool-report-to-video/look"; +import { validateRoom } from "umtool-report-to-video/room"; import { TRANSITION_STYLES, validateTransitionStyle } from "umtool-report-to-video/transition"; import { applySectionEnter } from "./sections.mjs"; import { normalizeClaim, validateClaims } from "umtool-report-to-video/factcheck"; @@ -399,6 +400,22 @@ export async function updateClip(dir, clipId, patch, { token = null, edit = "tri } } + // ---- room at the clip's edges (release 36 lane E) ------------------------ + // + // `room: false` (none for this clip) or `{tail?, head?}` (that edge, whatever + // the cut's render.room says) -- room.mjs validateRoom, the build's own + // check. null or "" removes it: the cut's room again. + if (patch.room !== undefined) { + const v = patch.room; + if (v === null || v === "") delete entry.room; + else { + const errors = validateRoom({ timeline: [{ ...entry, room: v }] }); + if (errors.length) throw new Error(errors.join("; ")); + const vv = /** @type {false | { tail?: boolean, head?: boolean }} */ (v); + entry.room = vv === false ? false : { ...(typeof vv.tail === "boolean" ? { tail: vv.tail } : {}), ...(typeof vv.head === "boolean" ? { head: vv.head } : {}) }; + } + } + // ---- an assistant's clip, edited by a person (release 35 C2) ------------- // // A clip the clip finder proposed carries `assist`. The first human edit @@ -920,7 +937,7 @@ export class ChromeRefused extends Error { // --------------------------------------------------------------------------- /** The render keys the Look panel writes, in its order. */ -export const LOOK_KEYS = Object.freeze(["headerHeight", "footerHeight", "qr", "transition", "transitionStyle", "loudness", "captions"]); +export const LOOK_KEYS = Object.freeze(["headerHeight", "footerHeight", "qr", "transition", "transitionStyle", "loudness", "captions", "room"]); /** The look keys of a render block as written (absent keys left out). */ export function lookOf(render) { @@ -992,7 +1009,7 @@ export async function updateRender(dir, patch, { token = null } = {}) { else render.transitionStyle = v; break; default: - // loudness, captions: stored as given; the build's validators below say what is wrong. + // loudness, captions, room: stored as given; the build's validators below say what is wrong. render[k] = v; } } diff --git a/umtool/lib/report/reactions-r36.test.mjs b/umtool/lib/report/reactions-r36.test.mjs @@ -217,8 +217,8 @@ test("a channel on no site: each clip links its platform page, provenance.channe assert.equal(m.provenance.channel, "Synth Reacts Channel"); assert.equal(m.provenance.siteOrigin, ""); assert.deepEqual( - { headerHeight: m.render.headerHeight, footerHeight: m.render.footerHeight, qr: m.render.qr, transition: m.render.transition, transitionStyle: m.render.transitionStyle, loudness: m.render.loudness }, - { ...SITELESS_LOOK, loudness: { target: -16 } }, + { headerHeight: m.render.headerHeight, footerHeight: m.render.footerHeight, qr: m.render.qr, transition: m.render.transition, transitionStyle: m.render.transitionStyle, loudness: m.render.loudness, room: m.render.room }, + { ...SITELESS_LOOK, loudness: { target: -16 }, room: { tail: true, head: true } }, ); assert.ok(r.notes.some((n) => /no site carries synth-reacts: each clip links YouTube's page/.test(n)), r.notes.join("\n")); // The build's validators and lint take it (render.loudness is a key they do not refuse). diff --git a/umtool/lib/report/room.test.mjs b/umtool/lib/report/room.test.mjs @@ -0,0 +1,102 @@ +// Room at a clip's edges in umtool (release 36 lane E): render.room through +// updateRender (the Look panel's writer), a clip's `room` through updateClip +// and the clip editor's `room` operation, and what the clip editor's view +// says of it. Synthetic. +// +// Run with: pnpm test:scripts +import assert from "node:assert/strict"; +import { mkdtemp, readFile, rm, writeFile } from "node:fs/promises"; +import { tmpdir } from "node:os"; +import path from "node:path"; +import test from "node:test"; + +import { MANIFEST_NAME, RenderRefused, manifestToken, updateClip, updateRender } from "./manifest.mjs"; +import { clipEditorView, runClipEditorOp } from "./clipEditor.mjs"; +import { SITELESS_LOOK } from "../projects/scaffold.mjs"; +import { validateLook } from "umtool-report-to-video/look"; + +const manifest = (render = {}) => ({ + schemaVersion: 1, + slug: "room", + provenance: { channelSlug: "chan" }, + render: { width: 1920, height: 1080, fps: 30, palette: { bg: "#000000" }, ...render }, + timeline: [ + { type: "clip", id: "r001", video: "v1", start: 10, end: 20, cutStart: 11, cutEnd: 19, quote: "q" }, + { type: "clip", id: "r002", video: "v1", start: 30, end: 40 }, + ], +}); + +async function project(render = {}) { + const dir = await mkdtemp(path.join(tmpdir(), "umtool-room-")); + await writeFile(path.join(dir, MANIFEST_NAME), JSON.stringify(manifest(render), null, 2) + "\n"); + return { id: "reports/room", dir, kind: "report" }; +} +const read = async (dir) => JSON.parse(await readFile(path.join(dir, MANIFEST_NAME), "utf8")); + +test("the site-less seed's look: 0.4 s blur slides with room at both edges, and the build's validators take it", () => { + assert.equal(SITELESS_LOOK.transition, 0.4); + assert.equal(SITELESS_LOOK.transitionStyle, "blurslide"); + assert.deepEqual(SITELESS_LOOK.room, { tail: true, head: true }); + assert.deepEqual(validateLook({ render: { ...SITELESS_LOOK }, timeline: [] }), []); +}); + +test("updateRender: render.room is a look key; null removes it; a bad one is refused in the build's words", async () => { + const p = await project({ transition: 0.4 }); + try { + const r = await updateRender(p.dir, { room: { tail: true, head: false } }, { token: await manifestToken(p.dir) }); + assert.deepEqual(r.look.room, { tail: true, head: false }); + assert.deepEqual((await read(p.dir)).render.room, { tail: true, head: false }); + await assert.rejects(updateRender(p.dir, { room: { tail: "on" } }), (e) => e instanceof RenderRefused && /render\.room\.tail must be true or false/.test(e.errors.join(";"))); + await updateRender(p.dir, { room: null }); + assert.equal((await read(p.dir)).render.room, undefined); + } finally { + await rm(p.dir, { recursive: true, force: true }); + } +}); + +test("updateClip: a clip's room -- false, per-edge booleans, null removes it; a bad one refused", async () => { + const p = await project({ room: { tail: true, head: true } }); + try { + await updateClip(p.dir, "r001", { room: false }); + assert.equal((await read(p.dir)).timeline[0].room, false); + await updateClip(p.dir, "r001", { room: { tail: false } }); + assert.deepEqual((await read(p.dir)).timeline[0].room, { tail: false }); + await updateClip(p.dir, "r001", { room: null }); + assert.equal("room" in (await read(p.dir)).timeline[0], false); + await assert.rejects(updateClip(p.dir, "r001", { room: { middle: true } }), /room\.middle is not a setting here/); + // The cut itself is untouched by a room edit. + const e = (await read(p.dir)).timeline[0]; + assert.deepEqual([e.cutStart, e.cutEnd], [11, 19]); + } finally { + await rm(p.dir, { recursive: true, force: true }); + } +}); + +test("the clip editor: the view says each clip's edges and the cut's room; the room op writes the override", async () => { + const p = await project({ transition: 0.4, room: { tail: true, head: true } }); + try { + let view = await clipEditorView(p); + assert.deepEqual(view.room, { tail: true, head: true, minGap: null, maxS: null, join: 0.4 }); + assert.deepEqual(view.clips.map((c) => c.roomEdges), [{ tail: true, head: true }, { tail: true, head: true }]); + assert.equal(view.clips[0].room, null); + const off = await runClipEditorOp(p, { op: "room", clip: "r001", room: false, token: view.token }); + view = off.view; + assert.equal(view.clips[0].room, false); + assert.equal(view.clips[0].roomEdges, null); + const on = await runClipEditorOp(p, { op: "room", clip: "r001", room: null, token: view.token }); + assert.equal(on.view.clips[0].roomEdges.tail, true); + await assert.rejects(runClipEditorOp(p, { op: "room", clip: "r001", room: "yes" }), /room is false, \{tail\?, head\?\}, or null/); + // A cut with no room: a clip can still ask for its own. + const q = await project({ transition: 0 }); + try { + const v = await clipEditorView(q); + assert.deepEqual(v.room, { tail: false, head: false, minGap: null, maxS: null, join: 0 }); + const r = await runClipEditorOp(q, { op: "room", clip: "r002", room: { tail: true, head: true }, token: v.token }); + assert.deepEqual(r.view.clips[1].roomEdges, { tail: true, head: true }); + } finally { + await rm(q.dir, { recursive: true, force: true }); + } + } finally { + await rm(p.dir, { recursive: true, force: true }); + } +});