Archilyzer · Source

archilyzer

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

commit bfe85a8549fcb20ac1dbc34293ed0a1e6e67f3af
parent 3c9fc6c81d32f4a8b9cabe52bee1e5d71e068197
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Wed,  4 Nov 2026 12:16:51 -0500

umtool: a MANUAL THREAD (thread.group) -- consecutive items of one group play as one scene even when X does not link them (the post that opens it may be shown, not read), every earlier post kept on screen oldest first, each reply saying what it answers ("replying to @X", "replying to the post above"); timeline threads --write gathers a group at its first item in date order

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

Diffstat:
Mumtool/lib/report/timelineCli.mjs | 2+-
Mumtool/report-to-video/post-conversation.mjs | 39+++++++++++++++++++++++++++++----------
Mumtool/report-to-video/post-thread-scenes.test.mjs | 46++++++++++++++++++++++++++++++++++++++++++++++
Mumtool/report-to-video/post-thread.mjs | 2++
4 files changed, 78 insertions(+), 11 deletions(-)

diff --git a/umtool/lib/report/timelineCli.mjs b/umtool/lib/report/timelineCli.mjs @@ -885,7 +885,7 @@ export async function threadsCommand(project, manifest, { write = false, only = } out(`${project.id}: ${convs.length} conversation(s) of two post items or more`); for (const c of convs) { - out(` root ${c.root ?? "?"} ${c.items.length} items ${c.split ? `SPLIT into ${c.runs} runs` : "one run"}`); + out(` ${c.group ? `group ${c.group} (a manual thread, in date order) ` : ""}root ${c.root ?? "?"} ${c.items.length} items ${c.split ? `SPLIT into ${c.runs} runs` : "one run"}`); out(` in the cut: ${c.items.map((it) => `${it.id}@${it.at}`).join(" ")}`); const inOrder = c.items.map((it) => it.id).join(" ") === c.order.join(" "); if (!inOrder) out(` tree order: ${c.order.join(" ")} (umtool timeline ${project.id} threads --write --conversation ${c.root ?? c.items[0].id})`); diff --git a/umtool/report-to-video/post-conversation.mjs b/umtool/report-to-video/post-conversation.mjs @@ -39,7 +39,7 @@ import { cardAuthors, cardText, contextText, isParaphrased, parentsOf } from "./post-item.mjs"; import { isNarrated } from "./post-narration.mjs"; import { followKnobs } from "./read-follow.mjs"; -import { partRoles, shownIdOf, threadLayout } from "./post-thread.mjs"; +import { groupOf, partRoles, shownIdOf, threadLayout } from "./post-thread.mjs"; const isObj = (v) => !!v && typeof v === "object" && !Array.isArray(v); const str = (v) => (typeof v === "string" ? v : ""); @@ -57,11 +57,16 @@ export function chainOf(e) { export function treeKeysOf(e) { const out = new Set(chainOf(e).filter(Boolean)); if (str(e?.conversation)) out.add(str(e.conversation)); + // A MANUAL THREAD (`thread.group`): its items are one conversation whether X links them or not. + if (groupOf(e)) out.add(`group:${groupOf(e)}`); return out; } -/** Whether an item plays in a run: a narrated post item that read-follows (its card can carry a scene). */ -export const runsIn = (e, render) => e?.type === "post" && isNarrated(e) && followKnobs(e, render).on; +/** + * Whether an item plays in a run: a narrated post item that read-follows (its card can carry a scene) -- or any + * read-following post item of a manual thread (`thread.group`: the post that opens it may be shown, not read). + */ +export const runsIn = (e, render) => e?.type === "post" && (isNarrated(e) || !!groupOf(e)) && followKnobs(e, render).on; /** Compare two post ids: snowflakes by number (their time), else as strings. */ function idCmp(a, b) { @@ -191,11 +196,14 @@ export function conversationRuns(timeline, render = undefined) { return; } const keys = treeKeysOf(e); - if (cur && [...keys].some((k) => cur.keys.has(k))) { + // A manual thread takes its own items only: consecutive items of one group are one run (in timeline order). + const g = groupOf(e); + const joins = cur && (g || cur.group ? g === cur.group : [...keys].some((k) => cur.keys.has(k))); + if (joins) { cur.items.push(i); for (const k of keys) cur.keys.add(k); } else { - cur = { items: [i], keys }; + cur = { items: [i], keys, group: g }; runs.push(cur); } runOf[i] = runs.length - 1; @@ -204,7 +212,9 @@ export function conversationRuns(timeline, render = undefined) { runOf, runs: runs.map((r) => { const tree = treeOf(r.items.map((i) => tl[i])); - return { items: r.items, tree, rank: treeRank(tree, "seen") }; + // A manual thread is stacked in the order its posts came on screen ("as if a thread"), not the tree's. + const rank = r.group ? new Map([...tree.seen.entries()].sort((a, b) => a[1] - b[1] || idCmp(a[0], b[0])).map(([id], n) => [id, n])) : treeRank(tree, "seen"); + return { items: r.items, tree, rank, group: r.group ?? null }; }), }; } @@ -265,9 +275,11 @@ function contextsOf(tl, render) { const run = runs[r]; const anc = new Set([...ancestorsOf(run.tree, shownIdOf(e)), ...chainOf(e).slice(0, -1).filter(Boolean)]); const prevId = shownIdOf(prev); + // A manual thread keeps every earlier post on screen (stacked, small and dim): none collapses away. scene = { - tiles: end.map((t) => ({ id: t.id, ref: t.ref, from: t.id === prevId ? "full" : "small", action: anc.has(t.id) ? "keep" : "collapse" })), + tiles: end.map((t) => ({ id: t.id, ref: t.ref, from: t.id === prevId ? "full" : "small", action: run.group || anc.has(t.id) ? "keep" : "collapse" })), rank: Object.fromEntries(run.rank), + ...(run.group ? { group: run.group } : {}), }; } const ctx = { prev, scene }; @@ -277,6 +289,8 @@ function contextsOf(tl, render) { if (r >= 0) { const L = threadLayout(e, render, ctx); end = []; + // An item that draws no scene (one shown, not read, in a manual thread): what the run had stays for the next. + if (!isNarrated(e) && scene) for (const t of scene.tiles) if (t.action === "keep") end.push({ id: t.id, ref: t.ref }); for (const t of L.tiles) { if (t.mode === "hidden") continue; if (t.mode === "scene") { @@ -368,7 +382,12 @@ export function conversations(timeline, render = undefined) { if (it.at !== lastAt + 1) runs += 1; lastAt = it.at; } - const order = [...items].sort((a, b) => (byDate.get(a.post) ?? Infinity) - (byDate.get(b.post) ?? Infinity) || a.at - b.at).map((x) => x.id); + // A manual thread (`thread.group`) is gathered by its posts' DATES ("include the whole thread chronologically"). + const grouped = members.some((x) => groupOf(x.e)); + const dateOf = (x) => Date.parse(str(x.e?.date)); + const order = grouped + ? [...members].sort((a, b) => (dateOf(a) || Infinity) - (dateOf(b) || Infinity) || a.at - b.at).map((x) => x.e.id) + : [...items].sort((a, b) => (byDate.get(a.post) ?? Infinity) - (byDate.get(b.post) ?? Infinity) || a.at - b.at).map((x) => x.id); const atOfPost = new Map(); for (const it of items) if (!atOfPost.has(it.post)) atOfPost.set(it.post, it); const misplaced = []; @@ -404,7 +423,7 @@ export function conversations(timeline, render = undefined) { if (str(p?.id) && roles.has(`parent:${i}`) && !readBy.has(str(p.id))) readBy.set(str(p.id), e.id); }); } - out.push({ root, items, runs, split: runs > 1, order, misplaced, rereads }); + out.push({ root, items, runs, split: runs > 1, order, misplaced, rereads, ...(grouped ? { group: groupOf(members.find((x) => groupOf(x.e)).e) } : {}) }); } return out.sort((a, b) => a.items[0].at - b.items[0].at); } @@ -427,7 +446,7 @@ export function gatheredOrder(timeline, render = undefined, { sectionOf = null, const left = []; const sec = (id) => (sectionOf ? sectionOf.get(id) : undefined); for (const c of conversations(tl, render)) { - if (only && !(c.root === only || c.items.some((it) => it.id === only || it.post === only || it.chain.includes(only)))) continue; + if (only && !(c.root === only || c.group === only || c.items.some((it) => it.id === only || it.post === only || it.chain.includes(only)))) continue; const first = c.items[0]; // One group a section (one group in all, with no sections), each in tree order. const groups = new Map(); diff --git a/umtool/report-to-video/post-thread-scenes.test.mjs b/umtool/report-to-video/post-thread-scenes.test.mjs @@ -93,3 +93,49 @@ test("AN IMAGE-ONLY REPLY is a tile (its head and a chip), never read; a parent' 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); }); + +import { conversationRuns, gatheredOrder, planContext } from "./post-conversation.mjs"; + +const said = (id, text, h, o = {}) => narrate(base({ id: `p-${id}`, post: `subj-x/${id}`, text, date: at(h), ...o }), [[text]]); + +test("A MANUAL THREAD (thread.group): consecutive items of one group are one run -- the opening post shown (not read) and three of his, unlinked on X -- every earlier post kept on screen, oldest first, each reply saying what it answers", () => { + const g = { group: "jiggle" }; + const movail = base({ id: "p-m", post: "mov-x/2117295478345998503", author: "Movail", handle: "Movail2", text: "Ready for more lessons?", date: at(16), thread: g }); + const tl = [ + { type: "clip", id: "c-0" }, + movail, + said("6841", "Phat ass jiggle, oh my god.", 22, { thread: g, post: "subj-x/2117379977360326841" }), + said("4063", "It jiggle.", 22, { thread: g, parents: [ref("2117379977360326841", "subject", "Phat ass jiggle, oh my god.", 22)] }), + said("0390", "it jiggle, oh my god, i literally cannot, hypnotism", 23, { thread: g, parents: [ref("2117295478345998503", "Movail2", "Ready for more lessons?", 16)] }), + said("9999", "Something else entirely.", 23), + ]; + const { runOf } = conversationRuns(tl); + assert.deepEqual(runOf, [-1, 0, 0, 0, 0, 1]); + const last = planContext(tl, 4); + assert.equal(last.scene.group, "jiggle"); + assert.deepEqual(last.scene.tiles.map((t) => [t.id, t.action]), [["2117295478345998503", "keep"], ["2117379977360326841", "keep"], ["4063", "keep"]]); + // His last message draws the stack: Movail2's post (its own parent:0 -- one tile), the two before, his words. + const L = threadLayout(tl[4], undefined, last); + assert.deepEqual(L.tiles.map((t) => t.scope), ["parent:0", "conv:2117379977360326841", "conv:4063", "post"]); + // The relations: "It jiggle." answers the post above; his last answers Movail2's post, three tiles up. + const L3 = threadLayout(tl[3], undefined, planContext(tl, 3)); + assert.deepEqual(L3.tiles.find((t) => t.scope === "post").rel, { to: "subject", above: true, id: "2117379977360326841" }); + assert.deepEqual(L.tiles.find((t) => t.scope === "post").rel, { to: "Movail2", above: false, id: "2117295478345998503" }); + const html = postCardHtml(tl[4], { width: 1600, height: 900, follow: true, thread: postItemPlan(tl[4], undefined, last).follow.thread }); + assert.match(html, /data-thread-rel="branch">replying to <span class="redact">@xxxxxxxx<\/span>/); +}); + +test("A MANUAL THREAD is gathered in DATE order (timeline threads --write): the group at its first item's place, the other conversations after it in their order", () => { + const g = { group: "grok" }; + const tl = [ + said("72", "She better watch her back.", 10, { thread: g }), + said("73", "I meant it as advice.", 12, { thread: g }), + said("74", "Another conversation.", 11), + said("75", "And another one.", 13), + said("78", "I was simply offering advice.", 14, { thread: g }), + said("80", "Last word.", 16, { thread: g }), + said("79", "Do you agree?", 15, { thread: g }), + ]; + const { ids } = gatheredOrder(tl); + assert.deepEqual(ids, ["p-72", "p-73", "p-78", "p-79", "p-80", "p-74", "p-75"]); +}); diff --git a/umtool/report-to-video/post-thread.mjs b/umtool/report-to-video/post-thread.mjs @@ -606,6 +606,8 @@ export function threadSchedule(entry, render, { layout, blocks, lead = 0.4 }) { } } if (t.above) row.above = true; + if (t.rel) row.rel = t.rel; + if (t.linkedFrom) row.linkedFrom = t.linkedFrom; tiles.push(row); } return { shrink: k.shrink, dim: k.dim, seconds: k.seconds, pan: k.pan, contextRoom: THREAD_CONTEXT_ROOM, quotedAt: above ? "above" : "inside", tiles };