Archilyzer · Source

archilyzer

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

commit 034e5c0cfccfebe049b5330033230ac2fdc7295e
parent 080b892a8710938bd659d80b546b73892f475210
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Thu,  5 Nov 2026 01:26:38 -0500

umtool: Play from anywhere a cut or a take is named -- one PlayLink (the newest take by default, at the item when there is one): the project head's primary row (Play <latest>, Walk, + Add a clip) and status line (latest take, length, rendered, open notes) on every tab, a ▶ on every Cut tab row and walk-a-take chip, Play the cut on a cut of posts too (it was hidden when the cut had no clips), take cards' Play a button, the take walk page and its rows, /jobs take renders (and their mp4's local path with Copy), the Inbox's cards of a report video (at the note), the rail's Recent cuts (operator, 5 Nov: "sometimes going to the play screen for a cut is hard to do without just entering the /play page")

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

Diffstat:
Mumtool/app/page.tsx | 7++++++-
Mumtool/components/inbox/InboxList.tsx | 7+++++++
Mumtool/components/piece/PieceFrame.tsx | 8++++++++
Mumtool/components/projects/PlayCutPage.tsx | 2++
Aumtool/components/projects/PlayLink.tsx | 74++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aumtool/components/projects/ProjectPrimary.tsx | 57+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mumtool/components/projects/ReportProject.tsx | 16+++++++++++++++-
Mumtool/components/projects/TakeWalkPage.tsx | 3+++
Mumtool/components/projects/TakesBench.tsx | 6++++--
Aumtool/components/projects/playable.ts | 21+++++++++++++++++++++
Mumtool/components/projects/report/CutTab.tsx | 17++++++++++++-----
Mumtool/components/queue/RenderRecord.tsx | 11+++++++++++
Mumtool/components/shell/AppRail.tsx | 3+++
Aumtool/components/shell/RecentCuts.tsx | 71+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mumtool/lib/queue/view.ts | 5++++-
15 files changed, 298 insertions(+), 10 deletions(-)

diff --git a/umtool/app/page.tsx b/umtool/app/page.tsx @@ -12,6 +12,7 @@ import { headlineNote, inboxHeadline } from "@/lib/inbox/headline.mjs"; import { whatOf } from "@/lib/inbox/what.mjs"; import type { Decision } from "@/lib/decisions"; import type { LifecycleState } from "@/lib/lifecycle"; +import { playHrefOfPiece } from "@/components/projects/playable"; export const dynamic = "force-dynamic"; @@ -121,6 +122,10 @@ export default async function Inbox({ extra.push({ id: "hidden", label: "Hidden", note: "on parked and done pieces", collapsed: false, decisions: parkedN, hidden: 0, cards }); } + // ▶ Play beside every card of a report video (at its note, for a note card): lane/ui-simplify. + const all = [...groups, ...extra]; + await Promise.all(all.flatMap((g) => g.cards.map(async (c) => (c.play = await playHrefOfPiece(c.piece, c.action.href))))); + return ( <div className="flex h-full flex-col"> <AppShell @@ -177,7 +182,7 @@ export default async function Inbox({ </span> </div> - <InboxList groups={[...groups, ...extra]} /> + <InboxList groups={all} /> </main> <UndoBar /> </div> diff --git a/umtool/components/inbox/InboxList.tsx b/umtool/components/inbox/InboxList.tsx @@ -43,6 +43,8 @@ export type InboxCard = { muted?: boolean; /** Mark done is the action (POST), not a link. */ finish?: boolean; + /** A report video's Play address (at the card's note), when the piece has one. */ + play?: string | null; }; export type InboxGroup = { @@ -149,6 +151,11 @@ function Card({ card: c }: { card: InboxCard }) { {c.action.label} </Link> )} + {c.play && ( + <Link href={c.play} prefetch={false} data-play-link="note" aria-label={`play ${c.title}`} title="play the newest take (at this note)" className="ml-1 text-[12px] text-signal-text hover:underline"> + ▶ + </Link> + )} </span> <LitActions className="ml-auto gap-0.5 sm:ml-0 max-md:hidden"> {!parked && !c.muted && c.piece && ( diff --git a/umtool/components/piece/PieceFrame.tsx b/umtool/components/piece/PieceFrame.tsx @@ -51,6 +51,7 @@ export default function PieceFrame({ meta, head, more, + primary, schedule, edition, children, @@ -74,6 +75,8 @@ export default function PieceFrame({ note?: React.ReactNode; /** The ⋯ menu's items (Delete project …). */ more?: React.ReactNode; + /** The head's primary action row (a report video's Play, Walk): before the lifecycle chip, on every tab. */ + primary?: React.ReactNode; /** A living report's schedule (R5): the cadence chip, Pause/Resume, Tick now. */ schedule?: { id: string; shape: string; chip: string; paused: boolean; cadence: Cadence; running: boolean } | null; /** The series this article is an edition of (R5). */ @@ -99,6 +102,11 @@ export default function PieceFrame({ sheet={head} actions={ <> + {primary && ( + <span className="inline-flex flex-wrap items-center gap-1.5" data-piece-primary=""> + {primary} + </span> + )} {piece && <LifecycleChip piece={frame.pieceId} title={piece.title} state={frame.lifecycle} />} {more && ( <Menu diff --git a/umtool/components/projects/PlayCutPage.tsx b/umtool/components/projects/PlayCutPage.tsx @@ -7,6 +7,7 @@ import { NotesProvider } from "@/components/notes/NotesProvider"; import { BenchFrame, BenchTop } from "./bench/BenchShell"; import PlayCut, { type PlayViewData } from "./review/PlayCut"; import CutApp from "./cutApp/CutApp"; +import { RememberCut } from "@/components/shell/RecentCuts"; // `/projects/<project>/play` (and `?take=<id>`) -- THE PLAY VIEW // (umtool/docs/knobs.md, "Play the cut"): the whole cut, or a take, played in the browser in @@ -62,6 +63,7 @@ export default async function PlayCutPage({ // Play and the clip bench as ONE app (cutApp/CutApp.tsx): Play stays mounted, the bench opens in place. return ( <CutApp project={project.id} playTop={top}> + <RememberCut project={project.id} title={project.name ?? project.id} /> <NotesProvider target={{ project: project.id }}> <PlayCut view={view as PlayViewData} diff --git a/umtool/components/projects/PlayLink.tsx b/umtool/components/projects/PlayLink.tsx @@ -0,0 +1,74 @@ +import Link from "next/link"; +import { buttonVariants } from "@/components/ui/button"; +import { playHref } from "@/lib/hrefs"; +import { cn } from "@/lib/utils"; + +// --------------------------------------------------------------------------- +// PLAY, FROM ANYWHERE A CUT OR A TAKE IS NAMED (lane/ui-simplify, 5 Nov; the +// operator: "sometimes going to the play screen for a cut is hard to do without +// just entering the /play page"). +// +// One link, one address builder (lib/hrefs.ts playHref): with no take it lands +// on Play of the NEWEST take (the working cut, lib/report/workingCut.mjs -- +// "the latest draft is the working cut"), with a take on that take, with a clip +// at that item. Every surface that names a cut or a take wears this rather +// than a hand-built `/play` link, so no surface leaves the operator typing it. +// +// `where` is the surface (`header`, `row`, `take-card`, `walk`, `jobs`, `rail`, +// `note`): `data-play-link="<where>"`, the e2e's handle. +// --------------------------------------------------------------------------- + +export type PlayLinkVariant = "primary" | "header" | "button" | "link" | "icon"; + +export default function PlayLink({ + project, + take = null, + clip = null, + at = null, + note = null, + where, + variant = "button", + label, + title, + className, +}: { + project: string; + /** A take id; null plays the newest take. */ + take?: string | null; + /** Start on this item (a clip or a post item's id). */ + clip?: string | null; + at?: number | null; + note?: string | null; + where: string; + variant?: PlayLinkVariant; + label?: React.ReactNode; + title?: string; + className?: string; +}) { + const href = playHref(project, { take, clip, at, note }); + const words = label ?? (variant === "icon" ? "▶" : clip ? "▶ Play here" : take ? `▶ Play ${take}` : "▶ Play"); + const look = + variant === "primary" + ? buttonVariants({ variant: "go", size: "md" }) + : variant === "header" + ? buttonVariants({ variant: "outline", size: "md" }) + : variant === "button" + ? buttonVariants({ variant: "outline", size: "sm" }) + : variant === "icon" + ? "inline-flex items-center rounded-[3px] px-1 text-[11px] text-signal-text hover:bg-panel-2" + : "ink-link text-[11.5px]"; + return ( + <Link + href={href} + prefetch={false} + data-play-link={where} + data-play-link-take={take ?? ""} + data-play-link-clip={clip ?? ""} + aria-label={variant === "icon" ? (clip ? `play from ${clip}` : take ? `play ${take}` : "play the newest take") : undefined} + title={title ?? (clip ? `play the newest take from ${clip}` : take ? `play take ${take} in the browser, no render` : "play the newest take in the browser, no render")} + className={cn(look, className)} + > + {words} + </Link> + ); +} diff --git a/umtool/components/projects/ProjectPrimary.tsx b/umtool/components/projects/ProjectPrimary.tsx @@ -0,0 +1,57 @@ +import Link from "next/link"; +import { buttonVariants } from "@/components/ui/button"; +import { clipBenchHref, projectHref, takeWalkHref } from "@/lib/hrefs"; +import PlayLink from "./PlayLink"; +import type { ClipDetail } from "./report/shared"; + +// --------------------------------------------------------------------------- +// A report video's ONE PRIMARY ROW, in the piece head on every tab +// (lane/ui-simplify, 5 Nov): Play the newest take, Walk it, Add a clip. The +// status line beside the title says what the working cut is (primaryStatus). +// Everything else lives on the tabs, under their Options / Advanced. +// --------------------------------------------------------------------------- + +type Working = { latest: { id: string; seconds: number | null; builtAt: string | null } | null } | null; + +const mmss = (s: number | null | undefined) => (typeof s === "number" ? `${Math.floor(s / 60)}:${String(Math.floor(s % 60)).padStart(2, "0")}` : null); +const day = (iso: string | null | undefined) => { + if (!iso) return null; + const d = new Date(iso); + return Number.isNaN(d.getTime()) ? null : d.toLocaleDateString("en-GB", { day: "numeric", month: "short" }); +}; + +/** "latest mid-14 · 38:56 · rendered 4 Nov · 0 open notes · <the cut's own status>". */ +export function primaryStatus(working: Working, openNotes: number, cut: string): string { + const l = working?.latest; + const head = l ? [`latest ${l.id}`, mmss(l.seconds), day(l.builtAt) ? `rendered ${day(l.builtAt)}` : null].filter(Boolean).join(" · ") : "no take yet"; + return `${head} · ${openNotes} open note${openNotes === 1 ? "" : "s"} · ${cut}`; +} + +export default function ProjectPrimary({ project, detail, latest }: { project: string; detail: ClipDetail; latest: string | null }) { + const entries = detail.entries; + if (entries.length === 0) { + return ( + <Link href={projectHref(project, { tab: "cut" }) + "&add=1"} prefetch={false} data-primary-add-clip="" className={buttonVariants({ variant: "outline", size: "md" })}> + + Add a clip + </Link> + ); + } + const firstClip = entries.find((e) => e.kind === "clip")?.id ?? null; + return ( + <> + <PlayLink project={project} where="header" variant="header" label={latest ? `▶ Play ${latest}` : "▶ Play the cut"} /> + {latest ? ( + <Link href={takeWalkHref(project, latest)} prefetch={false} data-primary-walk={latest} className={buttonVariants({ variant: "quiet", size: "md" })} title={`walk take ${latest}: its clips, a verdict each`}> + Walk + </Link> + ) : firstClip ? ( + <Link href={clipBenchHref(project, firstClip)} prefetch={false} data-primary-walk="" className={buttonVariants({ variant: "quiet", size: "md" })}> + Walk + </Link> + ) : null} + <Link href={projectHref(project, { tab: "cut" }) + "&add=1"} prefetch={false} data-primary-add-clip="" className={buttonVariants({ variant: "quiet", size: "md" })} title="find a moment, set its in and out, place it in the cut; fetched through the editor"> + + Add a clip + </Link> + </> + ); +} diff --git a/umtool/components/projects/ReportProject.tsx b/umtool/components/projects/ReportProject.tsx @@ -8,6 +8,11 @@ import type { ProjectRef } from "@/lib/project-types"; import DeleteProject from "./DeleteProject"; import ReportTabBody, { reportCounts, reportStatus } from "./report/ReportTabBody"; import { readClipDetail } from "@/lib/projects/report.mjs"; +import path from "node:path"; +import { readNotes } from "@/lib/annotations/store.mjs"; +import { readWorkingCut } from "@/lib/report/workingCut.mjs"; +import ProjectPrimary, { primaryStatus } from "./ProjectPrimary"; +import { RememberCut } from "@/components/shell/RecentCuts"; // --------------------------------------------------------------------------- // A report video, as a PIECE PAGE (plans/umtool-redesign.md, P4a-1). @@ -54,6 +59,13 @@ export default async function ReportProject({ const m = detail.manifest; const tab = tabOf(search, { noteTab: !search.tab ? await projectNoteTab(project.dir, search.note) : null }); const frame = await readPieceFrame(project); + // The head's one primary row (lane/ui-simplify): Play the newest take, on every tab, and the status line + // "latest mid-14 · 38:56 · rendered 4 Nov · 0 open notes". + const [working, notes] = await Promise.all([ + readWorkingCut(project.dir).catch(() => null), + readNotes(path.join(project.dir, "notes.json")).catch(() => ({ doc: null })), + ]); + const openNotes = (notes.doc?.notes ?? []).filter((n: { status?: string }) => (n.status ?? "open") === "open").length; return ( <div className="flex h-full flex-col"> @@ -63,7 +75,8 @@ export default async function ReportProject({ tab={tab} tabs={PIECE_TABS.map((t) => ({ ...t, href: projectHref(project.id, { tab: t.id }) }))} counts={await reportCounts(detail, project.dir)} - note={reportStatus(detail)} + note={primaryStatus(working, openNotes, reportStatus(detail))} + primary={<ProjectPrimary project={project.id} detail={detail} latest={working?.latest?.id ?? null} />} more={ <> <span className="px-2 pb-1 pt-0.5 font-mono text-[11px] text-muted">{project.id}</span> @@ -71,6 +84,7 @@ export default async function ReportProject({ </> } > + <RememberCut project={project.id} title={typeof m.title === "string" && m.title ? m.title : project.id} /> <ReportTabBody project={project} detail={detail} search={search} tab={tab} frame={frame} /> </PieceFrame> </div> diff --git a/umtool/components/projects/TakeWalkPage.tsx b/umtool/components/projects/TakeWalkPage.tsx @@ -8,6 +8,7 @@ import { isTakeId } from "@/lib/report/takes.mjs"; import { walkOf } from "@/lib/report/walkData.mjs"; import type { ProjectRef } from "@/lib/project-types"; import { BenchBody, BenchFrame, BenchTop } from "./bench/BenchShell"; +import PlayLink from "./PlayLink"; import TakeActions from "./TakeActions"; import BenchPrepPanel from "./report/BenchPrepPanel"; @@ -76,6 +77,7 @@ export default async function TakeWalkPage({ {all ? "Nothing fetched to walk." : "Every fetched clip has a verdict."} </span> )} + <PlayLink project={project.id} take={take} where="walk" variant="button" /> <Link href={takeWalkHref(project.id, take, { all: !all })} data-take-walk-all={all ? "1" : "0"} className="text-[12px] ink-link"> {all ? "walk only the clips needing a verdict" : "walk every clip (judged ones too)"} </Link> @@ -106,6 +108,7 @@ export default async function TakeWalkPage({ {c.id} </Link> {c.onWalk && <span className="ml-1 text-meter" title="on the walk">→</span>} + <PlayLink project={project.id} take={take} clip={c.id} where="walk-row" variant="icon" /> </td> <td className="num py-1 pr-2 whitespace-nowrap"> {hms(c.start)}–{hms(c.end)} diff --git a/umtool/components/projects/TakesBench.tsx b/umtool/components/projects/TakesBench.tsx @@ -10,6 +10,7 @@ import TimedNotes from "@/components/notes/TimedNotes"; import { badgeVariants, type BadgeVariants } from "@/components/ui/badge"; import { buttonVariants } from "@/components/ui/button"; import { fmtAgo, fmtBytes } from "@/lib/format"; +import { cn } from "@/lib/utils"; import { playHref, takeWalkHref } from "@/lib/hrefs"; import RenderRecord from "@/components/queue/RenderRecord"; import type { RenderView } from "@/lib/queue/view"; @@ -754,10 +755,11 @@ function TakeCard({ <Link href={playHref(project, { take: t.id })} data-play-take={t.id} - className="ml-auto text-[11px] ink-link" + data-play-link="take-card" + className={cn(buttonVariants({ variant: "outline", size: "sm" }), "ml-auto")} title="play this take's whole cut in the browser, in its final look, without rendering it" > - Play + ▶ Play </Link> <button type="button" diff --git a/umtool/components/projects/playable.ts b/umtool/components/projects/playable.ts @@ -0,0 +1,21 @@ +import { resolveProjectPath } from "@/lib/projects"; +import { playHref } from "@/lib/hrefs"; + +// Which pieces have a Play view (a report video), for surfaces outside +// components/projects/ that name a piece -- the Inbox's cards -- and may not +// name a kind themselves (the registry rule: kind ids stay in lib/projects/ +// and components/projects/). `p:<project>` → its Play address, at the note +// when the card's action points at one; null for anything else. +export async function playHrefOfPiece(piece: string | null, actionHref?: string | null): Promise<string | null> { + if (!piece || !piece.startsWith("p:")) return null; + const id = piece.slice(2); + const r = await resolveProjectPath(id.split("/")).catch(() => null); + if (!r || !("project" in r) || !r.project || r.rest.length || r.project.kind !== "report-video") return null; + let note: string | null = null; + try { + note = actionHref ? new URL(actionHref, "http://umtool").searchParams.get("note") : null; + } catch { + note = null; + } + return playHref(r.project.id, { note }); +} diff --git a/umtool/components/projects/report/CutTab.tsx b/umtool/components/projects/report/CutTab.tsx @@ -12,6 +12,7 @@ import { narrationRecordHref, postBenchHref, clipBenchHref, clipDeckHref, clipEd import { readTrailerBeats } from "@/lib/report/trailerBeats.mjs"; import { montageClipsOf, momentKeysOf, readRulingsState } from "@/lib/report/montageRulings.mjs"; import FetchUnfetchedButton from "../FetchUnfetchedButton"; +import PlayLink from "../PlayLink"; import TightWindowsPanel from "./TightWindowsPanel"; import { clipRecord, storedUrlOf } from "@/lib/clips/stored"; import { Fragment } from "react"; @@ -205,6 +206,7 @@ export default async function CutTab({ project, detail, search, tabHref }: Repor <span className="num micro ml-auto" data-post-seconds=""> {postItemSeconds(e).toFixed(1)}s{typeof e.hold === "number" ? " (hold)" : ""} </span> + <PlayLink project={project.id} clip={e.id} where="row" variant="icon" /> <Link href={postBenchHref(project.id, e.id)} className="ink-link text-[11px]" data-post-bench-link={e.id}> bench </Link> @@ -232,6 +234,7 @@ export default async function CutTab({ project, detail, search, tabHref }: Repor {e.heading ?? e.title ?? e.label ?? ""} </span> {e.seconds != null && <span className="num micro ml-auto">{e.seconds}s</span>} + <PlayLink project={project.id} clip={e.id} where="row" variant="icon" className={e.seconds != null ? "" : "ml-auto"} /> <div className="basis-full"> <RowNotes id={e.id} project={project.id} /> </div> @@ -308,6 +311,7 @@ export default async function CutTab({ project, detail, search, tabHref }: Repor </Pill> )} <span className="ml-auto flex items-center gap-2"> + <PlayLink project={project.id} clip={e.id} where="row" variant="icon" /> {mixHref(e) ? ( <Link href={mixHref(e)!} @@ -404,7 +408,7 @@ export default async function CutTab({ project, detail, search, tabHref }: Repor </div> )} {/* The whole cut played in the browser in its final look, no render (the Play view). */} - {clips.length > 0 && ( + {entries.length > 0 && ( <Link href={playHref(project.id)} data-play-cut-link="" className={buttonVariants({ size: "lg" })} title="play the whole cut here, chrome and all, without rendering it; notes at the playhead"> Play the cut </Link> @@ -460,10 +464,13 @@ export default async function CutTab({ project, detail, search, tabHref }: Repor .sort((a: { draft?: boolean }, b: { draft?: boolean }) => Number(!!b.draft) - Number(!!a.draft)) .slice(0, 6) .map((t: { id: string; label: string; draft?: boolean }) => ( - <Link key={t.id} href={takeWalkHref(project.id, t.id)} data-walk-take={t.id} className="ink-link" title={t.label}> - {t.id} - {t.draft ? " (draft)" : ""} - </Link> + <span key={t.id} className="inline-flex items-center"> + <Link href={takeWalkHref(project.id, t.id)} data-walk-take={t.id} className="ink-link" title={t.label}> + {t.id} + {t.draft ? " (draft)" : ""} + </Link> + <PlayLink project={project.id} take={t.id} where="walk-chip" variant="icon" /> + </span> ))} </span> )} diff --git a/umtool/components/queue/RenderRecord.tsx b/umtool/components/queue/RenderRecord.tsx @@ -1,4 +1,6 @@ import Link from "next/link"; +import CopyButton from "@/components/CopyButton"; +import PlayLink from "@/components/projects/PlayLink"; import { badgeVariants, type BadgeVariants } from "@/components/ui/badge"; import { takeRenderLogHref, takesHref } from "@/lib/hrefs"; import type { RenderView } from "@/lib/queue/view"; @@ -34,6 +36,8 @@ export default function RenderRecord({ compact?: boolean; }) { const live = rec.state === "running" || rec.state === "waiting"; + // The output file as a local path (never an /api/ URL shown as where a file is). + const mp4Path = rec.mp4 ? (rec.mp4.startsWith("/") ? rec.mp4 : rec.projectDir ? `${rec.projectDir}/takes/${rec.take}/${rec.mp4}` : `takes/${rec.take}/${rec.mp4}`) : null; const bad = rec.state === "failed" || rec.state === "cancelled"; return ( <div @@ -52,6 +56,7 @@ export default function RenderRecord({ </Link> )} <span className="font-mono">{rec.take}</span> + {showProject && project && <PlayLink project={project} take={rec.take} where="jobs" variant="icon" />} {rec.label && !compact && <span className="text-text-2">{rec.label}</span>} {live && ( <span className="text-text-2" data-render-stage=""> @@ -70,6 +75,12 @@ export default function RenderRecord({ log </a> </div> + {rec.state === "done" && mp4Path && ( + <p className="m-0 flex flex-wrap items-center gap-1.5 font-mono text-[11px] text-text-2" data-render-mp4={mp4Path}> + {mp4Path} + <CopyButton text={mp4Path} label="copy path" /> + </p> + )} {rec.error && ( <p className="m-0 font-mono text-[11px] text-reject-text" data-render-error=""> {rec.error} diff --git a/umtool/components/shell/AppRail.tsx b/umtool/components/shell/AppRail.tsx @@ -8,6 +8,7 @@ import CreateMenu from "./CreateMenu"; import JumpButton from "./JumpButton"; import PhoneDock from "./PhoneDock"; import RunningList from "./RunningList"; +import RecentCuts from "./RecentCuts"; import ThemeControl from "./ThemeControl"; import { Mark, Wordmark } from "./Wordmark"; @@ -53,6 +54,8 @@ export default async function AppRail({ active }: { active: string }) { <p className="px-5 text-[12px] text-muted-2">Nothing pinned</p> </section> + <RecentCuts /> + <RunningList initial={initialRunning()} /> <div data-rail-section="theme" className="px-4 pb-4 pt-3"> diff --git a/umtool/components/shell/RecentCuts.tsx b/umtool/components/shell/RecentCuts.tsx @@ -0,0 +1,71 @@ +"use client"; + +import { useEffect, useState } from "react"; +import PlayLink from "@/components/projects/PlayLink"; +import Link from "next/link"; +import { projectHref } from "@/lib/hrefs"; + +// --------------------------------------------------------------------------- +// THE RAIL'S RECENT CUTS (lane/ui-simplify, 5 Nov): the last report videos this +// viewer opened, each with ▶ Play (the newest take) -- so Play is one click from +// any page. A per-viewer convenience, so localStorage (wrapped: a private +// window or blocked storage just shows nothing); <RememberCut> on a project's +// page and on Play writes it. +// --------------------------------------------------------------------------- + +const KEY = "umtool.recentCuts"; +const MAX = 4; +type Recent = { project: string; title: string }; + +function read(): Recent[] { + try { + const v = JSON.parse(window.localStorage.getItem(KEY) ?? "[]"); + return Array.isArray(v) ? v.filter((x) => x && typeof x.project === "string").slice(0, MAX) : []; + } catch { + return []; + } +} + +/** Remember a report video as just opened (no UI). */ +export function RememberCut({ project, title }: { project: string; title: string }) { + useEffect(() => { + try { + const next = [{ project, title }, ...read().filter((r) => r.project !== project)].slice(0, MAX); + window.localStorage.setItem(KEY, JSON.stringify(next)); + window.dispatchEvent(new Event("umtool:recent-cuts")); + } catch { + // storage refused: nothing to remember + } + }, [project, title]); + return null; +} + +export default function RecentCuts() { + const [list, setList] = useState<Recent[]>([]); + useEffect(() => { + const on = () => setList(read()); + on(); + window.addEventListener("umtool:recent-cuts", on); + window.addEventListener("storage", on); + return () => { + window.removeEventListener("umtool:recent-cuts", on); + window.removeEventListener("storage", on); + }; + }, []); + if (!list.length) return null; + return ( + <section data-rail-section="recent-cuts" aria-label="Recent cuts"> + <h2 className="micro px-5 pb-1.5 pt-4">Recent cuts</h2> + <ul className="m-0 list-none space-y-0.5 px-4 p-0"> + {list.map((r) => ( + <li key={r.project} data-recent-cut={r.project} className="flex items-center gap-1 px-1 text-[12px]"> + <Link href={projectHref(r.project)} prefetch={false} className="min-w-0 flex-1 truncate text-text-2 no-underline hover:text-text" title={r.project}> + {r.title} + </Link> + <PlayLink project={r.project} where="rail" variant="icon" /> + </li> + ))} + </ul> + </section> + ); +} diff --git a/umtool/lib/queue/view.ts b/umtool/lib/queue/view.ts @@ -42,6 +42,8 @@ export type RenderView = { error: string | null; tail: string[]; mp4: string | null; + /** The project's directory (the jobs' pointer, or the take's reader): the mp4's absolute path is projectDir/takes/<take>/<mp4>. */ + projectDir?: string | null; seconds: number | null; pid: number; gone?: boolean; @@ -81,5 +83,6 @@ export async function rendersView(): Promise<RenderView[]> { /** One take's render record, resolved, or null. */ export async function takeRender(projectDir: string, take: string): Promise<RenderView | null> { - return (await readRenderRecord(path.join(/* turbopackIgnore: true */ projectDir, "takes", take))) as RenderView | null; + const rec = (await readRenderRecord(path.join(/* turbopackIgnore: true */ projectDir, "takes", take))) as RenderView | null; + return rec ? { ...rec, projectDir } : null; }