Archilyzer · Source

archilyzer

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

commit b172b40453da3e2b79edeeacef775b38f2cd3f93
parent 380d06cdc4db1594fd6fac1492aae476c48984a0
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Tue, 10 Nov 2026 09:57:56 -0500

umtool: workspace e2e, fixture and docs; the piece head's Workspace; specs that meant the Overview say ?tab=overview

workspace.spec.ts (workspace-fixture: play-cut's cut on vid1 with a text post item after c02, its made take): one
screen at 1366x768 with no page scroll, the viewer plays the draft, a clip block's inspector is the bench's window
and cue rail, a nudged edge lands in the draft and not the take, Undo / Redo / Ctrl+Z, a post block's L6 panel and
post bench, Alt+Right moves a block, Save version lists it in Versions, E opens the bench in place and Back returns,
the piece page at ?tab=overview. The specs that opened a report video's bare address for its Overview (add-clip,
article-delete, cut-integrity, phone, piece, source-backlog, ui-ops) open ?tab=overview; piece.spec's claimed
project's own address is its workspace (200), its ?tab=overview still the article's piece (307). A workspace write
refused as stale reads the token and asks once more. knobs.md "The workspace".

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

Diffstat:
Mumtool/components/projects/ProjectPrimary.tsx | 6+++++-
Mumtool/components/projects/workspace/Workspace.tsx | 14++++++--------
Mumtool/docs/knobs.md | 35+++++++++++++++++++++++++++++++++++
Mumtool/e2e/add-clip.spec.ts | 2+-
Mumtool/e2e/article-delete.spec.ts | 2+-
Mumtool/e2e/cut-integrity.spec.ts | 10+++++-----
Mumtool/e2e/fixtures/make-fixture.mjs | 17+++++++++++++++++
Mumtool/e2e/phone.spec.ts | 6+++---
Mumtool/e2e/piece.spec.ts | 23++++++++++++++---------
Mumtool/e2e/source-backlog.spec.ts | 2+-
Mumtool/e2e/ui-ops.spec.ts | 6+++---
Aumtool/e2e/workspace.spec.ts | 153+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
12 files changed, 244 insertions(+), 32 deletions(-)

