commit 9f9d80720c7a5e22c5b1fb9d2b493bbeb601df48
parent 1739921967e7d68558bf53f73687c7567b6bbc53
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Tue, 10 Nov 2026 13:42:26 -0500
umtool: a workspace block's menu -- right-click, its ⋯, Shift+F10 or the context-menu key: the strip's own writers, then the registry verbs for its kind, each the ⌘K form filled in from the block (redesign L8b)
BlockMenu (components/projects/workspace/BlockMenu.tsx): on top what needs no form -- Edit in place (E), Play
from here, Move left / right (the strip's move), Remove (the timeline's remove; the top bar's Undo takes it
back), Full bench, Life cycle (the `ingredient` row is navigation: a link). Under them every row whose `blocks`
names the block's kind, grouped by command (the kind's own verbs, The cut, Post item); choosing one opens the
palette's own form (JumpPalette `umtool:command` -> CommandForm `prefill`, verbs.mjs fromBlockValues), so Run
is POST /api/cli exactly as ⌘K's and Copy as CLI stays. A role=menu with roving focus: ↑ ↓ Home End and a
letter, Enter / Space, Esc / Tab, the focus back on the block; a press outside closes it.
CommandForm: a draft verb's run that ends done announces the write (MANIFEST_CHANGED), so the workspace under
the palette reads its draft again; opened with the palette in one go, the focus lands on the first arg still
to give. Workspace: the menu's actions (one prop on BlockStrip); editHere and the move take a block id, and E's
bench opens at the playhead only when it is in the clip. knobs.md: the workspace's "a block's menu" row and
paragraph, ⌘K's "From a block".
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
6 files changed, 525 insertions(+), 19 deletions(-)
diff --git a/umtool/components/projects/workspace/BlockMenu.tsx b/umtool/components/projects/workspace/BlockMenu.tsx
@@ -0,0 +1,301 @@
+"use client";
+
+import Link from "next/link";
+import { useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
+import { createPortal } from "react-dom";
+import { blockVerbs, commandOf, fromBlockValues } from "@/lib/cli/verbs.mjs";
+import { clipBenchHref, ingredientHref, postBenchHref } from "@/lib/hrefs";
+import { openCommand } from "@/components/shell/JumpPalette";
+import type { CliVerb } from "@/components/shell/CommandForm";
+import { cn } from "@/lib/utils";
+
+// ---------------------------------------------------------------------------
+// A BLOCK'S MENU (umtool redesign L8b): right-click a block of the workspace's
+// strip, or its ⋯, or Shift+F10 / the context-menu key on it. On top, what needs
+// no form -- Edit in place (E), Play from here, Move left / right (Alt+← →),
+// Remove (the top bar's Undo takes it back), the full bench, the recording's
+// life cycle -- the strip's own writers. Under them, every verb of the registry
+// whose row names this block's kind (lib/cli/verbs.mjs `blocks`), grouped by its
+// command; choosing one opens THE form ⌘K opens (shell/CommandForm, in the
+// palette), filled in from the block by the row's own `fromBlock` rules. A row
+// with `nav` is a page, not a run: it is a link here.
+//
+// Keys: ↑ ↓ (Home, End, a letter) move, Enter or Space chooses, Esc or Tab
+// closes; the focus goes back to the block.
+// ---------------------------------------------------------------------------
+
+/** What a block tells its menu: verbs.mjs BLOCK_FIELDS (the fromBlock templates read these). */
+export type BlockInfo = {
+ project: string;
+ id: string;
+ type: string;
+ at: number | null;
+ start?: number | null;
+ end?: number | null;
+ cutStart?: number | null;
+ cutEnd?: number | null;
+ second?: number | null;
+ video?: string | null;
+ channel?: string | null;
+};
+
+/** The strip's own writers, as the workspace does them. */
+export type BlockActions = {
+ info: (id: string) => 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;
+};
+
+/** 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: "link"; href: string }
+ | { key: string; label: string; hint?: string; kind: "verb"; row: CliVerb };
+
+type Group = { key: string; label: string; items: Item[] };
+
+const KIND_WORD: Record<string, string> = { clip: "Clip", post: "Post item", teaser: "Card", card: "Chapter card", intro: "Intro", video: "Video" };
+const COMMAND_WORD: Record<string, string> = { timeline: "The cut", posts: "Post item", "trailer-beats": "Trailer" };
+
+/** A nav row's page, from what the block filled in. */
+function navHref(row: CliVerb, values: Record<string, string | boolean>): string | null {
+ if (row.nav === "ingredient") {
+ const [ch, id] = String(values.recording ?? "").split("/");
+ return ch && id ? ingredientHref(ch, id) : null;
+ }
+ return null;
+}
+
+function groupsOf(info: BlockInfo, actions: BlockActions): Group[] {
+ const entry = info.at !== null;
+ 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 (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) });
+ }
+ 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) });
+
+ const rows = blockVerbs(info.type) as CliVerb[];
+ for (const row of rows) {
+ if (!row.nav) continue;
+ const href = navHref(row, fromBlockValues(row, info));
+ if (href) direct.push({ key: `nav:${row.verb}`, label: row.nav === "ingredient" ? "Life cycle" : row.verb, hint: `umtool ${row.verb}`, kind: "link", href });
+ }
+
+ // The verbs, by command: the kind's own verbs (one each) first, then each command's sub-verbs.
+ const byCmd = new Map<string, CliVerb[]>();
+ for (const row of rows) {
+ if (row.nav) continue;
+ const c = commandOf(row.verb);
+ byCmd.set(c, [...(byCmd.get(c) ?? []), row]);
+ }
+ const own: CliVerb[] = [];
+ const multi: Group[] = [];
+ for (const [c, list] of byCmd) {
+ if (list.length === 1 && list[0].verb === c) own.push(list[0]);
+ else multi.push({ key: `cmd:${c}`, label: COMMAND_WORD[c] ?? c, items: list.map((row) => ({ key: `verb:${row.verb}`, label: row.verb, hint: row.summary, kind: "verb", row })) });
+ }
+ const verbGroups: Group[] = [];
+ if (own.length) verbGroups.push({ key: "own", label: KIND_WORD[info.type] ?? info.type, items: own.map((row) => ({ key: `verb:${row.verb}`, label: row.verb, hint: row.summary, kind: "verb", row })) });
+ // A group of one sub-verb (trailer-beats add) joins the kind's own.
+ for (const g of multi) {
+ if (g.items.length === 1 && verbGroups[0]?.key === "own") verbGroups[0].items.push(g.items[0]);
+ else verbGroups.push(g);
+ }
+ return [{ key: "direct", label: `${KIND_WORD[info.type] ?? info.type} ${info.id}`, items: direct }, ...verbGroups];
+}
+
+export default function BlockMenu({
+ info,
+ actions,
+ anchor,
+ onClose,
+}: {
+ info: BlockInfo;
+ actions: BlockActions;
+ anchor: MenuAnchor;
+ /** Closed: `refocus` -- the focus goes back to the block (Esc, Tab, a choice). */
+ onClose: (refocus: boolean) => void;
+}) {
+ const groups = useMemo(() => groupsOf(info, actions), [info, actions]);
+ const flat = useMemo(() => groups.flatMap((g) => g.items), [groups]);
+ const usable = (i: number) => !(flat[i]?.kind === "action" && flat[i].disabled);
+ const [at, setAt] = useState(() => Math.max(0, flat.findIndex((_, i) => usable(i))));
+ const box = useRef<HTMLDivElement | null>(null);
+ const els = useRef<Array<HTMLElement | null>>([]);
+ const [pos, setPos] = useState<{ left: number; top: number } | null>(null);
+
+ // Placed inside the window: at the pointer (flipped up when there is no room below), or above the block.
+ useLayoutEffect(() => {
+ const el = box.current;
+ if (!el) return;
+ const w = el.offsetWidth;
+ const h = el.offsetHeight;
+ const W = window.innerWidth;
+ const H = window.innerHeight;
+ let left: number;
+ let top: number;
+ if ("rect" in anchor) {
+ left = anchor.rect.left;
+ top = anchor.rect.top - h - 4 >= 8 ? anchor.rect.top - h - 4 : anchor.rect.bottom + 4 + h <= H - 8 ? anchor.rect.bottom + 4 : 8;
+ } else {
+ left = anchor.x;
+ top = anchor.y + h <= H - 8 ? anchor.y : Math.max(8, anchor.y - h);
+ }
+ setPos({ left: Math.max(8, Math.min(left, W - w - 8)), top: Math.max(8, top) });
+ }, [anchor]);
+
+ useEffect(() => {
+ if (pos) els.current[at]?.focus({ preventScroll: false });
+ }, [at, pos]);
+
+ // A press outside closes it (the focus stays where that press put it); so does the window moving under it.
+ useEffect(() => {
+ const down = (e: PointerEvent) => {
+ if (box.current && !box.current.contains(e.target as Node)) onClose(false);
+ };
+ const away = () => onClose(false);
+ document.addEventListener("pointerdown", down, true);
+ window.addEventListener("resize", away);
+ window.addEventListener("blur", away);
+ return () => {
+ document.removeEventListener("pointerdown", down, true);
+ window.removeEventListener("resize", away);
+ window.removeEventListener("blur", away);
+ };
+ }, [onClose]);
+
+ const choose = (it: Item) => {
+ if (it.kind === "action") {
+ if (it.disabled) return;
+ onClose(true);
+ it.run();
+ } else if (it.kind === "verb") {
+ onClose(true);
+ // The palette's dialog opens after the focus is back on the block, so closing it returns there.
+ const req = { row: it.row, values: fromBlockValues(it.row, info) };
+ setTimeout(() => openCommand(req), 0);
+ } else {
+ onClose(false);
+ }
+ };
+
+ const step = (d: 1 | -1, from = at) => {
+ for (let n = 1; n <= flat.length; n++) {
+ const i = (from + d * n + flat.length * 2) % flat.length;
+ if (usable(i)) return i;
+ }
+ return from;
+ };
+
+ const onKey = (e: React.KeyboardEvent) => {
+ const k = e.key;
+ // The menu's keys are its own: not the workspace's (data-ws-own-keys), not the page's.
+ e.stopPropagation();
+ if (k === "ArrowDown") setAt((i) => step(1, i));
+ else if (k === "ArrowUp") setAt((i) => step(-1, i));
+ else if (k === "Home") setAt(step(1, -1));
+ else if (k === "End") setAt(step(-1, flat.length));
+ else if (k === "Escape") onClose(true);
+ else if (k === "Tab") onClose(true);
+ else if (k === "Enter" || k === " ") {
+ const it = flat[at];
+ if (it?.kind === "link") {
+ els.current[at]?.click();
+ } else if (it) choose(it);
+ } else if (k.length === 1 && /\S/.test(k) && !e.ctrlKey && !e.metaKey && !e.altKey) {
+ // A letter: the next item whose label starts with it.
+ const c = k.toLowerCase();
+ for (let n = 1; n <= flat.length; n++) {
+ const i = (at + n) % flat.length;
+ if (usable(i) && flat[i].label.toLowerCase().startsWith(c)) {
+ setAt(i);
+ break;
+ }
+ }
+ } else return;
+ e.preventDefault();
+ };
+
+ let n = -1;
+ const menu = (
+ <div
+ ref={box}
+ role="menu"
+ aria-label={`${KIND_WORD[info.type] ?? info.type} ${info.id}`}
+ aria-orientation="vertical"
+ data-ws-menu={info.id}
+ data-ws-menu-type={info.type}
+ data-ws-own-keys=""
+ onKeyDown={onKey}
+ onContextMenu={(e) => e.preventDefault()}
+ style={pos ? { left: pos.left, top: pos.top } : { left: -9999, top: 0 }}
+ className="fixed z-50 max-h-[calc(100dvh-16px)] w-[min(380px,calc(100vw-16px))] overflow-y-auto rounded-[3px] border border-seam-2 bg-panel py-1 text-[12.5px] text-text shadow-2xl"
+ >
+ {groups.map((g, gi) => (
+ <div key={g.key} role="group" aria-labelledby={`ws-menu-${g.key}`} data-ws-menu-group={g.key}>
+ {gi > 0 && <div role="separator" className="my-1 border-t border-seam" />}
+ <div id={`ws-menu-${g.key}`} className={cn("micro px-3 pb-0.5 pt-1", gi === 0 && "font-mono normal-case tracking-normal text-text-2")}>
+ {g.label}
+ </div>
+ {g.items.map((it) => {
+ n += 1;
+ const i = n;
+ const on = i === at;
+ const cls = cn(
+ "flex w-full min-w-0 items-baseline gap-3 px-3 py-[5px] text-left outline-none",
+ on && "bg-panel-2 text-text",
+ it.kind === "action" && it.disabled && "cursor-default opacity-40",
+ );
+ const body = (
+ <>
+ <span className={cn("shrink-0", it.kind === "verb" && "font-mono text-[12px]")}>{it.label}</span>
+ {it.hint && <span className={cn("ml-auto min-w-0 truncate text-[11px]", it.kind === "verb" ? "text-muted-2" : "font-mono text-muted")}>{it.hint}</span>}
+ </>
+ );
+ const common = {
+ ref: (el: HTMLElement | null) => void (els.current[i] = el),
+ role: "menuitem",
+ tabIndex: on ? 0 : -1,
+ onMouseMove: () => i !== at && usable(i) && setAt(i),
+ className: cls,
+ } as const;
+ if (it.kind === "link") {
+ return (
+ <Link key={it.key} {...common} href={it.href} prefetch={false} data-ws-menu-link={it.key} onClick={() => onClose(false)}>
+ {body}
+ </Link>
+ );
+ }
+ return (
+ <button
+ key={it.key}
+ type="button"
+ {...common}
+ 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}
+ onClick={() => choose(it)}
+ >
+ {body}
+ </button>
+ );
+ })}
+ </div>
+ ))}
+ </div>
+ );
+ return typeof document === "undefined" ? null : createPortal(menu, document.body);
+}
diff --git a/umtool/components/projects/workspace/BlockStrip.tsx b/umtool/components/projects/workspace/BlockStrip.tsx
@@ -1,7 +1,8 @@
"use client";
-import { useEffect, useRef, useState } from "react";
+import { useCallback, useEffect, useRef, useState } from "react";
import { cn } from "@/lib/utils";
+import BlockMenu, { type BlockActions, type MenuAnchor } from "./BlockMenu";
// ---------------------------------------------------------------------------
// THE STRIP (umtool redesign L7a): the cut as blocks, in the draft's order --
@@ -15,6 +16,9 @@ import { cn } from "@/lib/utils";
// the writer the Cut tab's TimelineList uses, one undo point
// drag a block onto another: it goes to that place (the same write)
// + Add a clip, Add posts, insert a card (the workspace's menu)
+// right-click, ⋯, Shift+F10 or the context-menu key
+// its menu (BlockMenu, lane L8b): the strip's own writers and
+// every registry verb for its kind, each the ⌘K form filled in
//
// The intro is not a timeline entry (render.intro: the build prepends it), so
// it is selected and played like any block but never moved.
@@ -55,6 +59,7 @@ export default function BlockStrip({
onSelect,
onMove,
plus,
+ menu,
}: {
blocks: Block[];
selected: string | null;
@@ -66,10 +71,35 @@ export default function BlockStrip({
onMove: (id: string, at: number, to: number) => void;
/** The + at the end: what it opens. */
plus: React.ReactNode;
+ /** What a block's menu does (none: no menus). */
+ menu?: BlockActions;
}) {
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();
+ const at: MenuAnchor = anchor ?? { rect: { left: r?.left ?? 8, top: r?.top ?? 8, bottom: r?.bottom ?? 8 } };
+ openRef.current = id;
+ setOpen({ id, anchor: at });
+ };
+ const closeMenu = useCallback((refocus: boolean) => {
+ const id = openRef.current;
+ openRef.current = null;
+ setOpen(null);
+ if (refocus && id) (ref.current?.querySelector(`[data-ws-block="${CSS.escape(id)}"]`) 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.
+ useEffect(() => {
+ if (open && !openInfo) closeMenu(false);
+ }, [open, openInfo, closeMenu]);
// The selected block kept in view (the keys walk past the strip's edge).
useEffect(() => {
if (!selected) return;
@@ -91,9 +121,10 @@ 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;
return (
+ <div key={`${b.id}@${i}`} className="group relative flex shrink-0">
<button
- key={`${b.id}@${i}`}
type="button"
role="option"
aria-selected={on}
@@ -128,13 +159,31 @@ export default function BlockStrip({
onMove(from.id, from.at, b.at);
}}
onClick={() => onSelect(b.id)}
- title={`${b.id} · ${TYPE_WORD[b.type] ?? b.type}${b.seconds ? ` · ${b.seconds.toFixed(1)} s` : ""}${b.heading ? ` · ${b.heading}` : ""}${b.rejected ? ` · rejected: ${b.rejected}` : ""}${b.missing ? " · no media — fetch it" : ""}${b.at !== null ? " · Alt+← → moves it" : ""}`}
+ onContextMenu={(e) => {
+ if (!menu) return;
+ 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 });
+ }}
+ onKeyDown={(e) => {
+ if (!menu) return;
+ if ((e.shiftKey && e.key === "F10") || e.key === "ContextMenu") {
+ e.preventDefault();
+ e.stopPropagation();
+ showMenu(b.id, null);
+ }
+ }}
+ aria-haspopup={menu ? "menu" : undefined}
+ aria-keyshortcuts={menu ? "Shift+F10" : undefined}
+ title={`${b.id} · ${TYPE_WORD[b.type] ?? b.type}${b.seconds ? ` · ${b.seconds.toFixed(1)} s` : ""}${b.heading ? ` · ${b.heading}` : ""}${b.rejected ? ` · rejected: ${b.rejected}` : ""}${b.missing ? " · no media — fetch it" : ""}${b.at !== null ? " · Alt+← → moves it" : ""}${menu ? " · right-click or Shift+F10: its menu" : ""}`}
style={{ width: w, minWidth: w }}
className={cn(
"relative flex h-[60px] flex-col justify-between overflow-hidden rounded-[3px] border px-1.5 py-1 text-left outline-none transition-colors",
TINT[b.type] ?? TINT.clip,
on && "ring-2 ring-[var(--color-signal)] ring-offset-1 ring-offset-[var(--color-ground)]",
over === b.id && "border-[var(--color-signal)]",
+ menuOn && "border-[var(--color-signal)]",
drag === b.id && "opacity-50",
b.rejected && "opacity-60",
"focus-visible:ring-2 focus-visible:ring-[var(--color-signal)]",
@@ -151,11 +200,34 @@ export default function BlockStrip({
{b.missing && <span className="truncate text-[var(--color-dirty)]">no media</span>}
</span>
</button>
+ {menu && (
+ <button
+ type="button"
+ tabIndex={-1}
+ aria-label={`${b.id}: its menu`}
+ aria-haspopup="menu"
+ aria-expanded={menuOn}
+ data-ws-block-more={b.id}
+ onClick={(e) => {
+ e.stopPropagation();
+ if (menuOn) closeMenu(true);
+ else showMenu(b.id, 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",
+ on || menuOn ? "opacity-100" : "opacity-0 group-hover:opacity-100 group-focus-within:opacity-100",
+ )}
+ >
+ ⋯
+ </button>
+ )}
+ </div>
);
})}
<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} />}
</div>
);
}
diff --git a/umtool/components/projects/workspace/Workspace.tsx b/umtool/components/projects/workspace/Workspace.tsx
@@ -5,7 +5,7 @@ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import { buttonVariants } from "@/components/ui/button";
import { cn } from "@/lib/utils";
import { clipBenchHref, postBenchHref } from "@/lib/hrefs";
-import { runningTime, startOf } from "@/lib/report/playCut.mjs";
+import { runningTime, sourceAt, startOf } from "@/lib/report/playCut.mjs";
import { PlayStage, usePlayCore } from "../review/playCore";
import type { PlayViewData } from "../review/PlayCut";
import { useCutApp } from "../cutApp/CutApp";
@@ -14,6 +14,7 @@ import { AddClipToggle } from "../AddClip";
import AddPosts from "../AddPosts";
import TeaserInspector from "../inspector/TeaserInspector";
import BlockStrip, { type Block } from "./BlockStrip";
+import type { BlockActions, BlockInfo } from "./BlockMenu";
import WorkspaceInspector from "./WorkspaceInspector";
import WorkspaceTop, { type UndoState } from "./WorkspaceTop";
import GeneratedBanner from "@/components/notes/GeneratedBanner";
@@ -45,7 +46,8 @@ import GeneratedBanner from "@/components/notes/GeneratedBanner";
// Space play / pause · ← → the block before / after · Alt+← → move the
// selected block · E edit it in place · Esc nothing selected (the project's
// panels) · ⌘Z / Ctrl+Z undo · ⌘⇧Z / Ctrl+Y redo · ? the keys · ⌘K the
-// palette (shell/JumpPalette.tsx), as everywhere.
+// palette (shell/JumpPalette.tsx), as everywhere · Shift+F10 (or a
+// right-click, or its ⋯) a block's menu (BlockMenu, lane L8b).
// ---------------------------------------------------------------------------
/** The + block: the inspector's add panels. */
@@ -60,6 +62,7 @@ const KEYS: { keys: string; what: string }[] = [
{ keys: "⌘Z Ctrl+Z", what: "undo the newest edit to the draft" },
{ keys: "⌘⇧Z Ctrl+Y", what: "redo" },
{ keys: "⌘K", what: "the command palette" },
+ { keys: "Shift+F10", what: "the focused block's menu (or right-click it, or its ⋯): its verbs, each a form filled in from it" },
{ keys: "?", what: "these keys" },
];
@@ -256,9 +259,9 @@ export default function Workspace({
},
[write],
);
- const moveSelected = useCallback(
- async (d: 1 | -1) => {
- const b = blocks.find((x) => x.id === selected);
+ 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;
@@ -266,16 +269,19 @@ export default function Workspace({
if (at < 0) return;
await move(b.id, at, at + d);
},
- [blocks, selected, move, undo.busy, loadTimeline],
+ [blocks, move, undo.busy, loadTimeline],
);
+ const moveSelected = useCallback((d: 1 | -1) => moveBlock(selected, d), [moveBlock, selected]);
// ---- edit in place (E): the clip bench over the workspace, Back returns here ----------
- const editHere = useCallback(() => {
- const id = selected && selected !== ADD ? selected : (core.item?.id ?? null);
+ const editHere = useCallback((which?: string) => {
+ const id = which ?? (selected && selected !== ADD ? selected : (core.item?.id ?? null));
const e = id ? entryOf.get(id) : null;
if (!e) return;
const p = itemOf.get(e.id);
- const at = p ? Math.round(Math.max(0, now().t - p.it.from) * 100) / 100 : 0;
+ // The bench opens where the playhead is in the clip (at its start when the playhead is not in it: a block's menu).
+ const t0 = now().t;
+ const at = p && t0 >= p.it.from && t0 < p.it.to ? Math.round(Math.max(0, t0 - p.it.from) * 100) / 100 : 0;
setPlaying(false);
if (e.type === "post") {
router.push(postBenchHref(project, e.id, { play: { at } }));
@@ -371,6 +377,46 @@ export default function Workspace({
() => [...new Set(view.entries.filter((e) => e.type === "post").map((e) => String((e.post as { post?: unknown } | undefined)?.post ?? "").split("/")[0]).filter(Boolean))],
[view.entries],
);
+ // ---- a block's menu (BlockMenu, lane L8b): the strip's own writers, and what fills a verb's form in ----
+ const nowRef = useRef(now);
+ nowRef.current = now;
+ const menu = useMemo<BlockActions>(
+ () => ({
+ 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;
+ const p = itemOf.get(id);
+ const t = nowRef.current().t;
+ const cutStart = typeof e.cutStart === "number" ? e.cutStart : (e.start ?? null);
+ const cutEnd = typeof e.cutEnd === "number" ? e.cutEnd : (e.end ?? null);
+ // The second under the playhead when it is in this clip, else the start of its cut.
+ 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 };
+ },
+ edit: (id: string) => {
+ select(id);
+ editHere(id);
+ },
+ play: (id: string) => {
+ select(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 });
+ });
+ },
+ }),
+ [tlIds.length, undo.busy, entryOf, blocks, itemOf, project, select, editHere, setPlaying, moveBlock, write],
+ );
+
const iconBtn = cn(buttonVariants({ variant: "outline", size: "sm" }), "min-w-9 font-mono");
const t = core.t;
const item = core.item;
@@ -445,7 +491,7 @@ export default function Workspace({
type="button"
className={cn(buttonVariants({ variant: "quiet", size: "sm" }))}
disabled={!(selEntry ?? (item ? entryOf.get(item.id) : null)) || !["clip", "post"].includes((selEntry ?? (item ? entryOf.get(item.id) : null))?.type ?? "")}
- onClick={editHere}
+ onClick={() => editHere()}
data-ws-edit-here=""
title="the selected clip on the full bench, in place (E): Back returns here"
>
@@ -469,6 +515,7 @@ export default function Workspace({
busy={undo.busy}
onSelect={(id) => select(id)}
onMove={(id, at, to) => void move(id, at, to)}
+ menu={menu}
plus={
<button
type="button"
diff --git a/umtool/components/shell/CommandForm.tsx b/umtool/components/shell/CommandForm.tsx
@@ -2,6 +2,7 @@
import { useEffect, useMemo, useRef, useState } from "react";
import { buildArgv, cliLine, confirmOf } from "@/lib/cli/argv.mjs";
+import { announceManifestChanged } from "@/components/projects/timelineApi";
import { cn } from "@/lib/utils";
// ---------------------------------------------------------------------------
@@ -14,10 +15,27 @@ import { cn } from "@/lib/utils";
// it deletes, evicts or kills) asks a second press, "Yes, <what it does>",
// and the server wants that confirm too. What Run started is handed up
// (onStarted), so the palette lists it under Runs after an Escape.
+//
+// A workspace block's menu (lane block-menus L8b) opens this same form with
+// `prefill`: what the block filled in (verbs.mjs fromBlockValues), over the
+// page's context; the focus goes to the first arg still to give. A run of a
+// draft verb that ends done announces the write (MANIFEST_CHANGED), so the
+// page under the palette reads its draft again.
// ---------------------------------------------------------------------------
export type CliArg = { name: string; type: string; required?: boolean; choices?: string[]; default?: unknown; help?: string; repeat?: boolean; context?: string };
-export type CliVerb = { verb: string; summary: string; target: string; queue: boolean; confirm?: { what: string; when?: string[]; unless?: string[] } | null; args: CliArg[] };
+export type CliVerb = {
+ verb: string;
+ summary: string;
+ target: string;
+ queue: boolean;
+ confirm?: { what: string; when?: string[]; unless?: string[] } | null;
+ args: CliArg[];
+ /** The block kinds whose menu offers it, what a block fills in, and a page it opens instead (lib/cli/verbs.mjs). */
+ blocks?: string[];
+ fromBlock?: Record<string, string | true>;
+ nav?: string;
+};
export type CliContext = { project: string | null; clip: string | null; post: string | null; take: string | null };
export type Value = string | boolean;
/** A run the palette keeps: its form's values and what it started. */
@@ -31,7 +49,7 @@ const TEXTAREA = new Set(["pairs", "flagpairs", "list", "text", "json"]);
const TERMINAL = new Set(["done", "failed", "cancelled", "blocked"]);
/** What the page tells the form: the project for a project arg, the selection for one that asks. */
-function initialValues(row: CliVerb, ctx: CliContext): Record<string, Value> {
+function initialValues(row: CliVerb, ctx: CliContext, prefill: Record<string, Value> | null): Record<string, Value> {
const v: Record<string, Value> = {};
for (const a of row.args) {
if (a.type === "project" && a.name === "project" && ctx.project) v[a.name] = ctx.project;
@@ -40,7 +58,7 @@ function initialValues(row: CliVerb, ctx: CliContext): Record<string, Value> {
else if (a.context === "take" && ctx.take && a.required) v[a.name] = ctx.take;
else if (a.default !== undefined) v[a.name] = typeof a.default === "boolean" ? a.default : String(a.default);
}
- return v;
+ return prefill ? { ...v, ...prefill } : v;
}
export default function CommandForm({
@@ -48,16 +66,19 @@ export default function CommandForm({
ctx,
onBack,
resume = null,
+ prefill = null,
onStarted,
}: {
row: CliVerb;
ctx: CliContext;
onBack: () => void;
+ /** Values a block's menu filled in (over the page's context). */
+ prefill?: Record<string, Value> | null;
/** A run started before (the palette's Runs): its values, and it is followed again. */
resume?: CliRun | null;
onStarted?: (run: CliRun) => void;
}) {
- const [values, setValues] = useState<Record<string, Value>>(() => (resume ? resume.values : initialValues(row, ctx)));
+ const [values, setValues] = useState<Record<string, Value>>(() => (resume ? resume.values : initialValues(row, ctx, prefill)));
const [run, setRun] = useState<Run | null>(() =>
resume
? resume.kind === "job"
@@ -71,9 +92,21 @@ export default function CommandForm({
const [copied, setCopied] = useState(false);
const first = useRef<HTMLElement | null>(null);
const logRef = useRef<HTMLPreElement>(null);
+ // The field the focus starts in: the first required arg still empty when something was filled in for it, else the first.
+ const [focusAt] = useState(() => {
+ if (!prefill) return 0;
+ const i = row.args.findIndex((a) => a.required && (values[a.name] === undefined || values[a.name] === ""));
+ return i >= 0 ? i : 0;
+ });
useEffect(() => {
first.current?.focus();
+ // Opened with the palette in one go (a block's menu): the dialog's showModal runs after this and focuses its
+ // first button, so the field is focused again once it has.
+ const f = requestAnimationFrame(() => {
+ if (first.current && document.activeElement !== first.current && first.current.closest("dialog")?.contains(document.activeElement)) first.current.focus();
+ });
+ return () => cancelAnimationFrame(f);
}, []);
const built = useMemo(() => buildArgv(row, values), [row, values]);
@@ -122,6 +155,15 @@ export default function CommandForm({
if (el) el.scrollTop = el.scrollHeight;
}, [run?.log.length]);
+ // A draft verb's run done: the page under the palette (the workspace, the Cut tab) reads its draft again.
+ const announced = useRef(false);
+ const draftProject = row.target === "draft" && typeof values.project === "string" && values.project.trim() ? values.project.trim() : null;
+ useEffect(() => {
+ if (run?.state !== "done" || announced.current || !draftProject) return;
+ announced.current = true;
+ announceManifestChanged(draftProject);
+ }, [run?.state, draftProject]);
+
const set = (name: string, v: Value) => setValues((cur) => ({ ...cur, [name]: v }));
const submit = async (confirmed = false) => {
@@ -134,6 +176,7 @@ export default function CommandForm({
setAsking(null);
setPosting(true);
setRefused(null);
+ announced.current = false;
try {
const r = await fetch("/api/cli", {
method: "POST",
@@ -179,7 +222,7 @@ export default function CommandForm({
const field = (a: CliArg, i: number) => {
const id = `cli-arg-${i}`;
const v = values[a.name];
- const ref = i === 0 ? (el: HTMLElement | null) => void (first.current = el) : undefined;
+ const ref = i === focusAt ? (el: HTMLElement | null) => void (first.current = el) : undefined;
const bad = !built.ok && built.field === a.name;
const control =
a.type === "boolean" ? (
diff --git a/umtool/components/shell/JumpPalette.tsx b/umtool/components/shell/JumpPalette.tsx
@@ -23,7 +23,7 @@ import {
} from "@/lib/hrefs";
import { MODES } from "@/lib/types";
import { cn } from "@/lib/utils";
-import CommandForm, { type CliContext, type CliRun, type CliVerb } from "./CommandForm";
+import CommandForm, { type CliContext, type CliRun, type CliVerb, type Value } from "./CommandForm";
// ---------------------------------------------------------------------------
// ⌘K: jump to any piece, place, tool or create action (plans/umtool-redesign.md,
@@ -45,9 +45,21 @@ import CommandForm, { type CliContext, type CliRun, type CliVerb } from "./Comma
// gets the last page's project: the form is keyed on the context and remounts when
// it arrives). What a form's Run started stays under Runs (nothing typed) for
// the page's life, so an Escape mid-run loses nothing.
+//
+// A WORKSPACE BLOCK'S MENU (lane block-menus L8b) opens a verb's form here, the
+// same form, with `umtool:command` ({ row, values }: the row and what the
+// block filled in) -- one form component, one Runs list, one POST /api/cli.
// ---------------------------------------------------------------------------
export const JUMP_EVENT = "umtool:jump";
+export const COMMAND_EVENT = "umtool:command";
+/** `umtool:command`'s detail: the row's form opened with these values over the page's context. */
+export type CommandRequest = { row: CliVerb; values: Record<string, Value> };
+
+/** Open one verb's form in the palette, pre-filled (a block's menu). */
+export function openCommand(req: CommandRequest) {
+ window.dispatchEvent(new CustomEvent<CommandRequest>(COMMAND_EVENT, { detail: req }));
+}
type Item = { id: string; section: "Runs" | "Places" | "Tools" | "Create" | "Pieces" | "Commands"; label: string; hint: string; href: string; verb?: string; run?: CliRun };
@@ -127,12 +139,14 @@ export default function JumpPalette() {
const [form, setForm] = useState<CliVerb | null>(null);
const [resume, setResume] = useState<CliRun | null>(null);
const [runs, setRuns] = useState<CliRun[]>([]);
+ const [prefill, setPrefill] = useState<Record<string, Value> | null>(null);
const show = useCallback(() => {
setQ("");
setAt(0);
setForm(null);
setResume(null);
+ setPrefill(null);
setCtx(NO_CONTEXT);
setOpen(true);
}, []);
@@ -148,12 +162,21 @@ export default function JumpPalette() {
}
};
const onJump = () => show();
+ const onCommand = (e: Event) => {
+ const req = (e as CustomEvent<CommandRequest>).detail;
+ if (!req?.row?.verb) return;
+ show();
+ setForm(req.row);
+ setPrefill(req.values ?? {});
+ };
document.addEventListener("keydown", onKey);
window.addEventListener(JUMP_EVENT, onJump);
+ window.addEventListener(COMMAND_EVENT, onCommand);
setReady(true);
return () => {
document.removeEventListener("keydown", onKey);
window.removeEventListener(JUMP_EVENT, onJump);
+ window.removeEventListener(COMMAND_EVENT, onCommand);
};
}, [show]);
@@ -252,6 +275,7 @@ export default function JumpPalette() {
const v = verbs?.find((x) => x.verb === it.verb);
if (v) {
setResume(it.run ?? null);
+ setPrefill(null);
setForm(v);
}
return;
@@ -279,12 +303,14 @@ export default function JumpPalette() {
row={form}
ctx={ctx}
resume={resume}
+ prefill={resume ? null : prefill}
onStarted={(r) => {
setRuns((cur) => [r, ...cur.filter((x) => x.id !== r.id)].slice(0, 8));
}}
onBack={() => {
setForm(null);
setResume(null);
+ setPrefill(null);
setTimeout(() => input.current?.focus(), 0);
}}
/>
diff --git a/umtool/docs/knobs.md b/umtool/docs/knobs.md
@@ -731,6 +731,7 @@ to the article's piece). `?block=<id>` opens with that block selected.
| move a block | the strip: drag a block onto a place, or **Alt+← →** on the selected one (the timeline's `move`) | `umtool timeline <p> move <id> --to <index>` |
| add | the strip's **+**: Add a clip, Add posts, insert a teaser or closing card | `umtool timeline <p> insert …` · `umtool posts add …` · `umtool timeline <p> teaser-insert …` |
| undo / redo | **Undo**, **Redo** (⌘Z / Ctrl+Z, ⌘⇧Z / Ctrl+Y) | `umtool timeline <p> undo` · `umtool timeline <p> redo` |
+| a block's menu | right-click a block, its **⋯**, or **Shift+F10** / the context-menu key on it: **Edit in place**, **Play from here**, **Move left / right**, **Remove**, **Full bench**, **Life cycle**, then its kind's verbs (below) | each verb is its own `umtool …` line (the form's **Copy as CLI**); Remove is `umtool timeline <p> remove <id>` |
- **The viewer is Play's player core** (`components/projects/review/playCore.tsx`: `usePlayCore` + `PlayStage`, the same
code Play draws — not a copy): the draft live, the intro, the deck, the post items and the teasers as Play plays
@@ -742,6 +743,18 @@ to the article's piece). `?block=<id>` opens with that block selected.
item panel (excerpt, media, my recording) and the post bench (`PostBench` `layout="inspector"`); a **card** — the
teaser panel; the **intro** — the intro editor; **nothing** (Esc) — the project's panels (title, provenance, links,
ledger, a still).
+- **A block's menu** (`components/projects/workspace/BlockMenu.tsx`, lane L8b) lists, under the strip's own writers,
+ every verb of the registry whose row names the block's kind — `blocks: [...]` on the row in
+ `umtool/lib/cli/verbs.mjs` (clip, post, teaser, card — a chapter card —, intro, video); a verb with no `blocks` is
+ never in a block menu. Choosing one opens **the same form ⌘K opens** (below), filled in from the block by the row's
+ own `fromBlock` rules (`{id}`, `{at}`, `{second}` — the playhead's source second in the clip, else its cut's start —,
+ `{cutStart}-{cutEnd}`, `{channel}/{video}`): `timeline teaser-insert --after <this block>`, `still <clip> --at
+ <second>`, `timeline split <clip> <second>`, `quote-check --clips <clip>`, `links --embed-ids --clips <clip>` (the
+ one-clip Rumble cite fix), `posts set-item <item>`, `timeline move <id> --to <its index>` … Its Run is `POST
+ /api/cli`, as ⌘K's; a draft verb's run that ends done makes the workspace read the draft again, and **Undo** takes
+ it back. A row with `nav` is a page, not a run (`ingredient`: the **Life cycle** link). Keys: ↑ ↓ Home End and a
+ letter move, Enter or Space chooses, Esc or Tab closes, and the focus goes back to the block. A new block verb is
+ `blocks` and `fromBlock` on its row; `verbs.test.mjs` fails until every arg that names a block has a rule.
- **E edits in place**: the selected clip on the full bench over the workspace (the CutApp shell: the viewer stays
mounted, paused), and **Back to the cut** returns to it; a post item opens its own bench.
- **Every edit lands in the draft.** What takes an undo point (`revisions/<stamp>-auto-before-<op>`): every structural
@@ -1924,6 +1937,10 @@ What a form may name, and what it asks first:
a tailnet name) needs that name in `UMTOOL_ALLOWED_HOSTS`, or the app's own pages cannot save anything.
- **Runs.** What a form started stays under **Runs** in the palette (nothing typed) for the page's life: an Escape
mid-run loses nothing. The same queued command sent twice within 5 s is the one step.
+- **From a block.** A workspace block's menu ([The workspace](#the-workspace-one-screen-per-report-video), "A block's
+ menu") opens these forms too, filled in from the block (`fromBlock` on the row), in this palette: one form, one
+ Runs list, one `POST /api/cli`. A draft verb's run that ends **done** announces the write, so the page under the
+ palette reads its draft again.
## Reading them back