Archilyzer · Source

archilyzer

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

commit 7ca6b7d2c3919efbfb00a6040c12c3b68d3c3dfa
parent cd97fdb16e501bfd8862c3addc15b21b633660f3
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Tue, 10 Nov 2026 15:55:32 -0500

umtool: a version on screen never leaves its mode, and nothing reachable from it writes the draft -- the workspace is keyed on the address's mode and take, so a soft navigation (Versions ▾ → Review, a pill, Done from a version) is a fresh one; one read-only flag (workspace/readOnly.ts: the rule, a context, the refusal's words) derived once and handed down: the timeline writes (move, Undo, Redo), E, the undo and move keys, the inspector's panels, the review pass's marks, Look and Render all refuse or step aside while it is set; e2e by clicking, both ways -- L7b review item 1 (blocker)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Diffstat:
Mumtool/components/projects/workspace/ReviewPass.tsx | 11++++++++---
Mumtool/components/projects/workspace/Workspace.tsx | 30++++++++++++++++++++++++------
Mumtool/components/projects/workspace/WorkspaceInspector.tsx | 34+++++++++++++++++++++++++++++++++-
Mumtool/components/projects/workspace/WorkspacePage.tsx | 3+++
Mumtool/components/projects/workspace/WorkspaceTop.tsx | 9++++++---
Aumtool/components/projects/workspace/readOnly.ts | 25+++++++++++++++++++++++++
Mumtool/e2e/review-pass.spec.ts | 39+++++++++++++++++++++++++++++++++++++++
7 files changed, 138 insertions(+), 13 deletions(-)

