Archilyzer · Source

archilyzer

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

commit 555dab16274a4ef597689065324aea33d89eaebf
parent baf8e1c6b16e61d3b67bf539395fa7bf1403e7ad
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Mon,  2 Nov 2026 18:28:42 -0500

umtool: the Cut tab lists post items with their own glyph; the post bench trims an attachment, sets the hold, the crop and the blur

The Cut tab's row for a post item: a ❝ glyph, its day, author, what it carries (text,
image, video, gif; repost, reply), the seconds it plays (the rule, or its hold), its
first words and a link to its bench; it moves, joins a section or a group and takes a
section boundary like a clip (RowControls, the drag rules). The status lines count post
items ("· 36 posts") and their seconds.

The post bench (/projects/<p>/post/<id>, PostBenchPage + PostBench; the kind's `post`
view): the item played on its own clock (PostItemPlayer), the plan as a strip, and its
knobs -- a video's or a GIF's in and out (In / Out at playhead, Whole), its sound, a crop
of any attachment, an image's push-in, the images' grid, the blur of other authors, the
hold -- saved by one write (updatePostItem), and Transcribe for a video's words through
the editor. ‹ Back to the cut from Play, ‹ › to the neighbouring post items.

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

Diffstat:
Aumtool/components/projects/PostBench.tsx | 375+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aumtool/components/projects/PostBenchPage.tsx | 56++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mumtool/components/projects/ProjectView.tsx | 3+++
Mumtool/components/projects/TimelineEditor.tsx | 7++++---
Mumtool/components/projects/report/CutTab.tsx | 48+++++++++++++++++++++++++++++++++++++++++++++++-
Mumtool/components/projects/report/OverviewTab.tsx | 9++++++---
Mumtool/components/projects/report/ReportTabBody.tsx | 7+++++--
Mumtool/lib/projects/kinds.mjs | 3++-
Mumtool/lib/projects/report.mjs | 6+++++-
9 files changed, 503 insertions(+), 11 deletions(-)