diff --git a/umtool/components/projects/ProjectPrimary.tsx b/umtool/components/projects/ProjectPrimary.tsx @@ -1,6 +1,6 @@ import Link from "next/link"; import { buttonVariants } from "@/components/ui/button"; -import { clipBenchHref, projectHref, presentHref } from "@/lib/hrefs"; +import { clipBenchHref, projectHref, presentHref, workspaceHref } from "@/lib/hrefs"; import PlayLink from "./PlayLink"; import SaveVersionButton from "./SaveVersionButton"; import type { ClipDetail } from "./report/shared"; @@ -45,6 +45,10 @@ export default function ProjectPrimary({ project, detail, latest, words = null } const firstClip = entries.find((e) => e.kind === "clip")?.id ?? null; return ( <> + {/* The workspace (L7a): the project's own address, one screen -- the draft playing, its blocks, the inspector. */} + <Link href={workspaceHref(project)} prefetch={false} data-primary-workspace="" className={buttonVariants({ variant: "outline", size: "md" })} title="the workspace: the draft playing, its blocks, an inspector for the one you pick"> + Workspace + </Link> <PlayLink project={project} where="header" variant="header" label="▶ Play the draft" title="the working draft: every edit lands here" /> <Link href={presentHref(project)} prefetch={false} data-present-link="header" className={buttonVariants({ variant: "quiet", size: "md" })} title="the cut as slides, one at a time, navigated like a deck (present mode)"> Present diff --git a/umtool/components/projects/workspace/Workspace.tsx b/umtool/components/projects/workspace/Workspace.tsx @@ -117,19 +117,20 @@ export default function Workspace({ view: served, initialBlock = null, introWrit const [undo, setUndo] = useState<UndoState>({ busy: false, said: null, error: false, canRedo: false }); /** Bumped by the workspace's own structural writes: the inspector's panels are read afresh. */ const [epoch, setEpoch] = useState(0); - const ownWrite = useRef(false); const write = useCallback( async (op: string, args: Record<string, unknown> = {}) => { setUndo((u) => ({ ...u, busy: true, said: null, error: false })); const token = tl.current.token ?? (await loadTimeline()).token; - const res = await timelineOp(project, token, op, args); + 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); 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; - ownWrite.current = true; setEpoch((n) => n + 1); await Promise.all([reloadView(), loadTimeline()]); return res.json; @@ -145,15 +146,12 @@ export default function Workspace({ view: served, initialBlock = null, introWrit if (j) setUndo((u) => ({ busy: false, said: `Redone: ${String(j.op ?? "")}`, error: false, canRedo: u.canRedo })); }, [write]); // A write elsewhere on the page (an inspector panel, the bench, Add a clip): the draft read again, and a - // Redo is gone (an edit since the undo ends it). + // Redo is gone (an edit since the undo ends it). The workspace's own writes (above) do not announce: they + // read the draft again themselves, and remount the inspector (`epoch`). useEffect(() => { let t: ReturnType<typeof setTimeout> | null = null; const on = (e: Event) => { if ((e as CustomEvent).detail?.project !== project) return; - if (ownWrite.current) { - ownWrite.current = false; - return; - } setUndo((u) => ({ ...u, canRedo: false, said: null })); if (t) clearTimeout(t); t = setTimeout(() => { diff --git a/umtool/docs/knobs.md b/umtool/docs/knobs.md @@ -681,6 +681,41 @@ expected the cut). A take is a **saved version** — FROZEN: the Open in draft page now — then the draft's bench. The take-scoped CLI (`--in-take`, `umtool timeline <p> --take`, `umtool window --take`, `/api/report/takes/timeline`) stays for agents. +## The workspace (one screen per report video) + +`/projects/<p>` — a report video's own address — is **the workspace** (umtool redesign L7a): one screen at 1366×768, +nothing scrolling but the strip and the inspector. The piece page's tabs are `?tab=` (`?tab=overview` written out; +the head's **Workspace** comes back), and a claimed project's own address is its workspace too (its tabs still go +to the article's piece). `?block=<id>` opens with that block selected. + +| Knob | UI | CLI twin | +|---|---|---| +| the draft's line, versions | the top bar: **Draft · from v2 · 3 edits**; **Versions ▾** — each version's **Play** (read-only) and **Open in draft**, and **Save version** | `umtool takes ls <p>` · `takes open <p> <t>` · `takes save <p>` | +| mode | **Edit** · **Review pass** (the walk, until L7b brings it in) · **Present ⛶** | `umtool walk <p>` · `umtool present <p>` | +| look | **Look Basic \| Deck** (`render.mode`) | `umtool look <p> mode=basic\|deck` | +| render the draft | **Render ▾** — **Render 60 s**, **Render full** (a take of the draft, queued) | `umtool take <p> --at 0 --dur 60` · `umtool take <p> --full` | +| share | **Copy share line** for the selected clip (else the one on screen) | `umtool share <p> <clip>` | +| 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` | + +- **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 + them. Space plays and pauses; **‹ ›** (and **← →**) step the selected block, and the viewer goes to its start. +- **The inspector is the selected block's**, each panel the one its own page draws, mounted unchanged: a **clip** — + the clip bench's work column (`ClipBench` `layout="inspector"`: the window row with **Save window**, the instrument + with its handles and gaps, the cue rail; its keys `[ ] , .` `g G` `z f` are its own while the focus is in it; the + verdict, the claim and the attribution stay on the **Full bench**) and its **Life cycle**; a **post item** — the post + 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). +- **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). + ## Play the cut (the whole cut, or a take, with no render) `/projects/<p>/play` — the head's **▶ Play the draft**, or a version's **Play** on the takes page diff --git a/umtool/e2e/add-clip.spec.ts b/umtool/e2e/add-clip.spec.ts @@ -31,7 +31,7 @@ test.afterEach(() => { test("Add a clip: find the words, in and out on the cues, after a row, added and fetched", async ({ page }) => { test.setTimeout(120_000); // The head's + Add a clip lands on the Cut tab with the panel open. - await page.goto(urls.projectHref(P)); + await page.goto(urls.projectHref(P, { tab: "overview" })); await page.locator("[data-primary-add-clip]").click(); await expect(page.locator('[data-add-clip="cut"]')).toBeVisible(); diff --git a/umtool/e2e/article-delete.spec.ts b/umtool/e2e/article-delete.spec.ts @@ -143,7 +143,7 @@ test("a take the project's manifest is, is refused until forced; another take an expect(existsSync(path.join(PROJECT, "takes", "drop"))).toBe(false); expect(existsSync(path.join(PROJECT, "takes", "keep", "take.json"))).toBe(true); - await page.goto("/browse/reports/delete-fixture"); + await page.goto(urls.projectHref("reports/delete-fixture", { tab: "overview" })); // Delete is in the piece head's ⋯ menu (P4a-1). await page.getByRole("button", { name: "More" }).click(); await page.getByRole("button", { name: "Delete project" }).click(); diff --git a/umtool/e2e/cut-integrity.spec.ts b/umtool/e2e/cut-integrity.spec.ts @@ -91,7 +91,7 @@ test.afterAll(() => { const row = (page: Page, kind: string, target: string) => page.locator(`[data-decision="${kind}"][data-target="${target}"]`); test("the check rows: an overlap, a clock and QR off the clip, a stale take patch, links never checked — each with its settle and its fix", async ({ page }) => { - await page.goto(urls.projectHref(PROJECT)); + await page.goto(urls.projectHref(PROJECT, { tab: "overview" })); const overlap = row(page, "window-overlap", "c01"); await expect(overlap).toContainText("overlaps c02 by 2.0s"); await expect(overlap.locator('[data-settle-button="c02"]')).toHaveText("It's deliberate: c02 repeats c01"); @@ -111,7 +111,7 @@ test("the check rows: an overlap, a clock and QR off the clip, a stale take patc }); test("#3 It's deliberate: repeatOf through the writer, the row gone, the chip on the Cut tab and the bench", async ({ page }) => { - await page.goto(urls.projectHref(PROJECT)); + await page.goto(urls.projectHref(PROJECT, { tab: "overview" })); await row(page, "window-overlap", "c01").locator('[data-settle-button="c02"]').click(); await expect(row(page, "window-overlap", "c01")).toHaveCount(0); expect(entry("c02")?.repeatOf).toBe("c01"); @@ -132,7 +132,7 @@ test("#3 It's deliberate: repeatOf through the writer, the row gone, the chip on }); test("#5 Move to 0:06: the clock and the QR back on the clip, and the row gone", async ({ page }) => { - await page.goto(urls.projectHref(PROJECT)); + await page.goto(urls.projectHref(PROJECT, { tab: "overview" })); await row(page, "clip-cite-off", "c03").locator('[data-settle-button="c03"]').click(); await expect(row(page, "clip-cite-off", "c03")).toHaveCount(0); expect(entry("c03")?.cite).toBe(6); @@ -176,7 +176,7 @@ test("#7 ★ (s) and the walk note on the bench: not a verdict, not a correction }); test("#8 Check links: one link dead on the site blocks, naming the clip and why; offline they are not verified", async ({ page }) => { - await page.goto(urls.projectHref(PROJECT)); + await page.goto(urls.projectHref(PROJECT, { tab: "overview" })); await row(page, "links-unchecked", "QR links").locator('[data-settle-button="links"]').click(); const host = new URL(origin).host; const dead = row(page, "link-dead", host); @@ -212,7 +212,7 @@ test("#6 removing a clip re-anchors the take patch's markers; the hand-made one const patchMarkers = () => (JSON.parse(readFileSync(path.join(DIR, "draft-1.patch.json"), "utf8")) as { render: { chrome: { deck: { markers: { after: string; label: string }[] } } } }).render.chrome.deck.markers; await expect.poll(patchMarkers).toEqual([{ after: "c02", label: "After four" }, { after: "gone", label: "Hand-made" }]); - await page.goto(urls.projectHref(PROJECT)); + await page.goto(urls.projectHref(PROJECT, { tab: "overview" })); await expect(row(page, "patch-markers-stale", "draft-1.patch.json")).toContainText('"Hand-made" after gone — a take made with --patch draft-1.patch.json is refused'); await expect(row(page, "patch-markers-stale", "draft-1.patch.json")).not.toContainText("After four"); await shot(page, "6-patch-markers-stale"); diff --git a/umtool/e2e/fixtures/make-fixture.mjs b/umtool/e2e/fixtures/make-fixture.mjs @@ -2150,6 +2150,23 @@ makePlayCutFixture({ reports, deckManifest, cachedWindow: path.join(REPORT, "out rmSync(path.join(dvDir, "takes"), { recursive: true, force: true }); } +// THE WORKSPACE (workspace.spec.ts, umtool redesign L7a, WRITES): play-cut-fixture's cut on vid1 (its cues: the +// inspector's cue rail) with a text post item after c02 -- c01 c02 p-5 k01 c03 c04 -- and its made take +// (takes/short/take.json), which no edit here may touch. +{ + const { dir: wsDir } = makePlayCutFixture({ + reports, deckManifest, cachedWindow: path.join(REPORT, "out", "clips-raw", "vid1_0.00-9.00.mp4"), + name: "workspace-fixture", title: "The Workspace Fixture", video: "vid1", + }); + const wsFile = path.join(wsDir, "video.manifest.json"); + const wsM = JSON.parse(readFileSync(wsFile, "utf8")); + 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"], + }); + writeFileSync(wsFile, JSON.stringify(wsM, null, 2) + "\n"); +} + // The inspector panels (inspector-*.spec.ts, umtool redesign L6, WRITE): one project per panel // (inspector-fixture.mjs), each with a take the specs check is never written. await makeInspectorFixtures({ reports, channels: CHANNELS, deckManifest, cachedWindow: path.join(REPORT, "out", "clips-raw", "vid1_0.00-9.00.mp4"), makePlayCutFixture }); diff --git a/umtool/e2e/phone.spec.ts b/umtool/e2e/phone.spec.ts @@ -98,7 +98,7 @@ test.describe("on a phone (390×844)", () => { test.use({ viewport: PHONE, isMobile: true, hasTouch: true }); test("the shell: the place bar and the dock, the title in flow, no rail", async ({ page }) => { - await page.goto(urls.projectHref(PROJECT)); + await page.goto(urls.projectHref(PROJECT, { tab: "overview" })); await hydrated(page); await expect(page.locator("[data-app-rail]")).toBeHidden(); const bar = page.locator("[data-place-bar]"); @@ -213,7 +213,7 @@ test.describe("on a phone (390×844)", () => { test("the piece's ⋯ → Done says what it did; Undo puts it back in Active", async ({ page, request }) => { try { - await page.goto(urls.projectHref(PROJECT)); + await page.goto(urls.projectHref(PROJECT, { tab: "overview" })); await hydrated(page); await page.locator("[data-place-more]").tap(); const sheet = page.getByRole("dialog", { name: "Page actions" }); @@ -339,7 +339,7 @@ test.describe("at 360×740", () => { // ── the desk is unchanged ─────────────────────────────────────────────────── test("on the desk the head is as it was: the rail, the trail, the actions inline, the stepper; no phone chrome", async ({ page }) => { - await page.goto(urls.projectHref(PROJECT)); + await page.goto(urls.projectHref(PROJECT, { tab: "overview" })); await expect(page.locator("[data-app-rail]")).toBeVisible(); await expect(page.locator("[data-place-bar]")).toBeHidden(); await expect(page.locator("[data-phone-dock]")).toBeHidden(); diff --git a/umtool/e2e/piece.spec.ts b/umtool/e2e/piece.spec.ts @@ -22,7 +22,7 @@ const tab = (page: Page, id: string) => page.getByTestId(`piece-tab-${id}`); const keysReady = (page: Page) => expect(page.locator("[data-piece-keys=ready]")).toBeAttached(); test("the frame: title, trail, stepper at Video, the Next card, seven tabs with the Overview lit", async ({ page }) => { - const res = await page.goto(urls.projectHref(PROJECT)); + const res = await page.goto(urls.projectHref(PROJECT, { tab: "overview" })); expect(res?.status()).toBe(200); const crumbs = page.getByRole("navigation", { name: "Breadcrumb" }); await expect(crumbs.locator("h1")).toHaveText("The Report Fixture"); @@ -66,7 +66,7 @@ test("the Next card is the piece's top Inbox call, and its one action goes where const top = inbox.groups.filter((g) => g.id !== "quiet").flatMap((g) => g.cards).find((c) => c.piece === PIECE); expect(top, "the fixture's report has a call waiting").toBeTruthy(); - await page.goto(urls.projectHref(PROJECT)); + await page.goto(urls.projectHref(PROJECT, { tab: "overview" })); const next = page.locator("[data-next]:visible"); await expect(next.locator("[data-next-kind]")).toHaveAttribute("data-next-kind", top!.kind); const action = next.locator("[data-next-action] > a:visible"); @@ -89,9 +89,12 @@ test("the tab is the URL: ?tab=, ?all=1 on the Cut, a bad tab the Overview, and await page.goto(`${urls.projectHref(PROJECT)}?tab=nonsense`); await expect(tab(page, "overview")).toHaveAttribute("aria-current", "page"); - // /browse/<project> (before P3) rides the redirect to the Overview. + // /browse/<project> (before P3) rides the redirect to the project's own address: its workspace (L7a); + // the Overview is written out. await page.goto(`/browse/${PROJECT}`); await expect(page).toHaveURL(new RegExp(`/projects/${PROJECT}$`)); + await expect(page.locator(`[data-workspace="${PROJECT}"]`)).toBeVisible(); + await page.goto(urls.projectHref(PROJECT, { tab: "overview" })); await expect(tab(page, "overview")).toHaveAttribute("aria-current", "page"); // Clicking a tab is a link: the address changes, the section is there. @@ -120,7 +123,7 @@ test("the lifecycle chip: Park, then Reactivate, each a round trip through the s ((await (await request.get("/api/pieces")).json()) as { pieces: { id: string; lifecycle: string }[] }).pieces.find((p) => p.id === PIECE) ?.lifecycle; try { - await page.goto(urls.projectHref(PROJECT)); + await page.goto(urls.projectHref(PROJECT, { tab: "overview" })); const chip = page.locator("[data-lifecycle-chip]"); await expect(chip).toHaveAttribute("data-lifecycle-chip", "active"); await chip.getByRole("button", { name: "Lifecycle: Active" }).click(); @@ -147,7 +150,7 @@ test("the lifecycle chip: Mark done says it hid the piece from Active, and Undo ((await (await request.get("/api/pieces")).json()) as { pieces: { id: string; lifecycle: string }[] }).pieces.find((p) => p.id === PIECE) ?.lifecycle; try { - await page.goto(urls.projectHref(PROJECT)); + await page.goto(urls.projectHref(PROJECT, { tab: "overview" })); const chip = page.locator("[data-lifecycle-chip]"); await chip.getByRole("button", { name: "Lifecycle: Active" }).click(); await chip.getByRole("button", { name: "Mark done" }).click(); @@ -165,7 +168,7 @@ test("the lifecycle chip: Mark done says it hid the piece from Active, and Undo }); test("keys: 1–7 open the tabs, n runs the Next card's action; typing in a field is left alone", async ({ page }) => { - await page.goto(urls.projectHref(PROJECT)); + await page.goto(urls.projectHref(PROJECT, { tab: "overview" })); await keysReady(page); await page.keyboard.press("2"); await expect(page).toHaveURL(/\?tab=cut$/); @@ -263,7 +266,9 @@ test("a claimed project's address redirects to its article piece on the same tab return { status: r.status(), location: r.headers()["location"] ?? "" }; }; expect(await at(urls.projectHref(ZETA_CUT, { tab: "build" }))).toEqual({ status: 307, location: urls.articleHref(ZETA, { tab: "build" }) }); - expect(await at(urls.projectHref(ZETA_CUT))).toEqual({ status: 307, location: urls.articleHref(ZETA) }); + expect(await at(urls.projectHref(ZETA_CUT, { tab: "overview" }))).toEqual({ status: 307, location: urls.articleHref(ZETA) }); + // Its own address is its workspace (L7a): the video's one screen, claimed or not. + expect((await at(urls.projectHref(ZETA_CUT))).status).toBe(200); expect(await at(urls.projectHref(ZETA_OTHER, { tab: "sources" }))).toEqual({ status: 307, location: urls.articleHref(ZETA, { tab: "sources", project: ZETA_OTHER }), @@ -318,7 +323,7 @@ test("a note on the video lands on its tab inside the article piece", async ({ p test("fits 1366×768: the head, the tabs and the Next card's action without a horizontal scroll", async ({ page }) => { await page.setViewportSize({ width: 1366, height: 768 }); - for (const href of [urls.projectHref(PROJECT), urls.articleHref(ZETA)]) { + for (const href of [urls.projectHref(PROJECT, { tab: "overview" }), urls.articleHref(ZETA)]) { await page.goto(href); await expect(page.locator("[data-next-action] > :is(a, button):visible")).toBeInViewport(); await expect(tab(page, "history")).toBeInViewport(); @@ -341,7 +346,7 @@ test("a video started from a research board: Research done, Article not applicab const done = await request.post(`/api/research/cases/${id}/handoff`, { data: { to: "video", slug, confirm: true } }); expect(done.ok(), await done.text()).toBe(true); - await page.goto(urls.projectHref(slug)); + await page.goto(urls.projectHref(slug, { tab: "overview" })); const steps = page.getByRole("list", { name: "Stage" }).locator("li"); await expect(steps.nth(0)).toHaveAttribute("data-step", "done"); await expect(steps.nth(1)).toHaveAttribute("data-step", "na"); diff --git a/umtool/e2e/source-backlog.spec.ts b/umtool/e2e/source-backlog.spec.ts @@ -48,7 +48,7 @@ test.afterAll(async ({ request }) => { }); async function open(page: Page) { - await page.goto(urls.projectHref(PROJECT)); + await page.goto(urls.projectHref(PROJECT, { tab: "overview" })); await expect(page.getByTestId("source-backlog")).toBeVisible({ timeout: 20_000 }); } diff --git a/umtool/e2e/ui-ops.spec.ts b/umtool/e2e/ui-ops.spec.ts @@ -85,7 +85,7 @@ test.beforeAll(async ({ playwright }) => { // The site the QRs open, as transcripts/sites/<id>/site.json names it. mkdirSync(SITE_DIR, { recursive: true }); writeFileSync(path.join(SITE_DIR, "site.json"), JSON.stringify({ siteId: "ui-ops-site", siteTitle: "UI Ops Site", siteUrl: origin, channels: [{ slug: "uiopschan", order: 0 }] })); - await warm(playwright, [urls.projectHref(PROJECT), urls.takesHref(PROJECT), urls.clipBenchHref(SPEAKERS, "k04")]); + await warm(playwright, [urls.projectHref(PROJECT, { tab: "overview" }), urls.takesHref(PROJECT), urls.clipBenchHref(SPEAKERS, "k04")]); }); test.afterAll(() => { server?.close(); @@ -97,7 +97,7 @@ const row = (page: Page, kind: string, target: string) => page.locator(`[data-de test("#9 the sites the links depend on: the deploy's date, the cited videos newer than it, and Publish <site>", async ({ page }) => { const host = new URL(origin).host; - await page.goto(urls.projectHref(PROJECT)); + await page.goto(urls.projectHref(PROJECT, { tab: "overview" })); const site = page.locator(`[data-link-site="${host}"]`); await expect(site).toHaveAttribute("data-link-site-id", "ui-ops-site"); await expect(site.locator("[data-link-site-deploy]")).toContainText("deploy date unknown · not checked yet"); @@ -120,7 +120,7 @@ test("#9 the sites the links depend on: the deploy's date, the cited videos newe }); test("#10 the link policy: cite via ui-ops-site, uiopsdirect direct; the check's row and its fix; a new clip is written by it", async ({ page }) => { - await page.goto(urls.projectHref(PROJECT)); + await page.goto(urls.projectHref(PROJECT, { tab: "overview" })); const panel = page.locator("[data-link-policy]"); await expect(panel).toHaveAttribute("data-link-policy", "none"); // "Cite via ui-ops-site; uiopsdirect direct." diff --git a/umtool/e2e/workspace.spec.ts b/umtool/e2e/workspace.spec.ts @@ -0,0 +1,153 @@ +import { test, expect, type Page } from "@playwright/test"; +import { readFileSync } from "node:fs"; +import path from "node:path"; +import { fileURLToPath } from "node:url"; +import * as urls from "./urls"; + +// --------------------------------------------------------------------------- +// THE WORKSPACE (umtool redesign L7a; components/projects/workspace/): a report video's own address is one +// screen -- the top bar, the viewer (Play's player core), the strip of blocks, the inspector chosen by the +// selected block -- and every edit made in it lands in THE DRAFT, never in a take, with one undo stack. +// +// workspace-fixture (WRITES; make-fixture.mjs): play-cut-fixture's cut on vid1 with a post item after c02 -- +// c01 c02 p-5 k01 c03 c04 -- and its made take, takes/short/take.json, which nothing here may touch. The tests +// run in order, each leaving what the next reads. +// --------------------------------------------------------------------------- + +test.describe.configure({ mode: "serial" }); + +const P = "reports/workspace-fixture"; +const DIR = path.join(path.dirname(fileURLToPath(import.meta.url)), "..", ".e2e-song", "reports", "workspace-fixture"); +const manifestText = () => readFileSync(path.join(DIR, "video.manifest.json"), "utf8"); +const manifest = () => JSON.parse(manifestText()) as { timeline: { id: string; start?: number; end?: number }[] }; +const order = () => manifest().timeline.map((e) => e.id).join(" "); +const takeText = () => readFileSync(path.join(DIR, "takes", "short", "take.json"), "utf8"); +const viewer = (page: Page) => page.locator("[data-ws-viewer]"); +const blocks = (page: Page) => page.locator("[data-ws-block]"); +const blockIds = (page: Page) => blocks(page).evaluateAll((els) => els.map((e) => e.getAttribute("data-ws-block"))); + +test.beforeEach(async ({ page }) => { + test.setTimeout(120_000); + await page.setViewportSize({ width: 1366, height: 768 }); +}); + +test("one screen at 1366×768: the top bar, the viewer plays the draft, the strip's blocks, no page scroll", async ({ page }) => { + expect(order()).toBe("c01 c02 p-5 k01 c03 c04"); + await page.goto(urls.workspaceHref(P)); + await expect(page.locator(`[data-workspace="${P}"]`)).toBeVisible(); + await expect(page.locator("[data-ws-title]")).toHaveText("The Workspace Fixture"); + await expect(page.locator("[data-ws-draft]")).toContainText("Draft"); + await expect(page.locator("[data-ws-mode-edit]")).toHaveAttribute("aria-current", "page"); + await expect(page.locator("[data-ws-mode-present]")).toHaveAttribute("href", urls.presentHref(P)); + expect(await blockIds(page)).toEqual(["c01", "c02", "p-5", "k01", "c03", "c04"]); + await expect(page.locator('[data-ws-block="c03"]')).toContainText("no media"); + // Nothing selected: the project's own panels (L6). + await expect(page.locator("[data-ws-inspector]")).toHaveAttribute("data-ws-inspector", "project"); + await expect(page.locator('[data-ws-project-panels] [data-inspector="title"]')).toBeVisible(); + // The page itself never scrolls: only the inspector and the strip do. + const fit = await page.evaluate(() => ({ h: document.documentElement.scrollHeight, w: document.documentElement.scrollWidth, ih: window.innerHeight, iw: window.innerWidth })); + expect(fit.h).toBeLessThanOrEqual(fit.ih); + expect(fit.w).toBeLessThanOrEqual(fit.iw); + + // 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 }); + 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); + await expect(page.locator('[data-ws-block="c01"]')).toHaveAttribute("data-ws-block-now", ""); + // Space pauses (the workspace's key). + await page.keyboard.press("Space"); + await expect(viewer(page)).toHaveAttribute("data-play-state", "paused"); + await page.screenshot({ path: path.join(process.env.WS_SHOTS ?? path.join(DIR, ".."), "ws-overview.png") }).catch(() => {}); +}); + +test("a clip block: the inspector is the bench's window and word strip; a nudged edge lands in the draft, not the take; Undo and Redo", async ({ page }) => { + const original = manifestText(); + const take = takeText(); + await page.goto(urls.workspaceHref(P)); + await page.locator('[data-ws-block="c01"]').click(); + await expect(page.locator('[data-ws-block="c01"]')).toHaveAttribute("aria-selected", "true"); + await expect(page).toHaveURL(/[?&]block=c01/); + await expect(page.locator("[data-ws-inspector]")).toHaveAttribute("data-ws-inspector", "clip"); + const bench = page.locator('[data-bench-layout="inspector"][data-bench="c01"]'); + await expect(bench).toBeVisible({ timeout: 20_000 }); + // The window row and the word strip (the cue rail), and no verdict bar. + await expect(bench.locator("[data-save-window]")).toBeVisible(); + await expect.poll(() => bench.locator("[data-cue]").count(), { timeout: 15_000 }).toBeGreaterThan(0); + await page.screenshot({ path: path.join(process.env.WS_SHOTS ?? path.join(DIR, ".."), "ws-clip.png") }).catch(() => {}); + + // Nudge the end on (the bench's own `.`, its focus inside it), save the window. + await bench.evaluate((el) => (el as HTMLElement).focus()); + await page.keyboard.press("."); + await expect(bench.locator("[data-save-window]")).toBeEnabled(); + 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(); + expect(takeText()).toBe(take); + + // One Undo restores the draft byte for byte; Redo puts the edit back; Undo again. + await page.locator("[data-ws-undo]").click(); + await expect.poll(manifestText, { timeout: 15_000 }).toBe(original); + await expect(page.locator("[data-ws-undo-said]")).toContainText("Undone"); + await expect(page.locator("[data-ws-redo]")).toBeEnabled(); + await page.locator("[data-ws-redo]").click(); + await expect.poll(manifestText, { timeout: 15_000 }).toBe(nudged); + await page.locator("body").press("Control+z"); + await expect.poll(manifestText, { timeout: 15_000 }).toBe(original); + expect(takeText()).toBe(take); +}); + +test("a post block: the L6 post item panel and the post bench in the inspector", async ({ page }) => { + await page.goto(urls.workspaceHref(P, { block: "p-5" })); + await expect(page.locator('[data-ws-block="p-5"]')).toHaveAttribute("aria-selected", "true"); + await expect(page.locator("[data-ws-inspector]")).toHaveAttribute("data-ws-inspector", "post"); + await expect(page.locator('[data-ws-inspector] [data-inspector="post-item"]')).toBeVisible({ timeout: 20_000 }); + await expect(page.locator('[data-ws-inspector] [data-post-bench-shape="inspector"]')).toBeVisible({ timeout: 20_000 }); + await page.screenshot({ path: path.join(process.env.WS_SHOTS ?? path.join(DIR, ".."), "ws-post.png") }).catch(() => {}); + // ← → walk the blocks; Esc lets go of the block (the project's panels). + await page.locator("body").press("ArrowRight"); + await expect(page.locator('[data-ws-block="k01"]')).toHaveAttribute("aria-selected", "true"); + await page.locator("body").press("Escape"); + await expect(page.locator("[data-ws-inspector]")).toHaveAttribute("data-ws-inspector", "project"); +}); + +test("two blocks reordered by keys: one move in the draft, the take untouched", async ({ page }) => { + const take = takeText(); + await page.goto(urls.workspaceHref(P)); + await page.locator('[data-ws-block="c02"]').click(); + await page.keyboard.press("Alt+ArrowRight"); + await expect.poll(order, { timeout: 15_000 }).toBe("c01 p-5 c02 k01 c03 c04"); + await expect.poll(() => blockIds(page)).toEqual(["c01", "p-5", "c02", "k01", "c03", "c04"]); + await expect(page.locator('[data-ws-block="c02"]')).toHaveAttribute("aria-selected", "true"); + expect(takeText()).toBe(take); +}); + +test("Save version: the versions menu lists it; E opens the bench in place and Back returns", async ({ page }) => { + await page.goto(urls.workspaceHref(P)); + await page.locator("[data-ws-versions] > summary").click(); + await expect(page.locator('[data-ws-version="v1"]')).toHaveCount(0); + await page.locator("[data-ws-versions] [data-save-version]").click(); + await expect(page.locator("[data-ws-versions] [data-save-version-said]")).toContainText("saved as v1"); + await expect(page.locator('[data-ws-version="v1"]')).toBeVisible({ timeout: 15_000 }); + await expect(page.locator('[data-ws-version-open="v1"]')).toHaveAttribute("href", urls.openInDraftHref(P, "v1")); + await expect(page.locator("[data-ws-draft]")).toHaveAttribute("data-ws-draft", "v1"); + await page.keyboard.press("Escape"); + + // E: the clip on the full bench, in place; the workspace stays mounted under it. + await page.locator('[data-ws-block="c01"]').click(); + await page.locator("body").press("e"); + await expect(page.locator('[data-cut-app-bench="c01"] [data-bench-shell="clip"]')).toBeVisible({ timeout: 20_000 }); + await expect(page.locator("[data-cut-app-play]")).toHaveAttribute("data-cut-app-play", "hidden"); + await page.locator("[data-back-to-play]").click(); + await expect(page.locator("[data-cut-app-play]")).toHaveAttribute("data-cut-app-play", "shown"); + await expect(page).toHaveURL(new RegExp(`/projects/${P}(\\?|$)`)); +}); + +test("the piece page's tabs stay at ?tab=; the Overview is written out", async ({ page }) => { + await page.goto(urls.projectHref(P, { tab: "overview" })); + await expect(page.locator("[data-workspace]")).toHaveCount(0); + await expect(page.locator("[data-piece-tabs]")).toHaveAttribute("data-piece-tabs", "overview"); + // ...and the piece page's own Workspace link goes back to it. + await expect(page.locator("[data-primary-workspace]")).toHaveAttribute("href", urls.workspaceHref(P)); +});