Archilyzer · Source

archilyzer

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

commit dfbe6a93b3fcf6353ae588a2f0ff88d7dc831345
parent e92d317b15e758240fe76b24185ee6f5eada4338
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Tue, 10 Nov 2026 15:13:26 -0500

umtool: a block moves and is removed by its OWN timeline index -- the play view says each entry's place in the manifest (`timelineAt`), so a variant twin is never taken for the one on screen; a twin it cannot place is not moved or removed from the menu (L8b review 1)

Remove used the FIRST entry with the block's id and `{at}` the LAST, while the view shows the default variant's.
playView now carries `timelineAt` (by identity, through the variant selection; a turned or prepended entry has
none). A block's `at` is that, checked against the timeline, else the only entry with its id; an id twice
with no place said leaves it with none, and Remove / Move left / Move right are disabled, "this entry has a
twin -- use the Cut tab". The menu addresses a block by its place in the strip (a duplicate shares its id), and
Alt+← → and drag move by the same index. e2e: c03's full-cut twin before it -- Remove takes the one on screen,
Undo restores; c04 turned by `variants` with a twin -- disabled, nothing written.

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

Diffstat:
Mumtool/components/projects/review/PlayCut.tsx | 2++
Mumtool/components/projects/workspace/BlockMenu.tsx | 40+++++++++++++++++++++++++++-------------
Mumtool/components/projects/workspace/BlockStrip.tsx | 42+++++++++++++++++++++++-------------------
Mumtool/components/projects/workspace/Workspace.tsx | 61+++++++++++++++++++++++++++++++++----------------------------
Mumtool/e2e/block-menus.spec.ts | 45++++++++++++++++++++++++++++++++++++++++++++-
Mumtool/lib/report/playView.mjs | 6++++++
6 files changed, 135 insertions(+), 61 deletions(-)

