Archilyzer · Source

archilyzer

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

commit d97a834c54d281f0885a2da03496b0fe7c5bf145
parent 25a96f0d7b3e883b9a63ae0f5e0d7b766fcd07cb
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Wed, 11 Nov 2026 20:54:08 -0500

umtool: posts narrate --keep-preview of the record page's session ends that session, as the page's Keep does

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

Diffstat:
Mumtool/lib/report/postNarrationCli.mjs | 5++++-
Mumtool/lib/report/recordPreview.mjs | 11+++++++----
Mumtool/lib/report/recordPreview.test.mjs | 5++++-
3 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/umtool/lib/report/postNarrationCli.mjs b/umtool/lib/report/postNarrationCli.mjs @@ -561,6 +561,8 @@ export async function narrateCommand(project, words, flags, { json = false, dryR } if (flags.has("--keep-preview")) { const r = await keepPreview(project, e, { label, note: str("--note"), script: str("--script") }); + // A preview of the record page's session: its parts are takes now, the session is over. + if (r.session) await (await import("./recordSession.mjs")).clearSession(project.dir, e, label); if (json) out(JSON.stringify({ ok: true, id: e.id, takes: r.takes, picked: r.picked, notes: r.notes, disclosure: r.disclosure, character: r.character, token: r.token }, null, 2)); else { out(`${e.id}: ${r.takes.map((t) => `${t.step} -> ${t.file}`).join(", ")}; picked ${r.picked} (from its preview: nothing converted again)`); @@ -571,6 +573,7 @@ export async function narrateCommand(project, words, flags, { json = false, dryR // The recording: the file named, else the record page's session of this post (every part of it in). const file = str("--recording"); let parts; + const fromSession = file === null; if (file !== null) { const abs = path.resolve(file); if (!(await stat(abs).catch(() => null))?.isFile()) throw new NarrateError(`--recording takes a sound file (no ${file})`); @@ -585,7 +588,7 @@ export async function narrateCommand(project, words, flags, { json = false, dryR } const events = flags.has("--events"); const r = await runPreview(project, e, parts, { - label, as: str("--as"), clean: flags.has("--no-clean") ? false : flags.has("--clean") ? true : undefined, + label, session: fromSession, as: str("--as"), clean: flags.has("--no-clean") ? false : flags.has("--clean") ? true : undefined, ...(flags.has("--no-trim") ? { trim: { on: false, padMs: null } } : flags.has("--trim") ? { trim: { on: true, padMs: null } } : {}), spans: trimSpans(multi("--trim-span"), parts.length), convert: !flags.has("--no-convert"), engine: str("--engine"), voice: str("--voice"), ...pitchFlags(str), out: str("--out"), ask, // --events: one JSON object a line (the record page's job reads them); else the sentences. diff --git a/umtool/lib/report/recordPreview.mjs b/umtool/lib/report/recordPreview.mjs @@ -167,11 +167,12 @@ const notInstalled = (err) => err?.name === "OpNotInstalled" || /not installed/i * * Returns `{ dir, raw, clean, filtered, listen, notes, character, direction, convert, spans, lufs, cached }` -- the * files absolute; `listen` is what to compare with `raw` (the converted read, else the cleaned one, else null). - * `out`: `listen` (else `raw`) copied there. + * `out`: `listen` (else `raw`) copied there. `session: true`: the parts are the record page's session of the item + * (keepPreview says so, and its caller clears the session). */ export async function runPreview(project, entry, parts, { label = "operator", as = null, clean = undefined, trim = undefined, spans = null, convert = true, pitch = undefined, semitones = undefined, engine = null, voice = null, - out = null, emit = () => {}, editor = null, ask = null, + out = null, emit = () => {}, editor = null, ask = null, session = false, } = {}) { const layers = await readLayers(project.dir); const who = layers.characterForRead(entry, as); @@ -301,6 +302,8 @@ export async function runPreview(project, entry, parts, { } } doc.notes = notes; + // Made from the record page's session (not a file): keeping it is the end of that session. + doc.session = session === true; doc.character = character ? { id: character.id, name: shownNameOf(character), layer: who.layer } : null; await writePreview(dir, doc); const listen = doc.convert ? abs(doc.convert.file) : doc.built.clean ? abs(doc.built.clean.file) : null; @@ -361,7 +364,7 @@ export async function previewFile(projectDir, entry, which, { label = "operator" * original: trimmed, joined, levelled), the cleaned one (`steps: [{op: "enhance"}]`), the converted one (`steps: [{op: * "convert", engine, voice, pitch?, semitones?}]`) -- each a new take through the writer (an undo point each), the * last one PICKED (a pick takes the approval away: it awaits approval). Nothing is asked of the editor. The scratch dir - * is removed. Returns `{ takes: [{ step, file }], picked, notes, disclosure, character, entry, token }`. + * is removed. Returns `{ takes: [{ step, file }], picked, notes, disclosure, character, session, entry, token }`. * * @param {{ id: string, dir: string }} project * @param {Record<string, any>} entry @@ -435,5 +438,5 @@ export async function keepPreview(project, entry, { label = "operator", script = } await rm(dir, { recursive: true, force: true }); const now = findPostItem(await readManifest(project.dir), entry.id); - return { takes, picked: takes.at(-1).file, notes: doc.notes ?? [], disclosure: now ? postNarrationDisclosure(now) : null, character: who ?? null, entry: result.entry, token: result.token }; + return { takes, picked: takes.at(-1).file, notes: doc.notes ?? [], disclosure: now ? postNarrationDisclosure(now) : null, character: who ?? null, session: doc.session === true, entry: result.entry, token: result.token }; } diff --git a/umtool/lib/report/recordPreview.test.mjs b/umtool/lib/report/recordPreview.test.mjs @@ -255,7 +255,7 @@ test("the preset is honoured: enhance off, trim off; an editor with no enhance e await discardPreview(DIR, await item("p-3")); }); -test("the record page's session: a parted read previewed part by part, another recording starts over, Keep clears nothing it should not", async () => { +test("the record page's session: a parted read previewed part by part, kept from the terminal (the session over), or kept alone at its marks", async () => { const e = await item("p-2"); const a = path.join(ROOT, "part-a.wav"); const b = path.join(ROOT, "part-b.wav"); @@ -286,7 +286,10 @@ test("the record page's session: a parted read previewed part by part, another r for (const t of n.takes) for (const p of t.parts) assert.ok(existsSync(path.join(DIR, p.file)), p.file); assert.ok(Math.abs(n.takes[0].parts[1].seconds - 1.2) < 0.02, "the second part at its marks"); assert.deepEqual(validatePostNarration(await item("p-2")), []); + assert.equal(existsSync(path.join(DIR, "narration", "posts", "2", ".recording-operator")), false, "a session's preview kept: the session is over"); // finishSession with marks (Keep with no Filter): the recorded take alone, cut at them. + await savePart(DIR, e, { n: 1, count: 2, text: "A first paragraph.", para: 0, bytes: await readFile(a), type: "audio/wav" }); + await savePart(DIR, e, { n: 2, count: 2, text: "A second one.", para: 1, bytes: await readFile(b), type: "audio/wav" }); const kept = await finishSession(project, await item("p-2"), { manifest: await manifest(), spans: [{ from: 0.5, to: 1.5 }, null] }); assert.ok(Math.abs(kept.take.parts[0].seconds - 1) < 0.02); assert.equal(existsSync(path.join(DIR, "narration", "posts", "2", ".recording-operator")), false);