Archilyzer · Source

archilyzer

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

commit 16716b18ae5bf2c9d57632f8a3e11d012c78accd
parent 61698cdd51cba7edb835fb8796305e51f089b804
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Wed,  4 Nov 2026 02:18:18 -0500

umtool: quotes read in place -- read before his words (p-2116364553542070563, p-2116651428425150687), the quoted post was drawn inside his post, under his words, so the card opened scrolled down to it with his words cut off above, then jumped back up. Now it is its own tile ABOVE his post (threadLayout's quotedAt "above", labelled "quoted", at the size that fits it alone): in full and lit while read, then shrunk and dimmed like a parent as his words are revealed under it; read after his words it stays inside his post. Nothing read is clamped (audited: the 4-5 line clamp, the strip's ellipsis and a long link's "…" only touch unread words). The lint warns of an archived text the read reads that ends cut short (X's "…"/"Show more", not a link's). A status link is a quote: posts context resolves an x.com/twitter.com status link in an item's words (or its row's links) to a post any channel's archive holds (looked up lazily) and fills `quoted` (via: "link") when it has none, and snapshots the row's threadId as the item's `conversation` (both validated)

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

Diffstat:
Mumtool/lib/report/manifest.mjs | 7++++---
Mumtool/lib/report/postContext.mjs | 97+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----
Mumtool/lib/report/postContext.test.mjs | 26+++++++++++++++++++++++++-
Mumtool/lib/report/postsCli.mjs | 3++-
Mumtool/report-to-video/post-item.mjs | 21+++++++++++++++++++--
Mumtool/report-to-video/post-thread.mjs | 48++++++++++++++++++++++++++++++++++++------------
Mumtool/report-to-video/post-thread.test.mjs | 49+++++++++++++++++++++++++++++++++++++++++++++++--
Mumtool/report-to-video/read-follow.mjs | 3++-
8 files changed, 228 insertions(+), 26 deletions(-)

diff --git a/umtool/lib/report/manifest.mjs b/umtool/lib/report/manifest.mjs @@ -2839,12 +2839,13 @@ export async function fitPostItems(dir, fits, { token = null } = {}) { } /** What a context write may set on a post item (postContext.mjs). */ -export const POST_ITEM_CONTEXT_KEYS = Object.freeze(["quoted", "parents"]); +export const POST_ITEM_CONTEXT_KEYS = Object.freeze(["quoted", "parents", "conversation"]); /** * FILL POST ITEMS' CONTEXT (`umtool posts context`, postContext.mjs): `patches` - * is `{ <entry id>: { quoted?, parents? } }` -- the post it quotes and the posts - * it answers, snapshotted from each post's capture; a null clears one. ONE + * is `{ <entry id>: { quoted?, parents?, conversation? } }` -- the post it quotes, the posts + * it answers (snapshotted from each post's capture, or a status link's archived post) and + * the conversation it is part of (its archive row's threadId); a null clears one. ONE * structural write for them all (one undo point), refused whole in the * build's words (validatePostItem). Returns `{ ids }`. * diff --git a/umtool/lib/report/postContext.mjs b/umtool/lib/report/postContext.mjs @@ -23,11 +23,21 @@ // grey-checked; the badge the capture read is what it decides by. // // Plain ESM: the CLI runs it under bare node. -import { readFile } from "node:fs/promises"; +// +// A STATUS LINK IS A QUOTE (operator, 4 Nov: a post that embeds another by +// its link, not X's quote): a post item with no quoted post whose words (or +// its archive row's links) carry an x.com / twitter.com status link takes the +// post it names as its `quoted` (`via: "link"`) when any channel's posts +// archive holds it (read lazily, only for a link), else the capture's. The +// same pass snapshots the row's `threadId` as the entry's `conversation` +// (post-conversation.mjs reads a conversation by it). +import { readFile, readdir, stat } from "node:fs/promises"; import path from "node:path"; +import { joinSplitLinks } from "umtool-report-to-video/post-narration"; import { channelsDirFor, readManifest } from "../projects/report.mjs"; import { withEditNotes } from "./edit-guard.mjs"; import { manifestToken, setPostItemsContext } from "./manifest.mjs"; +import { findPostRow } from "./postsCli.mjs"; const isObj = (v) => !!v && typeof v === "object" && !Array.isArray(v); const str = (v) => (typeof v === "string" ? v : ""); @@ -111,6 +121,65 @@ export function applyCaptureContext(entry, context) { return filled; } +/** An x.com / twitter.com status link: its handle and the post's id. */ +const STATUS_RE = /https?:\/\/(?:www\.|mobile\.)?(?:x|twitter)\.com\/([A-Za-z0-9_]{1,30})\/status(?:es)?\/(\d{5,25})/gi; + +/** + * The status links in a post's words (X's split links put back first) and in + * its archive row's `links`, in order, each once: `[{ handle, id }]`. Pure. + */ +export function statusLinksOf(text, links = []) { + const out = []; + const seen = new Set(); + const from = [joinSplitLinks(str(text)), ...(Array.isArray(links) ? links.map((l) => (typeof l === "string" ? l : str(l?.url) || str(l?.expanded))) : [])]; + for (const t of from) { + for (const m of t.matchAll(STATUS_RE)) { + if (seen.has(m[2])) continue; + seen.add(m[2]); + out.push({ handle: m[1], id: m[2] }); + } + } + return out; +} + +/** A post item ref from an archive row (postsCli.mjs findPostRow's), `via: "link"`; null for nothing usable. */ +export function refFromRow(row) { + if (!isObj(row)) return null; + const ref = contextRefOf({ id: str(row.id), author: str(row.authorName), handle: str(row.author), date: str(row.createdAt), text: str(row.text), url: str(row.url) }); + return ref ? { ...ref, via: "link" } : null; +} + +/** + * A RESOLVER of status ids to archived posts across every channel's posts + * archive (`channels/<slug>/posts/*.jsonl`), lazy: the channels are listed on + * the first call, a channel named for the link's handle read first, each id + * looked up once. + */ +export function statusResolver(channelsDir) { + let slugs = null; + const cache = new Map(); + return async function resolve({ handle, id }) { + if (cache.has(id)) return cache.get(id); + if (slugs === null) { + const names = await readdir(channelsDir).catch(() => []); + slugs = []; + for (const n of names) if (POST_KEY_RE.test(n) && (await stat(path.join(channelsDir, n, "posts")).catch(() => null))?.isDirectory()) slugs.push(n); + } + const h = str(handle).toLowerCase(); + const order = [...slugs.filter((s) => h && s.toLowerCase().startsWith(h)), ...slugs.filter((s) => !(h && s.toLowerCase().startsWith(h)))]; + let row = null; + for (const slug of order) { + const hit = await findPostRow(channelsDir, slug, id).catch(() => null); + if (hit?.row) { + row = hit.row; + break; + } + } + cache.set(id, row); + return row; + }; +} + /** * The `context` of a post's capture (`channels/<slug>/posts-media/<postId>/capture.json`), * or null when there is no capture or it read none. @@ -150,19 +219,38 @@ export async function postsContext(project, { channelsDir = null, dryRun = false const report = []; /** @type {Map<string, string[]>} */ const missing = new Map(); + const resolve = statusResolver(dir); for (const e of items) { const [slug, rowId] = e.post.split("/"); // A repost is drawn as its original: the original's capture first. const shownId = str(e.originalId) || rowId; const context = (await readCaptureContext(dir, slug, shownId)) ?? (shownId !== rowId ? await readCaptureContext(dir, slug, rowId) : null); - if (!context) { + const copy = structuredClone(e); + const filled = context ? applyCaptureContext(copy, context) : []; + // Its archive row: the conversation it is part of, and the links its words carry. + const row = ID_RE.test(String(shownId)) ? (await findPostRow(dir, slug, String(shownId)).catch(() => null))?.row ?? null : null; + // A status link is a quote, when it has none (or one with no words): the post it names, archived anywhere. + if (!isObj(copy.quoted) || !str(copy.quoted.text).trim()) { + for (const link of statusLinksOf(e.text, row?.links)) { + if (link.id === shownId || link.id === rowId) continue; + const ref = refFromRow(await resolve(link)); + if (!ref) continue; + copy.quoted = isObj(copy.quoted) && sameRef(copy.quoted, ref) ? completed(copy.quoted, ref) : ref; + if (!filled.includes("quoted")) filled.push("quoted"); + break; + } + } + const conv = str(row?.threadId); + if (!str(e.conversation) && ID_RE.test(conv)) { + copy.conversation = conv; + filled.push("conversation"); + } + if (!context && !filled.length) { report.push({ id: e.id, post: e.post, state: "no-context" }); if (!missing.has(slug)) missing.set(slug, []); missing.get(slug).push(shownId); continue; } - const copy = structuredClone(e); - const filled = applyCaptureContext(copy, context); if (!filled.length) { report.push({ id: e.id, post: e.post, state: "complete" }); continue; @@ -170,6 +258,7 @@ export async function postsContext(project, { channelsDir = null, dryRun = false patches[e.id] = { ...(filled.includes("quoted") ? { quoted: copy.quoted } : {}), ...(filled.includes("parents") ? { parents: copy.parents } : {}), + ...(filled.includes("conversation") ? { conversation: copy.conversation } : {}), }; report.push({ id: e.id, post: e.post, state: "filled", filled, ...patches[e.id] }); } diff --git a/umtool/lib/report/postContext.test.mjs b/umtool/lib/report/postContext.test.mjs @@ -10,7 +10,7 @@ import { tmpdir } from "node:os"; import path from "node:path"; import { after, test } from "node:test"; import { cardAuthors, validatePostItem } from "umtool-report-to-video/post-item"; -import { applyCaptureContext, contextCaptureCall, contextRefOf, postsContext, readCaptureContext, sameRef } from "./postContext.mjs"; +import { applyCaptureContext, contextCaptureCall, contextRefOf, postsContext, readCaptureContext, refFromRow, sameRef, statusLinksOf } from "./postContext.mjs"; import { postItemFromArchive, postsReel } from "./postReel.mjs"; import { postsCommand } from "./postsCli.mjs"; import { setPostItemsContext, undoStructural } from "./manifest.mjs"; @@ -174,3 +174,27 @@ test("the writer: only quoted and parents, refused whole in the build's words; t assert.equal(await readCaptureContext(CH, "obv-x", "302"), null); assert.equal((await readCaptureContext(CH, "obv-x", "300")).parent.handle, "Kirsche"); }); + +test("A STATUS LINK IS A QUOTE: a post with no quoted post whose words link another (X's split link put back) takes it from any channel's archive (via: link); the row's threadId is its conversation", async () => { + assert.deepEqual(statusLinksOf("look\nhttps://\nx.com/OtherPerson/status/7770000000000001\n…", ["https://twitter.com/a_b/status/123456789"]), [{ handle: "OtherPerson", id: "7770000000000001" }, { handle: "a_b", id: "123456789" }]); + assert.deepEqual(statusLinksOf("no links here"), []); + assert.equal(refFromRow({ id: "1", author: "x_y", authorName: "X Y", createdAt: "2026-10-01T00:00:00.000Z", text: "hi", url: "https://x.com/x_y/status/1" }).via, "link"); + await archive("other-x", [row("7770000000000001", { channelSlug: "other-x", slug: "other-x/7770000000000001", author: "OtherPerson", authorName: "Other Person", text: "The post he linked to." })]); + await archive("obv-z", [ + row("500", { channelSlug: "obv-z", slug: "obv-z/500", text: "Read this\nhttps://\nx.com/OtherPerson/status/7770000000000001\n…", threadId: "499" }), + row("501", { channelSlug: "obv-z", slug: "obv-z/501", createdAt: "2026-10-29T15:00:00.000Z" }), + ]); + const p = await project("ctx-link"); + await postsReel(p, { channels: ["obv-z"] }); + const r = await postsContext(p); + const x = r.report.find((y) => y.id === "p-500"); + assert.deepEqual(x.filled, ["quoted", "conversation"]); + const e = (await manifest(p)).timeline.find((y) => y.id === "p-500"); + assert.deepEqual([e.quoted.handle, e.quoted.text, e.quoted.via, e.conversation], ["OtherPerson", "The post he linked to.", "link", "499"]); + assert.deepEqual(validatePostItem(e), []); + assert.equal(r.report.find((y) => y.id === "p-501").state, "no-context"); + // Re-run: nothing more to fill. + assert.equal((await postsContext(p)).filled, 0); + assert.match(validatePostItem({ ...e, conversation: 5 }).join(" "), /conversation must be/); + assert.match(validatePostItem({ ...e, quoted: { ...e.quoted, via: "guess" } }).join(" "), /via must be "link"/); +}); diff --git a/umtool/lib/report/postsCli.mjs b/umtool/lib/report/postsCli.mjs @@ -736,8 +736,9 @@ async function contextCommand(projectArg, { root, json, dryRun, out }) { for (const x of r.report) { if (x.state !== "filled") continue; const what = [ - x.quoted ? `quotes ${x.quoted.handle ? `@${x.quoted.handle}` : x.quoted.author ?? "?"}` : "", + x.quoted ? `quotes ${x.quoted.handle ? `@${x.quoted.handle}` : x.quoted.author ?? "?"}${x.quoted.via === "link" ? " (its status link, archived)" : ""}` : "", x.parents ? `answers ${x.parents[0]?.handle ? `@${x.parents[0].handle}` : x.parents[0]?.author ?? "?"}` : "", + x.conversation ? `conversation ${x.conversation}` : "", ].filter(Boolean).join(", "); out(` ${x.id} ${what}`); } diff --git a/umtool/report-to-video/post-item.mjs b/umtool/report-to-video/post-item.mjs @@ -412,6 +412,8 @@ function refErrors(r, where) { } if (r.handle !== undefined && (typeof r.handle !== "string" || !HANDLE_RE.test(r.handle))) errors.push(`${where}.handle must be a handle`); if (r.badge !== undefined && r.badge !== null && !BADGES.includes(r.badge)) errors.push(`${where}.badge must be one of ${BADGES.join(", ")}`); + // How it was found: "link" -- a status link in the post's words, resolved to an archived post (postContext.mjs). + if (r.via !== undefined && r.via !== "link") errors.push(`${where}.via must be "link" (a status link resolved to an archived post)`); if (typeof r.text === "string" && r.text.length > TEXT_MAX) errors.push(`${where}.text is longer than ${TEXT_MAX} characters`); if (r.paraphrase !== undefined) { if (typeof r.paraphrase !== "string") errors.push(`${where}.paraphrase must be a string (your retelling of its words; absent: its own words)`); @@ -447,6 +449,8 @@ export function validatePostItem(e) { if (!isObj(e.repostedBy) || typeof e.repostedBy.handle !== "string" || !HANDLE_RE.test(e.repostedBy.handle)) errors.push(`${w}.repostedBy must be { author?, handle }`); } if (e.quoted !== undefined) errors.push(...refErrors(e.quoted, `${w}.quoted`)); + // The conversation it is part of (postContext.mjs: the archive row's threadId, snapshotted; post-conversation.mjs). + if (e.conversation !== undefined && !(typeof e.conversation === "string" && /^[A-Za-z0-9_-]{1,64}$/.test(e.conversation))) errors.push(`${w}.conversation must be the conversation's id (a string)`); if (e.parents !== undefined) { if (!Array.isArray(e.parents)) errors.push(`${w}.parents must be a list (the posts it answers, nearest first)`); else { @@ -918,11 +922,19 @@ export function postCardHtml(entry, { width, height, palette = {}, fonts = {}, p ); } const qmode = q ? tmode("quoted") : null; + // Read before his words, the quoted post is its own tile ABOVE his post (post-thread.mjs threadLayout's + // quotedAt), labelled, at the size that fits it alone; read after them (or not), inside his post. + const qabove = !!tiles.find((t) => t.scope === "quoted")?.above; let quotedTile = ""; if (q && qmode && qmode !== "hidden") { const qsize = sizeFor(contextText(q), innerW - Math.round(36 * k), innerH - 140 * k); for (const kk of cut("quoted") ?? []) cutCss.push(`[data-thread-tile="quoted"] [data-post-block="${kk}"]`); - quotedTile = `<div class="tslot" data-thread-slot="quoted"><div class="tile quoted" data-thread-tile="quoted" data-thread-mode="${qmode}" data-post-quoted=""${red("quoted") ? ' data-redacted=""' : ""}><div class="phead">${avatarHtml(q, { redact: red("quoted"), size: Math.round(36 * k), img: pic(q) })}${nameHtml(q, { redact: red("quoted") })}<span class="pdate">${esc(cardDate(q.date).split(" · ")[0])}</span>${qmode === "excerpt" ? '<span class="plabel" data-thread-excerpt="">excerpt</span>' : ""}${paraLabel(q)}</div><div class="qtext tt"${isParaphrased(q) ? ' data-post-paraphrase=""' : ""} style="font-size:${Math.round(qsize * 0.9)}px">${wordsHtml(contextText(q), blurred, "quoted", hlOf("quoted"), blk("quoted"))}</div></div></div>`; + const label = qabove ? '<span class="plabel" data-thread-quoted-label="">quoted</span>' : ""; + quotedTile = `<div class="tslot" data-thread-slot="quoted"${qabove ? ' data-thread-above=""' : ""}><div class="tile quoted${qabove ? " tabove" : ""}" data-thread-tile="quoted" data-thread-mode="${qmode}" data-post-quoted=""${red("quoted") ? ' data-redacted=""' : ""}><div class="phead">${avatarHtml(q, { redact: red("quoted"), size: Math.round((qabove ? 44 : 36) * k), img: pic(q) })}${nameHtml(q, { redact: red("quoted"), cls: qabove ? "big" : "" })}<span class="pdate">${esc(cardDate(q.date).split(" · ")[0])}</span>${label}${qmode === "excerpt" ? '<span class="plabel" data-thread-excerpt="">excerpt</span>' : ""}${paraLabel(q)}</div><div class="qtext tt"${isParaphrased(q) ? ' data-post-paraphrase=""' : ""} style="font-size:${qabove ? qsize : Math.round(qsize * 0.9)}px">${wordsHtml(contextText(q), blurred, "quoted", hlOf("quoted"), blk("quoted"))}</div></div></div>`; + } + if (qabove && quotedTile) { + tileHtml.push(quotedTile); + quotedTile = ""; } const own = cardText(entry); const psize = own.trim() ? sizeFor(own, innerW, innerH - 170 * k) : size; @@ -935,6 +947,10 @@ export function postCardHtml(entry, { width, height, palette = {}, fonts = {}, p css: cutCss.length ? `\n${cutCss.join(", ")} { display: none; }` : "", }; }; + // NOTHING READ IS CLAMPED (post-thread.mjs): a context post's 4-5 line clamp (.ptext/.qtext) is on the plain + // card only, where no part reads it (a read one makes the card threaded, its tiles unclamped -- .tt -- or the + // guard refuses it with follow off); the strip's one-line ellipsis and a long link's "…" only touch words no + // part reads (links are never read: post-narration.mjs dropUrls). const tc = threaded ? threadCard(L.card) : null; const body = strip ? `${stripHtml}${slot}` : `${tc ? tc.html : card(L.card)}${slot}`; const minSize = tc ? size : follow ? followMin : Math.round(POST_TEXT_SIZES[POST_TEXT_SIZES.length - 1] * k); @@ -996,7 +1012,8 @@ b, .name, .mark { font-family: 'PostSansBold', sans-serif; font-weight: 400; } .tpost { display: flex; flex-direction: column; gap: ${Math.round(16 * k)}px; } .tile .tt { display: block; -webkit-line-clamp: none; overflow: visible; line-height: ${LINE}; color: ${pal.fg}; margin-top: ${Math.round(6 * k)}px; } .twords { line-height: ${LINE}; overflow-wrap: anywhere; } -.tile.quoted .tt { color: ${mixHex(pal.fg, pal.bg, 0.08)}; }${tc.css}` : ""}${highlight ? ` +.tile.quoted .tt { color: ${mixHex(pal.fg, pal.bg, 0.08)}; } +.tile.quoted.tabove .tt { color: ${pal.fg}; }${tc.css}` : ""}${highlight ? ` [data-w-hl] { background: ${rgbaOf(highlight.color, WORD_ZOOM_HIGHLIGHT_ALPHA)}; box-shadow: inset 0 -0.12em 0 ${highlight.color}; border-radius: 0.16em; padding: 0 0.08em; margin: 0 -0.08em; -webkit-box-decoration-break: clone; box-decoration-break: clone; }` : ""} ${BAR_CSS(pal.fg)} </style></head> diff --git a/umtool/report-to-video/post-thread.mjs b/umtool/report-to-video/post-thread.mjs @@ -49,7 +49,7 @@ // bench, the writers and the lint all read the same rules from here. import { cardText, contextText, parentsOf } from "./post-item.mjs"; -import { draftScript, isNarrated, isOnlyUrls, pickedTake, scriptParts, spokenUrls } from "./post-narration.mjs"; +import { draftScript, isNarrated, isOnlyUrls, joinSplitLinks, pickedTake, scriptParts, spokenUrls } from "./post-narration.mjs"; import { normWord, scriptWordsOf } from "./word-zoom.mjs"; import { followKnobs } from "./read-follow.mjs"; @@ -269,13 +269,21 @@ export function threadLayout(entry, render = undefined, { prev = null } = {}) { if (mode === "carry" && isRead) mode = "full"; tiles.push({ scope, mode, read: isRead }); } - tiles.push({ scope: "post", mode: "full", read: read.has("post") }); + // THE QUOTED POST (operator, 4 Nov: the quote read first while it sat under his words -- "the card opens + // scrolled down"): read BEFORE his words, it is its own tile ABOVE his post, read in full and lit, then + // shrunk and dimmed like a parent as his words come in; read after them (or not at all), inside his post. + const postAt = roles.findIndex((r) => r.role === "post"); + const quotedFirst = roles.findIndex((r) => r.role === "quoted"); + const quotedAt = quotedFirst >= 0 && (postAt < 0 || quotedFirst < postAt) ? "above" : "inside"; + const post = { scope: "post", mode: "full", read: read.has("post") }; if (isObj(entry?.quoted) && contextText(entry.quoted).trim()) { const m = k.quoted === "auto" ? (read.has("quoted") ? "full" : "context") : k.quoted; - tiles.push({ scope: "quoted", mode: m, read: read.has("quoted") }); - } + const q = { scope: "quoted", mode: m, read: read.has("quoted"), ...(quotedAt === "above" && m !== "hidden" && m !== "context" ? { above: true } : {}) }; + if (q.above) tiles.push(q, post); + else tiles.push(post, q); + } else tiles.push(post); const on = isNarrated(entry) && tiles.some((t) => t.scope !== "post" && t.mode !== "hidden"); - return { on, tiles, roles }; + return { on, tiles, roles, quotedAt: tiles.some((t) => t.above) ? "above" : "inside" }; } /** A tile's mode in a layout (null: no such tile). */ @@ -350,9 +358,9 @@ export function threadSchedule(entry, render, { layout, blocks, lead = 0.4 }) { const ts = p.parts.map((n) => startOfPart.get(n)).filter(fin); return { ...p, start: ts.length ? Math.min(...ts) : null }; }).filter((p) => p.start !== null && p.role); - // A tile's pieces (the quoted post reads inside his post's tile: the post tile shows for both). - const tileOf = (role) => (role === "quoted" ? "quoted" : role); - const firstRead = (scope) => pieces.find((p) => tileOf(p.role) === scope || (scope === "post" && p.role === "quoted"))?.start ?? null; + // A tile's pieces (a quoted post inside his post's tile: the post tile shows for both; above it, its own). + const above = layout.quotedAt === "above"; + const firstRead = (scope) => pieces.find((p) => p.role === scope || (scope === "post" && p.role === "quoted" && !above))?.start ?? null; /** The start of the first piece after the last piece of `scope` that is of another tile. */ const after = (scope) => { let last = -1; @@ -379,7 +387,7 @@ export function threadSchedule(entry, render, { layout, blocks, lead = 0.4 }) { if (t.scope === "post") { // His post: revealed when its first piece (or the quoted post inside it) starts, when something else is read first. const T = firstRead("post"); - if (revealed("post", T) && (carried || first.role !== "quoted")) { + if (revealed("post", T) && (carried || above || first.role !== "quoted")) { row.from = [1, 0]; Object.assign(row, win(T)); } @@ -396,20 +404,23 @@ export function threadSchedule(entry, render, { layout, blocks, lead = 0.4 }) { // Read: in full while it is read, then small and dim (a quoted post only dims) as the next piece starts. const T = after(t.scope); const T0 = firstRead(t.scope); - if (t.scope !== "quoted" && revealed(t.scope, T0)) { + // A quoted post above his: a top-level tile like a parent (revealed, shrunk); inside his: it only dims. + const own = t.scope !== "quoted" || !!t.above; + if (own && revealed(t.scope, T0)) { // Revealed when its read comes (an older post read before it). row.from = [1, 0]; row.to = [1, 1]; Object.assign(row, win(T0)); if (T !== null) row.then = { to: small, ...win(T) }; } else if (T !== null) { - row.to = t.scope === "quoted" ? [1, k.dim] : small; + row.to = own ? small : [1, k.dim]; Object.assign(row, win(T)); } } + if (t.above) row.above = true; tiles.push(row); } - return { shrink: k.shrink, dim: k.dim, seconds: k.seconds, pan: k.pan, contextRoom: THREAD_CONTEXT_ROOM, tiles }; + return { shrink: k.shrink, dim: k.dim, seconds: k.seconds, pan: k.pan, contextRoom: THREAD_CONTEXT_ROOM, quotedAt: above ? "above" : "inside", tiles }; } /** inOut cubic over [0, 1]. */ @@ -521,9 +532,22 @@ export function threadReadWarnings(entry) { : `re-make the take on a script without it (umtool posts narrate <p> ${id} --take; a drafted script drops links)`; out.push(`timeline ${id}: ${where} a link aloud (${said}) -- ${fix}`); } + // A text the archive kept cut short (X's "…" or "Show more", not a link's): the read and the card stop mid-thought. + const roles = new Set(partRoles(entry).map((r) => r.role).filter(Boolean)); + const texts = [["post", "his words", entry?.text], ["quoted", "the post it quotes", entry?.quoted?.text], ...parentsOf(entry).map((p, i) => [`parent:${i}`, i ? "the post that one answers" : "the post it answers", p?.text])]; + for (const [scope, name, text] of texts) { + if ((scope !== "post" && !roles.has(scope)) || !isTruncated(text)) continue; + out.push(`timeline ${id}: ${name} (${scope}) ends cut short in the archive ("…") -- the read stops mid-thought; re-fetch the post (umtool posts context <p>, or the editor's capture) or paraphrase it`); + } return out; } +/** Whether an archived text ends CUT SHORT: X's "…" or "Show more" at its end that is not a link's (joinSplitLinks drops those). */ +export function isTruncated(text) { + const t = joinSplitLinks(str(text)).trim(); + return /…$/.test(t) || /\bshow more$/i.test(t); +} + /** THE WARNINGS over a cut (the build's lint): every narrated post item's (threadReadWarnings). */ export function validateThreadReadWarnings(manifest) { const tl = Array.isArray(manifest?.timeline) ? manifest.timeline : []; diff --git a/umtool/report-to-video/post-thread.test.mjs b/umtool/report-to-video/post-thread.test.mjs @@ -10,7 +10,7 @@ import { validatePostNarrationRender } from "./post-narration.mjs"; import { followPath, followStateAt, followStateKey } from "./read-follow.mjs"; import { THREAD_DEFAULTS, partRoles, readPieces, threadGeoAt, threadKnobs, threadLayout, threadReadErrors, threadStateAt, tileStateAt, validateThreadReads, - threadReadWarnings, urlParts, validateThreadReadWarnings, + threadReadWarnings, urlParts, validateThreadReadWarnings, isTruncated, } from "./post-thread.mjs"; const PARENT = "The first thing anyone notices is the noise from the street.\n\nThen the lights in the hall go out without warning.\n\nNobody had planned for any of this at all."; @@ -161,6 +161,7 @@ test("THE INVARIANT: every part's time span lies inside its block's on-screen, h ["a quoted post read first", narrate(base({ quoted: { author: "Other", handle: "other", text: `${QUOTED}\n\n${PARENT}` } }), [[`${QUOTED}\n\n${PARENT}`], [REPLY]]), null], ["two parents, then him", narrate(base({ parents: [parentRef({ id: "901", handle: "second_one", text: "Is anyone else hearing the street noise again tonight?" }), parentRef()] }), [[PARENT], ["Is anyone else hearing the street noise again tonight?"], [REPLY]]), null], ["a carried parent", narrate(base({ parents: [parentRef()] }), [[REPLY]]), { post: "acct-x/900" }], + ["a quoted post read after his words", narrate(base({ quoted: { author: "Other", handle: "other", text: QUOTED } }), [[REPLY], [QUOTED]]), null], ]; for (const [what, e, prev] of cases) { const render = { postNarration: { lead: 0.4 } }; @@ -179,7 +180,8 @@ test("THE INVARIANT: every part's time span lies inside its block's on-screen, h const st = followStateAt(plan.follow, path, s); const [sc, op] = st.tiles[blk.scope]; assert.equal(sc, 1, `${what}: part ${k + 1} at ${s.toFixed(2)} s -- its tile (${blk.scope}) in full`); - if (blk.scope !== "quoted") assert.equal(op, 1, `${what}: part ${k + 1} at ${s.toFixed(2)} s -- its tile at full strength`); + // A quoted post read first is its own tile above his post: at full strength like any other. + if (blk.scope !== "quoted" || plan.follow.thread.quotedAt === "above") assert.equal(op, 1, `${what}: part ${k + 1} at ${s.toFixed(2)} s -- its tile at full strength`); else assert.equal(st.tiles.post[1], 1, `${what}: the post the quoted post is in, shown`); assert.equal(st.op[blk.k] ?? 1, 1, `${what}: part ${k + 1} at ${s.toFixed(2)} s -- its block lit`); assert.equal(st.current, blk.k, `${what}: part ${k + 1} is the block being read`); @@ -236,3 +238,46 @@ test("A READ NEVER SAYS A LINK: a take whose parts say one is warned, with the f assert.deepEqual(threadReadWarnings(narrate(base({ quoted }), [[QUOTED], [REPLY]])), []); assert.equal(validateThreadReadWarnings({ timeline: [e, base({ id: "p-2" })] }).length, 1); }); + +test("QUOTES READ IN PLACE: read before his words, the quoted post is its own tile ABOVE his post -- in full and lit, then shrunk and dimmed as his words come in under it; read after them, inside his post", () => { + const quoted = { author: "Other", handle: "other", text: QUOTED }; + const first = narrate(base({ quoted }), [[QUOTED], [REPLY]]); + const L = threadLayout(first); + assert.equal(L.quotedAt, "above"); + assert.deepEqual(L.tiles.map((t) => [t.scope, t.mode, !!t.above]), [["quoted", "full", true], ["post", "full", false]]); + const plan = postItemPlan(first, { postNarration: { lead: 0.4 } }); + const th = plan.follow.thread; + assert.equal(th.quotedAt, "above"); + const q = th.tiles.find((t) => t.scope === "quoted"); + const post = th.tiles.find((t) => t.scope === "post"); + assert.deepEqual([q.from, q.to], [[1, 1], [THREAD_DEFAULTS.shrink, THREAD_DEFAULTS.dim]]); + assert.deepEqual([post.from, post.to], [[1, 0], [1, 1]]); + // The card opens on the quoted post: his post not yet shown, the flow not panned down to it. + assert.deepEqual(threadStateAt(th, 0.5), { quoted: [1, 1], post: [1, 0] }); + const html = postCardHtml(first, { width: 1600, height: 900, follow: true, thread: th }); + assert.ok(html.indexOf('data-thread-slot="quoted"') < html.indexOf('data-thread-slot="post"'), "the quoted tile is above his post's"); + assert.match(html, /data-thread-slot="quoted" data-thread-above=""><div class="tile quoted tabove"/); + assert.match(html, /data-thread-quoted-label="">quoted</); + // His tile closes the flow up under the quoted post as it shrinks (followStateAt's height counts it). + const geo = fakeGeo(plan); + const fp = followPath(plan.follow, geo); + assert.ok(fp.start < geo.tiles.quoted.top + 100 && fp.start < geo.tiles.post.top, "it opens on the quoted post, not scrolled down to his"); + // Read after his words: inside his post, as before. + const afterIt = narrate(base({ quoted }), [[REPLY], [QUOTED]]); + assert.equal(threadLayout(afterIt).quotedAt, "inside"); + const html2 = postCardHtml(afterIt, { width: 1600, height: 900, follow: true, thread: postItemPlan(afterIt, {}).follow.thread }); + assert.ok(html2.indexOf('data-thread-slot="quoted"') > html2.indexOf('data-thread-slot="post"'), "inside his post"); + assert.doesNotMatch(html2, /data-thread-above/); +}); + +test("TRUNCATED archive text: a text the read reads that ends in X's \"…\" (not a link's) is warned, naming the item and the piece", () => { + assert.equal(isTruncated("He said this and then…"), true); + assert.equal(isTruncated("Look\nhttps://\nx.com/a/status/1\n…"), false, "a link's ellipsis"); + assert.equal(isTruncated("Read the rest. Show more"), true); + assert.equal(isTruncated("A whole post."), false); + const cut = parentRef({ text: "The first thing anyone notices is the noise from the street and then…" }); + const e = narrate(base({ parents: [cut] }), [[cut.text], [REPLY]]); + assert.match(threadReadWarnings(e).join(" "), /timeline p-1: the post it answers \(parent:0\) ends cut short/); + // Not read, not warned (a context post shows only a strip of it). + assert.deepEqual(threadReadWarnings(narrate(base({ parents: [cut] }), [[REPLY]])), []); +}); diff --git a/umtool/report-to-video/read-follow.mjs b/umtool/report-to-video/read-follow.mjs @@ -565,7 +565,8 @@ export function followStateAt(follow, path, s) { for (const [scope, [sc, o]] of Object.entries(ts)) { const h = path?.tiles?.[scope]?.height ?? 0; tiles[scope] = [sc, o, Math.round(h * 100) / 100]; - if (sc < 0.9995 && scope !== "quoted") C -= (1 - sc) * h; + // A tile closes the flow up under it as it shrinks -- a quoted post inside his post never shrinks; one above it does. + if (sc < 0.9995 && (scope !== "quoted" || follow.thread.quotedAt === "above")) C -= (1 - sc) * h; } const below = C - (path?.H ?? 0) - offset; return {