Archilyzer · Source

archilyzer

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

commit 369253471b63cdd7c10878ff76da0c1ce3ef04f8
parent d0de22133672dbf7264bcfb3df1204d2804a2937
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Wed,  4 Nov 2026 12:11:22 -0500

umtool: a whole thread is read in date order -- up to 8 ancestors (parents[] set by hand), each read oldest first; the tiles follow the take's read (a quoted take older than the post he answers is read and drawn first); an image-only reply is a tile; context posts may carry media and linked refs (links[]); a tile that does not answer the one above it says "replying to @X"

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

Diffstat:
Mumtool/lib/report/postReel.mjs | 6+++---
Mumtool/report-to-video/post-conversation.mjs | 2++
Mumtool/report-to-video/post-item.mjs | 86++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------
Mumtool/report-to-video/post-item.test.mjs | 3++-
Mumtool/report-to-video/post-media-scene.mjs | 2+-
Aumtool/report-to-video/post-thread-scenes.test.mjs | 95+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mumtool/report-to-video/post-thread.mjs | 145+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------
Mumtool/report-to-video/read-follow.mjs | 10+++++++---
8 files changed, 313 insertions(+), 36 deletions(-)

diff --git a/umtool/lib/report/postReel.mjs b/umtool/lib/report/postReel.mjs @@ -20,7 +20,7 @@ // words, author, date, link and counts snapshotted from the archive row; a // repost drawn as the post it reposts, "reposted by" its reposter; a reply // with the posts it answers (from the archive, nearest first, up to -// POST_PARENTS_MAX) -- else the capture's `shot-thread.png` -- else a +// POST_PARENTS_FILL) -- else the capture's `shot-thread.png` -- else a // "replying to" line; its attachments COPIED into the project // (`posts-media/<slug>/<postId>/`, never a link out of it) and measured (a // video's length and whether it has sound; X serves a GIF as a silent mp4 @@ -37,7 +37,7 @@ import { execFile } from "node:child_process"; import { copyFile, mkdir, readFile, readdir, realpath, stat } from "node:fs/promises"; import path from "node:path"; import { promisify } from "node:util"; -import { POST_MEDIA_MAX, POST_PARENTS_MAX, authorRedaction, cardAuthors, subjectsOf } from "umtool-report-to-video/post-item"; +import { POST_MEDIA_MAX, POST_PARENTS_FILL, authorRedaction, cardAuthors, subjectsOf } from "umtool-report-to-video/post-item"; import { ARCHIVE_AVATARS_DIR, ARCHIVE_AVATARS_FILE, AVATARS_DIR, AVATAR_EXT_RE, avatarEntryOf, handleKey } from "umtool-report-to-video/post-avatars"; import { channelsDirFor, readManifest } from "../projects/report.mjs"; import { withEditNotes } from "./edit-guard.mjs"; @@ -265,7 +265,7 @@ export async function postEntryFrom(row, { index, io, subjects = [] }) { if (shown.isReply === true && replyTo?.id) { const parents = []; let at = replyTo; - while (at?.id && parents.length < POST_PARENTS_MAX) { + while (at?.id && parents.length < POST_PARENTS_FILL) { const p = index.get(String(at.id)); if (!p) break; parents.push(refOf(p)); diff --git a/umtool/report-to-video/post-conversation.mjs b/umtool/report-to-video/post-conversation.mjs @@ -220,6 +220,7 @@ export function sceneRefOf(e, scope) { date: str(e?.date) || undefined, text: cardText(e), redact: authors.find((a) => a.where === "author")?.redact === true, + ...(parentsOf(e)[0] ? { replyTo: { id: str(parentsOf(e)[0].id), handle: str(parentsOf(e)[0].handle) } } : str(e?.replyingTo) ? { replyTo: { id: "", handle: str(e.replyingTo) } } : {}), src: { post: str(e?.post), scope: "text" }, }; } @@ -235,6 +236,7 @@ export function sceneRefOf(e, scope) { text: contextText(p), ...(isParaphrased(p) ? { paraphrased: true } : {}), redact: authors.find((a) => a.where === `parents[${i}]`)?.redact === true, + ...(parentsOf(e)[i + 1] ? { replyTo: { id: str(parentsOf(e)[i + 1].id), handle: str(parentsOf(e)[i + 1].handle) } } : {}), src: { post: str(e?.post), scope: "parent", index: i }, }; } diff --git a/umtool/report-to-video/post-item.mjs b/umtool/report-to-video/post-item.mjs @@ -71,8 +71,15 @@ export const POST_GIF = Object.freeze({ min: 3, max: 10 }); export const POST_GRID = Object.freeze({ base: 3.5, per: 1 }); export const POST_HOLD = Object.freeze({ min: 1, max: 120 }); export const POST_MEDIA_MAX = 4; -/** The posts it answers drawn above it (the reply chain), nearest first: at most this many. */ -export const POST_PARENTS_MAX = 2; +/** + * The posts it answers drawn above it (the reply chain), nearest first: at most this many (a WHOLE-THREAD read, + * operator 4 Nov: "include the whole thread context" -- set by hand, `posts set-item <p> <item> parent.<i>=<ref>`). + */ +export const POST_PARENTS_MAX = 8; +/** How many of them a reel or `posts context` fills from the archive by itself (the post it answers and its parent). */ +export const POST_PARENTS_FILL = 2; +/** The posts a post's words link to that it draws (`links[]`, post-thread.mjs: a link visit), at most this many. */ +export const POST_LINKS_MAX = 4; /** A context post's paraphrase (`quoted.paraphrase`, `parents[i].paraphrase`): at most this many characters. */ export const POST_PARAPHRASE_MAX = 600; /** A video attachment's shortest trimmed span, in seconds. */ @@ -101,6 +108,15 @@ export function cardText(entry) { /** The posts it answers (nearest first), at most POST_PARENTS_MAX. */ export const parentsOf = (entry) => (Array.isArray(entry?.parents) ? entry.parents.filter(isObj).slice(0, POST_PARENTS_MAX) : []); +/** The posts its words link to that it draws (`links[]`: a status link resolved by hand, `posts set-item … link.add=`). */ +export const linksOf = (entry) => (Array.isArray(entry?.links) ? entry.links.filter(isObj).slice(0, POST_LINKS_MAX) : []); + +/** A context post's attachments (`ref.media`: a parent's picture, a linked post's -- project files). */ +export const refMediaOf = (ref) => (Array.isArray(ref?.media) ? ref.media.filter((m) => isObj(m) && typeof m.src === "string") : []); + +/** Whether a context post is drawn at all: it has words, or an attachment (an image-only reply). */ +export const refShown = (ref) => !!contextText(ref).trim() || refMediaOf(ref).length > 0; + /** Seconds to read the post itself (the rule above, its first line). */ export function readSeconds(entry) { return clamp(POST_READ.lead + wordCount(cardText(entry)) / POST_READ.wps, POST_READ.min, POST_READ.max); @@ -394,6 +410,7 @@ export function cardAuthors(entry) { if (Array.isArray(entry?.subjects)) out.push({ where: "author", handle: str(entry.handle) || null, ...authorRedaction({ handle: entry.handle, badge: entry.badge }, o) }); parentsOf(entry).forEach((p, i) => out.push({ where: `parents[${i}]`, handle: str(p.handle) || null, ...authorRedaction(p, o) })); if (isObj(entry?.quoted)) out.push({ where: "quoted", handle: str(entry.quoted.handle) || null, ...authorRedaction(entry.quoted, o) }); + linksOf(entry).forEach((p, i) => out.push({ where: `links[${i}]`, handle: str(p.handle) || null, ...authorRedaction(p, o) })); if (!parentsOf(entry).length && str(entry?.replyingTo)) out.push({ where: "replyingTo", handle: entry.replyingTo, ...authorRedaction({ handle: entry.replyingTo }, o) }); return out; } @@ -427,6 +444,14 @@ function refErrors(r, where) { // 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`); + // Its attachments (a parent's picture, shown in the slot while it is on screen): project files, as an item's. + if (r.media !== undefined) { + if (!Array.isArray(r.media)) errors.push(`${where}.media must be a list of attachments`); + else { + if (r.media.length > POST_MEDIA_MAX) errors.push(`${where}.media: at most ${POST_MEDIA_MAX} attachments`); + r.media.forEach((m, i) => errors.push(...mediaErrors(m, `${where}.media[${i}]`))); + } + } 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)`); else if (r.paraphrase.length > POST_PARAPHRASE_MAX) errors.push(`${where}.paraphrase is longer than ${POST_PARAPHRASE_MAX} characters (${r.paraphrase.length}): a paraphrase is short`); @@ -466,10 +491,20 @@ export function validatePostItem(e) { if (e.parents !== undefined) { if (!Array.isArray(e.parents)) errors.push(`${w}.parents must be a list (the posts it answers, nearest first)`); else { - if (e.parents.length > POST_PARENTS_MAX) errors.push(`${w}.parents: at most ${POST_PARENTS_MAX} (the post it answers and its parent)`); + if (e.parents.length > POST_PARENTS_MAX) errors.push(`${w}.parents: at most ${POST_PARENTS_MAX} (the posts it answers, nearest first)`); e.parents.forEach((p, i) => errors.push(...refErrors(p, `${w}.parents[${i}]`))); } } + if (e.links !== undefined) { + if (!Array.isArray(e.links)) errors.push(`${w}.links must be a list (the posts its words link to)`); + else { + if (e.links.length > POST_LINKS_MAX) errors.push(`${w}.links: at most ${POST_LINKS_MAX}`); + e.links.forEach((p, i) => { + errors.push(...refErrors(p, `${w}.links[${i}]`)); + if (isObj(p) && !(typeof p.id === "string" && /^\d{1,25}$/.test(p.id))) errors.push(`${w}.links[${i}].id must be the linked post's id (its status number)`); + }); + } + } if (e.replyingTo !== undefined && (typeof e.replyingTo !== "string" || !HANDLE_RE.test(e.replyingTo))) errors.push(`${w}.replyingTo must be a handle`); if (e.parentShot !== undefined) { const er = relFileError(e.parentShot, `${w}.parentShot`); @@ -587,6 +622,9 @@ export function postItemFiles(entry) { if (typeof m?.src === "string") out.push({ where: `${w}.media[${i}]`, src: m.src }); }); if (typeof entry?.parentShot === "string") out.push({ where: `${w}.parentShot`, src: entry.parentShot }); + // A context post's attachments (a parent's, a linked post's, the quoted post's). + const refs = [...parentsOf(entry).map((p, i) => [`parents[${i}]`, p]), ...linksOf(entry).map((p, i) => [`links[${i}]`, p]), ...(isObj(entry?.quoted) ? [["quoted", entry.quoted]] : [])]; + for (const [where, ref] of refs) refMediaOf(ref).forEach((m, i) => out.push({ where: `${w}.${where}.media[${i}]`, src: m.src })); out.push(...postNarrationFiles(entry)); return out; } @@ -638,7 +676,7 @@ export function postLayout(entry, { width, height }) { const steps = mediaSteps(entry); const words = cardText(entry); // What the card spends besides the words: its head (avatar, name, date), its counts, the context. - const context = parentsOf(entry).length * 130 * k + (isObj(entry?.quoted) ? 170 * k : 0) + (entry?.replyingTo || entry?.parentShot ? 40 * k : 0); + const context = Math.min(2, parentsOf(entry).length) * 130 * k + (isObj(entry?.quoted) ? 170 * k : 0) + (entry?.replyingTo || entry?.parentShot ? 40 * k : 0); const chrome = 150 * k + context + (entry?.repostedBy ? 34 * k : 0); const textCard = (w) => { const cw = Math.min(w, Math.round(1180 * k)); @@ -921,6 +959,17 @@ export function postCardHtml(entry, { width, height, palette = {}, fonts = {}, p const av = Math.round(56 * k); const cut = (scope) => (tmode(scope) === "excerpt" && fmap ? new Set(fmap.blocks.filter((b) => b.scope === scope && b.part === null).map((b) => b.k)) : null); const cutCss = []; + const t0 = (scope) => tiles.find((t) => t.scope === scope) ?? null; + // A tile's RELATION (post-thread.mjs withRelations): "replying to @X" when what it answers is not just above it + // (a branch), or "replying to the post above" in a manual thread -- the handle blurred by the card's rule. + const relationHtml = (t) => { + const rel = t?.rel; + if (!rel) return ""; + const h = str(rel.to).replace(/^@/, ""); + const hidden = !h || blurred.some((b) => b.replace(/^@/, "").toLowerCase() === h.toLowerCase()); + const who = hidden ? '<span class="redact">@xxxxxxxx</span>' : `<span class="mention">@${esc(h)}</span>`; + return `<div class="rel" data-thread-rel="${rel.above ? "above" : "branch"}">${rel.above ? `replying to ${h ? `${who}'s` : "the"} post above` : `replying to ${who}`}</div>`; + }; // Each tile's HTML by its scope, then drawn in the layout's order (the tree's: a scene's posts among his own). const byScope = new Map(); const tileHtml = { push: (h) => byScope.set(/data-thread-slot="([^"]+)"/.exec(h)?.[1] ?? `x${byScope.size}`, h) }; @@ -928,19 +977,26 @@ export function postCardHtml(entry, { width, height, palette = {}, fonts = {}, p for (const t of tiles) { if (t.scope.startsWith("scene:") && isObj(t.entry)) tileHtml.push(sceneTileHtml(t, { k, pal, size: (text) => sizeFor(text, innerW, innerH - 170 * k), redaction, avatars })); } - for (let i = parents.length - 1; i >= 0; i -= 1) { - const scope = `parent:${i}`; + // A context post's tile: a parent (`data-post-parent`), a post its words link to (`data-post-linked`). One with + // no words but an attachment (an image-only reply) is its head and a chip naming what it carries -- the + // attachment itself is in the slot while it is on screen (post-thread.mjs panelSchedule). + const refTile = (scope, p, where, attr) => { const mode = tmode(scope); - const p = parents[i]; - if (!mode || mode === "hidden" || !contextText(p).trim()) continue; - const r = red(`parents[${i}]`); + if (!mode || mode === "hidden" || !refShown(p)) return; + const r = red(where); const subject = !r && subjectsOf(entry).some((h) => String(h).toLowerCase() === String(p.handle ?? "").replace(/^@/, "").toLowerCase()); - const size = sizeFor(contextText(p), innerW - av - Math.round(16 * k), innerH - 90 * k); + const words = contextText(p); + const size = sizeFor(words || " ", innerW - av - Math.round(16 * k), innerH - 90 * k); for (const kk of cut(scope) ?? []) cutCss.push(`[data-thread-tile="${scope}"] [data-post-block="${kk}"]`); + const med = refMediaOf(p); + const chip = med.length ? `<span class="plabel" data-thread-media="${med.length}">${med[0].kind === "image" ? (med.length > 1 ? `${med.length} photos` : "photo") : med[0].kind}</span>` : ""; + const rel = relationHtml(t0(scope)); tileHtml.push( - `<div class="tslot" data-thread-slot="${scope}"><div class="tile tparent" data-thread-tile="${scope}" data-thread-mode="${mode}" data-post-parent="${i}"${r ? ' data-redacted=""' : ""}>${avatarHtml(p, { redact: r, size: av, accent: subject ? pal.accent : undefined, img: pic(p) })}<div class="pbody"><div class="phead">${nameHtml(p, { redact: r, cls: "big" })}<span class="pdate">${esc(cardDate(p.date).split(" · ")[0])}</span>${mode === "excerpt" ? '<span class="plabel" data-thread-excerpt="">excerpt</span>' : ""}${paraLabel(p)}</div><div class="ptext tt"${isParaphrased(p) ? ' data-post-paraphrase=""' : ""} style="font-size:${size}px">${wordsHtml(contextText(p), blurred, scope, hlOf(scope), blk(scope))}</div></div></div></div>`, + `<div class="tslot" data-thread-slot="${scope}"><div class="tile tparent" data-thread-tile="${scope}" data-thread-mode="${mode}" ${attr}${r ? ' data-redacted=""' : ""}>${avatarHtml(p, { redact: r, size: av, accent: subject ? pal.accent : undefined, img: pic(p) })}<div class="pbody">${rel}<div class="phead">${nameHtml(p, { redact: r, cls: "big" })}<span class="pdate">${esc(cardDate(p.date).split(" · ")[0])}</span>${mode === "excerpt" ? '<span class="plabel" data-thread-excerpt="">excerpt</span>' : ""}${scope.startsWith("linked:") ? '<span class="plabel" data-thread-linked="">linked</span>' : ""}${chip}${paraLabel(p)}</div>${words ? `<div class="ptext tt"${isParaphrased(p) ? ' data-post-paraphrase=""' : ""} style="font-size:${size}px">${wordsHtml(words, blurred, scope, hlOf(scope), blk(scope))}</div>` : ""}</div></div></div>`, ); - } + }; + for (let i = parents.length - 1; i >= 0; i -= 1) refTile(`parent:${i}`, parents[i], `parents[${i}]`, `data-post-parent="${i}"`); + linksOf(entry).forEach((l, i) => refTile(`linked:${i}`, l, `links[${i}]`, `data-post-linked="${i}"`)); 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. @@ -960,7 +1016,7 @@ export function postCardHtml(entry, { width, height, palette = {}, fonts = {}, p const psize = own.trim() ? sizeFor(own, innerW, innerH - 170 * k) : size; const lead = !parents.length && (parentShotUrl || entry.replyingTo) ? ctx.join("") : ""; tileHtml.push( - `<div class="tslot" data-thread-slot="post"><div class="tile tpost" data-thread-tile="post">${repost}${lead}${head}<div class="twords" style="font-size:${psize}px">${wordsHtml(own, blurred, "post", hlOf("post"), blk("post"))}</div>${quotedTile}${counts ? `<div class="counts" data-post-counts="">${counts}</div>` : ""}</div></div>`, + `<div class="tslot" data-thread-slot="post"><div class="tile tpost" data-thread-tile="post">${repost}${lead}${relationHtml(t0("post"))}${head}<div class="twords" style="font-size:${psize}px">${wordsHtml(own, blurred, "post", hlOf("post"), blk("post"))}</div>${quotedTile}${counts ? `<div class="counts" data-post-counts="">${counts}</div>` : ""}</div></div>`, ); // THE SCENE (post-conversation.mjs): the posts the run left on screen, drawn as they were -- never read (no // blocks, no word spans), their words redacted by the same terms, their authors blurred by their own item's rule. @@ -971,7 +1027,7 @@ export function postCardHtml(entry, { width, height, palette = {}, fonts = {}, p const text = str(ref.text); const tsize = sizeFor(text || " ", innerW - av - Math.round(16 * k), innerH - 90 * k); tileHtml.push( - `<div class="tslot" data-thread-slot="${esc(t.scope)}" data-thread-scene="${t.action === "keep" ? "keep" : "collapse"}"><div class="tile tparent tscene" data-thread-tile="${esc(t.scope)}" data-thread-mode="scene" data-post-scene="${esc(t.scope.slice(5))}"${r ? ' data-redacted=""' : ""}>${avatarHtml(ref, { redact: r, size: av, img: pic(ref) })}<div class="pbody"><div class="phead">${nameHtml(ref, { redact: r, cls: "big" })}<span class="pdate">${esc(cardDate(ref.date).split(" · ")[0])}</span>${ref.paraphrased ? '<span class="plabel" data-post-paraphrased="">paraphrased</span>' : ""}</div><div class="ptext tt" style="font-size:${tsize}px">${wordsHtml(text, r && ref.handle ? [...blurred, ref.handle] : blurred)}</div></div></div></div>`, + `<div class="tslot" data-thread-slot="${esc(t.scope)}" data-thread-scene="${t.action === "keep" ? "keep" : "collapse"}"><div class="tile tparent tscene" data-thread-tile="${esc(t.scope)}" data-thread-mode="scene" data-post-scene="${esc(t.scope.slice(5))}"${r ? ' data-redacted=""' : ""}>${avatarHtml(ref, { redact: r, size: av, img: pic(ref) })}<div class="pbody">${relationHtml(t)}<div class="phead">${nameHtml(ref, { redact: r, cls: "big" })}<span class="pdate">${esc(cardDate(ref.date).split(" · ")[0])}</span>${ref.paraphrased ? '<span class="plabel" data-post-paraphrased="">paraphrased</span>' : ""}</div><div class="ptext tt" style="font-size:${tsize}px">${wordsHtml(text, r && ref.handle ? [...blurred, ref.handle] : blurred)}</div></div></div></div>`, ); } const order = [...tiles.map((t) => t.scope).filter((sc) => byScope.has(sc)), ...[...byScope.keys()].filter((sc) => !tiles.some((t) => t.scope === sc))]; @@ -1043,6 +1099,8 @@ b, .name, .mark { font-family: 'PostSansBold', sans-serif; font-weight: 400; } .tparent { display: flex; gap: ${Math.round(16 * k)}px; position: relative; } .tparent::after { content: ""; position: absolute; left: ${Math.round(27 * k)}px; top: ${Math.round(64 * k)}px; bottom: -${Math.round(20 * k)}px; width: 2px; background: ${line}; } .tpost { display: flex; flex-direction: column; gap: ${Math.round(16 * k)}px; } +.rel { color: ${pal.muted}; font-size: ${Math.round(18 * k)}px; margin-bottom: ${Math.round(4 * k)}px; letter-spacing: 0.01em; } +.rel::before { content: "\\21b3 "; } .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)}; } diff --git a/umtool/report-to-video/post-item.test.mjs b/umtool/report-to-video/post-item.test.mjs @@ -29,7 +29,8 @@ test("a valid post item passes; each field is refused in words", () => { assert.ok(validatePostItem(base({ media: [video({ start: 3, end: 3.2 })] })).some((e) => e.includes("at least 0.5 s after start"))); assert.ok(validatePostItem(base({ media: [video({ end: 9 })] })).some((e) => e.includes("a second inside it"))); assert.ok(validatePostItem(base({ media: [video({ crop: [0.5, 0, 0.6, 1] })] })).some((e) => e.includes(".crop must be"))); - assert.ok(validatePostItem(base({ parents: [{}, {}, {}] })).some((e) => e.includes("at most 2"))); + assert.ok(validatePostItem(base({ parents: Array.from({ length: 9 }, () => ({})) })).some((e) => e.includes("at most 8"))); + assert.deepEqual(validatePostItem(base({ parents: [{}, {}, {}] })), []); assert.ok(validatePostItem(base({ media: [video(), video(), video(), video(), video()] })).some((e) => e.includes("at most 4 attachments"))); }); diff --git a/umtool/report-to-video/post-media-scene.mjs b/umtool/report-to-video/post-media-scene.mjs @@ -293,7 +293,7 @@ const postIdOf = (e) => String(e?.post ?? "").split("/")[1] ?? ""; */ export function sceneLayout(base, entry, scene) { if (!scene || scene.n === 0 || !scene.before.length) return base; - const parents = (Array.isArray(entry?.parents) ? entry.parents : []).filter(isObj).slice(0, 2); + const parents = (Array.isArray(entry?.parents) ? entry.parents : []).filter(isObj).slice(0, 8); const drawn = new Set(); if (base?.tiles) { for (const t of base.tiles) { diff --git a/umtool/report-to-video/post-thread-scenes.test.mjs b/umtool/report-to-video/post-thread-scenes.test.mjs @@ -0,0 +1,95 @@ +// lane/thread-scenes: whole-thread reads (every ancestor read, oldest first), the read in DATE order, context +// posts with attachments, manual threads (`thread.group`), the join between items, the branch map, link visits. +import assert from "node:assert/strict"; +import { test } from "node:test"; +import { postCardHtml, postItemPlan, validatePostItem } from "./post-item.mjs"; +import { followPath, readInViewErrors, shotStateAt } from "./read-follow.mjs"; +import { partRoles, roleOrderOf, threadLayout, threadReadErrors } from "./post-thread.mjs"; + +const at = (h) => `2026-11-02T${String(h).padStart(2, "0")}:00:00.000Z`; +const ref = (id, handle, text, h, o = {}) => ({ id, author: handle, handle, date: at(h), text, ...o }); +const base = (o = {}) => ({ type: "post", id: "p-1", post: "acct-x/1001", platform: "x", author: "Subject", handle: "subject", date: at(20), text: "I was simply offering advice to everyone in the community today.", ...o }); +/** A take of pieces in order (para = piece * 100 + paragraph), each paragraph a part. */ +export function take(pieces, { roles = false } = {}) { + const parts = []; + let t = 0; + pieces.forEach(([text, role], pi) => { + text.split(/\n\n/).forEach((para, k) => { + const seconds = Math.round((para.split(/\s+/).length / 3) * 100) / 100; + t += parts.length ? (k === 0 ? 0.8 : 0.6) : 0; + parts.push({ n: parts.length + 1, para: pi * 100 + k, text: para, start: Math.round(t * 100) / 100, seconds, ...(roles && role ? { role } : {}) }); + t += seconds; + }); + }); + return { file: "narration/posts/1001/take-1.wav", engine: "orpheus", voice: "leo+zac", seconds: Math.round(t * 100) / 100, script: pieces.map((p) => p[0]).join("\n\n"), parts }; +} +export const narrate = (e, pieces, o) => ({ ...e, narration: { script: e.text, takes: [take(pieces, o)], pick: 0 } }); + +export function fakeGeo(plan, { H = 520, line = 44 } = {}) { + const blocks = {}; + const tiles = {}; + let y = 0; + for (const scope of plan.follow.thread.tiles.map((t) => t.scope)) { + const top = y; + y += 70; + for (const b of plan.follow.blocks.filter((x) => x.scope === scope)) { + const h = Math.max(1, Math.ceil((b.to - b.from + 1) / 6)) * line; + blocks[b.k] = { top: y, bottom: y + h }; + y += h + line; + } + tiles[scope] = { top, height: y - top }; + y += 22; + } + return { H, C: y, blocks, tiles }; +} + +const ROOT = "I was hit by my own brother and it hurt. I am real close to going atomic."; +const Q = "Lol what? You playing games with all of us again tonight?"; +const G = "Yes, that phrasing can be viewed as a threat under the law in most places."; + +test("WHOLE-THREAD READ: three ancestors read oldest first, then his words -- roles parent:2, parent:1, parent:0, post; each tile in full while read, then shrunk; the invariant holds", () => { + const parents = [ref("3", "grok", G, 19), ref("2", "asker", Q, 18), ref("1", "subject", ROOT, 17)]; + const e = narrate(base({ parents }), [[ROOT], [Q], [G], [base().text]]); + assert.deepEqual(partRoles(e).map((r) => r.role), ["parent:2", "parent:1", "parent:0", "post"]); + assert.deepEqual(validatePostItem(e), []); + const L = threadLayout(e); + assert.deepEqual(L.tiles.map((t) => [t.scope, t.mode]), [["parent:2", "full"], ["parent:1", "full"], ["parent:0", "full"], ["post", "full"]]); + assert.deepEqual(threadReadErrors(e), []); + const plan = postItemPlan(e, { postNarration: { lead: 0.4 } }); + const th = plan.follow.thread; + // The oldest opens the card; each later one revealed as its piece starts, each earlier one shrunk as the next starts. + const row = (sc) => th.tiles.find((t) => t.scope === sc); + assert.deepEqual(row("parent:2").from, [1, 1]); + assert.deepEqual(row("parent:1").from, [1, 0]); + assert.ok(row("parent:1").then, "parent:1 shrinks once parent:0 is read"); + const geo = fakeGeo(plan, { H: 400 }); + const path = followPath(plan.follow, geo); + assert.deepEqual(readInViewErrors(plan.follow, geo, shotStateAt(plan.follow, path, 30), { total: plan.total, id: e.id }), []); +}); + +test("THE READ IN DATE ORDER (operator, 4 Nov: D): a quoted take older than the post he answers is read first and drawn first -- the quote, the parent, his words", () => { + const take0 = "Here is my take on the whole situation, in two points."; + const kirsche = "I hate watching people defend the very tactics that lead to that happening."; + const e0 = base({ date: at(19), quoted: { author: "Subject", handle: "subject", date: at(16), text: take0 }, parents: [ref("2115500212617703691", "kirsche", kirsche, 17)] }); + assert.deepEqual(["quoted", "parent:0", "post"].map(roleOrderOf(e0)), [1, 2, 3]); + const e = narrate(e0, [[take0], [kirsche], [e0.text]]); + assert.deepEqual(partRoles(e).map((r) => r.role), ["quoted", "parent:0", "post"]); + const L = threadLayout(e); + assert.deepEqual(L.tiles.map((t) => t.scope), ["quoted", "parent:0", "post"]); + assert.equal(L.quotedAt, "above"); + const plan = postItemPlan(e, { postNarration: { lead: 0.4 } }); + const html = postCardHtml(e, { width: 1600, height: 900, follow: true, thread: plan.follow.thread }); + assert.ok(html.indexOf('data-thread-slot="quoted"') < html.indexOf('data-thread-slot="parent:0"'), "the quote drawn above the parent"); + const geo = fakeGeo(plan, { H: 400 }); + assert.deepEqual(readInViewErrors(plan.follow, geo, shotStateAt(plan.follow, followPath(plan.follow, geo), 30), { total: plan.total, id: e.id }), []); +}); + +test("AN IMAGE-ONLY REPLY is a tile (its head and a chip), never read; a parent's attachment is a file the lint checks", () => { + const e = narrate(base({ parents: [ref("9", "furri", "", 19, { media: [{ src: "posts-media/f/9/9_1.jpg", kind: "image", width: 600, height: 800 }] }), ref("1", "subject", ROOT, 17)] }), [[base().text]]); + assert.deepEqual(validatePostItem(e), []); + const L = threadLayout(e); + assert.deepEqual(L.tiles.map((t) => [t.scope, t.mode]), [["parent:1", "context"], ["parent:0", "context"], ["post", "full"]]); + const html = postCardHtml(e, { width: 1600, height: 900, follow: true, thread: L }); + assert.match(html, /data-post-parent="0"[^>]*>.*data-thread-media="1">photo</s); + assert.deepEqual(validatePostItem({ ...e, parents: [{ media: [{ src: "/abs.jpg", kind: "image" }] }] }).length > 0, true); +}); diff --git a/umtool/report-to-video/post-thread.mjs b/umtool/report-to-video/post-thread.mjs @@ -48,7 +48,7 @@ // PURE and dependency-free (but its siblings): the plan, the build, Play, the // bench, the writers and the lint all read the same rules from here. -import { cardText, contextText, parentsOf } from "./post-item.mjs"; +import { POST_PARENTS_MAX, cardText, contextText, linksOf, parentsOf, refShown } from "./post-item.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"; @@ -63,12 +63,14 @@ const ROLE_MIN = 0.5; /** The share of the window kept for the post a new piece answers (its foot above the new piece). */ export const THREAD_CONTEXT_ROOM = 0.3; -const KEYS = new Set(Object.keys(THREAD_DEFAULTS)); +/** `thread.group` (one item's): a MANUAL THREAD -- consecutive items of one group play as one scene (post-conversation.mjs). */ +export const THREAD_GROUP_RE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,47}$/; +const KEYS = new Set([...Object.keys(THREAD_DEFAULTS), "group"]); const isObj = (v) => !!v && typeof v === "object" && !Array.isArray(v); const fin = (v) => typeof v === "number" && Number.isFinite(v); const str = (v) => (typeof v === "string" ? v : ""); const r3 = (v) => Math.round(v * 1000) / 1000; -const ROLE_RE = /^(post|quoted|parent:\d|media:\d)$/; +const ROLE_RE = /^(post|quoted|parent:\d|media:\d|linked:\d)$/; // --------------------------------------------------------------------------- // The knobs. @@ -79,16 +81,17 @@ const modeOk = (v, carryOk) => typeof v === "string" && THREAD_MODES.includes(v) /** One thread knob's errors (`where`: its path in the manifest). */ export function threadKnobErrors(v, where) { if (v === undefined || v === null) return []; - if (!isObj(v)) return [`${where} must be { parent?, quoted?, carry?, reveal?, shrink?, dim?, seconds?, pan? }`]; + if (!isObj(v)) return [`${where} must be { parent?, quoted?, carry?, reveal?, shrink?, dim?, seconds?, pan?, group? }`]; const errors = []; for (const k of Object.keys(v)) if (!KEYS.has(k)) errors.push(`${where}.${k} is not a thread knob (${[...KEYS].join(", ")})`); if (v.parent !== undefined) { const list = Array.isArray(v.parent) ? v.parent : [v.parent]; - if (!list.length || list.length > 2 || !list.every((m) => modeOk(m, true))) errors.push(`${where}.parent must be one of ${THREAD_MODES.join(", ")} (or a list of them, nearest parent first)`); + if (!list.length || list.length > POST_PARENTS_MAX || !list.every((m) => modeOk(m, true))) errors.push(`${where}.parent must be one of ${THREAD_MODES.join(", ")} (or a list of them, nearest parent first)`); } if (v.quoted !== undefined && !modeOk(v.quoted, false)) errors.push(`${where}.quoted must be one of ${THREAD_MODES.filter((m) => m !== "carry").join(", ")}`); if (v.carry !== undefined && !(v.carry === "auto" || typeof v.carry === "boolean")) errors.push(`${where}.carry must be auto, true or false`); if (v.reveal !== undefined && typeof v.reveal !== "boolean") errors.push(`${where}.reveal must be true or false`); + if (v.group !== undefined && !(typeof v.group === "string" && THREAD_GROUP_RE.test(v.group))) errors.push(`${where}.group must be a name (letters, digits, . _ -): the manual thread the item plays in`); for (const k of ["shrink", "dim", "seconds", "pan"]) { if (v[k] !== undefined && !(fin(v[k]) && v[k] >= THREAD_LIMITS[k][0] && v[k] <= THREAD_LIMITS[k][1])) { errors.push(`${where}.${k} must be ${THREAD_LIMITS[k][0]}–${THREAD_LIMITS[k][1]}${k === "shrink" ? " (a context post's size)" : k === "dim" ? " (a context post's opacity)" : " seconds"}`); @@ -110,9 +113,14 @@ const pick = (o) => (isObj(o) ? Object.fromEntries(Object.entries(o).filter(([k, */ export function threadKnobs(entry, render = undefined) { const r = isObj(render?.postNarration) ? render.postNarration.thread : undefined; - return /** @type {any} */ ({ ...THREAD_DEFAULTS, ...pick(r), ...pick(entry?.thread) }); + const { group: _g, ...cut } = pick(r); + void _g; + return /** @type {any} */ ({ ...THREAD_DEFAULTS, ...cut, ...pick(entry?.thread) }); } +/** An item's manual thread (`thread.group`), or null. */ +export const groupOf = (e) => (typeof e?.thread?.group === "string" && THREAD_GROUP_RE.test(e.thread.group) ? e.thread.group : null); + /** Parent `i`'s mode as the knobs set it (before `auto` is resolved). */ const parentKnob = (k, i) => (Array.isArray(k.parent) ? k.parent[i] ?? k.parent[k.parent.length - 1] : k.parent) ?? "auto"; @@ -144,6 +152,8 @@ export function readTexts(entry) { const q = entry.quoted; add("quoted", [contextText(q), str(q.text), spoken(contextText(q)), spoken(q.text)]); } + // A post its words link to (`links[]`): read in place when the take reads it. + linksOf(entry).forEach((l, i) => add(`linked:${i}`, [contextText(l), str(l.text), spoken(contextText(l)), spoken(l.text)])); add("post", [cardText(entry), str(entry?.narration?.script), spoken(cardText(entry))]); return out; } @@ -157,8 +167,25 @@ function shareOf(keys, text) { return keys.filter((w) => text.keys.has(w)).length / keys.length; } -/** The read's order of the roles (a parent before the quoted post before his words). */ -const orderOf = (role) => (role.startsWith("parent:") ? 2 - Number(role.slice(7)) / 10 : role === "quoted" ? 3 : role === "post" ? 4 : 5); +/** The read's order of the roles by KIND (a parent, oldest first, before the quoted post before his words). */ +const kindOrder = (role) => (role.startsWith("parent:") ? 2 - Number(role.slice(7)) / 10 : role === "quoted" ? 3 : role.startsWith("linked:") ? 3.5 : role === "post" ? 4 : 5); + +/** + * THE READ's ORDER of the roles (operator, 4 Nov: "include the whole thread chronologically"): by the DATE of + * the post each reads when every text has one -- the chain oldest first, a quoted post at its own date, his words + * at theirs -- else by kind (kindOrder). An attachment's words come last. Ranks from 1. + */ +export function roleOrderOf(entry) { + const dates = new Map(); + parentsOf(entry).forEach((p, i) => dates.set(`parent:${i}`, Date.parse(str(p?.date)))); + if (isObj(entry?.quoted)) dates.set("quoted", Date.parse(str(entry.quoted.date))); + linksOf(entry).forEach((l, i) => dates.set(`linked:${i}`, Date.parse(str(l?.date)))); + dates.set("post", Date.parse(str(entry?.date))); + if (![...dates.values()].every(Number.isFinite)) return kindOrder; + const ranked = [...dates.keys()].sort((a, b) => dates.get(a) - dates.get(b) || kindOrder(a) - kindOrder(b)); + const rank = new Map(ranked.map((r, i) => [r, i + 1])); + return (role) => rank.get(role) ?? ranked.length + 1; +} /** * THE ROLES of the picked take's parts, pure: `[{ role, source }]` (one a @@ -178,6 +205,7 @@ export function partRoles(entry, take = undefined) { } if (!parts.length) return []; const texts = readTexts(entry); + const orderOf = roleOrderOf(entry); const images = (Array.isArray(entry?.media) ? entry.media : []).map((m, i) => ({ m, i })).filter((x) => x.m?.kind === "image"); // The pieces: consecutive parts of one `para` div 100 (a take of one piece: all of it). const pieceOf = (p) => (Number.isInteger(p?.para) ? Math.floor(p.para / 100) : 0); @@ -267,7 +295,8 @@ export function threadLayout(entry, render = undefined, { prev = null, scene = n const parents = parentsOf(entry); for (let i = parents.length - 1; i >= 0; i -= 1) { const scope = `parent:${i}`; - if (!contextText(parents[i]).trim()) continue; + // An image-only reply (no words, a picture) is drawn too: its head and its attachment in the slot. + if (!refShown(parents[i])) continue; let mode = parentKnob(k, i); const isRead = read.has(scope); if (mode === "auto") { @@ -290,20 +319,76 @@ export function threadLayout(entry, render = undefined, { prev = null, scene = n if (q.above) tiles.push(q, post); else tiles.push(post, q); } else tiles.push(post); + // THE POSTS ITS WORDS LINK TO (`links[]`, a link visit): each a tile after the one whose words link it (else after his). + linksOf(entry).forEach((l, i) => { + if (!refShown(l)) return; + const scope = `linked:${i}`; + const isRead = read.has(scope); + const from = linkedFrom(entry, l); + const at = tiles.findIndex((t) => t.scope === (from ?? "post")); + tiles.splice(at < 0 ? tiles.length : at + 1, 0, { scope, mode: isRead ? "full" : "context", read: isRead, ...(from ? { linkedFrom: from } : {}) }); + }); + // THE READ's ORDER (operator, 4 Nov: "read the whole thread chronologically"): the tiles in the order the take + // reads them -- a quote read before the post it answers sits above it -- one not read where it stood before the next. + orderByRead(tiles, roles); const quotedAtOut = tiles.some((t) => t.above) ? "above" : "inside"; // THE SCENE (post-conversation.mjs): what the run had on screen, in the tree's order with this item's own tiles. - const scened = isNarrated(entry) ? sceneTiles(entry, tiles, scene, k) : tiles; + const scened = withRelations(entry, isNarrated(entry) ? sceneTiles(entry, tiles, scene, k) : tiles, { group: !!scene?.group || !!groupOf(entry) }); const on = isNarrated(entry) && scened.some((t) => t.scope !== "post" && t.mode !== "hidden"); return { on, tiles: scened, roles, quotedAt: quotedAtOut }; } -/** The id a tile of `entry` draws (a parent's, his post's; null: a quoted post, a scene tile's own). */ -function tileIdOf(entry, t) { +/** The id a tile of `entry` draws (a parent's, his post's, a quoted or linked post's; null: none known). */ +export function tileIdOf(entry, t) { if (t.scope === "post") return shownIdOf(entry) || null; + if (t.scope === "quoted") return str(entry?.quoted?.id) || statusIdOf(entry?.quoted?.url) || null; + const l = /^linked:(\d)$/.exec(t.scope); + if (l) return str(linksOf(entry)[Number(l[1])]?.id) || null; const m = /^parent:(\d)$/.exec(t.scope); return m ? str(parentsOf(entry)[Number(m[1])]?.id) || null : null; } +/** The status id an x.com / twitter.com link names (null: none). */ +export function statusIdOf(url) { + const m = /(?:x|twitter)\.com\/[^/\s]+\/status(?:es)?\/(\d{5,25})/i.exec(str(url)); + return m ? m[1] : null; +} + +/** The tile whose words link to post `ref` (a status link naming its id): "post", "parent:<i>", "quoted" -- null: none. */ +export function linkedFrom(entry, ref) { + const id = str(ref?.id) || statusIdOf(ref?.url); + if (!id) return null; + const holds = (t) => [...str(t).matchAll(/https?:\/\/\S+/g)].some((m) => statusIdOf(m[0]) === id); + if (holds(cardText(entry))) return "post"; + const ps = parentsOf(entry); + for (let i = 0; i < ps.length; i += 1) if (holds(ps[i]?.text)) return `parent:${i}`; + if (isObj(entry?.quoted) && holds(entry.quoted.text)) return "quoted"; + return null; +} + +/** + * The tiles in place in THE READ's ORDER: each read tile by its first part; a tile not read (and a quoted post + * inside his) keeps its place before the next tile it stood before. Stable when the read is in the drawn order. + */ +function orderByRead(tiles, roles) { + const first = new Map(); + roles.forEach((r, k) => { + if (r?.role && !first.has(r.role)) first.set(r.role, k); + }); + const own = (t) => t.scope !== "quoted" || !!t.above; + const keyed = tiles.map((t, i) => ({ t, i, k: own(t) && first.has(t.scope) ? first.get(t.scope) : null })); + // A tile not read takes the key of the next read tile after it (it stands before it), less a little. + for (let i = keyed.length - 1, next = Infinity; i >= 0; i -= 1) { + if (keyed[i].k !== null) next = keyed[i].k; + else keyed[i].k = next - 0.5 + i / 1000; + } + // A quoted post inside his post rides with it. + const post = keyed.find((x) => x.t.scope === "post"); + for (const x of keyed) if (x.t.scope === "quoted" && !x.t.above && post) x.k = post.k + 0.0001; + keyed.sort((a, b) => a.k - b.k || a.i - b.i); + tiles.splice(0, tiles.length, ...keyed.map((x) => x.t)); +} + /** * The layout's tiles with the SCENE's (planContext's `scene.tiles`: `{ id, * ref, from: "full"|"small", action: "keep"|"collapse" }`) merged in, in the @@ -344,6 +429,38 @@ function sceneTiles(entry, tiles, scene, k) { return [...mine, ...theirs].map((x, i) => ({ ...x, i })).sort((a, b) => a.r - b.r || a.i - b.i).map((x) => x.t); } +/** + * Each tile's RELATION to what it answers (operator, 4 Nov: "subtly indicate the original relations"): `rel` -- + * `{ to: <handle> | null, above: boolean, id }` -- when the post it answers is NOT the tile drawn just above it + * (a branch: "replying to @X"), and, in a manual thread (`group`), on every reply ("replying to the post above"). + * From the real parents: his post answers parents[0], parents[i] answers parents[i + 1], a scene post its own. + */ +function withRelations(entry, tiles, { group = false } = {}) { + const parents = parentsOf(entry); + const answers = (t) => { + if (t.scope === "post") return parents[0] ? { id: str(parents[0].id), handle: str(parents[0].handle) } : str(entry?.replyingTo) ? { id: "", handle: str(entry.replyingTo) } : null; + const m = /^parent:(\d)$/.exec(t.scope); + if (m) { + const p = parents[Number(m[1]) + 1]; + return p ? { id: str(p.id), handle: str(p.handle) } : null; + } + if (t.mode === "scene" && isObj(t.ref?.replyTo)) return { id: str(t.ref.replyTo.id), handle: str(t.ref.replyTo.handle) }; + return null; + }; + const idOf = (t) => (t.mode === "scene" ? t.scope.slice(5) : tileIdOf(entry, t)); + const drawn = tiles.filter((t) => t.mode !== "hidden" && (t.scope !== "quoted" || t.above)); + return tiles.map((t) => { + if (t.mode === "hidden" || (t.scope === "quoted" && !t.above) || t.scope.startsWith("linked:")) return t; + const a = answers(t); + if (!a) return t; + const at = drawn.indexOf(t); + const above = at > 0 ? idOf(drawn[at - 1]) : null; + const isAbove = !!a.id && above === a.id; + if (isAbove && !group) return t; + return { ...t, rel: { to: a.handle || null, above: isAbove, id: a.id || null } }; + }); +} + /** A tile's mode in a layout (null: no such tile). */ export const tileModeOf = (layout, scope) => layout?.tiles?.find((t) => t.scope === scope)?.mode ?? null; @@ -351,7 +468,7 @@ export const tileModeOf = (layout, scope) => layout?.tiles?.find((t) => t.scope // THE GUARD: never narrate hidden text. // --------------------------------------------------------------------------- -const ROLE_NAME = (r) => (r === "post" ? "his words" : r === "quoted" ? "the post it quotes" : r.startsWith("parent:") ? (r === "parent:0" ? "the post it answers" : "the post that one answers") : `the words on attachment ${Number(r.slice(6)) + 1}`); +const ROLE_NAME = (r) => (r === "post" ? "his words" : r === "quoted" ? "the post it quotes" : r.startsWith("linked:") ? "the post its words link to" : r.startsWith("parent:") ? (r === "parent:0" ? "the post it answers" : "the post that one answers") : `the words on attachment ${Number(r.slice(6)) + 1}`); /** * Every reason post item `entry`'s read narrates text the card does not show, @@ -383,7 +500,7 @@ export function threadReadErrors(entry, render = undefined, { prev = null, scene const mode = tileModeOf(L, r.role); if (mode === null) errors.push(`${w}: its take's part ${n} reads ${ROLE_NAME(r.role)}, which the item does not carry -- set its role (umtool posts roles) ${remake}`); else if (mode === "hidden" || mode === "context") { - const knob = r.role === "quoted" ? "thread.quoted" : "thread.parent"; + const knob = r.role === "quoted" ? "thread.quoted" : r.role.startsWith("linked:") ? "thread.linked" : "thread.parent"; errors.push(`${w}: its take's part ${n} reads ${ROLE_NAME(r.role)}, which is drawn ${mode === "hidden" ? "hidden (not at all)" : "as context (small and dim)"} -- show it (${fix} ${knob}=full) ${remake}`); } }); diff --git a/umtool/report-to-video/read-follow.mjs b/umtool/report-to-video/read-follow.mjs @@ -43,7 +43,7 @@ // sets it on the page -- in the build per frame before a screenshot // (post-render.mjs), in Play per tick (PostItemPlayer). -import { cardText, contextReadSeconds, contextText, parentsOf, readSeconds } from "./post-item.mjs"; +import { cardText, contextReadSeconds, contextText, linksOf, parentsOf, readSeconds } from "./post-item.mjs"; import { isNarrated, narrationSchedule, partStartOnItem, pickedTake, scriptParts } from "./post-narration.mjs"; import { cardTokens, easeOf, normWord, scriptWordsOf } from "./word-zoom.mjs"; import { partRoles, threadGeoAt, threadKnobs, threadLayout, threadSchedule, threadStateAt } from "./post-thread.mjs"; @@ -119,6 +119,10 @@ export function cardScopes(entry) { } out.push({ scope: "post", text: cardText(entry), ref: null }); if (isObj(entry?.quoted) && contextText(entry.quoted).trim()) out.push({ scope: "quoted", text: contextText(entry.quoted), ref: entry.quoted }); + // The posts its words link to (post-thread.mjs: a link visit; read in place when the take reads them). + linksOf(entry).forEach((l, i) => { + if (contextText(l).trim()) out.push({ scope: `linked:${i}`, text: contextText(l), ref: l }); + }); return out; } @@ -441,7 +445,7 @@ export function followPath(follow, geo) { } /** The tile a block's scope is drawn in (a quoted post is a tile inside his post's). */ -const tileScopeOf = (scope) => (scope === "quoted" || scope === "post" || String(scope).startsWith("parent:") ? scope : null); +const tileScopeOf = (scope) => (scope === "quoted" || scope === "post" || String(scope).startsWith("parent:") || String(scope).startsWith("linked:") ? scope : null); /** * A THREADED card's PAN (post-thread.mjs), pure: `{ thread: true, start, @@ -650,7 +654,7 @@ export function isDrawnState(st) { export const READ_IN_VIEW = Object.freeze({ tol: 2, slack: 0.25, share: 0.5, step: 0.05, size: 0.005 }); const pct = (v) => `${Math.round(v * 100)}%`; -const tileName = (scope) => (scope === "post" ? "his post" : scope === "quoted" ? "the quoted post" : String(scope).startsWith("parent:") ? `the post it answers (${scope})` : String(scope)); +const tileName = (scope) => (scope === "post" ? "his post" : scope === "quoted" ? "the quoted post" : String(scope).startsWith("parent:") ? `the post it answers (${scope})` : String(scope).startsWith("linked:") ? `the post it links (${scope})` : String(scope)); /** * THE READ IN VIEW, pure: every reason the words being read are not on screen,