Archilyzer · Source

archilyzer

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

commit 2d8dfd4aa78cdc0f17bd8c7f57026c34a919a2c4
parent 43a415bab6c267f1d9214044db99ed6ac66a0704
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Thu, 12 Nov 2026 02:05:52 -0500

umtool: set <p> <entry> chapter='…' [--take <t>] -- an entry's name in the chapter list, any entry, one line of at most 100 characters, chapter= clears it

Co-Authored-By: Claude <noreply@anthropic.com>

Diffstat:
Meditor/CHANGELOG.md | 1+
Mumtool/docs/cli.md | 2+-
Mumtool/docs/knobs.md | 1+
Mumtool/lib/cli/groups.mjs | 2+-
Mumtool/lib/report/knobsCli.mjs | 11++++++++++-
Mumtool/lib/report/knobsCli.test.mjs | 32++++++++++++++++++++++++++++++++
Mumtool/lib/report/manifest.mjs | 40++++++++++++++++++++++++++++++++++++++--
7 files changed, 84 insertions(+), 5 deletions(-)

diff --git a/editor/CHANGELOG.md b/editor/CHANGELOG.md @@ -1,6 +1,7 @@ # Changelog ## [Unreleased] +- **umtool: an entry's chapter name is set from a terminal.** An entry's `chapter` names it in the chapter list (the YouTube text, `umtool export --format chapters`) in place of its on-screen title, and it could only be written by editing the manifest by hand. `umtool set <p> <entry> chapter='The weigh-in'` writes it for any entry (a clip, a post item, a still), `chapter=` clears it, and `--take <t>` writes it on that take alone. One line, at most 100 characters. - **umtool: a windowed take preview no longer fails on an effect that names a clip outside the window.** `umtool take <p> --id <t> --preview --at S --dur S` on a cut with `render.chrome.fx.glitch.clips` or `fx.thenNow.pairs` was refused with "names k06, which is not a clip of the cut". The window's manifest now keeps only the named clips inside it (a glitch's only when a clip stands right before it in the window, a then/now pair only with both ends), as it already did for markers and claim checks; an effect left naming no clip is off in that window. The same for `fx.kineticQuote.clips` and `fx.redact.clips`. - **umtool: `quote-check` works on a project whose `out/` is on the media drive.** The check asked the editor to write its word files under `<project>/out/quote-check/`; when `out/` is a link onto a media drive, that is inside the corpus and the editor refuses to write there, so every clip failed. The work files now go to `<project>/.quote-check/`, and if the editor refuses that too (the project itself is inside the corpus) to `<reports>/.umtool/quote-check/<project>/`, then `~/.cache/umtool/quote-check/<project>/`. The rows are still the project's `quote-check.json`; the editor's refusal is unchanged. - **umtool: the words under the promise clock's REFUNDED stamp can be the record's own.** The stamp always read "by <date> · no video" under REFUNDED or WITHDRAWN, whatever the outcome row said. A `promise_outcome` row may now carry `stampNote` (`umtool ledger <p> set <row> --stampNote "by her account · no receipt"`, `--stampNote null` to take it off): it is the stamp's second line, and the one-line strip over a post's card shows its first clause. Without one the words are as before. `umtool lint` warns when a note is longer than the stamp's line holds (26 characters). diff --git a/umtool/docs/cli.md b/umtool/docs/cli.md @@ -46,7 +46,7 @@ Inbox cannot disagree about what is wrong with one. | `review-pass <project> [ls] [--json]` · `review-pass <project> mark <block> keep\|fix\|clear [--note T]` | the workspace's **review pass** (`?mode=review`): every block but the intro and a clip rejected for a cut reason, its answer and the block the pass resumes on; a Fix ("needs work", saying what) is a mark in `<project>/review-pass.json` on any block, a clip too — never a clip's verdict (`incorrect` is the bench's fact-error ruling, never written or overwritten here); a clip's Keep is its walk verdict (`window --verdict confirmed`), a post's or a card's a mark — `mark` writes one (a Fix needs `--note`; a clip takes `fix` and `clear`) ([knobs.md](knobs.md#the-review-pass)) | | `review-pass <project> verdict like\|maybe\|no\|clear [--note T] [--json]` | the pass's **verdict on the draft**, one locked call: a draft that differs from its parent version only by what the walk and the review pass write (verdict, correction, reason, reject note, walk note, ★) judges the PARENT and saves nothing; otherwise the draft is saved as the next version and that is judged (`takes/verdicts.json`) | | `present <project> [--take <take> \| --cut] [--json] [--public] [--open] [--url <origin>]` | **present mode**: the cut as slides, navigated like a deck (`/projects/<p>/present`) — prints the address and every slide (its kind, id — a post's `<channel>/<id>`, a clip's id, `section-<n>`, `day-<YYYY-MM-DD>` — date, words and censor counts); `--json` the payload (each post's card as Play draws it and its censor data by kind, each clip's spans, the dividers); `--public` the payload a public page would carry (censored, no reveal data); `--open` opens it; `<address>#<slide id>` opens a slide ([knobs.md](knobs.md#present-mode-the-cut-as-slides-navigated-like-a-deck)) | -| `set <project> <clip> key=value …` | a clip's **knobs**: `claim.at` `claim.hold` `claim.stamp` `claim.count` `claim.label` (the first mark's, or `--mark <id>`'s), its **marks** `mark.add=<verdict>[@<sec>]` `mark.remove=<id>` `mark.verdict=<verdict>` `marks=<json>`, `audio.offset` `audio.gain` `audio.fadeIn` `audio.fadeOut`, its picture's **blur** `blur.on=true` `blur.caption=…` `blur.strength` `blur.from` `blur.to` (`blur.on=` clears it; [knobs.md](knobs.md#a-clips-picture-blurred)), its **effects** `fx.zoom=<json>` `fx.receipts=<json>` `fx.punch=…` `fx.quote` `fx.punchIn=<json>` `fx.speakers=<json>` (`fx=<json>` all of them, `fx=` clears them; a shot is a file in the project; [knobs.md](knobs.md#effects)); `key=` clears one ([knobs.md](knobs.md#marks)) | +| `set <project> <clip> key=value …` | a clip's **knobs**: `claim.at` `claim.hold` `claim.stamp` `claim.count` `claim.label` (the first mark's, or `--mark <id>`'s), its **marks** `mark.add=<verdict>[@<sec>]` `mark.remove=<id>` `mark.verdict=<verdict>` `marks=<json>`, `audio.offset` `audio.gain` `audio.fadeIn` `audio.fadeOut`, its picture's **blur** `blur.on=true` `blur.caption=…` `blur.strength` `blur.from` `blur.to` (`blur.on=` clears it; [knobs.md](knobs.md#a-clips-picture-blurred)), its **effects** `fx.zoom=<json>` `fx.receipts=<json>` `fx.punch=…` `fx.quote` `fx.punchIn=<json>` `fx.speakers=<json>` (`fx=<json>` all of them, `fx=` clears them; a shot is a file in the project; [knobs.md](knobs.md#effects)); on ANY entry (a post item, a still, a clip) `hideModules=diet,streak`, `shelfNote='…'` and `chapter='…'` (its name in the chapter list, one line of at most 100 characters; `chapter=` none); `--take <t>` writes the entry knobs into that take's patch; `key=` clears one ([knobs.md](knobs.md#marks)) | | `intro <project> [key=value …] [--off] [--json]` · `intro <project> --take <take> --off\|--on` | **the intro** the cut opens on (`render.intro`): with no key, prints it as written, what the cut opens with (a `title-card`'s words resolved) and each version's on/off; `key=value` writes it through the look writer (`style` `seconds` 3.5–8 `mark` `ground` `sound` (`false` silent) `site` `title` `lines` (`a\|b`, ≤ 3) and the brand's keys; `key=` clears one; a new intro starts as `boot-dark`); `--off` takes it off the cut; `--take <t> --off` that version opens on no intro (its patch's `render.intro: null`), `--on` on the cut's again. **Exit 1** on a value the build refuses ([knobs.md](knobs.md#the-intro-played-and-edited)) | | `look <project> key=value … [--unset render.<key>]… [--take <t>]` | the cut's **knobs** (`--take <t>`: the `deck.*` keys given are set on that take -- its patch, an undo point of its own, the project's manifest untouched; the other knobs are the project's): `factcheck.stamp.*`, `factcheck.verdicts.<V>.stampLabel\|label\|color`, `deck.markers=<json>`, `deck.markerLayout`, `variants=<json>`, and the look's keys — `mode=basic\|deck` (the footage alone, [knobs.md](knobs.md#basic-output-the-footage-alone)) and `basic=<json>` (its fades) among them ([knobs.md](knobs.md)) **The deck on, legacy keys off** (`updateRenderKeys`, one write, an undo point `revisions/…auto-render-keys…` first): `chrome.layout=deck` turns the deck on (render.chrome created when the cut has none: engine hyperframes, an empty deck), `--unset render.<key>` (repeatable) drops a legacy render key -- only `rail` `chromeEngine` `railEngine` `chromeRegions` `claimSchedule` `wordmark` `title` `finale` `cut`; the deck beside the old rail is refused in the build's words unless the same command drops it; deck.* keys in the same command land after the chrome exists. Another key named: **exit 2** | | `variants <project> [--take <t>] [--list] [--json]` | **Make variants**: the encode ladder of the build (or of a take's); `--list` what was made and the build's sync report, each clip's lag (past a frame flagged) ([knobs.md](knobs.md)) | diff --git a/umtool/docs/knobs.md b/umtool/docs/knobs.md @@ -37,6 +37,7 @@ that generates it ([notes.md](notes.md)). | `chat` — `on`: the clip's live chat (its video's `live_chat.cues.json`, for the clip's source span, timed through its gaps) in a column beside the footage; `off` or `chat=` (the default): none. A video with no chat draws nothing and the build log says so ([Live chat](#live-chat)) | — | `umtool set <p> <clip> chat=on` (`chat=` clears it) | — | | `hideModules` — `["diet","streak",…]`: the measure extras (`goals` `peak` `promise` `diet` `streak`) hidden over THIS entry's span, each with its own fade, whatever it would otherwise do there -- for text in the footage no dodge can know of (a DM screenshot's refund email under the diet badge). Any entry, a post item too; an id no entry can hide is refused | — | `umtool set <p> <entry> hideModules=diet,streak` (`hideModules=` clears it; `--take <t>` writes the take's patch, the project's manifest untouched) | — | | `shelfNote` — one line of at most 80 characters on the shelf (`render.chrome.deck.shelf`, its `note` slot) over THIS entry's span, coming and going with it -- a short fact beside the footage for any video, with or without a measure slice ([Shelf](#shelf)). Any entry, a post item too | — | `umtool set <p> <entry> shelfNote='Weighed in on camera'` (`shelfNote=` clears it; `--take <t>` writes the take's patch) | — | +| `chapter` — the entry's name in the chapter list (`out/…chapters`, `youtube.txt`, `umtool export --format chapters`): one line of at most 100 characters. An authored `chapter` wins over the entry's on-screen title (under the deck) and the line derived from its record; without one the list is as before. Any entry, a post item too | — | `umtool set <p> <entry> chapter='The weigh-in'` (`chapter=` clears it; `--take <t>` writes the take's patch, the project's manifest untouched) | — | | `fx.zoom` — `{shot, focus, at?, hold?}`: a screenshot (a file in the project; a bare name under its `shots/` is written as `shots/<name>`) that comes up over the footage and pushes in on `focus` (`[left, top, right, bottom]`, fractions of the shot) — drawn once `render.chrome.fx.zoom` is on ([Effects](#effects)). **How long it stays**: up 0.2 s into the clip's clean span (rising in over 0.38 s), its focus box drawn 0.55 s later, the push at `at` (seconds into the clip; default as soon as the box has drawn) over 1 s, then a slow drift on the detail; it leaves with a 0.3 s fade 0.3 s before the clip's clean span ends — or, with `hold` (0.5–10 s), that long after the push lands (never past the clip's own leave) | — | `umtool set <p> <clip> fx.zoom='{"shot":"shots/x.png","focus":[0.1,0.2,0.9,0.4],"at":5.9,"hold":4}'` (`fx.zoom=` clears it) | `PUT /api/report/window {project, clip, "fx.zoom": {…} \| null}` | | `fx.receipts`, `fx.punch`, `fx.quote`, `fx.punchIn`, `fx.speakers` — the clip's other effect fields (`[{shot, mark?, at?, hold?, label?}]` 1–4, `at` the source second a receipt flies in at (default: as the clip comes up), `hold` 0.5–10 s it stays once landed (on every one: they leave then, not with the clip), `label` a line of at most 80 characters in a band under the screenshot (when it was taken, what it is); the words to punch; `false`: no line; 1–8 source seconds inside the clip; `[{at, who: 0\|1}]`), each inert until its effect is on; `fx` is all of them at once. Checked by the build's own `validateFxEntries` | — | `fx.punch="the words"` `fx.punchIn='[231.4]'` · `fx='{…}'` sets them all, `fx=` clears every one | `PUT /api/report/window {project, clip, fx}` (or one `"fx.<field>"`) | | `gaps` — `[{from, to}]`, SOURCE seconds cut out of the clip's middle: it renders as ONE segment of jump cuts (one pip, one card), not two clips with a crossfade ([below](#gaps-inside-a-clip)) | clip bench (Edit this clip), the waveform: **Select a gap** (`g`) or Alt + drag a span, **Cut gap** (`g`), **Hear it**; a click on a gap's band puts it back (`G`: the one at the playhead); **Undo** | `umtool window <p> <clip> --gap 12.3-15.1` (repeatable) · `--gap-remove 12.3` · `--gaps '12.3-15.1,20-20.6'` (`--gaps ''` clears) · `umtool set <p> <clip> gap.add=12.3-15.1 gap.remove=12.3 gaps=` | `PUT /api/report/window {project, clip, token, gapAdd \| gapRemove \| gaps}` | diff --git a/umtool/lib/cli/groups.mjs b/umtool/lib/cli/groups.mjs @@ -301,7 +301,7 @@ export const GROUPS = [ ], docs: [ ["`set <project> <clip> key=value …`", - "a clip's **knobs**: `claim.at` `claim.hold` `claim.stamp` `claim.count` `claim.label` (the first mark's, or `--mark <id>`'s), its **marks** `mark.add=<verdict>[@<sec>]` `mark.remove=<id>` `mark.verdict=<verdict>` `marks=<json>`, `audio.offset` `audio.gain` `audio.fadeIn` `audio.fadeOut`, its picture's **blur** `blur.on=true` `blur.caption=…` `blur.strength` `blur.from` `blur.to` (`blur.on=` clears it; [knobs.md](knobs.md#a-clips-picture-blurred)), its **effects** `fx.zoom=<json>` `fx.receipts=<json>` `fx.punch=…` `fx.quote` `fx.punchIn=<json>` `fx.speakers=<json>` (`fx=<json>` all of them, `fx=` clears them; a shot is a file in the project; [knobs.md](knobs.md#effects)); `key=` clears one ([knobs.md](knobs.md#marks))"], + "a clip's **knobs**: `claim.at` `claim.hold` `claim.stamp` `claim.count` `claim.label` (the first mark's, or `--mark <id>`'s), its **marks** `mark.add=<verdict>[@<sec>]` `mark.remove=<id>` `mark.verdict=<verdict>` `marks=<json>`, `audio.offset` `audio.gain` `audio.fadeIn` `audio.fadeOut`, its picture's **blur** `blur.on=true` `blur.caption=…` `blur.strength` `blur.from` `blur.to` (`blur.on=` clears it; [knobs.md](knobs.md#a-clips-picture-blurred)), its **effects** `fx.zoom=<json>` `fx.receipts=<json>` `fx.punch=…` `fx.quote` `fx.punchIn=<json>` `fx.speakers=<json>` (`fx=<json>` all of them, `fx=` clears them; a shot is a file in the project; [knobs.md](knobs.md#effects)); on ANY entry (a post item, a still, a clip) `hideModules=diet,streak`, `shelfNote='…'` and `chapter='…'` (its name in the chapter list, one line of at most 100 characters; `chapter=` none); `--take <t>` writes the entry knobs into that take's patch; `key=` clears one ([knobs.md](knobs.md#marks))"], ], }, { diff --git a/umtool/lib/report/knobsCli.mjs b/umtool/lib/report/knobsCli.mjs @@ -59,7 +59,7 @@ export const VERTICAL_SET_KEYS = Object.freeze(["vertical", "vertical.crop", "ve export const SIDE_SET_KEYS = Object.freeze(["side", "side.item", "side.post", "side.from", "side.to", "side.place"]); const SET_KEYS = [ "claim", ...CLAIM_KNOBS.map((k) => `claim.${k}`), ...MARK_KEYS, ...AUDIO_KNOBS.map((k) => `audio.${k}`), ...BLUR_KNOBS.map((k) => `blur.${k}`), "layout", ...REVIEW_KEYS, - ...FX_KEYS, ...GAP_KEYS, "chat", "hideModules", "shelfNote", + ...FX_KEYS, ...GAP_KEYS, "chat", "hideModules", "shelfNote", "chapter", // The vertical format (lane vertical): the clip's 9:16 crop and layout, and its side post. ...VERTICAL_SET_KEYS, ...SIDE_SET_KEYS, ]; @@ -105,6 +105,8 @@ export const SET_USAGE = [ " footage no dodge can know of; any entry, a post item too): goals peak promise diet streak; `hideModules=` none.", " shelfNote='Weighed in on camera' puts one line (≤ 80 characters) on the shelf (render.chrome.deck.shelf, its", " `note` slot) over this entry's span, coming and going with it; any entry; `shelfNote=` none.", + " chapter='The weigh-in' names this entry in the chapter list (out/chapters, youtube.txt) in place of its on-screen", + " title or the line derived from its record: one line, ≤ 100 characters; any entry; `chapter=` none.", " --take <t>: the entry knobs (not claim.* or marks) land in takes/<t>/take.json's patch, an undo point first", " (`umtool timeline <p> --take <t> undo`); the project's manifest is untouched.", " vertical.crop='[x,y,w,h]' (fractions of the source: the 9:16 box a vertical render cuts; vertical.aspect the", @@ -247,6 +249,11 @@ export async function setCommand(args, { root = REPORTS_ROOT, out = (s) => conso entryPatch.shelfNote = value === null || value === undefined ? null : String(value); continue; } + if (key === "chapter") { + // The entry's name in the chapter list (manifest.mjs parseEntryChapter checks it); words whatever they parse as. + entryPatch.chapter = value === null || value === undefined ? null : String(value); + continue; + } if (key === "hideModules") { // The modules hidden over this entry's span (deck.mjs parseHideModules checks the ids); `hideModules=` none. entryPatch.hideModules = value === null || value === undefined ? null : value; @@ -336,6 +343,7 @@ export async function setCommand(args, { root = REPORTS_ROOT, out = (s) => conso if (take) results.take = { id: take, undo: result.revision?.rel ? `takes/${take}/${result.revision.rel}` : null }; if ("hideModules" in entryPatch) results.hideModules = result.entry.hideModules ?? null; if ("shelfNote" in entryPatch) results.shelfNote = result.entry.shelfNote ?? null; + if ("chapter" in entryPatch) results.chapter = result.entry.chapter ?? null; if ("audio" in entryPatch) results.audio = result.entry.audio ?? null; if ("blur" in entryPatch) results.blur = result.entry.blur ?? null; if ("layout" in entryPatch) results.layout = result.entry.layout ?? "clip"; @@ -373,6 +381,7 @@ export async function setCommand(args, { root = REPORTS_ROOT, out = (s) => conso if ("layout" in results) out(`${clipId}: layout ${results.layout}`); if ("hideModules" in results) out(`${clipId}${results.take ? ` (take ${results.take.id})` : ""}: hideModules ${results.hideModules ? `${results.hideModules.join(", ")} (hidden over its span)` : "none"}`); if ("shelfNote" in results) out(`${clipId}${results.take ? ` (take ${results.take.id})` : ""}: shelfNote ${results.shelfNote ? JSON.stringify(results.shelfNote) + " (on the shelf over its span)" : "none"}`); + if ("chapter" in results) out(`${clipId}${results.take ? ` (take ${results.take.id})` : ""}: chapter ${results.chapter ? JSON.stringify(results.chapter) + " (its name in the chapter list)" : "none (named by its on-screen title, else its record)"}`); if (results.take?.undo) out(` undo point: ${results.take.undo} (umtool timeline ${project.id} --take ${results.take.id} undo)`); if ("chat" in results) out(`${clipId}: chat ${results.chat === true ? "on (its video's live_chat.cues.json beside the footage; the build says if there is none)" : results.chat === false ? "off" : "default (off)"}`); if ("fx" in results) out(`${clipId}: fx ${results.fx ? JSON.stringify(results.fx) : "none"}`); diff --git a/umtool/lib/report/knobsCli.test.mjs b/umtool/lib/report/knobsCli.test.mjs @@ -367,3 +367,35 @@ test("umtool look deck.<key>=… --take <t>: the take's patch, an undo point of assert.match(lines.at(-1), /has no take nope/); assert.equal(await readFile(path.join(dir, "video.manifest.json"), "utf8"), before); }); + +test("umtool set chapter='…': an entry's name in the chapter list, any entry; chapter= clears; --take writes the take's patch", async () => { + const dir = await project("chapter"); + const m = await read(dir); + m.timeline.push({ type: "post", id: "x01", item: "123" }); + await writeFile(path.join(dir, "video.manifest.json"), JSON.stringify(m, null, 2) + "\n"); + const { lines, run } = runner(setCommand); + assert.equal(await run("chapter", "c02", "chapter= The weigh-in "), 0, lines.join("\n")); + assert.equal((await read(dir)).timeline[1].chapter, "The weigh-in", "trimmed"); + assert.match(lines.at(-1), /c02: chapter "The weigh-in" \(its name in the chapter list\)/); + assert.equal(await run("chapter", "x01", "chapter=2026"), 0, lines.join("\n")); + assert.equal((await read(dir)).timeline[2].chapter, "2026", "a post item too; words whatever they parse as"); + // Beside a clip's other knobs in one command. + assert.equal(await run("chapter", "c01", "chapter=Arrival", "audio.gain=2"), 0, lines.join("\n")); + assert.deepEqual([(await read(dir)).timeline[0].chapter, (await read(dir)).timeline[0].audio], ["Arrival", { gain: 2 }]); + assert.equal(await run("chapter", "c02", `chapter=${"x".repeat(101)}`), 1); + assert.match(lines.at(-1), /chapter is 101 characters \(at most 100\)/); + assert.equal((await read(dir)).timeline[1].chapter, "The weigh-in", "a refused write changes nothing"); + assert.equal(await run("chapter", "c02", "chapter="), 0); + assert.equal("chapter" in (await read(dir)).timeline[1], false); + assert.match(lines.at(-1), /c02: chapter none/); + const { draftTake } = await import("./takeMaker.mjs"); + const { resolveTakeManifest } = await import("./takeManifest.mjs"); + await draftTake(dir, { id: "a9", label: "A9", patch: {} }); + const before = await readFile(path.join(dir, "video.manifest.json"), "utf8"); + assert.equal(await run("chapter", "c02", "chapter=Day 41", "--take", "a9"), 0, lines.join("\n")); + assert.match(lines.join("\n"), /c02 \(take a9\): chapter "Day 41"/); + assert.equal(await readFile(path.join(dir, "video.manifest.json"), "utf8"), before); + assert.equal((await resolveTakeManifest(dir, "a9")).manifest.timeline[1].chapter, "Day 41"); + assert.equal(await run("chapter", "x01", "chapter=", "--take", "a9"), 0, lines.join("\n")); + assert.equal("chapter" in (await resolveTakeManifest(dir, "a9")).manifest.timeline[2], false); +}); diff --git a/umtool/lib/report/manifest.mjs b/umtool/lib/report/manifest.mjs @@ -328,8 +328,41 @@ function applyShelfNote(entry, value) { else delete entry.shelfNote; } +/** The most characters an entry's `chapter` may have: one line of a chapter list (a YouTube title's own limit). */ +export const ENTRY_CHAPTER_MAX = 100; + +/** + * An entry's `chapter` as written: its name in the chapter list (build-video.mjs chapterTitle: an authored `chapter` + * wins over the on-screen title and the line derived from the record). One line, at most ENTRY_CHAPTER_MAX + * characters, trimmed; null, "" or blank is none. + * @param {unknown} v + * @returns {{ value: string | null, error: string | null }} + */ +export function parseEntryChapter(v) { + if (v === null || v === undefined || v === "" || v === false) return { value: null, error: null }; + if (typeof v !== "string") return { value: null, error: `chapter is words, not ${JSON.stringify(v)}` }; + const s = v.trim(); + if (!s) return { value: null, error: null }; + if (/[\r\n]/.test(s)) return { value: null, error: "chapter must be one line" }; + if ([...s].length > ENTRY_CHAPTER_MAX) return { value: null, error: `chapter is ${[...s].length} characters (at most ${ENTRY_CHAPTER_MAX})` }; + return { value: s, error: null }; +} + +/** + * Set an entry's `chapter` (parseEntryChapter); null or "" removes it -- the chapter list names the entry by its + * on-screen title or its record again. + * @param {Record<string, unknown>} entry + * @param {unknown} value + */ +function applyChapter(entry, value) { + const { value: text, error } = parseEntryChapter(value); + if (error) throw new Error(error); + if (text) entry.chapter = text; + else delete entry.chapter; +} + /** The patch keys any timeline entry may carry (a post item, a still, a clip): applied before the clip-only rules. */ -const ANY_ENTRY_KEYS = Object.freeze(["hideModules", "shelfNote"]); +const ANY_ENTRY_KEYS = Object.freeze(["hideModules", "shelfNote", "chapter"]); /** * updateClip's rules over a manifest held in memory: the ONE place a clip @@ -358,8 +391,9 @@ export function patchClipEntry(manifest, clipId, patch, { edit = "trim", now = n // So may its note on the shelf (`shelfNote`, deck.mjs entryShelfNotes). if (patch !== RESTORE_PATCH && Object.keys(patch).length && Object.keys(patch).every((k) => ANY_ENTRY_KEYS.includes(k))) { if (patch.hideModules !== undefined) applyHideModules(entry, patch.hideModules); - if (patch.shelfNote !== undefined) applyShelfNote(entry, patch.shelfNote); if (patch.shelfNote !== undefined) applyShelfNote(entry, patch.shelfNote); + // Its name in the chapter list (`chapter`, build-video.mjs chapterTitle). + if (patch.chapter !== undefined) applyChapter(entry, patch.chapter); return { entry, before: { start: entry.start, end: entry.end } }; } // `!== "clip"`, not `=== "card"`. The timeline's vocabulary is open -- one @@ -781,6 +815,8 @@ export function patchClipEntry(manifest, clipId, patch, { edit = "trim", now = n } if (patch.hideModules !== undefined) applyHideModules(entry, patch.hideModules); + // A clip's chapter name beside its other knobs in one patch. + if (patch.chapter !== undefined) applyChapter(entry, patch.chapter); // The live-chat column beside this clip (chat.mjs): true shows it, false is // the explicit no, null/"" removes the key (the default: off).