commit 4e39b056a6f03e78aff842d4b99835950a13f2bf
parent 75d8678f40f2bf861ce8892739ecf6d974ca0849
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Fri, 13 Nov 2026 01:02:48 -0500
umtool screens: --from-read -- a picture-only post's read made its screen, typed once
`umtool posts screen <p> <item> add --from-read [--media i] [--kind k] [--id] [--title]` and the
post bench's "From its read" (Screens section) make a screen of a PICTURE-ONLY post's read:
its narration.script a line per line (post-screens.mjs linesOfRead: blank lines and emotion
tags dropped, a long line split at its sentence ends), on its picture (its first image; a GIF
or a video visible its whole length), kind text, read whole, NOT checked. A "who:" is never
parsed out of a read (a shape or a heading would become a speaker). Refused off a picture-only
post, with no script, or an attachment/kind wrong. Nothing is drawn until the read reads it.
Co-Authored-By: Claude <noreply@anthropic.com>
Diffstat:
4 files changed, 218 insertions(+), 4 deletions(-)
diff --git a/umtool/components/projects/PostScreensPanel.tsx b/umtool/components/projects/PostScreensPanel.tsx
@@ -1,8 +1,9 @@
"use client";
import { useMemo, useRef, useState } from "react";
-import { SCREEN_KINDS, lineOfText, screenReadLines, screenWarnings, shapeSpans, validateScreens, withoutLines } from "umtool-report-to-video/post-screens";
+import { SCREEN_KINDS, lineOfText, screenFromRead, screenReadLines, screenWarnings, shapeSpans, validateScreens, withoutLines } from "umtool-report-to-video/post-screens";
import { isNarrated, pickedTake } from "umtool-report-to-video/post-narration";
+import { ownPictureOnly } from "umtool-report-to-video/post-item";
import { partRoles, threadReadErrors } from "umtool-report-to-video/post-thread";
import { postFileUrl } from "./review/PostItemPlayer";
@@ -51,12 +52,24 @@ export default function PostScreensPanel({ project, entry, setEntry }: { project
void _c;
return { ...rest, lines: f(s.lines) };
});
- const add = () => {
+ const nextId = () => {
const have = new Set(screens.map((s) => s.id));
let n = 1;
while (have.has(`s${n}`)) n += 1;
+ return `s${n}`;
+ };
+ // A PICTURE-ONLY post's read made its screen (post-screens.mjs screenFromRead: `posts screen … add --from-read`).
+ const pictureOnly = ownPictureOnly(entry) as boolean;
+ const script = typeof (entry.narration as { script?: unknown } | undefined)?.script === "string" ? String((entry.narration as { script: string }).script) : "";
+ const [fromReadError, setFromReadError] = useState<string | null>(null);
+ const addFromRead = () => {
+ const made = screenFromRead(entry, { pictureOnly, id: nextId() }) as { screen?: Screen; error?: string };
+ setFromReadError(made.error ?? null);
+ if (made.screen) setScreens((list) => [...list, made.screen as Screen]);
+ };
+ const add = () => {
const m = media[0];
- const sc: Screen = { id: `s${n}`, media: 0, kind: "dm", source: "transcribed", lines: [], read: "all", ...(m && (m.kind === "video" || m.kind === "gif") ? { at: [0, r2(Math.min(5, m.seconds ?? 5))] as [number, number] } : {}) };
+ const sc: Screen = { id: nextId(), media: 0, kind: "dm", source: "transcribed", lines: [], read: "all", ...(m && (m.kind === "video" || m.kind === "gif") ? { at: [0, r2(Math.min(5, m.seconds ?? 5))] as [number, number] } : {}) };
setScreens((list) => [...list, sc]);
};
if (!media.length) return null;
@@ -68,7 +81,17 @@ export default function PostScreensPanel({ project, entry, setEntry }: { project
<button type="button" className="ink-link ml-auto" onClick={add} data-post-screens-add="">
Add a screen
</button>
+ {pictureOnly && script.trim() && (
+ <button type="button" className="ink-link" onClick={addFromRead} title="its script, a line per line, on its picture -- not checked" data-post-screens-from-read="">
+ From its read
+ </button>
+ )}
</div>
+ {fromReadError && (
+ <p className="m-0 mb-1 text-[var(--color-bad,#e5484d)]" data-post-screens-from-read-error="">
+ {fromReadError}
+ </p>
+ )}
{screens.map((sc) => (
<ScreenEditor
key={sc.id}
diff --git a/umtool/lib/report/postScreensCli.mjs b/umtool/lib/report/postScreensCli.mjs
@@ -6,6 +6,7 @@
// umtool posts screen <p> <item> add --media <i> [--at <from>,<to>] --kind dm|email|post|text [--id <id>] [--title "…"]
// [--from <file>] [--line "who: words"]… [--read all|none|<n>,<n>…] [--unread omit|dim]
// [--ref <channel>/<postId>] [--json]
+// umtool posts screen <p> <item> add --from-read [--media <i>] [--kind …] [--id <id>] [--title "…"] [--json]
// umtool posts screen <p> <item> set <id> <key>=<value>… [--from <file>] [--json]
// umtool posts screen <p> <item> rm <id> [--json]
// umtool posts screen <p> <item> check <id> [--by <name>] [--undo] [--json]
@@ -27,12 +28,14 @@ import { voiceOverridesOf } from "umtool-report-to-video/post-say";
import { readManifest } from "../projects/report.mjs";
import { withEditNotes } from "./edit-guard.mjs";
import { manifestToken, updatePostItem } from "./manifest.mjs";
-import { SCREEN_KINDS, SCREEN_SIDES, SCREEN_UNREAD, lineOfText, screenLineSaid, screenReadLines, withoutLines, screenRows, screenWarnings, screensOf, validateScreens } from "umtool-report-to-video/post-screens";
+import { ownPictureOnly } from "umtool-report-to-video/post-item";
+import { SCREEN_KINDS, SCREEN_SIDES, SCREEN_UNREAD, lineOfText, screenFromRead, screenLineSaid, screenReadLines, withoutLines, screenRows, screenWarnings, screensOf, validateScreens } from "umtool-report-to-video/post-screens";
export const SCREEN_USAGE = [
"usage: umtool posts screen <project> <item> list [--json]",
" umtool posts screen <project> <item> add --media <i> [--at <from>,<to>] --kind dm|email|post|text [--id <id>] [--title \"…\"]",
" [--from <file>] [--line \"who: words\"]… [--read all|none|<n>,<n>…] [--unread omit|dim] [--ref <channel>/<postId>] [--json]",
+ " umtool posts screen <project> <item> add --from-read [--media <i>] [--kind dm|email|post|text] [--id <id>] [--title \"…\"] [--json]",
" umtool posts screen <project> <item> set <id> <key>=<value>… [--from <file>] [--json]",
" umtool posts screen <project> <item> rm <id> [--json]",
" umtool posts screen <project> <item> check <id> [--by <name>] [--undo] [--json]",
@@ -42,6 +45,8 @@ export const SCREEN_USAGE = [
" --media: the attachment it is in (its index); --at: the seconds of a video it is visible in. --read: the lines read",
" (all; none: transcribed only, not drawn); --unread: the lines not read left out (omit) or drawn dim. --from: a JSON",
" screen, or text lines `[right] who: words | time` (`- words`: no speaker; `[redact] …`: never drawn nor read).",
+ " --from-read: a PICTURE-ONLY post's read made its screen -- its script (narration.script) a line per line, on its",
+ " picture (--media: another attachment), kind text (--kind), read whole, NOT checked; no speakers (set them after).",
" set keys: kind= title=|off media= at=<a>,<b>|off unread= ref=|off read=all|none|<n>,… read.<n>=\"excerpt\"|on|off",
" line.add=\"who: words\" line.<n>=off line.<n>.who=|off line.<n>.side=left|right|auto line.<n>.text=",
" line.<n>.time=|off line.<n>.redact=on|off",
@@ -252,6 +257,23 @@ export async function screenCommand(project, rest, { flags, str: flag, multi, js
for (const sc of screens) for (const l of screenListing(e, sc)) out(l);
return 0;
}
+ if (verb === "add" && flags.has("--from-read")) {
+ // A PICTURE-ONLY post's read made its screen (post-screens.mjs screenFromRead): typed once, as its script.
+ if (flag("--from") !== null || multi("--line").length) fail("--from-read makes the lines from the read: not with --from or --line");
+ const id = flag("--id") ?? nextScreenId(e);
+ if (screens.some((s) => s.id === id)) fail(`${e.id} has a screen ${id} already (set changes it)`);
+ const mi = flag("--media");
+ if (mi !== null && !/^\d$/.test(String(mi))) fail("--media takes the attachment's index");
+ const made = screenFromRead(e, { pictureOnly: ownPictureOnly(e), id, media: mi === null ? null : Number(mi), kind: flag("--kind") });
+ if (made.error) fail(made.error);
+ const sc = { ...made.screen, ...(flag("--title") !== null ? { title: flag("--title") } : {}) };
+ if (dryRun) {
+ const errs = validateScreens({ ...e, screens: [...screens, sc] });
+ out(json ? JSON.stringify({ ok: !errs.length, dryRun: true, screen: sc, errors: errs }, null, 2) : [`would add ${sc.id} from its read:`, ...screenListing(e, sc).map((l) => ` ${l}`), ...errs.map((x) => ` refused: ${x}`)].join("\n"));
+ return errs.length ? 1 : 0;
+ }
+ return write([...screens, sc], `added screen ${sc.id} from its read (${sc.lines.length} line(s), not checked)`);
+ }
if (verb === "add") {
const from = flag("--from") ? await readFrom(path.resolve(String(flag("--from")))) : {};
const base = from.screen ?? {};
diff --git a/umtool/lib/report/postScreensRound2.test.mjs b/umtool/lib/report/postScreensRound2.test.mjs
@@ -0,0 +1,102 @@
+// A post's SCREENS, round 2 (lane/screens-2): a screen made from a picture-only post's READ (`posts screen … add
+// --from-read`, post-screens.mjs linesOfRead / screenFromRead) and a LINE RECORDED by the operator (`posts screen …
+// record`, the bench's per-line Record): kept as new takes of the item that are never its read, converted only to the
+// speaker's character's stock voice, chosen for a line by hand (`--line-take`, the screen's `lineTakes`), refused when
+// they are another line's or the line changed. No editor (stub ops), no real audio (synthetic tones), temp dirs.
+import assert from "node:assert/strict";
+import { mkdir, mkdtemp, readFile, readdir, rm, writeFile } from "node:fs/promises";
+import { tmpdir } from "node:os";
+import path from "node:path";
+import { after, test } from "node:test";
+import { encodeWav16 } from "yt-dlp-transcript-common/lib/montage/voiceMatch.mjs";
+import { VOICE_A, VOICE_B, syntheticVoice, withSilence } from "yt-dlp-transcript-common/testing/audio/syntheticVoice.mjs";
+import { postsCommand } from "./postsCli.mjs";
+import { linesOfRead, maskShapes, screenFromRead } from "umtool-report-to-video/post-screens";
+import { ownPictureOnly, validatePostItem } from "umtool-report-to-video/post-item";
+
+const ROOT = await mkdtemp(path.join(tmpdir(), "umtool-screens2-"));
+after(() => rm(ROOT, { recursive: true, force: true }));
+const wavOf = async (file, voice, seconds = 1.2) => {
+ await mkdir(path.dirname(file), { recursive: true });
+ await writeFile(file, encodeWav16(withSilence(syntheticVoice({ ...voice, seconds }), { before: 0.1, after: 0.1 })));
+};
+const IMG = { src: "posts-media/kir-x/7/7_1.jpg", kind: "image", width: 900, height: 1400 };
+const GIF = { src: "posts-media/kir-x/7/7_2.mp4", kind: "gif", width: 480, height: 270, seconds: 2.53 };
+const PIC = {
+ type: "post", id: "p-7", post: "kir-x/7", platform: "x", author: "Kirsche", handle: "kirsche", date: "2026-11-02T01:40:36.000Z",
+ text: "@thequartering", media: [IMG],
+ narration: { script: "I never said that.\n\nOrder number: 4419283 was refunded <sigh> on 11/02/2026.\n", takes: [{ file: "narration/posts/7/take-1.kokoro-af_heart.wav", engine: "kokoro", voice: "af_heart", seconds: 3, script: "I never said that." }], pick: 0 },
+};
+async function project(name, item) {
+ const dir = path.join(ROOT, name);
+ await mkdir(dir, { recursive: true });
+ for (const t of item.narration?.takes ?? []) await wavOf(path.join(dir, t.file), VOICE_A, 1);
+ await writeFile(path.join(dir, "video.manifest.json"), JSON.stringify({
+ schemaVersion: 1, slug: name, title: name, provenance: { channelsDir: "../channels", channelSlug: "chan" },
+ render: { width: 1920, height: 1080, fps: 30, postNarration: { engine: "kokoro", voice: "af_heart" } },
+ timeline: [item],
+ }, null, 2));
+ return { id: name, dir };
+}
+const read = async (p) => JSON.parse(await readFile(path.join(p.dir, "video.manifest.json"), "utf8"));
+const posts = async (args) => {
+ const lines = [];
+ const code = await postsCommand(args, { root: ROOT, out: (s) => lines.push(s), err: (s) => lines.push(s) });
+ return { code, text: lines.join("\n"), json: () => JSON.parse(lines.join("\n")) };
+};
+
+// ---------------------------------------------------------------------------
+// ITEM 3: --from-read
+// ---------------------------------------------------------------------------
+
+test("linesOfRead: a line per line of the script, blank lines and emotion tags dropped, a long line split at its sentences -- never a speaker parsed out", () => {
+ assert.deepEqual(linesOfRead("I never said that.\n\n \nOrder number: 4419283 was refunded <sigh> today."), [{ text: "I never said that." }, { text: "Order number: 4419283 was refunded today." }]);
+ // A "who: words" is words: a shape or a heading is never a speaker (round 1's p7).
+ for (const raw of ["Order number: 4419", "Ref: AB-1234", "savvy@gmail.com: hi there", "Phone: 555 201 4477", "TheQuartering: hi"]) assert.deepEqual(linesOfRead(raw), [{ text: raw }], raw);
+ const long = Array.from({ length: 30 }, (_, i) => `Sentence number ${i} goes on for a little while.`).join(" ");
+ const out = linesOfRead(long);
+ assert.ok(out.length > 1 && out.every((l) => l.text.length <= 600 && /\.$/.test(l.text)), "split at sentence ends");
+ assert.equal(out.map((l) => l.text).join(" "), long);
+ const noStop = "word ".repeat(200).trim();
+ assert.ok(linesOfRead(noStop).every((l) => l.text.length <= 600 && !/^ | $/.test(l.text)));
+ assert.throws(() => linesOfRead(" \n <sigh> \n"), /no words/);
+ assert.throws(() => linesOfRead(Array.from({ length: 61 }, (_, i) => `line ${i}`).join("\n")), /at most 60/);
+});
+
+test("screenFromRead: a picture-only post's script made a screen on its picture, read whole, NOT checked; refused for any other post", () => {
+ const made = screenFromRead(PIC, { pictureOnly: ownPictureOnly(PIC), id: "s1" });
+ assert.deepEqual(made.screen, { id: "s1", media: 0, kind: "text", source: "transcribed", lines: [{ text: "I never said that." }, { text: "Order number: 4419283 was refunded on 11/02/2026." }], read: "all" });
+ assert.deepEqual(validatePostItem({ ...PIC, screens: [made.screen] }), []);
+ // Its shapes are masked like any line's (the order number drawn as a bar, never said); its date stays.
+ assert.ok(!maskShapes(made.screen.lines[1].text).text.includes("4419283"));
+ assert.ok(maskShapes(made.screen.lines[1].text).text.includes("11/02/2026"));
+ // A GIF: visible its whole length.
+ const gif = screenFromRead({ ...PIC, media: [GIF] }, { pictureOnly: true, id: "s1", kind: "dm" });
+ assert.deepEqual([gif.screen.at, gif.screen.kind], [[0, 2.53], "dm"]);
+ assert.match(screenFromRead({ ...PIC, media: [{ ...GIF, seconds: undefined }] }, { pictureOnly: true, id: "s1" }).error, /--at/);
+ assert.match(screenFromRead({ ...PIC, text: "a whole sentence of words" }, { pictureOnly: false, id: "s1" }).error, /not a picture-only post/);
+ assert.match(screenFromRead({ ...PIC, narration: { ...PIC.narration, script: "" } }, { pictureOnly: true, id: "s1" }).error, /no words/);
+ assert.match(screenFromRead(PIC, { pictureOnly: true, id: "s1", kind: "chat" }).error, /--kind takes/);
+ assert.match(screenFromRead(PIC, { pictureOnly: true, id: "s1", media: 4 }).error, /--media 4/);
+});
+
+test("the CLI: posts screen … add --from-read writes one screen from narration.script (not checked; the lint says so); refused off a picture-only post", async () => {
+ const p = await project("fromread", PIC);
+ let r = await posts(["screen", "fromread", "p-7", "add", "--from-read", "--dry-run"]);
+ assert.equal(r.code, 0, r.text);
+ assert.equal((await read(p)).timeline[0].screens, undefined, "a dry run writes nothing");
+ r = await posts(["screen", "fromread", "p-7", "add", "--from-read", "--title", "A statement", "--json"]);
+ assert.equal(r.code, 0, r.text);
+ const j = r.json();
+ assert.deepEqual(j.screens[0].lines.map((l) => l.text), ["I never said that.", "Order number: 4419283 was refunded on 11/02/2026."]);
+ assert.equal(j.screens[0].title, "A statement");
+ assert.equal(j.screens[0].checked, undefined);
+ assert.ok(j.warnings.some((w) => /screen s1's transcription not checked/.test(w)));
+ assert.ok(j.warnings.some((w) => /does not read screen s1/.test(w)), "nothing drawn until the read reads it");
+ r = await posts(["screen", "fromread", "p-7", "add", "--from-read", "--line", "a: b"]);
+ assert.equal(r.code, 2);
+ await project("fromread2", { ...PIC, text: "A post with words of its own." });
+ r = await posts(["screen", "fromread2", "p-7", "add", "--from-read"]);
+ assert.equal(r.code, 2);
+ assert.match(r.text, /not a picture-only post/);
+});
diff --git a/umtool/report-to-video/post-screens.mjs b/umtool/report-to-video/post-screens.mjs
@@ -401,6 +401,73 @@ export function lineOfText(raw) {
return { ...(out.who ? { who: out.who } : {}), ...(out.side ? { side: out.side } : {}), text: t.trim(), ...(out.time ? { time: out.time } : {}), ...(out.redact ? { redact: true } : {}) };
}
+/** An Orpheus emotion tag in a script ("<sigh>", "<laugh>"): how it is read, never the picture's words. */
+const SCRIPT_TAG_RE = /<\s*[a-z]+\s*>/gi;
+
+/**
+ * A PICTURE-ONLY post's READ as a screen's LINES, pure (`posts screen … add --from-read`, the post bench's "From its
+ * read": one rule): its script (`narration.script`, the words on the picture as the operator wrote them to be read) a
+ * line per line of it -- blank lines dropped, its emotion tags left out, a line longer than a screen line split at its
+ * sentence ends (then at a space) -- each `{ text }` alone: a "who:" is NEVER parsed out of a read (a shape or a
+ * heading would become a speaker: "Order number: 4419"); the speakers are the operator's to set. Throws when it holds
+ * no words or more lines than a screen takes.
+ *
+ * @param {string} script
+ * @returns {Array<{ text: string }>}
+ */
+export function linesOfRead(script) {
+ const out = [];
+ const push = (t) => {
+ const v = t.replace(/\s+/g, " ").trim();
+ if (v) out.push({ text: v });
+ };
+ for (const raw of str(script).replace(SCRIPT_TAG_RE, " ").split(/\r?\n/)) {
+ let t = raw.replace(/\s+/g, " ").trim();
+ while (t.length > SCREEN_LINE_MAX) {
+ const head = t.slice(0, SCREEN_LINE_MAX + 1);
+ const ends = [...head.matchAll(/[.!?…]["')\]”’]*\s/g)].map((m) => m.index + m[0].length).filter((i) => i <= SCREEN_LINE_MAX);
+ const sp = head.lastIndexOf(" ");
+ const cut = ends.length ? ends[ends.length - 1] : sp > 0 ? sp + 1 : SCREEN_LINE_MAX;
+ push(t.slice(0, cut));
+ t = t.slice(cut).trim();
+ }
+ push(t);
+ }
+ if (!out.length) throw new Error("its read has no words to make lines of (narration.script is empty)");
+ if (out.length > SCREEN_LINES_MAX) throw new Error(`its read is ${out.length} lines -- a screen takes at most ${SCREEN_LINES_MAX}: shorten the script, or add the screen's lines by hand`);
+ return out;
+}
+
+/**
+ * A SCREEN MADE FROM A PICTURE-ONLY POST's READ, pure: `{ screen }` -- on its picture (`media`: the index given, else
+ * its first image, else its first attachment), `kind` (default "text"), its lines linesOfRead's, read whole, NOT
+ * checked (the lint says so until a person reads it against the picture) -- or `{ error }`: not picture-only
+ * (`pictureOnly`: the caller's post-item.mjs ownPictureOnly), no script, no attachment, a kind or an index wrong.
+ *
+ * @param {Record<string, any>} e
+ * @param {{ pictureOnly: boolean, id: string, media?: number | null, kind?: string | null }} o
+ */
+export function screenFromRead(e, { pictureOnly, id, media = null, kind = null }) {
+ if (!pictureOnly) return { error: `${e?.id ?? "the item"} is not a picture-only post: --from-read makes a screen of a picture-only post's read (its words on the picture); type or paste this one's lines (--from <file>, --line)` };
+ const list = Array.isArray(e?.media) ? e.media : [];
+ if (!list.length) return { error: `${e?.id ?? "the item"} has no attachment for the screen to be in` };
+ const at = media !== null && media !== undefined ? media : Math.max(0, list.findIndex((m) => m?.kind === "image"));
+ if (!Number.isInteger(at) || !isObj(list[at])) return { error: `--media ${media}: ${e?.id} has attachments 0–${list.length - 1}` };
+ const k = kind ?? "text";
+ if (!SCREEN_KINDS.includes(k)) return { error: `--kind takes ${SCREEN_KINDS.join(", ")}` };
+ let lines;
+ try {
+ lines = linesOfRead(str(e?.narration?.script));
+ } catch (err) {
+ return { error: `${e?.id}: ${err instanceof Error ? err.message : err}` };
+ }
+ // A GIF's or a video's: visible its whole length (the picture stays in its card), when its length is known.
+ const m = list[at];
+ const timed = m.kind === "video" || m.kind === "gif";
+ if (timed && !(fin(m.seconds) && m.seconds >= SCREEN_MIN_SPAN)) return { error: `attachment ${at} is a ${m.kind} of no known length: add the screen with --at <from>,<to>` };
+ return { screen: { id, media: at, ...(timed ? { at: [0, r3(m.seconds)] } : {}), kind: k, source: "transcribed", lines, read: "all" } };
+}
+
// ---------------------------------------------------------------------------
// THE VALIDATION.
// ---------------------------------------------------------------------------