diff --git a/umtool/components/projects/workspace/ReviewPass.tsx b/umtool/components/projects/workspace/ReviewPass.tsx @@ -12,6 +12,7 @@ import { writeWalkVerdict } from "../bench/walkVerdict"; import { announceManifestChanged } from "../timelineApi"; import VersionVerdict from "../review/VersionVerdict"; import type { PlayEntry } from "../review/PlayCut"; +import { READ_ONLY_SAID } from "./readOnly"; // --------------------------------------------------------------------------- // THE REVIEW PASS (umtool redesign L7b; the workspace's `?mode=review`): the inspector hidden, the viewer playing @@ -32,7 +33,7 @@ export type Answer = { mark: "keep" | "fix"; note: string | null }; type Mark = { mark: "keep" | "fix"; note?: string; at: string }; /** The pass's state: the marks (review-pass.json), each block's answer, the progress, and the writers. */ -export function useReviewPass(project: string, entries: PlayEntry[], on: boolean) { +export function useReviewPass(project: string, entries: PlayEntry[], on: boolean, readOnly = false) { const [marks, setMarks] = useState<Record<string, Mark>>({}); const [loaded, setLoaded] = useState(false); // A clip's answer as just written, until the draft is read again (MANIFEST_CHANGED) and its verdict is in it. @@ -76,6 +77,8 @@ export function useReviewPass(project: string, entries: PlayEntry[], on: boolean /** One block answered: a clip through the walk's writer, anything else into review-pass.json. */ const answer = useCallback( async (e: PlayEntry, mark: "keep" | "fix", note: string | null): Promise<string | null> => { + // A version on screen (readOnly.ts): its marks would land on the draft's blocks. + if (readOnly) return READ_ONLY_SAID; if (e.type === "clip") { const w = await writeWalkVerdict(project, e.id, mark === "keep" ? { verdict: "confirmed" } : { verdict: "incorrect", correction: note ?? "" }); if (!w.ok) return w.stale ? "the draft changed since — try again" : w.error; @@ -93,7 +96,7 @@ export function useReviewPass(project: string, entries: PlayEntry[], on: boolean setMarks(j.doc?.marks ?? {}); return null; }, - [project], + [project, readOnly], ); return { marks, loaded, progress, answers, answer }; } @@ -174,6 +177,7 @@ export default function ReviewPass({ entry, atEnd, take, + readOnly, draft, onPrev, onNext, @@ -187,6 +191,8 @@ export default function ReviewPass({ atEnd: boolean; /** A version reviewed read-only, or null for the draft. */ take: { id: string; label: string } | null; + /** The workspace's read-only flag (readOnly.ts): Keep and Fix refuse. */ + readOnly: boolean; draft: { line: string; parent: string | null; edits: number | null } | null; onPrev: () => void; onNext: () => void; @@ -208,7 +214,6 @@ export default function ReviewPass({ setFixText(""); }, [id]); const answer = id ? (rv.answers.get(id) ?? null) : null; - const readOnly = !!take; const go = useCallback( async (mark: "keep" | "fix", note: string | null) => { diff --git a/umtool/components/projects/workspace/Workspace.tsx b/umtool/components/projects/workspace/Workspace.tsx @@ -4,7 +4,7 @@ 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 { clipBenchHref, isWorkspaceMode, playHref, postBenchHref, workspaceHref, type WorkspaceMode } from "@/lib/hrefs"; +import { clipBenchHref, isWorkspaceMode, openInDraftHref, playHref, postBenchHref, workspaceHref, type WorkspaceMode } from "@/lib/hrefs"; import { runningTime, startOf } from "@/lib/report/playCut.mjs"; import { PlayStage, usePlayCore } from "../review/playCore"; import type { PlayViewData } from "../review/PlayCut"; @@ -20,6 +20,7 @@ import GeneratedBanner from "@/components/notes/GeneratedBanner"; import PresentView, { type PresentPayload } from "../present/PresentView"; import ReviewPass, { useReviewPass } from "./ReviewPass"; import ReadinessBar, { type Readiness } from "./ReadinessBar"; +import { READ_ONLY_SAID, WorkspaceReadOnly, workspaceReadOnly } from "./readOnly"; // --------------------------------------------------------------------------- // THE WORKSPACE (umtool redesign L7a): a report video's ONE screen, at its own @@ -110,6 +111,10 @@ export default function Workspace({ // A saved version reviewed or presented (`?take=`): read-only, its own view; Edit is the draft's page. const take = view.take ? { id: view.take.id, label: view.take.label } : null; const takeId = take?.id ?? null; + // THE read-only flag (readOnly.ts): derived here once, handed down; every draft writer below refuses on it. + const readOnly = workspaceReadOnly(view); + const readOnlyRef = useRef(readOnly); + readOnlyRef.current = readOnly; const reloadSeq = useRef(0); const reloadView = useCallback(async () => { const mine = ++reloadSeq.current; @@ -194,6 +199,11 @@ export default function Workspace({ const [epoch, setEpoch] = useState(0); const write = useCallback( async (op: string, args: Record<string, unknown> = {}) => { + // A version on screen: the draft is not what is shown, so nothing writes it (a move, an Undo, a Redo). + if (readOnlyRef.current) { + setUndo((u) => ({ ...u, busy: false, said: READ_ONLY_SAID, error: true })); + return null; + } setUndo((u) => ({ ...u, busy: true, said: null, error: false })); const token = tl.current.token ?? (await loadTimeline()).token; let res = await timelineOp(project, token, op, args); @@ -256,12 +266,12 @@ export default function Workspace({ heading: e.type === "clip" ? (e.quote ?? e.heading ?? "") : (e.heading ?? ""), seconds: p ? Math.max(0, p.it.to - p.it.from) : 0, // A version's blocks are never moved (its timeline is not the draft's). - at: e.type === "intro" || takeId ? null : (at.get(e.id) ?? null), + at: e.type === "intro" || readOnly ? null : (at.get(e.id) ?? null), rejected: e.rejected?.label ?? null, missing: e.type === "clip" && !e.media, }; }); - }, [view.entries, itemOf, tlIds, takeId]); + }, [view.entries, itemOf, tlIds, readOnly]); const entryOf = core.entryOf; // ---- the selection (the inspector's block), kept in the URL (`?block=`) ---------------- @@ -308,7 +318,7 @@ export default function Workspace({ [blocks, selected, select], ); // ---- the review pass (L7b): the selection is the block under review; past the last, the verdict ------------ - const rv = useReviewPass(project, view.entries, mode === "review" && !takeId); + const rv = useReviewPass(project, view.entries, mode === "review" && !takeId, readOnly); const [atEnd, setAtEnd] = useState(false); const reviewReady = mode === "review" && (takeId ? true : rv.loaded); const reviewPlaced = useRef(false); @@ -419,6 +429,7 @@ export default function Workspace({ // ---- edit in place (E): the clip bench over the workspace, Back returns here ---------- const editHere = useCallback(() => { + if (readOnlyRef.current) return; const id = selected && selected !== ADD ? selected : (core.item?.id ?? null); const e = id ? entryOf.get(id) : null; if (!e) return; @@ -463,6 +474,8 @@ export default function Workspace({ ev.preventDefault(); return; } + // A version on screen: no key here writes (undo, redo, a move, E). + if (readOnlyRef.current && (mod || ev.altKey || k === "e" || k === "E")) return; if (mod && !ev.altKey && (k === "z" || k === "Z")) { if (ev.shiftKey) { if (undoRef.current.canRedo && !undoRef.current.busy) void doRedo(); @@ -539,8 +552,10 @@ export default function Workspace({ const item = core.item; return ( + <WorkspaceReadOnly.Provider value={readOnly}> <div data-workspace={project} + data-ws-read-only={readOnly ? "" : undefined} // The draft's token as this page last read it (a spec waits on it before pressing Undo after a save). data-ws-token={tlToken ?? ""} data-ws-selected={selected ?? ""} @@ -552,6 +567,7 @@ export default function Workspace({ mode={mode} onMode={setMode} version={take} + readOnly={readOnly} title={view.title} draftLine={view.draft?.line ?? "Draft"} draftParent={view.draft?.parent ?? null} @@ -643,7 +659,7 @@ export default function Workspace({ }} onMove={(id, at, to) => void move(id, at, to)} marks={mode === "review" ? rv.answers : null} - plus={mode !== "edit" || takeId ? null : ( + plus={mode !== "edit" || readOnly ? null : ( <button type="button" onClick={() => setSelected(selected === ADD ? null : ADD)} @@ -685,6 +701,7 @@ export default function Workspace({ entry={atEnd ? null : selEntry} atEnd={atEnd || !selEntry} take={take} + readOnly={readOnly} draft={view.draft ?? null} onPrev={() => reviewStep(-1)} onNext={() => reviewStep(1)} @@ -696,7 +713,7 @@ export default function Workspace({ {selected === ADD ? ( <AddPanels project={project} after={blocks.length ? blocks[blocks.length - 1].id : null} channels={postChannels} /> ) : ( - <WorkspaceInspector project={project} entry={selEntry} hasLedger={hasLedger} hasClips={!!firstClip} introWritten={introWritten} /> + <WorkspaceInspector project={project} entry={selEntry} hasLedger={hasLedger} hasClips={!!firstClip} introWritten={introWritten} readOnly={readOnly} openInDraft={take ? openInDraftHref(project, take.id) : null} /> )} </div> )} @@ -745,6 +762,7 @@ export default function Workspace({ </div> )} </div> + </WorkspaceReadOnly.Provider> ); } diff --git a/umtool/components/projects/workspace/WorkspaceInspector.tsx b/umtool/components/projects/workspace/WorkspaceInspector.tsx @@ -143,7 +143,39 @@ function PostInspector({ project, entry }: { project: string; entry: PlayEntry } ); } -export default function WorkspaceInspector({ project, entry, hasLedger, hasClips, introWritten }: { project: string; entry: PlayEntry | null; hasLedger: boolean; hasClips: boolean; introWritten: unknown }) { +export default function WorkspaceInspector({ + project, + entry, + hasLedger, + hasClips, + introWritten, + readOnly = false, + openInDraft = null, +}: { + project: string; + entry: PlayEntry | null; + hasLedger: boolean; + hasClips: boolean; + introWritten: unknown; + /** The workspace's read-only flag (readOnly.ts): a saved version on screen -- no panel that writes the draft. */ + readOnly?: boolean; + openInDraft?: string | null; +}) { + if (readOnly) { + return ( + <> + <Head kind={entry?.type ?? "Version"} id={entry?.id ?? null} /> + <p className="m-0 px-3 py-2 text-[12px] text-muted" data-ws-inspector-read-only=""> + A saved version is read-only: its panels would write the draft.{" "} + {openInDraft && ( + <Link href={openInDraft} prefetch={false} className="ink-link"> + Open in draft + </Link> + )} + </p> + </> + ); + } if (entry?.type === "clip") return <ClipInspector project={project} entry={entry} />; if (entry?.type === "post") return <PostInspector project={project} entry={entry} />; if (entry?.type === "teaser") { diff --git a/umtool/components/projects/workspace/WorkspacePage.tsx b/umtool/components/projects/workspace/WorkspacePage.tsx @@ -44,7 +44,10 @@ export default async function WorkspacePage({ project, search }: { project: Proj <CutApp project={project.id} home={workspaceHref(project.id)} kind="workspace" playTop={null}> <RememberCut project={project.id} title={(view as PlayViewData).title || project.name || project.id} /> <NotesProvider target={{ project: project.id }}> + {/* Keyed on the address's mode and take: a navigation that changes either (Versions ▾ → Review, a pill, "Done — + back to Edit" from a version) is a fresh workspace, so its mode and the cut it shows never part (L7b). */} <Workspace + key={`${mode}:${take ?? ""}`} view={view as PlayViewData} initialBlock={search.block ?? null} initialAt={Number.isFinite(at) && at > 0 ? at : null} diff --git a/umtool/components/projects/workspace/WorkspaceTop.tsx b/umtool/components/projects/workspace/WorkspaceTop.tsx @@ -219,6 +219,7 @@ export default function WorkspaceTop({ mode = "edit", onMode, version = null, + readOnly = false, title, draftLine, draftParent, @@ -254,6 +255,8 @@ export default function WorkspaceTop({ onMode?: (m: "edit" | WorkspaceMode) => void; /** A saved version reviewed or presented read-only (`?take=`): nothing here writes the draft. */ version?: { id: string; label: string } | null; + /** The workspace's one read-only flag (readOnly.ts): nothing on the bar writes the draft. */ + readOnly?: boolean; }) { return ( <header data-app-header="workspace" data-ws-top="" className="flex flex-wrap items-center gap-x-2.5 gap-y-1 border-b border-seam bg-panel px-3 py-1.5"> @@ -308,11 +311,11 @@ export default function WorkspaceTop({ ); })} </nav> - {!version && <LookSwitch project={project} basic={basic} onChanged={onChanged} />} - {!version && <RenderMenu project={project} />} + {!readOnly && <LookSwitch project={project} basic={basic} onChanged={onChanged} />} + {!readOnly && <RenderMenu project={project} />} {shareClip && <CopyShareLine key={shareClip} project={project} clip={shareClip} testid="ws" />} <span className="ml-auto inline-flex items-center gap-1"> - {!version && ( + {!readOnly && ( <> <button type="button" className={btn("quiet")} disabled={undo.busy} onClick={onUndo} data-ws-undo="" title="take back the newest edit to the draft (⌘Z / Ctrl+Z; umtool timeline <p> undo)"> Undo diff --git a/umtool/components/projects/workspace/readOnly.ts b/umtool/components/projects/workspace/readOnly.ts @@ -0,0 +1,25 @@ +"use client"; + +import { createContext, useContext } from "react"; + +// --------------------------------------------------------------------------- +// THE WORKSPACE'S ONE READ-ONLY RULE (umtool redesign L7b): a saved version shown in the workspace (`?take=`, its +// review pass or present mode) is read-only -- nothing reachable from the screen writes the DRAFT while it shows +// another cut. Derived ONCE (Workspace.tsx: `workspaceReadOnly(view)`), then handed down: as a prop to the +// workspace's own parts, and through this context to anything mounted under it (the inspector's panels, the +// strip's menus). Every draft writer refuses while it is true: the timeline writes (move, undo, redo), E, the +// inspector, the review pass's marks. +// --------------------------------------------------------------------------- + +/** The rule: a version (a take) on screen is read-only. */ +export function workspaceReadOnly(view: { take?: unknown }): boolean { + return !!view.take; +} + +export const WorkspaceReadOnly = createContext(false); + +/** True while the workspace shows a saved version: a writer under it refuses. */ +export const useWorkspaceReadOnly = () => useContext(WorkspaceReadOnly); + +/** What a refused write says. */ +export const READ_ONLY_SAID = "a saved version is read-only: Open in draft to change it"; diff --git a/umtool/e2e/review-pass.spec.ts b/umtool/e2e/review-pass.spec.ts @@ -140,6 +140,45 @@ test("past the last block, the verdict: Like saves the draft as a version and wr await expect(page.locator("[data-ws-mode]")).toHaveAttribute("data-ws-mode", "review"); }); +test("by clicking, both ways: Versions ▾ → Review on v1 is v1's pass, where E, Ctrl+Z and k write nothing; Done is the draft in Edit, where k writes nothing", async ({ page }) => { + const disk = () => [ + readFileSync(path.join(DIR, "video.manifest.json"), "utf8"), + readFileSync(path.join(DIR, "takes", "v1", "take.json"), "utf8"), + existsSync(path.join(DIR, "review-pass.json")) ? readFileSync(path.join(DIR, "review-pass.json"), "utf8") : null, + ]; + await page.goto(urls.workspaceHref(P)); + await expect(page.locator("[data-ws-mode]")).toHaveAttribute("data-ws-mode", "edit"); + // A block selected in Edit first: the state a soft navigation must not carry over. + await page.locator('[data-ws-block="c02"]').click(); + await expect(page.locator("[data-ws-inspector]")).toHaveAttribute("data-ws-inspector", "clip"); + const before = disk(); + await page.locator("[data-ws-versions] > summary").click(); + await page.locator('[data-ws-version-review="v1"]').click(); + await expect(page).toHaveURL(new RegExp(`${urls.versionReviewHref(P, "v1").replace(/[?]/g, "\\?")}`)); + await expect(pass(page)).toHaveAttribute("data-review-pass", "v1", { timeout: 20_000 }); + await expect(page.locator("[data-ws-mode]")).toHaveAttribute("data-ws-mode", "review"); + await expect(page.locator("[data-workspace]")).toHaveAttribute("data-ws-read-only", ""); + await page.locator("body").press("e"); + await page.locator("body").press("Control+z"); + await page.locator("body").press("k"); + await page.waitForTimeout(600); + await expect(page.locator("[data-cut-app-bench]")).toHaveCount(0); + expect(disk()).toEqual(before); + + // "Done — back to Edit": the DRAFT, in Edit, writable again -- and k there is nothing. + await page.locator("[data-review-next]").click(); + for (let i = 0; i < 8 && !(await page.locator("[data-review-done]").isVisible()); i += 1) await page.locator("[data-review-next]").click(); + await page.locator("[data-review-done]").click(); + await expect(page).not.toHaveURL(/take=|mode=/); + await expect(page.locator("[data-ws-mode]")).toHaveAttribute("data-ws-mode", "edit", { timeout: 20_000 }); + await expect(page.locator("[data-ws-version-shown]")).toHaveCount(0); + await expect(page.locator("[data-workspace]")).not.toHaveAttribute("data-ws-read-only", ""); + await expect(page.locator("[data-ws-undo]")).toBeVisible(); + await page.locator("body").press("k"); + await page.waitForTimeout(600); + expect(disk()).toEqual(before); +}); + test("a version's review pass is read-only: watched and noted, never marked -- Open in draft to change it; its verdict at the end", async ({ page }) => { await page.goto(urls.versionReviewHref(P, "v1")); await expect(pass(page)).toHaveAttribute("data-review-pass", "v1", { timeout: 20_000 });