diff --git a/umtool/components/projects/PostBench.tsx b/umtool/components/projects/PostBench.tsx @@ -0,0 +1,375 @@ +"use client"; + +import Link from "next/link"; +import { useRouter } from "next/navigation"; +import { useCallback, useEffect, useMemo, useRef, useState } from "react"; +import { buttonVariants } from "@/components/ui/button"; +import { cn } from "@/lib/utils"; +import { postBenchHref } from "@/lib/hrefs"; +import { POST_HOLD, POST_MEDIA_MIN_SPAN, postItemPlan, readingSeconds, ruleSeconds } from "umtool-report-to-video/post-item"; +import PostItemPlayer, { type PostPlan } from "./review/PostItemPlayer"; + +// --------------------------------------------------------------------------- +// THE POST BENCH, the client half (PostBenchPage.tsx): the item played on its +// own clock in its final look (PostItemPlayer: the build's card page, the +// attachments laid into its slot), and its knobs, each change shown at once +// and saved by one write (updatePostItem, POST /api/report/post-item): +// +// hold the item's whole length (absent: the duration rule) +// layout a grid of its 2-4 images, or one after another +// redact other authors: auto (the privacy rule), blurred, shown +// media[i] a video's or a GIF's in and out (the playhead sets them), +// its sound, a crop of any attachment, an image's push-in, +// and a video's words: Transcribe asks the EDITOR's +// transcription (a job on a local worker), never ASR here +// --------------------------------------------------------------------------- + +type Media = Record<string, unknown> & { src: string; kind: string; seconds?: number; start?: number; end?: number; mute?: boolean; crop?: number[]; push?: boolean; words?: string; audio?: boolean; width?: number; height?: number }; +type Entry = Record<string, unknown> & { id: string; media?: Media[]; hold?: number; mediaLayout?: string; redact?: boolean }; + +const r2 = (v: number) => Math.round(v * 100) / 100; +const CROPS: Array<{ label: string; crop: number[] | null }> = [ + { label: "none", crop: null }, + { label: "centre 80%", crop: [0.1, 0.1, 0.8, 0.8] }, + { label: "top half", crop: [0, 0, 1, 0.5] }, + { label: "bottom half", crop: [0, 0.5, 1, 0.5] }, +]; + +export default function PostBench({ + project, entry: initial, token: initialToken, box, plan: initialPlan, back, prev, next, fromPlay, +}: { + project: string; + entry: Entry; + token: string | null; + box: { width: number; height: number }; + plan: PostPlan; + back: { href: string; label: string }; + prev: string | null; + next: string | null; + fromPlay: boolean; +}) { + const router = useRouter(); + const [entry, setEntry] = useState<Entry>(initial); + const [saved, setSaved] = useState<Entry>(initial); + const [token, setToken] = useState(initialToken); + const [status, setStatus] = useState<string | null>(null); + const [error, setError] = useState<string | null>(null); + const plan = useMemo(() => (entry === initial ? initialPlan : (postItemPlan(entry) as PostPlan)), [entry, initial, initialPlan]); + const total = plan.total; + const [s, setS] = useState(0); + const [playing, setPlaying] = useState(false); + const raf = useRef(0); + useEffect(() => { + if (!playing) return; + let last = performance.now(); + const tick = (now: number) => { + const dt = (now - last) / 1000; + last = now; + setS((x) => { + const n = x + dt; + if (n >= total) { + setPlaying(false); + return total; + } + return n; + }); + raf.current = requestAnimationFrame(tick); + }; + raf.current = requestAnimationFrame(tick); + return () => cancelAnimationFrame(raf.current); + }, [playing, total]); + useEffect(() => { + const onKey = (ev: KeyboardEvent) => { + const tgt = ev.target as HTMLElement | null; + if (tgt?.closest("input, textarea, select")) return; + if (ev.key === " ") { + ev.preventDefault(); + setPlaying((p) => (s >= total ? (setS(0), true) : !p)); + } + }; + window.addEventListener("keydown", onKey); + return () => window.removeEventListener("keydown", onKey); + }, [s, total]); + + const dirty = JSON.stringify(entry) !== JSON.stringify(saved); + const media = entry.media ?? []; + const setMedia = (i: number, patch: Partial<Media>) => + setEntry((e) => ({ ...e, media: (e.media ?? []).map((m, j) => (j === i ? clean({ ...m, ...patch }) : m)) })); + const clean = (m: Media): Media => { + const out = { ...m } as Record<string, unknown>; + for (const [k, v] of Object.entries(out)) if (v === undefined || v === null) delete out[k]; + return out as Media; + }; + + // The patch the writer takes: every knob as it stands now (null: the default again). + const patchOf = (e: Entry) => ({ + hold: typeof e.hold === "number" ? e.hold : null, + mediaLayout: e.mediaLayout ?? null, + redact: typeof e.redact === "boolean" ? e.redact : null, + media: Object.fromEntries( + (e.media ?? []).map((m, i) => [ + i, + { + start: typeof m.start === "number" ? m.start : null, + end: typeof m.end === "number" ? m.end : null, + mute: m.mute === true ? true : null, + crop: Array.isArray(m.crop) ? m.crop : null, + push: m.push === true ? true : null, + }, + ]), + ), + }); + const save = useCallback(async () => { + setError(null); + setStatus("saving…"); + const res = await fetch("/api/report/post-item", { + method: "POST", + headers: { "content-type": "application/json" }, + body: JSON.stringify({ project, op: "set", id: entry.id, patch: patchOf(entry), token }), + }); + const j = (await res.json().catch(() => ({}))) as { entry?: Entry; token?: string; error?: string; errors?: string[] }; + if (!res.ok || !j.entry) { + setStatus(null); + setError(j.errors?.join("; ") ?? j.error ?? `HTTP ${res.status}`); + return; + } + setEntry(j.entry); + setSaved(j.entry); + setToken(j.token ?? null); + setStatus("saved"); + }, [entry, project, token]); + + // Transcribe a video attachment through the editor (a job), then follow it. + const [jobs, setJobs] = useState<Record<number, { job: string; state: string; error?: string }>>({}); + const transcribe = async (i: number) => { + setError(null); + const res = await fetch("/api/report/post-item", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ project, op: "transcribe", id: entry.id, media: i }) }); + const j = (await res.json().catch(() => ({}))) as { jobId?: string; error?: string }; + if (!res.ok || !j.jobId) { + setJobs((x) => ({ ...x, [i]: { job: "", state: "failed", error: j.error ?? `HTTP ${res.status}` } })); + return; + } + setJobs((x) => ({ ...x, [i]: { job: j.jobId!, state: "transcribing" } })); + }; + useEffect(() => { + const running = Object.entries(jobs).filter(([, v]) => v.state === "transcribing" && v.job); + if (!running.length) return; + const t = setTimeout(async () => { + for (const [i, v] of running) { + const res = await fetch(`/api/report/post-item?project=${encodeURIComponent(project)}&id=${encodeURIComponent(entry.id)}&media=${i}&job=${encodeURIComponent(v.job)}`); + const j = (await res.json().catch(() => ({}))) as { state?: string; words?: string; error?: string }; + if (j.state === "done" && j.words) { + setMedia(Number(i), { words: j.words }); + setSaved((e) => ({ ...e, media: (e.media ?? []).map((m, k) => (k === Number(i) ? { ...m, words: j.words } : m)) })); + router.refresh(); + } + if (j.state !== "transcribing") setJobs((x) => ({ ...x, [i]: { ...v, state: j.state ?? "failed", error: j.error } })); + } + }, 2000); + return () => clearTimeout(t); + }); + + const stepOf = (i: number) => plan.steps.find((st) => st.items.some((m) => m.i === i)) ?? null; + const btn = cn(buttonVariants({ variant: "outline", size: "sm" })); + const reading = readingSeconds(entry); + + return ( + <div className="mx-auto grid max-w-[1400px] grid-cols-1 gap-4 min-[1100px]:grid-cols-[minmax(0,1fr)_360px]" data-post-bench={entry.id}> + <section className="min-w-0 space-y-2"> + <div className="flex flex-wrap items-center gap-2 text-[12px]"> + <Link href={back.href} className="ink-link" data-post-bench-back=""> + {back.label} + </Link> + {prev && ( + <Link href={postBenchHref(project, prev, fromPlay ? { play: { at: 0 } } : {})} className="ink-link" data-post-bench-prev={prev}> + ‹ {prev} + </Link> + )} + {next && ( + <Link href={postBenchHref(project, next, fromPlay ? { play: { at: 0 } } : {})} className="ink-link" data-post-bench-next={next}> + {next} › + </Link> + )} + <span className="ml-auto font-mono text-[13px] tabular-nums" data-post-bench-clock=""> + {s.toFixed(1)} / {total.toFixed(1)} s + </span> + </div> + <div className="relative w-full overflow-hidden rounded border border-seam bg-black" style={{ aspectRatio: `${box.width} / ${box.height}` }}> + <PostItemPlayer project={project} entry={entry} plan={plan} box={box} s={s} playing={playing} /> + </div> + <div className="flex items-center gap-2 text-[12px]"> + <button type="button" className={btn} data-post-bench-play="" onClick={() => (s >= total ? (setS(0), setPlaying(true)) : setPlaying((p) => !p))}> + {playing ? "Pause" : "Play"} + </button> + <input + type="range" + min={0} + max={total} + step={0.05} + value={s} + onChange={(e) => setS(Number(e.target.value))} + className="flex-1" + aria-label="item position" + data-post-bench-scrub="" + /> + </div> + {/* The plan, as a strip: the reading span, then each attachment's step. */} + <div className="relative h-6 w-full overflow-hidden rounded bg-[var(--color-panel)] text-[10.5px]" data-post-bench-plan=""> + <div className="absolute inset-y-0 left-0 flex items-center bg-white/10 px-1" style={{ width: `${(plan.reading / total) * 100}%` }}> + read {plan.reading.toFixed(1)} s + </div> + {plan.steps.map((st, k) => ( + <div key={k} className="absolute inset-y-0 flex items-center border-l border-black/40 bg-[var(--color-sel)]/25 px-1" style={{ left: `${(st.at / total) * 100}%`, width: `${(st.seconds / total) * 100}%` }} data-post-bench-step={st.kind}> + {st.kind} {st.seconds.toFixed(1)} s + </div> + ))} + <div className="absolute inset-y-0 w-px bg-[var(--color-signal,#e33)]" style={{ left: `${(s / total) * 100}%` }} /> + </div> + </section> + + <aside className="space-y-3 text-[12.5px]"> + <section className="rounded border border-[var(--color-line)] bg-[var(--color-panel)] p-3"> + <h2 className="micro mb-2">length</h2> + <p className="m-0 text-text-2"> + the rule: {reading.toFixed(1)} s to read{media.length ? ` + the attachments` : ""} = <b data-post-bench-rule="">{ruleSeconds(entry).toFixed(1)} s</b> + </p> + <label className="mt-2 flex items-center gap-2"> + hold + <input + type="number" + min={POST_HOLD.min} + max={POST_HOLD.max} + step={0.5} + value={typeof entry.hold === "number" ? entry.hold : ""} + placeholder="the rule" + onChange={(e) => setEntry((x) => ({ ...x, hold: e.target.value === "" ? undefined : Number(e.target.value) }))} + className="w-24 rounded border border-seam bg-ground px-1.5 py-0.5" + data-post-bench-hold="" + /> + s + {typeof entry.hold === "number" && ( + <button type="button" className="ink-link" onClick={() => setEntry((x) => ({ ...x, hold: undefined }))}> + clear + </button> + )} + </label> + {media.filter((m) => m.kind === "image").length >= 2 && ( + <label className="mt-2 flex items-center gap-2"> + images + <select value={entry.mediaLayout ?? "sequence"} onChange={(e) => setEntry((x) => ({ ...x, mediaLayout: e.target.value === "sequence" ? undefined : e.target.value }))} data-post-bench-layout=""> + <option value="sequence">one after another</option> + <option value="grid">a grid, all at once</option> + </select> + </label> + )} + <label className="mt-2 flex items-center gap-2" title="auto: another author is blurred unless the subject, or gold/grey verified (post-item.mjs authorRedaction)"> + other authors + <select + value={entry.redact === true ? "on" : entry.redact === false ? "off" : "auto"} + onChange={(e) => setEntry((x) => ({ ...x, redact: e.target.value === "auto" ? undefined : e.target.value === "on" }))} + data-post-bench-redact="" + > + <option value="auto">auto (the privacy rule)</option> + <option value="on">blur them all</option> + <option value="off">show them (public)</option> + </select> + </label> + </section> + + {media.map((m, i) => { + const st = stepOf(i); + const timed = m.kind === "video" || m.kind === "gif"; + const len = typeof m.seconds === "number" ? m.seconds : 0; + const srcNow = st && s >= st.at ? r2((st.srcFrom ?? 0) + Math.min(st.seconds, s - st.at)) : null; + return ( + <section key={i} className="rounded border border-[var(--color-line)] bg-[var(--color-panel)] p-3" data-post-bench-media={i} data-post-bench-media-kind={m.kind}> + <h2 className="micro mb-2"> + attachment {i + 1} · {m.kind} + {timed ? ` · ${len.toFixed(1)} s` : ""} + {m.kind === "video" && m.audio === false ? " · no sound" : ""} + </h2> + {timed && ( + <div className="space-y-1.5"> + <div className="flex items-center gap-2"> + in + <input type="number" min={0} max={len} step={0.1} value={m.start ?? 0} onChange={(e) => setMedia(i, { start: Number(e.target.value) || undefined })} className="w-20 rounded border border-seam bg-ground px-1.5 py-0.5" data-post-bench-start={i} /> + out + <input type="number" min={0} max={len} step={0.1} value={m.end ?? len} onChange={(e) => setMedia(i, { end: Number(e.target.value) >= len - 0.02 ? undefined : Number(e.target.value) })} className="w-20 rounded border border-seam bg-ground px-1.5 py-0.5" data-post-bench-end={i} /> + <span className="text-text-2">plays {Math.max(POST_MEDIA_MIN_SPAN, (m.end ?? len) - (m.start ?? 0)).toFixed(1)} s</span> + </div> + <div className="flex flex-wrap gap-1.5"> + <button type="button" className={btn} disabled={srcNow === null} onClick={() => srcNow !== null && setMedia(i, { start: srcNow || undefined })} data-post-bench-set-in={i}> + In at playhead + </button> + <button type="button" className={btn} disabled={srcNow === null} onClick={() => srcNow !== null && setMedia(i, { end: srcNow })} data-post-bench-set-out={i}> + Out at playhead + </button> + <button type="button" className={btn} onClick={() => setMedia(i, { start: undefined, end: undefined })}> + Whole + </button> + </div> + {m.kind === "video" && m.audio !== false && ( + <label className="flex items-center gap-2"> + <input type="checkbox" checked={m.mute !== true} onChange={(e) => setMedia(i, { mute: e.target.checked ? undefined : true })} data-post-bench-sound={i} /> + its sound + </label> + )} + </div> + )} + {m.kind === "image" && ( + <label className="flex items-center gap-2"> + <input type="checkbox" checked={m.push === true} onChange={(e) => setMedia(i, { push: e.target.checked ? true : undefined })} data-post-bench-push={i} /> + slow push-in + </label> + )} + <div className="mt-1.5 flex flex-wrap items-center gap-1.5"> + crop + {CROPS.map((c) => ( + <button + key={c.label} + type="button" + className={cn(btn, JSON.stringify(m.crop ?? null) === JSON.stringify(c.crop) && "border-[var(--color-sel)]")} + onClick={() => setMedia(i, { crop: c.crop ?? undefined })} + data-post-bench-crop={c.label} + > + {c.label} + </button> + ))} + </div> + {m.kind === "video" && m.audio !== false && ( + <div className="mt-2 text-[12px]"> + {m.words ? ( + <span data-post-bench-words={i}>its words are transcribed (shown under it)</span> + ) : jobs[i]?.state === "transcribing" ? ( + <span data-post-bench-transcribing={i}>transcribing on the editor…</span> + ) : ( + <button type="button" className={btn} onClick={() => void transcribe(i)} data-post-bench-transcribe={i}> + Transcribe its words (the editor) + </button> + )} + {jobs[i]?.state === "failed" && <span className="ml-2 text-[var(--color-blocking,#c33)]">{jobs[i].error ?? "the transcription failed"}</span>} + </div> + )} + </section> + ); + })} + + <div className="flex items-center gap-2"> + <button type="button" className={cn(buttonVariants({ variant: "go", size: "sm" }))} disabled={!dirty} onClick={() => void save()} data-post-bench-save=""> + Save + </button> + <button type="button" className={btn} disabled={!dirty} onClick={() => setEntry(saved)}> + Revert + </button> + {status && !dirty && <span data-post-bench-status="">{status}</span>} + {dirty && <span className="text-text-2">unsaved</span>} + </div> + {error && ( + <p className="m-0 text-[var(--color-blocking,#c33)]" data-post-bench-error=""> + {error} + </p> + )} + </aside> + </div> + ); +} diff --git a/umtool/components/projects/PostBenchPage.tsx b/umtool/components/projects/PostBenchPage.tsx @@ -0,0 +1,56 @@ +import { notFound } from "next/navigation"; +import AppShell from "@/components/shell/AppShell"; +import PostBench from "./PostBench"; +import { readManifest } from "@/lib/projects/report.mjs"; +import { manifestToken } from "@/lib/report/manifest.mjs"; +import { projectHref, playHref } from "@/lib/hrefs"; +import { deckGeometry, deckOn, feedGeometry, feedOn } from "umtool-report-to-video/deck"; +import { postItemPlan } from "umtool-report-to-video/post-item"; +import type { ProjectRef } from "@/lib/project-types"; +import type { PostPlan } from "./review/PostItemPlayer"; + +// THE POST BENCH (report-to-video/post-item.mjs; knobs.md, "A post item"): one +// post item of the cut on its own -- its card and attachments played on the +// item's clock, and its knobs: an attachment's trim, sound, crop and push-in, +// the images' grid, the blur of other authors, the item's hold, and a video's +// words through the editor's transcription. Every save is updatePostItem +// (POST /api/report/post-item {op: "set"}), the writer `umtool posts set-item` runs. + +export default async function PostBenchPage({ project, id, search = {} }: { project: ProjectRef; id: string; search?: Record<string, string | undefined> }) { + const m = (await readManifest(project.dir)) as Record<string, unknown> | null; + if (!m) notFound(); + const tl = (Array.isArray(m.timeline) ? m.timeline : []) as Array<Record<string, unknown> & { id: string; type?: string }>; + const at = tl.findIndex((e) => e?.type === "post" && e.id === id); + if (at < 0) notFound(); + const entry = tl[at]; + const render = (m.render ?? {}) as Record<string, unknown>; + const box = deckOn(render) + ? (feedOn({ render, posts: (m.posts ?? []) as never[], entries: tl as never[] }) ? feedGeometry(render).footage : deckGeometry(render).footage) + : { width: Number(render.width ?? 1920), height: Number(render.height ?? 1080) }; + const neighbours = tl.filter((e) => e?.type === "post").map((e) => e.id); + const k = neighbours.indexOf(id); + const fromPlay = search.from === "play"; + const back = fromPlay ? playHref(project.id, { clip: id, at: Number(search.at ?? 0) || null }) : projectHref(project.id, { tab: "cut" }); + return ( + <div className="flex h-full flex-col"> + <AppShell + active="projects" + crumbs={[{ href: "/projects", label: "Projects" }, { href: projectHref(project.id), label: project.name }, { label: `post ${id}` }]} + note={`post item ${k + 1} of ${neighbours.length} · ${String(entry.post ?? "")}`} + /> + <main className="deck-main flex-1 overflow-auto p-4"> + <PostBench + project={project.id} + entry={entry} + token={await manifestToken(project.dir)} + box={{ width: box.width, height: box.height }} + plan={postItemPlan(entry) as unknown as PostPlan} + back={{ href: back, label: fromPlay ? "‹ Back to the cut" : "‹ The Cut tab" }} + prev={k > 0 ? neighbours[k - 1] : null} + next={k < neighbours.length - 1 ? neighbours[k + 1] : null} + fromPlay={fromPlay} + /> + </main> + </div> + ); +} diff --git a/umtool/components/projects/ProjectView.tsx b/umtool/components/projects/ProjectView.tsx @@ -4,6 +4,7 @@ import SongProject from "./SongProject"; import CutPage from "./CutPage"; import ReportProject from "./ReportProject"; import ClipBenchPage from "./ClipBenchPage"; +import PostBenchPage from "./PostBenchPage"; import ClaimBenchPage from "./ClaimBenchPage"; import SweepProject from "./SweepProject"; import TakesPage from "./TakesPage"; @@ -53,6 +54,8 @@ export default async function ProjectView({ if (rest.length === 0) return <ReportProject project={project} search={search} />; // `/browse/<project>/clip/<id>` -- the bench. A view the kind does not // declare is a 404 rather than a page that silently drops half its URL. + // `/projects/<project>/post/<id>` -- a post item's bench (report-to-video/post-item.mjs). + if (rest.length === 2 && rest[0] === "post") return <PostBenchPage project={project} id={rest[1]} search={search} />; if (rest.length === 2 && rest[0] === "clip") { return <ClipBenchPage project={project} clipId={rest[1]} search={search} />; } diff --git a/umtool/components/projects/TimelineEditor.tsx b/umtool/components/projects/TimelineEditor.tsx @@ -201,7 +201,7 @@ export function TimelineList({ project, count, groupCount = 0, children }: { pro if (draggingBar.current !== null) { // A boundary goes after a CLIP. const li = rowOf(e.target); - if (!li || li.dataset.kind !== "clip") return; + if (!li || (li.dataset.kind !== "clip" && li.dataset.kind !== "post")) return; e.preventDefault(); setOver(rowKey(li).at); return; @@ -238,7 +238,7 @@ export function TimelineList({ project, count, groupCount = 0, children }: { pro return; } if (marker !== null) { - if (!li || li.dataset.kind !== "clip") return; + if (!li || (li.dataset.kind !== "clip" && li.dataset.kind !== "post")) return; e.preventDefault(); void run("section-boundary", { marker, afterId: rowKey(li).id }); return; @@ -394,7 +394,8 @@ export function RowControls({ id, at, kind = "entry" }: { id: string; at: number const [newSection, setNewSection] = useState(false); if (!ctx) return null; const { busy, run, dragging, sections, selected, toggle } = ctx; - const isClip = kind === "clip"; + // A footage row: a clip or a post item (both sit in sections and groups). + const isClip = kind === "clip" || kind === "post"; const mine = isClip ? sections.find((s) => s.clips.includes(id)) : undefined; return ( <> diff --git a/umtool/components/projects/report/CutTab.tsx b/umtool/components/projects/report/CutTab.tsx @@ -8,7 +8,7 @@ import { } from "@/lib/projects/report.mjs"; import { listTakes } from "@/lib/report/takes.mjs"; import { buttonVariants } from "@/components/ui/button"; -import { clipBenchHref, clipDeckHref, clipEditorHref, mixHref as toolsMixHref, playHref, projectHref, takeWalkHref, takesHref, trailerHref } from "@/lib/hrefs"; +import { postBenchHref, clipBenchHref, clipDeckHref, clipEditorHref, mixHref as toolsMixHref, playHref, projectHref, takeWalkHref, takesHref, trailerHref } from "@/lib/hrefs"; import { readTrailerBeats } from "@/lib/report/trailerBeats.mjs"; import { montageClipsOf, momentKeysOf, readRulingsState } from "@/lib/report/montageRulings.mjs"; import FetchUnfetchedButton from "../FetchUnfetchedButton"; @@ -16,6 +16,7 @@ import TightWindowsPanel from "./TightWindowsPanel"; import { clipRecord, storedUrlOf } from "@/lib/clips/stored"; import { Fragment } from "react"; import { deckOn } from "umtool-report-to-video/deck"; +import { postItemSeconds } from "umtool-report-to-video/post-item"; import { sectionModel, sectionWords } from "@/lib/report/sectionEdit.mjs"; import { GroupBar, RowControls, RowNotes, SectionBar, TimelineList, type GroupInfo, type SectionInfo } from "../TimelineEditor"; import { groupModel } from "@/lib/report/claimGroups.mjs"; @@ -170,6 +171,51 @@ export default async function CutTab({ project, detail, search, tabHref }: Repor // vocabulary is open -- one real manifest carries `scroll` and // `chart` beside its cards -- and a page that only knows two words // either crashes on the third or silently drops it. + // A POST ITEM (report-to-video/post-item.mjs): its own glyph, the post's day, author and + // first words, what it carries, how long it plays, and its bench. + if (e.kind === "post") { + const media = (Array.isArray(e.media) ? e.media : []) as { kind?: string }[]; + const words = String(e.text ?? "").replace(/^RT @[A-Za-z0-9_]+:\s*/, "").replace(/\s+/g, " ").trim(); + const inGroup = groupBars.of.get(e.id); + return ( + <li + data-entry={e.id} + data-kind="post" + data-at={at} + data-group={inGroup} + tabIndex={0} + className={`rounded border border-[var(--color-line)] bg-[var(--color-panel)] px-3 py-1.5 outline-none focus:border-[var(--color-sel)] ${inGroup ? "ml-6" : ""}`} + > + <div className="flex flex-wrap items-baseline gap-2 text-[12px]"> + <RowControls id={e.id} at={at} kind="post" /> + <span aria-hidden data-post-glyph="" title="a post item" className="font-display text-[14px] leading-none text-[var(--color-sel)]"> + ❝ + </span> + <span className="font-mono text-[var(--color-text)]">{e.id}</span> + <span className="num font-mono text-[11px] text-[var(--color-dim)]">{String(e.date ?? "").slice(0, 10)}</span> + <span className="text-[11px] text-[var(--color-dim)]"> + {e.author ?? ""} + {e.handle ? ` @${e.handle}` : ""} + </span> + {e.repostedBy ? <Pill>repost</Pill> : null} + {(Array.isArray(e.parents) && e.parents.length) || e.parentShot || e.replyingTo ? <Pill>reply</Pill> : null} + <span data-post-carries=""> + <Pill>{media.length ? media.map((m) => m.kind).join(" + ") : "text"}</Pill> + </span> + <span className="num micro ml-auto" data-post-seconds=""> + {postItemSeconds(e).toFixed(1)}s{typeof e.hold === "number" ? " (hold)" : ""} + </span> + <Link href={postBenchHref(project.id, e.id)} className="ink-link text-[11px]" data-post-bench-link={e.id}> + bench + </Link> + </div> + {words && <div className="mt-0.5 text-[12px] text-[var(--color-dim)]">{words.length > 160 ? `${words.slice(0, 157)}…` : words}</div>} + <div className="basis-full"> + <RowNotes id={e.id} project={project.id} /> + </div> + </li> + ); + } if (e.kind !== "clip") { return ( <li diff --git a/umtool/components/projects/report/OverviewTab.tsx b/umtool/components/projects/report/OverviewTab.tsx @@ -1,4 +1,5 @@ import { readFile } from "node:fs/promises"; +import { postItemSeconds } from "umtool-report-to-video/post-item"; import path from "node:path"; import Link from "next/link"; import { Suspense } from "react"; @@ -40,8 +41,10 @@ export default async function OverviewTab({ project, detail, frame }: ReportTabP const readme = await readFile(path.join(project.dir, "README.md"), "utf8").catch(() => null); const p = (m.provenance ?? {}) as Record<string, unknown>; const clips = entries.filter((e) => e.kind === "clip"); - const nonClips = entries.filter((e) => e.kind !== "clip"); - const runtime = clips.reduce((n, e) => n + Math.max(0, e.end - e.start), 0); + // Post items (report-to-video/post-item.mjs) are counted on their own, and play their rule's seconds. + const posts = entries.filter((e) => e.kind === "post"); + const nonClips = entries.filter((e) => e.kind !== "clip" && e.kind !== "post"); + const runtime = clips.reduce((n, e) => n + Math.max(0, e.end - e.start), 0) + posts.reduce((n, e) => n + postItemSeconds(e), 0); const article = frame.article; const iterations = article && article.site === ARTICLES_KEY ? await readArticleIterations(article.report).catch(() => null) : null; @@ -88,7 +91,7 @@ export default async function OverviewTab({ project, detail, frame }: ReportTabP <li className="flex gap-2.5 border-b border-seam py-1.5"> cut <span className="ml-auto font-mono text-[11.5px] text-meter"> - {clips.length} clips{nonClips.length ? ` · ${nonClips.length} other` : ""} · {hms(runtime)} + {clips.length} clips{posts.length ? ` · ${posts.length} posts` : ""}{nonClips.length ? ` · ${nonClips.length} other` : ""} · {hms(runtime)} </span> </li> <li className="flex gap-2.5 border-b border-seam py-1.5"> diff --git a/umtool/components/projects/report/ReportTabBody.tsx b/umtool/components/projects/report/ReportTabBody.tsx @@ -1,4 +1,5 @@ import GeneratedBanner from "@/components/notes/GeneratedBanner"; +import { postItemSeconds } from "umtool-report-to-video/post-item"; import { NotesProvider } from "@/components/notes/NotesProvider"; import { channelFor, clipsOf } from "@/lib/projects/report.mjs"; import type { PieceFrame } from "@/lib/pieces/frame"; @@ -32,10 +33,12 @@ export async function reportCounts(detail: ClipDetail, dir: string): Promise<{ c /** The page's one-line status: `4 clips · 2 other · 0:12 · not built`. */ export function reportStatus(detail: ClipDetail): string { const clips = detail.entries.filter((e) => e.kind === "clip"); - const nonClips = detail.entries.filter((e) => e.kind !== "clip"); - const runtime = clips.reduce((n, e) => n + Math.max(0, e.end - e.start), 0); + const posts = detail.entries.filter((e) => e.kind === "post"); + const nonClips = detail.entries.filter((e) => e.kind !== "clip" && e.kind !== "post"); + const runtime = clips.reduce((n, e) => n + Math.max(0, e.end - e.start), 0) + posts.reduce((n, e) => n + postItemSeconds(e), 0); return ( `${clips.length} clips` + + (posts.length ? ` · ${posts.length} posts` : "") + (nonClips.length ? ` · ${nonClips.length} other` : "") + ` · ${hms(runtime)} · ${detail.build.built ? "built" : "not built"}` ); diff --git a/umtool/lib/projects/kinds.mjs b/umtool/lib/projects/kinds.mjs @@ -102,7 +102,8 @@ export const PROJECT_KINDS = [ // Views reachable under the project's own URL: // /browse/<project>/clip/<id> the window bench // /browse/<project>/claim/<id> the adjudication bench - views: ["clip", "claim"], + // /browse/<project>/post/<id> a post item's bench + views: ["clip", "claim", "post"], // What "new project" asks for, beyond a slug and a title. Declared HERE so // the menu renders fields from data and never branches on a kind id. // `brand` offers report-to-video's presets (render.brand); none is the diff --git a/umtool/lib/projects/report.mjs b/umtool/lib/projects/report.mjs @@ -5,6 +5,7 @@ // this from a terminal with no server. It is also the only place that knows the // manifest's shape -- the walk knows a marker file, the page knows a summary, // and neither parses JSON. +import { postItemSeconds } from "umtool-report-to-video/post-item"; import { readdir, readFile, stat } from "node:fs/promises"; import path from "node:path"; import { DEFAULT_VARIANT, cachedWindowsFor, fetchSpans } from "umtool-report-to-video/build-video"; @@ -895,7 +896,10 @@ export async function summariseReport(ctx) { const others = (m?.timeline ?? []).filter((e) => e?.type !== "clip" && e?.type !== "card"); const build = await buildStateOf(dir, m); - const runtime = clips.reduce((n, e) => n + Math.max(0, (e.end ?? 0) - (e.start ?? 0)), 0); + // Post items (report-to-video/post-item.mjs) play their duration rule's seconds. + const runtime = + clips.reduce((n, e) => n + Math.max(0, (e.end ?? 0) - (e.start ?? 0)), 0) + + (m?.timeline ?? []).filter((e) => e?.type === "post").reduce((n, e) => n + postItemSeconds(e), 0); const sources = new Set(clips.map((e) => (e.src != null ? `src:${e.src}` : `${channelFor(m, e)}/${e.video}`))).size; const locked = clips.filter((e) => e.lock).length;