diff --git a/umtool/components/projects/review/PlayCut.tsx b/umtool/components/projects/review/PlayCut.tsx @@ -137,6 +137,8 @@ export type PlayEntry = { postScene?: { key: string; n: number; of: number; ids: string[]; anchor: string }; /** A VIDEO entry (video-entry.mjs, lib/report/playView.mjs videoPlayEntry): a file of the project, full frame. */ videoEntry?: VideoEntryPlay; + /** Its index in the played manifest's own timeline (null: not one of its entries as written -- the intro, a turned variant). */ + timelineAt?: number | null; }; export type PlayViewData = { diff --git a/umtool/components/projects/workspace/BlockMenu.tsx b/umtool/components/projects/workspace/BlockMenu.tsx @@ -29,7 +29,10 @@ export type BlockInfo = { project: string; id: string; type: string; + /** Its own index in the timeline (null: the intro, or a twin the view did not place). */ at: number | null; + /** Its id is in the timeline more than once and the view did not say which it is. */ + twin?: boolean; start?: number | null; end?: number | null; cutStart?: number | null; @@ -41,21 +44,23 @@ export type BlockInfo = { /** The strip's own writers, as the workspace does them. */ export type BlockActions = { - info: (id: string) => BlockInfo | null; + /** The block at this place in the strip (two blocks may share an id). */ + info: (place: number) => BlockInfo | null; /** The timeline's length (Move right stops at its end). */ entries: number; busy: boolean; - edit: (id: string) => void; - play: (id: string) => void; - move: (id: string, d: 1 | -1) => void; - remove: (id: string) => void; + edit: (b: BlockInfo) => void; + play: (b: BlockInfo) => void; + /** By the block's own index (`at`), never by its id. */ + move: (b: BlockInfo, d: 1 | -1) => void; + remove: (b: BlockInfo) => void; }; /** Where it opens: at the pointer, or over the block (the keyboard, the ⋯). */ export type MenuAnchor = { x: number; y: number } | { rect: { left: number; top: number; bottom: number } }; type Item = - | { key: string; label: string; hint?: string; kind: "action"; disabled?: boolean; run: () => void } + | { key: string; label: string; hint?: string; kind: "action"; disabled?: boolean; why?: string; run: () => void } | { key: string; label: string; hint?: string; kind: "link"; href: string } | { key: string; label: string; hint?: string; kind: "verb"; row: CliVerb }; @@ -73,15 +78,21 @@ function navHref(row: CliVerb, values: Record<string, string | boolean>): string return null; } +/** Why a timeline entry with no index of its own is not moved or removed here. */ +export const TWIN_WHY = "this entry has a twin — use the Cut tab"; + function groupsOf(info: BlockInfo, actions: BlockActions): Group[] { - const entry = info.at !== null; + const entry = info.type !== "intro"; + const placed = info.at !== null; + const why = placed ? undefined : TWIN_WHY; const direct: Item[] = []; - if (info.type === "clip" || info.type === "post") direct.push({ key: "edit", label: "Edit in place", hint: "E", kind: "action", run: () => actions.edit(info.id) }); - direct.push({ key: "play", label: "Play from here", kind: "action", run: () => actions.play(info.id) }); + if (info.type === "clip" || info.type === "post") direct.push({ key: "edit", label: "Edit in place", hint: "E", kind: "action", run: () => actions.edit(info) }); + direct.push({ key: "play", label: "Play from here", kind: "action", run: () => actions.play(info) }); if (entry) { - direct.push({ key: "move-left", label: "Move left", hint: "Alt+←", kind: "action", disabled: actions.busy || info.at === 0, run: () => actions.move(info.id, -1) }); - direct.push({ key: "move-right", label: "Move right", hint: "Alt+→", kind: "action", disabled: actions.busy || (info.at ?? 0) >= actions.entries - 1, run: () => actions.move(info.id, 1) }); - direct.push({ key: "remove", label: "Remove", hint: "Undo takes it back", kind: "action", disabled: actions.busy, run: () => actions.remove(info.id) }); + // Each by the block's OWN index: a twin the view did not place is never guessed at. + direct.push({ key: "move-left", label: "Move left", hint: "Alt+←", kind: "action", disabled: actions.busy || !placed || info.at === 0, why, run: () => actions.move(info, -1) }); + direct.push({ key: "move-right", label: "Move right", hint: "Alt+→", kind: "action", disabled: actions.busy || !placed || (info.at ?? 0) >= actions.entries - 1, why, run: () => actions.move(info, 1) }); + direct.push({ key: "remove", label: "Remove", hint: placed ? "Undo takes it back" : "a twin", kind: "action", disabled: actions.busy || !placed, why, run: () => actions.remove(info) }); } if (info.type === "clip") direct.push({ key: "bench", label: "Full bench", kind: "link", href: clipBenchHref(info.project, info.id) }); if (info.type === "post") direct.push({ key: "bench", label: "Full bench", kind: "link", href: postBenchHref(info.project, info.id) }); @@ -117,11 +128,14 @@ function groupsOf(info: BlockInfo, actions: BlockActions): Group[] { } export default function BlockMenu({ + place, info, actions, anchor, onClose, }: { + /** The block's place in the strip (its ⋯ toggles the menu: a press on it is not "outside"). */ + place: number; info: BlockInfo; actions: BlockActions; anchor: MenuAnchor; @@ -286,7 +300,7 @@ export default function BlockMenu({ aria-disabled={it.kind === "action" && it.disabled ? true : undefined} data-ws-menu-action={it.kind === "action" ? it.key : undefined} data-ws-menu-verb={it.kind === "verb" ? it.row.verb : undefined} - title={it.kind === "verb" ? `umtool ${it.row.verb}: ${it.row.summary} -- its form, filled in from ${info.id}` : undefined} + title={it.kind === "verb" ? `umtool ${it.row.verb}: ${it.row.summary} -- its form, filled in from ${info.id}` : it.kind === "action" ? it.why : undefined} onClick={() => choose(it)} > {body} diff --git a/umtool/components/projects/workspace/BlockStrip.tsx b/umtool/components/projects/workspace/BlockStrip.tsx @@ -34,6 +34,8 @@ export type Block = { at: number | null; rejected?: string | null; missing?: boolean; + /** Its id is in the timeline more than once and the view did not say which it is: no index, nothing moves it. */ + twin?: boolean; }; const TYPE_WORD: Record<string, string> = { clip: "clip", post: "post", teaser: "card", card: "card", intro: "intro", video: "video" }; @@ -77,26 +79,27 @@ export default function BlockStrip({ const ref = useRef<HTMLDivElement | null>(null); const [drag, setDrag] = useState<string | null>(null); const [over, setOver] = useState<string | null>(null); - // The open menu: its block and where it opens. A ref too, so the key's menu and the contextmenu event the - // browser may send after it open one menu. - const [open, setOpen] = useState<{ id: string; anchor: MenuAnchor } | null>(null); - const openRef = useRef<string | null>(null); - const blockEl = (id: string) => ref.current?.querySelector(`[data-ws-block="${CSS.escape(id)}"]`) as HTMLElement | null; - const showMenu = (id: string, anchor: MenuAnchor | null) => { - if (!menu || openRef.current === id) return; - const r = blockEl(id)?.getBoundingClientRect(); + // The open menu: its block -- by its place in the strip, two blocks may share an id -- and where it opens. A ref + // too, so the key's menu and the contextmenu event the browser may send after it open one menu. + const [open, setOpen] = useState<{ id: string; i: number; anchor: MenuAnchor } | null>(null); + const openRef = useRef<{ id: string; i: number } | null>(null); + const blockEl = (i: number) => ref.current?.querySelector(`[data-ws-block-i="${i}"]`) as HTMLElement | null; + const showMenu = (id: string, i: number, anchor: MenuAnchor | null) => { + if (!menu || openRef.current?.i === i) return; + const r = blockEl(i)?.getBoundingClientRect(); const at: MenuAnchor = anchor ?? { rect: { left: r?.left ?? 8, top: r?.top ?? 8, bottom: r?.bottom ?? 8 } }; - openRef.current = id; - setOpen({ id, anchor: at }); + openRef.current = { id, i }; + setOpen({ id, i, anchor: at }); }; const closeMenu = useCallback((refocus: boolean) => { - const id = openRef.current; + const o = openRef.current; openRef.current = null; setOpen(null); - if (refocus && id) (ref.current?.querySelector(`[data-ws-block="${CSS.escape(id)}"]`) as HTMLElement | null)?.focus(); + if (refocus && o) (ref.current?.querySelector(`[data-ws-block-i="${o.i}"]`) as HTMLElement | null)?.focus(); }, []); - const openInfo = open && menu ? menu.info(open.id) : null; - // Its block left the cut (an undo, another writer): the menu goes with it. + const found = open && menu ? menu.info(open.i) : null; + const openInfo = found && found.id === open?.id ? found : null; + // Its block left the cut, or moved from under it (an undo, another writer): the menu goes with it. useEffect(() => { if (open && !openInfo) closeMenu(false); }, [open, openInfo, closeMenu]); @@ -121,7 +124,7 @@ export default function BlockStrip({ const w = Math.round(Math.min(MAX_W, Math.max(MIN_W, b.seconds * PX_PER_S))); const on = b.id === selected; const movable = b.at !== null && !busy; - const menuOn = open?.id === b.id; + const menuOn = open?.i === i; return ( <div key={`${b.id}@${i}`} className="group relative flex shrink-0"> <button @@ -129,6 +132,7 @@ export default function BlockStrip({ role="option" aria-selected={on} data-ws-block={b.id} + data-ws-block-i={i} data-ws-block-type={b.type} data-ws-block-at={b.at ?? ""} data-ws-block-now={b.id === playing ? "" : undefined} @@ -164,14 +168,14 @@ export default function BlockStrip({ e.preventDefault(); // From the keyboard (Shift+F10, the context-menu key) the browser's event has no pointer: over the block. const keyed = (e.nativeEvent as PointerEvent).pointerType === "" || (e.clientX === 0 && e.clientY === 0); - showMenu(b.id, keyed ? null : { x: e.clientX, y: e.clientY }); + showMenu(b.id, i, keyed ? null : { x: e.clientX, y: e.clientY }); }} onKeyDown={(e) => { if (!menu) return; if ((e.shiftKey && e.key === "F10") || e.key === "ContextMenu") { e.preventDefault(); e.stopPropagation(); - showMenu(b.id, null); + showMenu(b.id, i, null); } }} aria-haspopup={menu ? "menu" : undefined} @@ -211,7 +215,7 @@ export default function BlockStrip({ onClick={(e) => { e.stopPropagation(); if (menuOn) closeMenu(true); - else showMenu(b.id, null); + else showMenu(b.id, i, null); }} className={cn( "absolute bottom-0.5 right-0.5 flex h-[18px] w-[22px] items-center justify-center rounded-[2px] font-mono text-[12px] leading-none text-muted hover:bg-panel-2 hover:text-text", @@ -227,7 +231,7 @@ export default function BlockStrip({ <div className="flex shrink-0 items-stretch" data-ws-plus-slot=""> {plus} </div> - {open && openInfo && menu && <BlockMenu key={open.id} info={openInfo} actions={menu} anchor={open.anchor} onClose={closeMenu} />} + {open && openInfo && menu && <BlockMenu key={`${open.id}@${open.i}`} place={open.i} info={openInfo} actions={menu} anchor={open.anchor} onClose={closeMenu} />} </div> ); } diff --git a/umtool/components/projects/workspace/Workspace.tsx b/umtool/components/projects/workspace/Workspace.tsx @@ -193,15 +193,22 @@ export default function Workspace({ // ---- the blocks ------------------------------------------------------------------ const itemOf = useMemo(() => new Map(plan.items.map((it, i) => [it.id, { it, i }])), [plan.items]); const blocks = useMemo<Block[]>(() => { - const at = new Map(tlIds.map((id, i) => [id, i])); + const count = new Map<string, number>(); + for (const id of tlIds) count.set(id, (count.get(id) ?? 0) + 1); return view.entries.map((e) => { const p = itemOf.get(e.id); + // ITS OWN place in the timeline (lane L8b): the one the view says (playView `timelineAt`), else the only entry + // with its id. A twin the view does not place is never guessed at: no index, and nothing moves or removes it. + const own = typeof e.timelineAt === "number" && tlIds[e.timelineAt] === e.id ? e.timelineAt : null; + const n = count.get(e.id) ?? 0; + const at = e.type === "intro" ? null : (own ?? (n === 1 ? tlIds.indexOf(e.id) : null)); return { id: e.id, type: e.type, heading: e.type === "clip" ? (e.quote ?? e.heading ?? "") : (e.heading ?? ""), seconds: p ? Math.max(0, p.it.to - p.it.from) : 0, - at: e.type === "intro" ? null : (at.get(e.id) ?? null), + at, + twin: e.type !== "intro" && at === null && n > 1, rejected: e.rejected?.label ?? null, missing: e.type === "clip" && !e.media, }; @@ -259,19 +266,15 @@ export default function Workspace({ }, [write], ); + // A block moves by its own index (a twin with none does not move: the Cut tab names which). const moveBlock = useCallback( - async (id: string | null, d: 1 | -1) => { - const b = blocks.find((x) => x.id === id); - if (!b || b.type === "intro" || undo.busy) return; - // Its place in the manifest's timeline, read now if the strip has not had it yet. - const ids = tl.current.ids.length ? tl.current.ids : (await loadTimeline()).ids; - const at = ids.indexOf(b.id); - if (at < 0) return; - await move(b.id, at, at + d); + async (b: { id: string; at: number | null } | undefined, d: 1 | -1) => { + if (!b || b.at === null || undo.busy) return; + await move(b.id, b.at, b.at + d); }, - [blocks, move, undo.busy, loadTimeline], + [move, undo.busy], ); - const moveSelected = useCallback((d: 1 | -1) => moveBlock(selected, d), [moveBlock, selected]); + const moveSelected = useCallback((d: 1 | -1) => moveBlock(blocks.find((x) => x.id === selected), d), [moveBlock, blocks, selected]); // ---- edit in place (E): the clip bench over the workspace, Back returns here ---------- const editHere = useCallback((which?: string) => { @@ -387,10 +390,12 @@ export default function Workspace({ () => ({ entries: tlIds.length, busy: undo.busy, - info: (id: string): BlockInfo | null => { - const e = entryOf.get(id); - const b = blocks.find((x) => x.id === id); - if (!e || !b) return null; + // A block by its place in the strip (two blocks may share an id: a duplicate). + info: (i: number): BlockInfo | null => { + const e = view.entries[i]; + const b = blocks[i]; + if (!e || !b || b.id !== e.id) return null; + const id = e.id; const p = itemOf.get(id); const t = nowRef.current().t; const cutStart = typeof e.cutStart === "number" ? e.cutStart : (e.start ?? null); @@ -399,25 +404,25 @@ export default function Workspace({ const it = p?.it ?? null; const src = e.type === "clip" && it?.clip && t >= it.from && t < it.to ? sourceAt(it, t) : null; const second = e.type !== "clip" ? null : typeof src === "number" ? Math.round(src * 100) / 100 : cutStart; - return { project, id, type: e.type, at: b.at, start: e.start ?? null, end: e.end ?? null, cutStart, cutEnd, second, video: e.video ?? null, channel: e.sourceChannel ?? e.channel ?? null }; + return { project, id, type: e.type, at: b.at, twin: !!b.twin, start: e.start ?? null, end: e.end ?? null, cutStart, cutEnd, second, video: e.video ?? null, channel: e.sourceChannel ?? e.channel ?? null }; }, - edit: (id: string) => { - select(id); - editHere(id); + edit: (b: BlockInfo) => { + select(b.id); + editHere(b.id); }, - play: (id: string) => { - select(id); + play: (b: BlockInfo) => { + select(b.id); setPlaying(true); }, - move: (id: string, d: 1 | -1) => void moveBlock(id, d), - remove: (id: string) => { - const at = tl.current.ids.indexOf(id); - void write("remove", { id, ...(at >= 0 ? { at } : {}) }).then((j) => { - if (j) setUndo({ busy: false, said: `Removed ${id} — Undo puts it back`, error: false, canRedo: false }); + move: (b: BlockInfo, d: 1 | -1) => void moveBlock(b, d), + remove: (b: BlockInfo) => { + if (b.at === null) return; + void write("remove", { id: b.id, at: b.at }).then((j) => { + if (j) setUndo({ busy: false, said: `Removed ${b.id} — Undo puts it back`, error: false, canRedo: false }); }); }, }), - [tlIds.length, undo.busy, entryOf, blocks, itemOf, project, select, editHere, setPlaying, moveBlock, write], + [tlIds.length, undo.busy, view.entries, blocks, itemOf, project, select, editHere, setPlaying, moveBlock, write], ); const iconBtn = cn(buttonVariants({ variant: "outline", size: "sm" }), "min-w-9 font-mono"); diff --git a/umtool/e2e/block-menus.spec.ts b/umtool/e2e/block-menus.spec.ts @@ -1,5 +1,5 @@ import { test, expect, type Page } from "@playwright/test"; -import { readFileSync } from "node:fs"; +import { readFileSync, writeFileSync } from "node:fs"; import path from "node:path"; import { fileURLToPath } from "node:url"; import * as urls from "./urls"; @@ -219,3 +219,46 @@ test("keyboard only: Shift+F10 opens it, the arrows move, Enter chooses, Esc clo await expect(menu).toHaveCount(0); expect(manifestText()).toBe(original); }); + +test("a variant twin: Remove takes the entry on screen, never its twin; a twin the view cannot place is not moved or removed", async ({ page }) => { + const original = manifestText(); + type Entry = Record<string, unknown> & { id: string }; + const m = JSON.parse(original) as { timeline: Entry[] }; + // c03's full-cut twin BEFORE it: the first entry with the id is not the one the default cut plays. + const i3 = m.timeline.findIndex((e) => e.id === "c03"); + m.timeline.splice(i3, 0, { ...m.timeline[i3], variant: "full", quote: "the full cut's twin" }); + // c04 turned by `variants` (the view makes it anew: it says no place for it) with a full-cut twin of its own. + const i4 = m.timeline.findIndex((e) => e.id === "c04"); + const c04 = m.timeline[i4]; + m.timeline.splice(i4, 1, { ...c04, variant: "full", quote: "c04's full twin" }, { ...c04, variants: { sourced: { quote: "turned" } } }); + const written = JSON.stringify(m, null, 2) + "\n"; + writeFileSync(path.join(DIR, "video.manifest.json"), written); + try { + expect(order()).toBe("c01 c02 p-5 k01 c03 c03 c04 c04"); + await open(page); + + await block(page, "c03").click({ button: "right" }); + const menu = menuOf(page, "c03"); + await expect(menu.locator('[data-ws-menu-action="remove"]')).not.toHaveAttribute("aria-disabled", "true"); + await menu.locator('[data-ws-menu-action="remove"]').click(); + // The one on screen left; its twin (the full cut's) stays. + await expect.poll(() => manifest().timeline.filter((e) => e.id === "c03").map((e) => (e as { variant?: string }).variant ?? "").join(","), { timeout: 15_000 }).toBe("full"); + await expect(page.locator("[data-ws-undo-said]")).toContainText("Removed c03"); + await page.locator("[data-ws-undo]").click(); + await expect.poll(manifestText, { timeout: 15_000 }).toBe(written); + + // c04: no place of its own, its id twice -- never guessed at. + await block(page, "c04").click({ button: "right" }); + const twin = menuOf(page, "c04"); + for (const a of ["remove", "move-left", "move-right"]) { + await expect(twin.locator(`[data-ws-menu-action="${a}"]`)).toHaveAttribute("aria-disabled", "true"); + await expect(twin.locator(`[data-ws-menu-action="${a}"]`)).toHaveAttribute("title", "this entry has a twin — use the Cut tab"); + } + await twin.locator('[data-ws-menu-action="remove"]').click(); + await page.keyboard.press("Escape"); + await expect(twin).toHaveCount(0); + expect(manifestText()).toBe(written); + } finally { + writeFileSync(path.join(DIR, "video.manifest.json"), original); + } +}); diff --git a/umtool/lib/report/playView.mjs b/umtool/lib/report/playView.mjs @@ -175,6 +175,11 @@ export async function playViewWith(project, { take = null, bare = false, postFor return { error: e instanceof Error ? e.message : String(e) }; } } + // Each entry's place in the manifest's own timeline, by identity: the variant selection keeps an entry's object + // (one it turns -- `variants` -- and the intro it prepends are new, so they carry none). The workspace's writers + // name an entry by it, so a variant twin is never taken for the one on screen (lane block-menus L8b). + const sourceAt = new WeakMap(); + (manifest.timeline ?? []).forEach((e, i) => e && typeof e === "object" && sourceAt.set(e, i)); const selected = selectVariant(manifest, DEFAULT_VARIANT); const render = selected.render ?? {}; // THE BASIC OUTPUT MODE (render.mode, report-to-video basic.mjs): Play plays what the basic render cuts -- @@ -247,6 +252,7 @@ export async function playViewWith(project, { take = null, bare = false, postFor // The combo counter (post-combo.mjs): a post item that repeats an earlier one's attachment carries its badge // (`postCombo`: its count, which attachment, the knobs, whether it shows), counted over the cut played. for (const e of entries) if (e.type === "post" && combos[e.id]) Object.assign(e, { postCombo: combos[e.id] }); + entries.forEach((e, i) => Object.assign(e, { timelineAt: sourceAt.get(timeline[i]) ?? null })); // The counter (the deck's tally): each stamp's landing second and count on // the estimate's clock, and each verdict's word -- the reel strip's // staircase before (or without) the chrome's own schedule.