commit c16aaab6a4a5b30d7329cabc357999db41016213
parent 4e0ca3ecb2cf12294c81dbed5dca5a34b789a424
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Tue, 10 Nov 2026 13:16:05 -0500
umtool: review fixes -- Undo/Redo never retried on a stale token, redo keys gated; the article piece leads to its video's workspace; knobs.md says what takes an undo point; the workspace fixture composes; home's settle fix is an outline at rest
- Workspace: ⌘⇧Z / Ctrl+Y only while a redo is offered; an Undo or Redo refused as stale is said, never sent again
on a fresh token (a move still is: it names its index); the page's token read before the view after a panel's write,
and carried as data-ws-token.
- The article piece's More menu: Open the workspace for its video project (a claimed project's only way there).
- knobs.md: what takes an undo point and what does not; a redo refuses after any write since the undo.
- workspace-fixture: the counter's tallyLabel fits the 72 px tally row, so the deck composes there; workspace.spec
asserts it composes and says no "did not compose" (Play fails the same way on play-cut-fixture -- the fixture,
not the workspace path). A new case: a title written since the undo, Redo refused, the title kept.
- Home (visual-audit "inbox (/)"): a patch fix on an Inbox card is an outline at rest, filled only on the lit line
(DecisionSettle `lit`) -- one filled action a page.
- GET /api/report/post-bench counts the combos once per draft token (memoised), not on every click.
- plans/FACTS.md: "workspace" as a naming hazard.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
10 files changed, 103 insertions(+), 20 deletions(-)
diff --git a/plans/FACTS.md b/plans/FACTS.md
@@ -137,6 +137,13 @@ source tree).
(`DisplaySummary` records), documented in `common/lib/corpus.ts:35-36` and served by
`common/components/summariesCache.ts`. Nothing to do with AI summaries. Use **`digest`**.
+**"Workspace" means two things in umtool.** THE WORKSPACE (umtool redesign L7a,
+`umtool/components/projects/workspace/`) is a report video's one screen at its own address
+`/projects/<p>` (`workspaceHref`, `kinds.mjs` `opensWorkspace`): viewer, block strip, inspector.
+An ARTICLE's "workspace files" are something else: the files of its research workspace, shown on the
+Article tab's `source` view (`umtool/lib/pieces/tabs.mjs` ARTICLE_SECTION_TAB `source`,
+`umtool/components/articles/WorkspacePanel.tsx`). Say which.
+
**Never name a sidecar `transcript.<x>.<y>`.** `common/lib/videoStatus.ts:88` —
`export const SUB_FILE_RE = /^transcript\.([^.]+)\.([^.]+)$/;` treats any such file as a
subtitle track. The exclusion list in `readSubTracks` is hardcoded. Use `ai-digest.json`,
diff --git a/umtool/components/articles/ArticlePage.tsx b/umtool/components/articles/ArticlePage.tsx
@@ -30,7 +30,7 @@ import { readArticleNotes, readReportFile, reportDirFor } from "@/lib/articles/s
import { sourceFor } from "@/lib/articles/sources.mjs";
import { readArticleProposals } from "@/lib/articles/verdicts";
import VerdictProposals from "@/components/articles/VerdictProposals";
-import { articleEvidenceHref, articleHref, projectHref } from "@/lib/hrefs";
+import { articleEvidenceHref, articleHref, projectHref, workspaceHref } from "@/lib/hrefs";
import { ARTICLES_KEY, corpusNotesFile } from "@/lib/paths";
import { readPieceGraph } from "@/lib/pieces";
import { articleVideo, projectNoteTab, readArticlePieceFrame, type ArticleVideo } from "@/lib/pieces/article";
@@ -212,6 +212,10 @@ export default async function ArticlePage({
<span className="px-2 pb-1 pt-1.5 font-mono text-[11px] text-muted" data-piece-more-project={videoRef.id}>
{videoRef.id}
</span>
+ {/* Its video's workspace (L7a): the project's own address -- the one way there from a claimed piece. */}
+ <Link href={workspaceHref(videoRef.id)} prefetch={false} data-primary-workspace={videoRef.id} className="block rounded-[2px] px-2 py-1 text-[12.5px] text-text-2 hover:bg-panel-2 hover:text-text">
+ Open the workspace
+ </Link>
<DeleteProject project={videoRef.id} />
</>
)}
diff --git a/umtool/components/inbox/InboxList.tsx b/umtool/components/inbox/InboxList.tsx
@@ -170,7 +170,7 @@ function Card({ card: c }: { card: InboxCard }) {
<LifecycleButton piece={c.piece} title={c.title} from={c.lifecycle} to="done" label="Mark done" variant="outline" size="md" className="lit-go max-md:min-h-11" />
) : oneClick && c.settle && c.project ? (
<span data-card-settle={c.settle.kind}>
- <DecisionSettle project={c.project} settle={c.settle} size="md" className="lit-go max-md:min-h-11" />
+ <DecisionSettle project={c.project} settle={c.settle} size="md" lit className="lit-go max-md:min-h-11" />
</span>
) : (
<Link href={c.action.href} prefetch={false} data-action-link="" className={cn(buttonVariants({ variant: "outline", size: "md" }), "lit-go max-md:min-h-11")}>
diff --git a/umtool/components/projects/report/DecisionSettle.tsx b/umtool/components/projects/report/DecisionSettle.tsx
@@ -22,6 +22,7 @@ export default function DecisionSettle({
token = null,
size = "sm",
className,
+ lit = false,
}: {
project: string;
settle: NonNullable<Decision["settle"]>;
@@ -29,6 +30,11 @@ export default function DecisionSettle({
/** The Inbox's card draws it as its primary action: `md`, lit. */
size?: "sm" | "md";
className?: string;
+ /**
+ * A list line's action (the Inbox's card): an OUTLINE at rest, filled only on the lit line (`lit-go`) -- a page
+ * has ONE filled action (visual-audit.spec), so a patch's fix is not filled on every card that offers one.
+ */
+ lit?: boolean;
}) {
const router = useRouter();
const [busy, setBusy] = useState(false);
@@ -116,7 +122,7 @@ export default function DecisionSettle({
data-settle-button={settle.kind === "patch" ? settle.clip : settle.kind === "patch-markers" ? settle.file : settle.kind === "publish-site" ? `publish-${settle.siteId}` : settle.kind === "quote-check" ? "quote-check" : "links"}
disabled={busy}
onClick={() => void run()}
- className={cn(buttonVariants({ variant: settle.kind === "patch" ? "go" : "outline", size }), className)}
+ className={cn(buttonVariants({ variant: settle.kind === "patch" && !lit ? "go" : "outline", size }), className)}
title={
settle.kind === "patch"
? `writes ${Object.keys(settle.patch).join(", ")} on ${settle.clip} through the window writer`
diff --git a/umtool/components/projects/workspace/Workspace.tsx b/umtool/components/projects/workspace/Workspace.tsx
@@ -114,12 +114,14 @@ export default function Workspace({
// ---- the timeline's order and token (TimelineList's: the writer the strip moves with) ----
const tl = useRef<Timeline>({ token: null, ids: [] });
const [tlIds, setTlIds] = useState<string[]>([]);
+ const [tlToken, setTlToken] = useState<string | null>(null);
const loadTimeline = useCallback(async () => {
const r = await fetch(`/api/report/timeline?project=${encodeURIComponent(project)}`, { cache: "no-store" });
const j = (await r.json().catch(() => ({}))) as { token?: string; timeline?: { id: string }[] };
if (r.ok) {
tl.current = { token: typeof j.token === "string" ? j.token : null, ids: Array.isArray(j.timeline) ? j.timeline.map((e) => e.id) : [] };
setTlIds(tl.current.ids);
+ setTlToken(tl.current.token);
}
return tl.current;
}, [project]);
@@ -129,6 +131,8 @@ export default function Workspace({
// ---- what writes the draft from here: Undo, Redo, a move ---------------------------
const [undo, setUndo] = useState<UndoState>({ busy: false, said: null, error: false, canRedo: false });
+ const undoRef = useRef(undo);
+ undoRef.current = undo;
/** Bumped by the workspace's own structural writes: the inspector's panels are read afresh. */
const [epoch, setEpoch] = useState(0);
const write = useCallback(
@@ -136,15 +140,18 @@ export default function Workspace({
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);
- // The draft moved since the token was read -- a panel's save a moment ago, announced but not read back
- // yet: read it and ask once more (Undo means the newest edit; a move names its index, refused if stale).
- if (!res.ok && res.json.stale) res = await timelineOp(project, (await loadTimeline()).token, op, args);
+ // The draft moved since the token was read -- a panel's save a moment ago, announced but not read back yet.
+ // A move names its index (refused if that is not it any more), so it is asked once more on the fresh token;
+ // an Undo or a Redo NEVER is: it would take back (or put back over) an edit this page has not seen. The
+ // refusal is said, and the token read again for the next press.
+ if (!res.ok && res.json.stale && op === "move") res = await timelineOp(project, (await loadTimeline()).token, op, args);
if (!res.ok) {
setUndo((u) => ({ ...u, busy: false, said: refusalOf(res), error: true, canRedo: op === "undo" ? u.canRedo : op === "redo" ? false : u.canRedo }));
if (res.json.stale) await loadTimeline();
return null;
}
tl.current.token = typeof res.json.token === "string" ? res.json.token : null;
+ setTlToken(tl.current.token);
setEpoch((n) => n + 1);
await Promise.all([reloadView(), loadTimeline()]);
return res.json;
@@ -168,10 +175,10 @@ export default function Workspace({
if ((e as CustomEvent).detail?.project !== project) return;
setUndo((u) => ({ ...u, canRedo: false, said: null }));
if (t) clearTimeout(t);
+ // The token first (the next Undo is asked on it), then the view.
t = setTimeout(() => {
- void reloadView();
- void loadTimeline();
- }, 120);
+ void loadTimeline().then(() => reloadView());
+ }, 60);
};
window.addEventListener(MANIFEST_CHANGED, on);
return () => {
@@ -294,13 +301,14 @@ export default function Workspace({
const k = ev.key;
const mod = ev.metaKey || ev.ctrlKey;
if (mod && !ev.altKey && (k === "z" || k === "Z")) {
- if (ev.shiftKey) void doRedo();
- else void doUndo();
+ if (ev.shiftKey) {
+ if (undoRef.current.canRedo && !undoRef.current.busy) void doRedo();
+ } else if (!undoRef.current.busy) void doUndo();
ev.preventDefault();
return;
}
if (mod && !ev.altKey && (k === "y" || k === "Y") && ev.ctrlKey) {
- void doRedo();
+ if (undoRef.current.canRedo && !undoRef.current.busy) void doRedo();
ev.preventDefault();
return;
}
@@ -370,6 +378,8 @@ export default function Workspace({
return (
<div
data-workspace={project}
+ // 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 ?? ""}
className="flex min-h-0 flex-1 flex-col overflow-hidden max-[899px]:pb-[44px]"
>
diff --git a/umtool/docs/knobs.md b/umtool/docs/knobs.md
@@ -744,10 +744,16 @@ to the article's piece). `?block=<id>` opens with that block selected.
ledger, a still).
- **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** with its own undo point, whatever wrote it; **Undo** takes back the newest,
- **Redo** puts it back while nothing was edited since (an edit ends it). An undo leaves `<stamp>-undo-saved.redo.json`
- naming the point it restored; a redo renames that point back to `auto-before-<op>`, so the next Undo takes the
- redone edit back again (`lib/report/manifest.mjs` redoStructural).
+- **Every edit lands in the draft.** What takes an undo point (`revisions/<stamp>-auto-before-<op>`): every structural
+ write (a move, a remove, an insert, a section, a group, a teaser, a reject, an open of a version, the inspector
+ panels' writes), a clip's moved edge (`trim`) and its gaps (`gaps`) — each its own in the app; from a terminal or
+ a step the app queues, one per op every two minutes. What does NOT: a clip's fields that move no edge (its title,
+ date, quote, attribution), a verdict, a saved version. **Undo** takes back the newest undo point. **Redo** puts back
+ what the newest Undo took back, and only while the draft is EXACTLY as that undo left it: an undo records a hash of
+ the manifest and `takes/draft.json` beside it (`<stamp>-undo-saved.redo.json`), and a redo refuses — *the draft
+ changed since the undo — nothing to redo* — after any write since, whichever writer and whether or not it took an
+ undo point. A redo renames the point back to `auto-before-<op>`, so the next Undo takes the redone edit back again
+ (`lib/report/manifest.mjs` redoStructural). `undo-saved` and `redone-*` keep their newest 200, as the undo points do.
## Play the cut (the whole cut, or a take, with no render)
diff --git a/umtool/e2e/fixtures/make-fixture.mjs b/umtool/e2e/fixtures/make-fixture.mjs
@@ -2171,6 +2171,9 @@ makePlayCutFixture({ reports, deckManifest, cachedWindow: path.join(REPORT, "out
});
const wsFile = path.join(wsDir, "video.manifest.json");
const wsM = JSON.parse(readFileSync(wsFile, "utf8"));
+ // The counter's cell word short enough for the tally's cell (play-cut-fixture's "Seizures" no longer fits since
+ // the tally's 72 px row): the deck COMPOSES here, so workspace.spec can say a composition failure is a regression.
+ wsM.render.chrome.factcheck.verdicts.CORROBORATED.tallyLabel = "Seized";
wsM.timeline.splice(2, 0, {
type: "post", id: "p-5", post: "postchan-x/5", platform: "x", author: "Post Subject", handle: "postsubject",
date: "2026-10-30T12:00:00.000Z", text: "The scale said 291 this morning. I said the scale was broken.", url: "https://x.com/postsubject/status/5", subjects: ["postsubject"],
diff --git a/umtool/e2e/piece.spec.ts b/umtool/e2e/piece.spec.ts
@@ -281,6 +281,9 @@ test("a claimed project's address redirects to its article piece on the same tab
await page.goto(`/browse/${ZETA_CUT}?tab=history`);
await expect(page).toHaveURL(new RegExp(`/articles/zeta\\?tab=history$`));
await expect(tab(page, "history")).toHaveAttribute("aria-current", "page");
+ // The video's workspace is its own address: the article piece's ⋯ More leads there.
+ await page.getByRole("button", { name: "More" }).click();
+ await expect(page.locator(`[data-primary-workspace="${ZETA_CUT}"]`)).toHaveAttribute("href", urls.workspaceHref(ZETA_CUT));
// The benches and kind views stay at the project's address, and lead back to the piece.
expect((await at(urls.takesHref(ZETA_CUT))).status).toBe(200);
diff --git a/umtool/e2e/workspace.spec.ts b/umtool/e2e/workspace.spec.ts
@@ -52,6 +52,10 @@ test("one screen at 1366×768: the top bar, the viewer plays the draft, the stri
// The viewer: the draft, on Play's clock, from the cached window.
await expect(viewer(page)).toHaveAttribute("data-play-state", "paused");
await expect(viewer(page)).toHaveAttribute("data-play-edges", "render", { timeout: 30_000 });
+ // The deck composes (the live preview's pages), as Play's does: no "the chrome did not compose".
+ await expect(viewer(page)).toHaveAttribute("data-play-compose", "ready", { timeout: 60_000 });
+ await expect(page.locator("[data-ws-compose-error]")).toHaveCount(0);
+ await expect(page.locator('[data-ws-viewer] [data-testid="play-deck"]')).toBeVisible();
await page.locator("[data-ws-play]").click();
await expect(viewer(page)).toHaveAttribute("data-play-item", "c01");
await expect.poll(async () => Number(await viewer(page).getAttribute("data-play-t")), { timeout: 20_000 }).toBeGreaterThan(0.5);
@@ -81,9 +85,14 @@ test("a clip block: the inspector is the bench's window and word strip; a nudged
await bench.evaluate((el) => (el as HTMLElement).focus());
await page.keyboard.press(".");
await expect(bench.locator("[data-save-window]")).toBeEnabled();
+ await expect(page.locator("[data-workspace]")).toHaveAttribute("data-ws-token", /./);
+ const tokenBefore = await page.locator("[data-workspace]").getAttribute("data-ws-token");
await bench.locator("[data-save-window]").click();
await expect.poll(() => manifest().timeline.find((e) => e.id === "c01")?.end, { timeout: 15_000 }).not.toBe(3.0);
const nudged = manifestText();
+ // The workspace has read the draft's new token (the save announced itself) before Undo is pressed: an Undo on a
+ // stale token is refused, never retried.
+ await expect(page.locator("[data-workspace]")).not.toHaveAttribute("data-ws-token", tokenBefore ?? "");
expect(takeText()).toBe(take);
// One Undo restores the draft byte for byte; Redo puts the edit back; Undo again.
@@ -170,3 +179,25 @@ test("under ~900 px the inspector is a sheet at the bottom, folded and unfolded
const fit = await page.evaluate(() => document.documentElement.scrollWidth - window.innerWidth);
expect(fit).toBeLessThanOrEqual(0);
});
+
+test("a write since the undo ends the redo: Redo is refused and the write is kept", async ({ page, request }) => {
+ await page.goto(urls.workspaceHref(P));
+ await expect(page.locator('[data-ws-block="c04"]')).toHaveAttribute("data-ws-block-at", /\d/);
+ const before = order();
+ await page.locator('[data-ws-block="c04"]').click();
+ await page.keyboard.press("Alt+ArrowLeft");
+ await expect(page.locator("[data-ws-undo-said]")).toContainText("Moved c04");
+ await expect.poll(order).not.toBe(before);
+ await page.locator("[data-ws-undo]").click();
+ await expect.poll(order, { timeout: 15_000 }).toBe(before);
+ await expect(page.locator("[data-ws-redo]")).toBeEnabled();
+ // Another writer (an agent, the terminal) titles a clip -- a write that takes no undo point.
+ const r = await request.put("/api/report/window", { data: { project: P, clip: "c01", title: "Titled since the undo" } });
+ expect(r.ok(), await r.text()).toBe(true);
+ const titled = manifestText();
+ await page.locator("[data-ws-redo]").click();
+ await expect(page.locator("[data-ws-undo-said]")).toContainText("the draft changed since the undo");
+ expect(manifestText()).toBe(titled);
+ expect(order()).toBe(before);
+ await expect(page.locator("[data-ws-redo]")).toBeDisabled();
+});
diff --git a/umtool/lib/report/postBenchData.ts b/umtool/lib/report/postBenchData.ts
@@ -34,6 +34,10 @@ export type PostBenchData = {
index: number;
};
+/** The combos counted per state of a draft (`<dir>\0<token>`), the newest few kept. */
+const combosByDraft = new Map<string, Promise<{ combos: unknown; groups: unknown }>>();
+const COMBOS_KEPT = 8;
+
/** The post item `id` of the draft at `dir`, or null when the manifest has no such post item. */
export async function postBenchData(dir: string, id: string): Promise<PostBenchData | null> {
const m = (await readManifest(dir)) as Record<string, unknown> | null;
@@ -49,14 +53,23 @@ export async function postBenchData(dir: string, id: string): Promise<PostBenchD
const neighbours = tl.filter((e) => e?.type === "post").map((e) => e.id);
// What it opens on (post-conversation.mjs): the item before it and the scene its run leaves on screen.
const ctx = planContext(tl, at, render) as { prev: Record<string, unknown> | null; scene: Record<string, unknown> | null };
- // Its combo (post-combo.mjs): counted over the whole cut, as the build counts it.
- const counted = await projectCombos(dir, m, { channelsDir: channelsDirFor(dir, m) }).catch(() => ({ combos: {}, groups: [] }));
+ // Its combo (post-combo.mjs): counted over the whole cut, as the build counts it -- once per state of the draft
+ // (its token): counting hashes every attachment, and the workspace asks again on each post block's click.
+ const token = await manifestToken(dir);
+ const key = `${dir}\0${token ?? ""}`;
+ let counting = combosByDraft.get(key);
+ if (!counting) {
+ counting = projectCombos(dir, m, { channelsDir: channelsDirFor(dir, m) }).catch(() => ({ combos: {}, groups: [] }));
+ combosByDraft.set(key, counting);
+ while (combosByDraft.size > COMBOS_KEPT) combosByDraft.delete(combosByDraft.keys().next().value as string);
+ }
+ const counted = (await counting) as { combos: unknown; groups: unknown };
const combos = counted.combos as Record<string, ComboInfo>;
// Its media scene (post-media-scene.mjs): its neighbours with the same attachment, by the combo's groups.
- const scene = mediaSceneOf(tl, at, counted.groups, render);
+ const scene = mediaSceneOf(tl, at, counted.groups as never, render);
return {
entry,
- token: await manifestToken(dir),
+ token,
box: { width: box.width, height: box.height },
plan: postItemPlan(panelEntry(sceneEntry(entry, scene), render), render, { ...ctx, mediaScene: ctx.scene ? null : scene }) as unknown as PostPlan,
scene,