commit f1a436878072ff8787ed14ff3b0364f4a924d851
parent 8a5ee09e1d4dfaf787cf6706941d3a11f4518dae
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Tue, 17 Nov 2026 11:43:36 -0500
umtool review 2 (findings 1-6): an unedited read is never "edited", a lost read is landed, the marker kept honest
- 1: a take's words are its written script (a single read), else its parts rebuilt into paragraphs (a long
paragraph's parts joined with a space; thread parts by para % 100); a thread read stamps itself from its post
piece's WRITTEN words (postWrittenEdited), the writer leaves it; an unstamped thread read is legacy only when its
script was edited. Tests: probe 5 (an old take and a new one), a lexicon word, an anonymous handle, a thread read.
- 2: five missed polls leave the read "lost" with Check again (the same GET lands its take); on load, GET ?pending
finds a read made and not kept and lands it. e2e: the lost read is landed by Check again.
- 3: one try from the claim to the marker naming its job; any throw removes the marker and the .ask.json.
- 4: the GET removes the marker only when it names that job.
- 5: the screen-line hook counts missed polls per job.
- 6: --import decides the stamp first; a stamped import keeps its parts role-less (Rule B). Test.
Co-Authored-By: Claude <noreply@anthropic.com>
Diffstat:
9 files changed, 204 insertions(+), 47 deletions(-)
diff --git a/umtool/app/api/report/post-narration/route.ts b/umtool/app/api/report/post-narration/route.ts
@@ -93,6 +93,8 @@ const benchVoice = (red: { slurs?: { voice?: string } | null } | null) => (red?.
// screens, else `posts narrate <p> <item> --take --thread` asked as the
// playing read was -- every synthesized piece's next reading, unpicked
// GET ?project&id&screenJob=<job> either job: its state, its result, and -- ended -- the entry as it is
+// GET ?project&id&pending=1 the post's read being made or made and not kept: {jobId, file,
+// script, note} -- the bench follows `?job` with them to land its take
const noStore = { "cache-control": "no-store" };
type Entry = Record<string, unknown> & { id: string; type?: string; narration?: Record<string, unknown> };
@@ -136,6 +138,15 @@ export async function GET(request: Request) {
}
return Response.json({ ok: true, prompts }, { headers: noStore });
}
+ if (id && q.get("pending") !== null) {
+ // THE READ OF THIS POST BEING MADE, or made and not yet kept (review 2, finding 2): its marker's job, file and
+ // words -- a bench that lost it follows the same `?job` GET to land its take. `{ pending: null }` when there is none.
+ const e = postsOf(m).find((x) => x.id === id);
+ if (!e) return Response.json({ error: `no post item ${id}` }, { status: 404 });
+ const marker = (await readFile(pendingFileOf(r.project.dir, e), "utf8").then(JSON.parse, () => null)) as { jobId?: string; file?: string; script?: string; note?: string } | null;
+ const kept = marker?.file && ((e.narration?.takes ?? []) as Array<{ file?: string }>).some((t) => t.file === marker.file);
+ return Response.json({ ok: true, pending: marker?.jobId && marker.file && !kept ? { jobId: marker.jobId, file: marker.file, script: marker.script ?? null, note: marker.note ?? null } : null }, { headers: noStore });
+ }
if (id && q.get("screenJob") !== null) {
const j = getJob(String(q.get("screenJob")));
if (!j || !screenJobKinds(r.project.id, id).includes(j.kind)) return Response.json({ error: "no such job" }, { status: 404 });
@@ -167,7 +178,10 @@ export async function GET(request: Request) {
// While render mode gives the machine to a render, the read waits for it -- and says so (lane line-rerun).
const waiting = !st.done ? renderWaitSentence() : null;
if (!st.done) return Response.json({ state: "running", status: st.status, ...(waiting ? { waiting } : {}) }, { headers: noStore });
- await rm(pendingFileOf(r.project.dir, e), { force: true });
+ // The post's marker goes only when it names THIS job (review 2, finding 4): another tab's older job never clears
+ // a newer claim.
+ const marker = (await readFile(pendingFileOf(r.project.dir, e), "utf8").then(JSON.parse, () => null)) as { jobId?: string } | null;
+ if (marker?.jobId === job) await rm(pendingFileOf(r.project.dir, e), { force: true });
if (st.status !== "done") {
// A read that failed leaves nothing behind (its .ask.json would count as a take number).
await rm(`${path.join(r.project.dir, ...rel.split("/"))}.ask.json`, { force: true });
@@ -373,47 +387,52 @@ async function postHere(request: Request) {
await rm(pendingFile, { force: true });
if (!(await claim())) return Response.json({ error: "a read of this post is being made: wait for it", busy: true }, { status: 409 });
}
- // The voice: the one asked for, the item's own character, the project's characters and voice map, the CAST, the
- // narrator's -- a single read's rule (readVoice.mjs).
- const said = await itemReadVoice(r.project, e, {
- render: (m.render ?? {}) as Record<string, unknown>,
- engine: typeof body.engine === "string" && body.engine ? body.engine : null,
- voice: typeof body.voice === "string" && body.voice ? body.voice : null,
- });
- const engine = String(said.engine ?? k.engine);
- const voice = String(said.voice ?? k.voice);
- const pid = postIdOf(e);
- const dir = path.join(r.project.dir, ...takesDirOf(pid).split("/"));
- await mkdir(dir, { recursive: true });
- const rel = takeFileOf(pid, nextTakeNumber(e, await readdir(dir).catch(() => [])), engine, voice);
- // Its speed: the one asked for, else the item's own (`narration.speed`), else its character's (the synthetic
- // preset's that answered for the voice) -- makeTake's order.
- const askedSpeed = body.speed === undefined || body.speed === null ? (e.narration as { speed?: number } | undefined)?.speed ?? (said as { speed?: number }).speed : Number(body.speed);
- const speed = askedSpeed === undefined || askedSpeed === null || engine === "orpheus" ? undefined : Number(askedSpeed);
- // What the voice SAYS: the script with every redacted term left out (post-redact.mjs), each slur as the cut's
- // filter has it (post-slurs.mjs) and the project's pronunciation lexicon applied (post-say.mjs); the script is kept as written. The bench cannot word-time a take as it is made,
- // so a beep falls back to skip here (the CLI's --take times it and beeps).
- const red = await projectRedaction(r.project.dir, m);
- const spoken = spokenRead(script, e, red, { voice: benchVoice(red) }).text;
- const out = path.join(r.project.dir, ...rel.split("/"));
- // Its speed and where it came from, for the take the GET makes when the job is done (a sidecar, removed then).
- // A re-read (`keepPick`, the bench's Read again) joins the list unpicked: said here too.
- const keepPick = body.keepPick === true;
- if (speed || keepPick) await writeFile(`${out}.ask.json`, JSON.stringify({ ...(speed ? { speed, speedAsked: body.speed !== undefined && body.speed !== null ? true : (e.narration as { speed?: number } | undefined)?.speed != null ? "item" : "preset" } : {}), ...(keepPick ? { keepPick: true } : {}) }));
- const tuning = tuned?.ok && Object.keys(tuned.value).length ? tuned.value : null;
- let jobId: string;
+ // From the claim to the marker naming its job, ONE try (review 2, finding 3): any throw takes the marker (and the
+ // .ask.json) away, so a failed press never answers 409 for two minutes.
+ let askFile: string | null = null;
try {
- jobId = await startJob("/api/ops/tts", { text: spoken, engine, voice, out, ...(speed ? { speed } : {}), ...(tuning ? { tuning } : {}), ...(reading !== null ? { reading } : {}) });
+ // The voice: the one asked for, the item's own character, the project's characters and voice map, the CAST, the
+ // narrator's -- a single read's rule (readVoice.mjs).
+ const said = await itemReadVoice(r.project, e, {
+ render: (m.render ?? {}) as Record<string, unknown>,
+ engine: typeof body.engine === "string" && body.engine ? body.engine : null,
+ voice: typeof body.voice === "string" && body.voice ? body.voice : null,
+ });
+ const engine = String(said.engine ?? k.engine);
+ const voice = String(said.voice ?? k.voice);
+ const pid = postIdOf(e);
+ const dir = path.join(r.project.dir, ...takesDirOf(pid).split("/"));
+ await mkdir(dir, { recursive: true });
+ const rel = takeFileOf(pid, nextTakeNumber(e, await readdir(dir).catch(() => [])), engine, voice);
+ // Its speed: the one asked for, else the item's own (`narration.speed`), else its character's (the synthetic
+ // preset's that answered for the voice) -- makeTake's order.
+ const askedSpeed = body.speed === undefined || body.speed === null ? (e.narration as { speed?: number } | undefined)?.speed ?? (said as { speed?: number }).speed : Number(body.speed);
+ const speed = askedSpeed === undefined || askedSpeed === null || engine === "orpheus" ? undefined : Number(askedSpeed);
+ // What the voice SAYS: the script with every redacted term left out (post-redact.mjs), each slur as the cut's
+ // filter has it (post-slurs.mjs) and the project's pronunciation lexicon applied (post-say.mjs); the script is kept as written. The bench cannot word-time a take as it is made,
+ // so a beep falls back to skip here (the CLI's --take times it and beeps).
+ const red = await projectRedaction(r.project.dir, m);
+ const spoken = spokenRead(script, e, red, { voice: benchVoice(red) }).text;
+ const out = path.join(r.project.dir, ...rel.split("/"));
+ // Its speed and where it came from, for the take the GET makes when the job is done (a sidecar, removed then).
+ // A re-read (`keepPick`, the bench's Read again) joins the list unpicked: said here too.
+ const keepPick = body.keepPick === true;
+ askFile = `${out}.ask.json`;
+ if (speed || keepPick) await writeFile(`${out}.ask.json`, JSON.stringify({ ...(speed ? { speed, speedAsked: body.speed !== undefined && body.speed !== null ? true : (e.narration as { speed?: number } | undefined)?.speed != null ? "item" : "preset" } : {}), ...(keepPick ? { keepPick: true } : {}) }));
+ const tuning = tuned?.ok && Object.keys(tuned.value).length ? tuned.value : null;
+ const jobId = await startJob("/api/ops/tts", { text: spoken, engine, voice, out, ...(speed ? { speed } : {}), ...(tuning ? { tuning } : {}), ...(reading !== null ? { reading } : {}) });
+ // The marker names its job, its file and what the take keeps (its words, its note): a bench that lost the job
+ // finds it again here and lands its take (GET ?pending).
+ await writeFile(pendingFile, JSON.stringify({ jobId, file: rel, script, ...(typeof body.note === "string" && body.note ? { note: body.note } : {}), at: new Date().toISOString() }));
+ // Echoed only for the engine that takes them (Orpheus): Kokoro and eSpeak NG ignore them (the editor's result
+ // says so in its `note`, which the GET below hands on), so the answer never claims a tuning that is not used.
+ const tunes = engine === "orpheus";
+ return Response.json({ ok: true, jobId, file: rel, engine, voice, script, ...(tunes && tuning ? { tuning } : {}), ...(tunes && reading !== null ? { reading } : {}) }, { headers: noStore });
} catch (err) {
await rm(pendingFile, { force: true });
- await rm(`${out}.ask.json`, { force: true });
+ if (askFile) await rm(askFile, { force: true });
throw err;
}
- await writeFile(pendingFile, JSON.stringify({ jobId, file: rel, at: new Date().toISOString() }));
- // Echoed only for the engine that takes them (Orpheus): Kokoro and eSpeak NG ignore them (the editor's result
- // says so in its `note`, which the GET below hands on), so the answer never claims a tuning that is not used.
- const tunes = engine === "orpheus";
- return Response.json({ ok: true, jobId, file: rel, engine, voice, script, ...(tunes && tuning ? { tuning } : {}), ...(tunes && reading !== null ? { reading } : {}) }, { headers: noStore });
}
if (body.op === "derive") {
const takes = (e.narration?.takes ?? []) as Array<{ file: string; parts?: Array<{ n: number; file?: string }> }>;
diff --git a/umtool/components/projects/PostNarrationPanel.tsx b/umtool/components/projects/PostNarrationPanel.tsx
@@ -246,6 +246,22 @@ export default function PostNarrationPanel({
const j = await post({ op: "take", note: dir.note || undefined, voice: dir.voice || undefined, speed: dir.speed ? Number(dir.speed) : undefined, script });
if (j?.jobId && j.file) setJob({ id: j.jobId, file: j.file, note: dir.note, script, state: "running" });
};
+ // A READ OF THIS POST MADE BUT NOT KEPT (a bench that lost it, review 2 finding 2): followed again on load, the same
+ // `?job` GET landing its take.
+ useEffect(() => {
+ let live = true;
+ fetch(`/api/report/post-narration?project=${encodeURIComponent(project)}&id=${encodeURIComponent(entry.id)}&pending=1`, { cache: "no-store" })
+ .then((r) => (r.ok ? r.json() : null))
+ .then((j: { pending?: { jobId: string; file: string; script: string | null; note: string | null } | null } | null) => {
+ const p = j?.pending;
+ if (live && p) setJob((cur) => (cur?.state === "running" ? cur : { id: p.jobId, file: p.file, note: p.note ?? "", script: p.script ?? n.script ?? "", state: "running", again: true }));
+ })
+ .catch(() => {});
+ return () => {
+ live = false;
+ };
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [project, entry.id]);
// ---- READ AGAIN (lane line-rerun): the next reading, unpicked, played as it lands ------------------------------
const [autoplay, setAutoplay] = useAutoPlay();
const [landed, setLanded] = useState<string | null>(null);
@@ -287,7 +303,8 @@ export default function PostNarrationPanel({
const r = await fetch(`/api/report/post-narration?${q}`, { cache: "no-store" }).catch(() => null);
if (!r) {
const misses = (job.polls ?? 0) + 1;
- setJob(misses >= 5 ? { ...job, state: "failed", error: "the bench did not answer" } : { ...job, polls: misses });
+ // Lost, not failed (review 2, finding 2): the job and its file are kept -- Check again lands the take the same way.
+ setJob(misses >= 5 ? { ...job, state: "lost", error: "the bench did not answer" } : { ...job, polls: misses });
return;
}
const j = (await r.json().catch(() => ({}))) as { state?: string; error?: string; entry?: Entry; token?: string; waiting?: string };
@@ -816,7 +833,12 @@ export default function PostNarrationPanel({
<button type="button" className={btn} disabled={!script.trim() || job?.state === "running"} onClick={() => void retake()} data-post-retake="">
{job?.state === "running" ? "Synthesizing on the editor…" : "Re-take with direction"}
</button>
- {job?.state === "failed" && <span className="text-[var(--color-blocking,#c33)]" data-post-take-failed="">{job.error}</span>}
+ {(job?.state === "failed" || job?.state === "lost") && <span className="text-[var(--color-blocking,#c33)]" data-post-take-failed="">{job.error}</span>}
+ {job?.state === "lost" && (
+ <button type="button" className={btn} onClick={() => setJob({ ...job, state: "running", polls: 0, error: undefined })} aria-label="Check again" data-post-take-check-again="">
+ Check again
+ </button>
+ )}
</div>
</section>
diff --git a/umtool/components/projects/ScreenLineVoice.tsx b/umtool/components/projects/ScreenLineVoice.tsx
@@ -48,6 +48,8 @@ export function useScreenVoice({ project, id, onEntry, unsaved }: { project: str
}, [loadPrompts]);
const follow = useCallback(
(j: Job) => {
+ // Each job its own count of missed polls (review 2, finding 5).
+ misses.current = 0;
setJob(j);
const tick = async () => {
const r = await fetch(`/api/report/post-narration?project=${encodeURIComponent(project)}&id=${encodeURIComponent(id)}&screenJob=${encodeURIComponent(j.id)}`, { cache: "no-store" }).catch(() => null);
diff --git a/umtool/e2e/post-narration.spec.ts b/umtool/e2e/post-narration.spec.ts
@@ -700,7 +700,13 @@ test("READ AGAIN (lane line-rerun): the next reading unpicked and heard as it la
await page.locator('[data-post-narration="p-31"] [aria-label="Read again"]').click();
await expect(page.locator('[data-post-narration="p-31"] [data-post-take-failed]')).toContainText("did not answer", { timeout: 20_000 });
await expect(page.locator('[data-post-narration="p-31"] [aria-label="Read again"]')).toBeEnabled();
+ // The bench back: Check again lands the take the editor made meanwhile (review 2, finding 2) -- nothing lost.
await page.unroute(/\/api\/report\/post-narration\?.*[?&]job=/);
+ const had = narr("p-31").takes!.length;
+ await page.locator('[data-post-narration="p-31"] [aria-label="Check again"]').click();
+ await expect.poll(() => narr("p-31").takes!.length, { timeout: 20_000 }).toBe(had + 1);
+ // A lost read is found again on load too: its marker is gone once its take is kept.
+ expect(existsSync(path.join(DIR, "narration", "posts", "31", ".reading.json"))).toBe(false);
});
test("READ A SCREEN LINE AGAIN (lane line-rerun): said as, read again alone, its readings listed and picked -- the controls by name; the narration page's too", async ({ page }) => {
diff --git a/umtool/lib/report/manifest.mjs b/umtool/lib/report/manifest.mjs
@@ -3443,7 +3443,8 @@ export function postNarrationIn(m, id, patch, { forReading = false } = {}) {
// STAMPED WHEN IT IS MADE (review 1, finding 3; the orchestrator's ruling): a take whose words are not the post's
// as drafted is a read edited for reading -- while it plays the card follows the shown text, whatever the script
// says later (post-item.mjs readEditOf).
- if (patch.addTake.forReading === undefined && takeIsEditedRead(e, patch.addTake)) patch.addTake.forReading = true;
+ // (A thread read decides its own when it is made: postThreadRead.mjs, from its post piece's written words.)
+ if (patch.addTake.forReading === undefined && patch.addTake.read?.kind !== "thread" && takeIsEditedRead(e, patch.addTake)) patch.addTake.forReading = true;
n.takes.push(patch.addTake);
if (patch.keepPick !== true) n.pick = n.takes.length - 1;
}
diff --git a/umtool/lib/report/postNarrationCli.mjs b/umtool/lib/report/postNarrationCli.mjs
@@ -29,7 +29,7 @@ import {
} from "umtool-report-to-video/post-narration";
import { CAST_CONVERT_PITCH, CAST_SEMITONES_MAX, convertPitchLabel } from "umtool-report-to-video/cast";
import { convertAskOf, stepPitchOf } from "./derivePitch.mjs";
-import { LEGACY_EDIT_TEXT, excerptSpansOf, legacyReadOf, postItemPlan, postReadText, readEditOf } from "umtool-report-to-video/post-item";
+import { LEGACY_EDIT_TEXT, excerptSpansOf, legacyReadOf, postItemPlan, postReadText, readEditOf, takeIsEditedRead } from "umtool-report-to-video/post-item";
import { partRoles } from "umtool-report-to-video/post-thread";
import { spokenRead } from "umtool-report-to-video/post-redact";
import { projectRedaction } from "./postRedaction.mjs";
@@ -202,9 +202,13 @@ export async function importPatches(manifest, rows, measure) {
...(typeof t.note === "string" ? { note: t.note } : {}),
// A take composed of parts (a long post, paragraph by paragraph): the row's, else take-<n>.parts.json beside it.
// Each part's ROLE stored as it comes in (post-thread.mjs): the text it reads, its own or inferred.
+ // Its STAMP decided FIRST (review 2, finding 6): an imported read of words edited for reading is his post's,
+ // part by part (Rule B, as a made take's) -- never a role inferred from the edited words.
...(() => {
const parts = normalizeParts(Array.isArray(t.parts) ? t.parts : m.parts);
- return parts ? { parts: withPartRoles(e, parts) } : {};
+ const script = typeof t.script === "string" ? t.script : String(row.script ?? "");
+ const edited = takeIsEditedRead(e, { script, ...(parts ? { parts } : {}) });
+ return { ...(edited ? { forReading: true } : {}), ...(parts ? { parts: edited ? parts : withPartRoles(e, parts) } : {}) };
})(),
});
files.add(t.file);
diff --git a/umtool/lib/report/postReadAgain.test.mjs b/umtool/lib/report/postReadAgain.test.mjs
@@ -137,3 +137,77 @@ test("RULING 3 HOLDS when the script is saved back to the post's words while an
postNarrationIn(m, "p-7003", { script: drafted });
assert.deepEqual(drawn(m.timeline[0]), base);
});
+
+// ---------------------------------------------------------------------------
+// AN UNEDITED READ IS NOT "EDITED" (review 2, finding 1): a paragraph over 60 words read in several parts, the parts
+// saying a lexicon word, an anonymous handle said as its shown name -- none is an edit for reading: no stamp, no notice.
+// ---------------------------------------------------------------------------
+
+test("AN UNEDITED READ in several parts of one long paragraph is neither stamped nor flagged (probe 5)", async () => {
+ const { postNarrationIn } = await import("./manifest.mjs");
+ const { singleItem } = await import("../../report-to-video/post-reading-pin.fixtures.mjs");
+ const { draftScript, scriptParts } = await import("umtool-report-to-video/post-narration");
+ const { legacyReadOf, readEditOf } = await import("umtool-report-to-video/post-item");
+ const long = Array.from({ length: 9 }, (_, i) => `The council met on day ${i + 1} about the new bridge and nobody came.`).join(" ");
+ const e = singleItem({ text: long });
+ const d = draftScript(long).script;
+ let t = 0;
+ const parts = scriptParts(d).map((p) => {
+ const q = { n: p.n, para: p.para, text: p.text, start: t, seconds: 5 };
+ t += 5.25;
+ return q;
+ });
+ assert.ok(parts.length > 1 && d.split("\n\n").length === 1, "one paragraph, read in several parts");
+ const take = { file: "narration/posts/7003/take-1.orpheus-zac.wav", engine: "orpheus", voice: "zac", seconds: t, script: d, parts };
+ // A take from before the rule: no notice.
+ assert.equal(legacyReadOf({ ...e, narration: { script: d, pick: 0, takes: [take] } }), false);
+ // A take made now: no stamp.
+ const m = { timeline: [{ ...e, narration: { script: d, takes: [] } }] };
+ postNarrationIn(m, e.id, { addTake: { ...take } });
+ assert.equal("forReading" in m.timeline[0].narration.takes[0], false);
+ assert.equal(readEditOf(m.timeline[0]), null);
+ // Its parts' words without its script (an imported take): rebuilt into the paragraph, still not an edit.
+ const { script: _s, ...noScript } = take;
+ void _s;
+ assert.equal(legacyReadOf({ ...e, narration: { script: d, pick: 0, takes: [noScript] } }), false);
+});
+
+test("A LEXICON WORD or AN ANONYMOUS HANDLE said another way is not an edit: a single read's written script decides; a thread read's post piece's written words", async () => {
+ const { postNarrationIn } = await import("./manifest.mjs");
+ const { singleItem, threadItem } = await import("../../report-to-video/post-reading-pin.fixtures.mjs");
+ const { legacyReadOf } = await import("umtool-report-to-video/post-item");
+ const { postWrittenEdited } = await import("./postThreadRead.mjs");
+ const e = singleItem();
+ const d = shownDraftOf(e);
+ // Lexicon: its parts say "the B R I D G E" where the post says "the bridge"; its script is the post's words.
+ const said = d.replace("bridge", "B R I D G E");
+ const lex = { file: "narration/posts/7003/take-2.orpheus-zac.wav", engine: "orpheus", voice: "zac", seconds: 6, script: d, parts: said.split("\n\n").map((text, i) => ({ n: i + 1, para: i, text, start: i * 3, seconds: 3 })), lexicon: [{ word: "bridge", say: "B R I D G E" }] };
+ // An anonymous handle said as its shown name (`said`), the script the post's words.
+ const anon = { file: "narration/posts/7003/take-3.orpheus-zac.wav", engine: "orpheus", voice: "zac", seconds: 6, script: d, said: d.replace("council", "Anon 1") };
+ for (const t of [lex, anon]) {
+ const m = { timeline: [{ ...e, narration: { script: d, takes: [] } }] };
+ postNarrationIn(m, e.id, { addTake: { ...t } });
+ assert.equal("forReading" in m.timeline[0].narration.takes[0], false, t.file);
+ assert.equal(legacyReadOf({ ...e, narration: { script: d, pick: 0, takes: [t] } }), false, t.file);
+ }
+ // A thread read: stamped from its post piece's WRITTEN words, not its spoken ones.
+ const th = threadItem();
+ assert.equal(postWrittenEdited(th, { pieces: [{ role: "post", written: shownDraftOf(th), text: "the B R I D G E said" }] }), false);
+ assert.equal(postWrittenEdited(th, { pieces: [{ role: "post", written: "Other words entirely.", text: "Other words entirely." }] }), true);
+ // An unstamped thread read whose parts say a lexicon word, its script the post's: no notice.
+ assert.equal(legacyReadOf(th), false);
+});
+
+test("AN IMPORTED READ of words edited for reading is stamped FIRST and its parts are his post's, never a role inferred from the edited words (review 2, finding 6)", async () => {
+ const { importPatches } = await import("./postNarrationCli.mjs");
+ const { singleItem, threadItem } = await import("../../report-to-video/post-reading-pin.fixtures.mjs");
+ const e = singleItem({ parents: [threadItem().parents[0]] });
+ const parentWords = "Does anyone know why the tolls on the old crossing keep rising?";
+ const script = `The council met on Tuesday about the new bridge.\n\n${parentWords}`;
+ const rows = [{ id: "7003", entry: e.id, script, takes: [{ file: "narration/posts/7003/take-5.orpheus-zac.wav", script, seconds: 6, parts: script.split("\n\n").map((text, i) => ({ n: i + 1, para: i, text, start: i * 3, seconds: 3 })) }] }];
+ const measure = async () => ({ seconds: 6, at: "2026-11-17T00:00:00.000Z", parts: null });
+ const { patches } = await importPatches({ timeline: [e] }, rows, measure);
+ const t = patches.find((p) => p.patch.addTake)?.patch.addTake;
+ assert.equal(t.forReading, true);
+ assert.ok(t.parts.every((p) => p.role === undefined), JSON.stringify(t.parts));
+});
diff --git a/umtool/lib/report/postThreadRead.mjs b/umtool/lib/report/postThreadRead.mjs
@@ -59,7 +59,7 @@ import path from "node:path";
import { promisify } from "node:util";
import { POST_PART_GAP, draftScript, nextTakeNumber, pickedTake, postIdOf, postNarrationKnobs, scriptParts, takeFileOf, takeIdOf, takesDirOf } from "umtool-report-to-video/post-narration";
import { chosenLineTakes, chronoPieces, lineTakesOf } from "umtool-report-to-video/post-thread";
-import { cardText, parentsOf } from "umtool-report-to-video/post-item";
+import { cardText, parentsOf, saysShownDraft, shownDraftOf } from "umtool-report-to-video/post-item";
import { planContext } from "umtool-report-to-video/post-conversation";
import { spokenRead, termsFor } from "umtool-report-to-video/post-redact";
import { readSpeedOf, resolvePieceVoice } from "umtool-report-to-video/post-say";
@@ -698,6 +698,9 @@ export async function threadTake(project, e, opts = {}) {
// Where its parts' speeds came from: --speed (kept as asked), else their characters' presets / the item's own.
...(plan.pieces.some((p) => typeof p.speed === "number") ? { speedAsked: typeof speed === "number" ? true : "preset" } : {}),
read: readRecordOf({ parents, skip, quoted, linked, readSeen, overrides, voice, speed, postTake, screens, lineTakes, pieces: plan.pieces }),
+ // STAMPED FOR READING when his post piece was WRITTEN as other words than the post's as drafted (review 2,
+ // finding 1: never judged from its parts, which hold the words as spoken -- a lexicon word is not an edit).
+ ...(postWrittenEdited(e, plan) ? { forReading: true } : {}),
};
// A re-read (--no-pick, the bench's Read again) joins the list unpicked: Pick makes it the one.
const patch = { addTake: take, ...(keepPick ? { keepPick: true } : {}), ...(plan.script ? { script: plan.script } : {}) };
@@ -710,6 +713,13 @@ export async function threadTake(project, e, opts = {}) {
return { ...base, upToDate: false, fresh, jobs, lane, take, result, editNotes };
}
+/** Whether a thread read's post piece was written as other words than the post's as drafted (its stamp). */
+export function postWrittenEdited(e, plan) {
+ const pc = plan.pieces.find((x) => x.role === "post");
+ if (!pc) return false;
+ return !!String(shownDraftOf(e) ?? "").trim() && !saysShownDraft(e, pc.written);
+}
+
/** The guard on the item as it is now (postThreadCli.mjs readListing): what the card would refuse, and its warnings. */
async function guardOf(project, id) {
const { readListing } = await import("./postThreadCli.mjs");
diff --git a/umtool/report-to-video/post-item.mjs b/umtool/report-to-video/post-item.mjs
@@ -197,17 +197,33 @@ export function scriptEditOf(entry, script = entry?.narration?.script) {
return entry?.narration?.forReading === true ? "reading" : "legacy";
}
-/** The post's words a take SAYS: its parts of his post ("post") when it has roles, else all its parts, else its script. */
+/**
+ * The post's words a take READ, as written (review 2, finding 1): a single read's `script` (the words before the
+ * lexicon, the redaction or an anonymous handle changed what was said), else its parts -- his post's ("post") when
+ * they store roles -- rebuilt into paragraphs (a paragraph over 60 words is read in several parts: they join with a
+ * space; a thread read's part is in paragraph `para` % 100 of its piece).
+ */
export function takePostWords(take) {
const parts = Array.isArray(take?.parts) ? take.parts : [];
const roled = parts.some((p) => typeof p?.role === "string");
+ if (!roled && str(take?.script).trim()) return str(take.script);
const own = roled ? parts.filter((p) => p?.role === "post") : parts;
- return own.length ? own.map((p) => str(p?.text)).join("\n\n") : str(take?.script);
+ if (!own.length) return str(take?.script);
+ const paras = [];
+ let last;
+ for (const p of own) {
+ const k = Number.isInteger(p?.para) ? (roled ? p.para % 100 : p.para) : null;
+ if (paras.length && k !== null && k === last) paras[paras.length - 1] += ` ${str(p?.text).trim()}`;
+ else paras.push(str(p?.text).trim());
+ last = k;
+ }
+ return paras.join("\n\n");
}
/**
- * Whether a take is stamped FOR READING when it is made (the writer, postNarrationIn): its words are not the post's
- * as drafted -- an edit for reading, so while it plays the card follows the shown text. False with no shown text.
+ * Whether a take is stamped FOR READING when it is made (the writer, postNarrationIn): the words it read are not the
+ * post's as drafted. False with no shown text. A THREAD read decides its own when it is made, from the words its post
+ * piece was WRITTEN as (postThreadRead.mjs: its parts hold the words as spoken) -- the writer leaves it as it comes.
*/
export const takeIsEditedRead = (entry, take) => !!spacing(shownDraftOf(entry)) && !!spacing(takePostWords(take)) && !saysShownDraft(entry, takePostWords(take));
@@ -227,6 +243,9 @@ export const legacyReadOf = (entry) => !!pickedTake(entry) && readEditOf(entry)
export function readEditOf(entry, take = pickedTake(entry)) {
if (!take) return scriptEditOf(entry);
if (take.forReading === true) return "reading";
+ // An unstamped THREAD read's parts hold its words as SPOKEN (the lexicon, the redaction): it is legacy only when the
+ // script it read from was edited too -- a lexicon word alone is not an edit.
+ if (take.read?.kind === "thread" && (!str(entry?.narration?.script).trim() || saysShownDraft(entry, entry.narration.script))) return null;
return takeIsEditedRead(entry, take) ? "legacy" : null;
}