From 1350df5256bc59c932080fe6cde37475634216b3 Mon Sep 17 00:00:00 2001 From: bailey <74082460+bmjcoding@users.noreply.github.com> Date: Mon, 23 Nov 2026 21:06:03 -0600 Subject: [PATCH 1/3] RunTimeline: the window's top edge fades the tail row it cuts (DECISIONS 337) The one finished tail row at depth 2 or deeper that the window's top edge cuts through its words carries data-cut and --_cut (its visible height, read from layout), set by edge() at the end of measure, at the start of onScroll, when a roll lands and on focus in and out. A mask in that row's own box fades it from transparent at the edge to opaque at its bottom. The selector is the guard: tail closed, no roll in flight, never a depth-1, full, running, waiting or retrying row; a plain cut under more contrast, in forced colours and in print. Foundations and AGENTS.md take the decision's words. Tests 1 to 9 are written, not run (browser tests paused, DECISIONS 330). The RunTimeline bundle limit moves from 41,750 to 42,500 (measured 42,465) and the size table is regenerated. Co-Authored-By: Claude Opus 5.5 --- AGENTS.md | 2 +- docs/foundations.md | 12 +- packages/react/src/run-timeline.tsx | 43 +++- packages/react/src/styles/components.css | 9 + packages/react/test/bundle.test.mjs | 6 +- packages/react/test/export-sizes.json | 10 +- packages/react/test/run-timeline.test.mjs | 282 +++++++++++++++++++++- 7 files changed, 343 insertions(+), 21 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index cf5fe486..67303a68 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -53,7 +53,7 @@ Basalt has one owner (Bailey) and a design panel of two independent design revie exception). - **WCAG 2.2 AA everywhere:** 4.5:1 for text, 3:1 for boundaries, focus and icons, on every surface the pair can appear on, in both themes. One exception, by name: a `RunTimeline`'s tail recedes below 4.5:1 from its second row (`opacity-recede-2` to `-5`), because - the control above it opens the whole record at full contrast (WCAG G174); it never recedes under more contrast or in forced colours. Contrast tests prove it; add a + the control above it opens the whole record at full contrast (WCAG G174); its window's top edge fades only the tail row it cuts, from the second step; it never recedes under more contrast or in forced colours. Contrast tests prove it; add a pair to them when you add a token. - **Borders build structure; shadows are only for things that float.** No gradient borders, glow or bounce, and no press scale beyond Button and IconButton's .98. Hover diff --git a/docs/foundations.md b/docs/foundations.md index a8cc09a3..d2277085 100644 --- a/docs/foundations.md +++ b/docs/foundations.md @@ -20,7 +20,9 @@ of Basalt's accent classes, in its named roles, and nowhere else. full ink and in full, and says when the tail holds a failure. Five things hold it: a step that is running, waiting or retrying never recedes; a failure was said when it happened and stood in full while it was among the newest; everything a tail row says stays in the accessibility tree; under more contrast and in forced colours nothing recedes; and no other text in Basalt uses these - tokens. A test holds each to it. + tokens. The window's top edge fades the one tail row it cuts, from transparent at the edge to opaque at that row's bottom, only when the row is at the + second step or deeper and the edge crosses its words; it never fades a whole row, a row holding focus, or a step that runs, waits or retries, + and under more contrast and in forced colours the edge is a plain cut. A test holds each to it. - **The page is the darkest layer, in both themes.** Anything closer to you is lighter. Light mode never puts a full white page in front of you. - **Borders build structure; shadows exist only for things that float.** @@ -2824,7 +2826,9 @@ Work that runs in stages and reports as it goes: a deploy pipeline, a CI job lis rolls, and nothing after it does). A tail row is `text-xs` at 400, 20px, one line cut with an ellipsis, its mark still 16, no connector and no detail, its ink its depth's step (see Principles); everything it says stays in the accessibility tree. The window is the list's scrolling box, its floor the larger of `keep` and `minRows` rows plus two and a half tail rows, only growing; it draws no scrollbar and is a named tab stop while it - overflows. A roll moves the rows inside the window by transform over `duration-slow` on `ease-out`, the ink stepping on the same clock and + overflows. Its top edge fades the tail row it cuts over the part that shows (from the second step down, only when the edge crosses the row's words; any + other row is cut plainly, and every row while a step rolls in), a still mask on that row + alone, so it moves with the row and never reaches another row or the window's focus ring. A roll moves the rows inside the window by transform over `duration-slow` on `ease-out`, the ink stepping on the same clock and the arrival fading over `duration-base`; past 48 counted rows it lands at once, as `Reflow` does. It follows new steps only while the reader is at its end (read from its geometry), holds still while a control in it has focus or the pointer, and starts at its end. The toggle above it ("Show 5 earlier steps", "Show 5 earlier steps, 1 failed"; open, "Hide earlier steps") holds its line from the first frame and opens the @@ -2846,8 +2850,8 @@ Work that runs in stages and reports as it goes: a deploy pipeline, a CI job lis detail and a roll land at once; an arriving step fades over 100ms; the badge's faces only fade; timers tick. The hold: the ring and braille stand still, the queued mark is still at full, every change of state lands at once, and a stage's own running time hides (see "A page can hold every loop"). A demonstration asks the hold when it would start and does not start under it; a run the reader starts runs whatever the - hold. More contrast: no tail, every stepped-back line at the first step and a failed one full `status-danger`. Forced colours: marks and - words are `currentColor`, nothing steps back, the queued mark is still and connectors are real borders. Print: as the hold, with the tail + hold. More contrast: no tail, every stepped-back line at the first step and a failed one full `status-danger`, and the window's top edge is a plain cut. Forced colours: marks and + words are `currentColor`, nothing steps back, the queued mark is still and connectors are real borders, and the top edge is a plain cut. Print: as the hold, with the tail open. ## Loading in the page's own shape diff --git a/packages/react/src/run-timeline.tsx b/packages/react/src/run-timeline.tsx index 92ad2276..284316f4 100644 --- a/packages/react/src/run-timeline.tsx +++ b/packages/react/src/run-timeline.tsx @@ -24,8 +24,8 @@ declare const process: { env: { NODE_ENV?: string } }; // row older (the one named exception to 4.5:1: the toggle above the tail opens the whole record in full ink). A step that is running, retrying or // waiting never rolls, and nothing after it does. The window is the list's scrolling box: its floor holds `keep` rows and two and a half tail rows // from the first frame and only grows; it follows new steps only while the reader is at its end, holds still while a control in it has focus or the -// pointer, and starts at its end. A roll moves the rows inside the window by transform; past REFLOW_BOUND counted rows it lands at once. Nothing -// here speaks: the run's `RunAnnouncer` does. +// pointer, and starts at its end. A roll moves the rows inside the window by transform; past REFLOW_BOUND counted rows it lands at once. Its top +// edge fades the tail row it cuts, from the second step (DECISIONS 337). Nothing here speaks: the run's `RunAnnouncer` does. export interface RunStepProps { /** The step's state; left out, the step is a finding (its own `mark`), and counts as finished. */ @@ -171,6 +171,7 @@ export function RunTimeline({ label, keep: keepProp, minRows, timeScale = "secon const rolling = React.useRef(0); const atEnd = (el: HTMLElement) => el.scrollHeight - el.scrollTop - el.clientHeight <= 2; const onScroll = () => { + edge(); const el = windowRef.current; if (!el || rolling.current > 0) return; if (lastSet.current !== null && Math.abs(el.scrollTop - lastSet.current) < 1) return; @@ -184,13 +185,40 @@ export function RunTimeline({ label, keep: keepProp, minRows, timeScale = "secon // eslint-disable-next-line react-hooks/exhaustive-deps }, []); + // ---- the top edge (DECISIONS 337): the one finished tail row at depth 2 or deeper that the window's top edge cuts through its words fades + // over the part that shows. Read from layout (offsetTop ignores a roll's transforms): the row, `data-cut` and `--_cut` (its visible height) are + // written on it and taken off the row that had them, or off every row. The stylesheet admits only such a row, outside a roll and outside more + // contrast, forced colours and print; everything else keeps the hard edge. + const marked = React.useRef(undefined); + const pad = React.useRef(0); + const edge = React.useCallback((focus: Element | null = document.activeElement) => { + const el = windowRef.current; + const list = listRef.current; + let next: HTMLElement | undefined; + let length = 0; + if (el && list && tailShown) { + // The row the edge is on: the first whose bottom is below it. It fades only when it is a tail row past the first step (data-depth 2 to 5), + // holds no focus, and the edge crosses its words, not only its padding: more than space-0-5 above the edge and more than space-0-5 below it. + pad.current ||= Number.parseFloat(getComputedStyle(document.documentElement).getPropertyValue("--basalt-space-0-5")) || 0; + const y = el.scrollTop; + next = ([...list.children] as HTMLElement[]).find((li) => li.offsetTop - list.offsetTop + li.offsetHeight > y); + const top = next ? next.offsetTop - list.offsetTop : 0; + length = top + (next?.offsetHeight ?? 0) - y; + if (!next || (next.dataset.depth ?? "1") === "1" || next.contains(focus) || y <= top + pad.current || length <= pad.current) next = undefined; + } + const was = marked.current; + if (was && was !== next) { was.removeAttribute("data-cut"); was.style.removeProperty("--_cut"); } + if (next) { next.setAttribute("data-cut", ""); next.style.setProperty("--_cut", `${length}px`); } + marked.current = next; + }, [tailShown]); + // ---- the floor that only grows: the newest `keep` full rows and two and a half tail rows, measured once a step is taller than a row const grown = React.useRef(0); const [overflows, setOverflows] = React.useState(false); const measure = React.useCallback(() => { const el = windowRef.current; const list = listRef.current; - if (!el || !list || !tailShown) return; + if (!el || !list || !tailShown) { edge(); return; } const full = [...list.children].filter((li) => !li.hasAttribute("data-tail")).slice(-(keep as number)); const rows = full.reduce((sum, li) => sum + (li as HTMLElement).offsetHeight, 0); // The floor's own rows and a tail row from their tokens (a row: text-sm's line and space-2 twice, and a second line under 640px of the @@ -206,7 +234,8 @@ export function RunTimeline({ label, keep: keepProp, minRows, timeScale = "secon if (want > grown.current) { grown.current = want; el.style.setProperty("--_grown", `${want}px`); } setOverflows(el.scrollHeight > el.clientHeight + 1); toEnd(); - }, [tailShown, keep, toEnd, floorRows]); + edge(); + }, [tailShown, keep, toEnd, floorRows, edge]); // ---- the roll: where each row was drawn before this change, read before React writes the DOM const shape = `${steps.length}:${rolled}:${open}`; @@ -275,7 +304,7 @@ export function RunTimeline({ label, keep: keepProp, minRows, timeScale = "secon if (!flying.current.delete(animation)) return; if (!roll) return; rolling.current -= 1; - if (rolling.current === 0) { windowRef.current?.removeAttribute("data-rolling"); toEnd(); } + if (rolling.current === 0) { windowRef.current?.removeAttribute("data-rolling"); toEnd(); edge(); } }; animation.addEventListener("finish", done); animation.addEventListener("cancel", done); @@ -301,8 +330,8 @@ export function RunTimeline({ label, keep: keepProp, minRows, timeScale = "secon const holdFor = { onPointerOver: (event: React.PointerEvent) => { const was = held(); hovered.current = controlOf(event.target); if (was && !held()) { toEnd(); release(); } }, onPointerLeave: () => { hovered.current = null; if (!held()) { toEnd(); release(); } }, - onFocus: (event: React.FocusEvent) => { focused.current = controlOf(event.target); }, - onBlur: (event: React.FocusEvent) => { focused.current = windowRef.current?.contains(event.relatedTarget as Node | null) ? controlOf(event.relatedTarget) : null; if (!held()) { toEnd(); release(); } }, + onFocus: (event: React.FocusEvent) => { focused.current = controlOf(event.target); edge(event.target as Element); }, + onBlur: (event: React.FocusEvent) => { focused.current = windowRef.current?.contains(event.relatedTarget as Node | null) ? controlOf(event.relatedTarget) : null; if (!held()) { toEnd(); release(); } edge(event.relatedTarget as Element | null); }, }; const items = steps.map((step, i) => ( diff --git a/packages/react/src/styles/components.css b/packages/react/src/styles/components.css index 24145fce..93a95f35 100644 --- a/packages/react/src/styles/components.css +++ b/packages/react/src/styles/components.css @@ -4660,6 +4660,15 @@ /* Hover and focus lift every tail row to the first step, over duration-fast: a convenience; the toggle is the way back that counts. */ .basalt-run-steps-window:is(:hover, :focus-within) .basalt-run-steps > .basalt-run-step[data-tail] > .basalt-run-step-line { opacity: 1; color: var(--basalt-text-tertiary); transition-duration: var(--basalt-duration-fast); } .basalt-run-steps-window:is(:hover, :focus-within) .basalt-run-steps > .basalt-run-step[data-tail][data-state="failed"] :is(.basalt-run-step-mark, .basalt-run-step-word) { color: color-mix(in srgb, var(--basalt-status-danger) calc(var(--basalt-opacity-recede-danger) * 100%), transparent); } + /* The top edge (DECISIONS 337): the window's top edge fades the one tail row it cuts, over the part that shows (--_cut, measured), from + transparent at the edge to opaque at the row's bottom. The mask is in that row's own box, so it moves with the row and never reaches + another row or the window's focus ring. The selector is the guard: only a finished tail row at depth 2 to 5, with the tail closed and + no roll in flight, whatever the attribute says. A still mask, kept under reduced motion and the hold; under more contrast, in forced + colours and in print the edge is a plain cut. The black only supplies the opaque alpha; no colour paints. */ + .basalt-run-steps-box:not([data-open]) .basalt-run-steps-window:not([data-rolling]) > .basalt-run-steps > .basalt-run-step[data-tail]:not([data-depth="1"])[data-cut] { + mask-image: linear-gradient(to top, var(--basalt-neutral-0), transparent var(--_cut)); + mask-repeat: no-repeat; + } } /* Past REFLOW_BOUND counted rows, under reduced motion and under the hold, a roll lands at once: no colour transition either. */ .basalt-run-steps-window[data-landing] .basalt-run-step-line, :root[data-loops="held"] .basalt-run-step-line { transition: none; } diff --git a/packages/react/test/bundle.test.mjs b/packages/react/test/bundle.test.mjs index 196467c8..23e7e8b6 100644 --- a/packages/react/test/bundle.test.mjs +++ b/packages/react/test/bundle.test.mjs @@ -729,9 +729,11 @@ for (const [name, limit, phosphor] of [["StageMark", 14_500, true], ["StageBadge } // RunTimeline carries its toggle (TextButton, and so Base UI's button and the press wait) and the shared stage parts; StageList does not carry it (above). -test("RunTimeline with RunStep loads Base UI's button and nothing else of Base UI (41,750 bytes at most)", async () => { +// The top edge's fade (DECISIONS 337: the cut row, measured on each scroll, focus and landing) added about 730 bytes: measured 42,465, so the limit is +// 42,500 (it was 41,750). +test("RunTimeline with RunStep loads Base UI's button and nothing else of Base UI (42,500 bytes at most)", async () => { const { bytes, inputs } = await graph("RunTimeline, RunStep"); - assert.ok(bytes < 41_750, `RunTimeline bundle is ${bytes} bytes (limit 41,750)`); + assert.ok(bytes < 42_500, `RunTimeline bundle is ${bytes} bytes (limit 42,500)`); assert.deepEqual(inputs.filter((f) => /cmdk|shiki/.test(f)), []); assert.ok(!inputs.some((f) => /@base-ui\/react\/(esm\/)?(menu|dialog|select|popover|progress|meter|tooltip)\//.test(f)), "an unrelated Base UI part"); }); diff --git a/packages/react/test/export-sizes.json b/packages/react/test/export-sizes.json index f1190009..38d833e4 100644 --- a/packages/react/test/export-sizes.json +++ b/packages/react/test/export-sizes.json @@ -226,7 +226,7 @@ "RunAnnouncer": 448, "RunStage": 21697, "RunStep": 21494, - "RunTimeline": 21843, + "RunTimeline": 22572, "RunTimer": 5645, "RunsGlyph": 3128, "STAGE_WORDS": 149, @@ -426,11 +426,11 @@ "useWaitMark": 303 }, "package": { - "bytes": 909580, - "gzip": 301315 + "bytes": 910464, + "gzip": 301541 }, "styles": { - "bytes": 429096, - "gzip": 55422 + "bytes": 429363, + "gzip": 55491 } } diff --git a/packages/react/test/run-timeline.test.mjs b/packages/react/test/run-timeline.test.mjs index a08b8c10..afa5d44d 100644 --- a/packages/react/test/run-timeline.test.mjs +++ b/packages/react/test/run-timeline.test.mjs @@ -7,9 +7,9 @@ import fs from "node:fs"; import { createRequire } from "node:module"; import { after, before, describe, test } from "node:test"; -import { chromium } from "playwright"; +import { chromium, webkit } from "playwright"; -import { fixturePage, freezeAnimations, launch, settle } from "./support.mjs"; +import { fixturePage, freezeAnimations, launch, pixels, settle } from "./support.mjs"; const axeSource = fs.readFileSync(createRequire(import.meta.url).resolve("axe-core/axe.min.js"), "utf8"); let browser; @@ -532,3 +532,281 @@ describe("the toggle's chevron", () => { assert.ok(seen > 2, `${seen} drawings over 12 frames: a morph passes through between`); }); }); + +// ---- The top edge (DECISIONS 337): the window's top edge fades the one finished tail row at depth 2 or deeper that it cuts through its words, over +// the part that shows (`data-cut` and `--_cut` on that row, a mask in its own box). Tests 1 to 9 of the revised decision. +describe("the top edge", () => { + // The shipped agent run (INC-0042): at its end the failed step is the cut row at depth 3; `passed` swaps it with the deploys step, so a passed + // step is cut and the failure is whole at depth 2 under it. + const SHIPPED = (cut = "failed") => { + const logs = { id: "logs", state: "failed", text: 'Searched logs for "pool timeout"', meta: "Timed out after 10 s" }; + const deploys = { id: "deploys", state: "success", text: "Listed deploys of payments-api", meta: "4f2a1c0 at 14:02", ms: 800 }; + return [ + { id: "read", state: "success", text: "Read deploy/payments-api.yaml", meta: "84 lines", ms: 700 }, + { id: "p99", state: "success", text: "Queried p99 latency · payments-api · 2 h", meta: "p99 1.8 s since 14:05", ms: 1400 }, + ...(cut === "failed" ? [logs, deploys] : [deploys, logs]), + { id: "finding", word: "Finding", text: "Connection pool exhausted after deploy 4f2a1c0", meta: "High confidence" }, + { id: "approve", state: "success", word: "Approved by Priya Shah", text: "Roll back payments-api to 4f29e0b", meta: "Medium risk", ms: 2600, detail: "kubectl rollout undo deployment/payments-api -n payments" }, + { id: "rollback", state: "success", text: "Ran kubectl rollout undo deployment/payments-api", meta: "Rolled back to 4f29e0b", ms: 2200 }, + { id: "check", state: "success", text: "Queried p99 latency · last 10 min", meta: "p99 240 ms", ms: 1100 }, + ]; + }; + const POST = { id: "post", state: "running", text: "Posting the summary to #inc-0042" }; + // Five tail rows (depths 5 to 1, 100px), then a running step and four full rows after it, so the window can be scrolled anywhere in the tail + // and onto the running row: [5 tail rows][running][4 full rows], the window's floor three rows and two and a half tail rows. + const DEEP = [1, 2, 3, 4, 5].map((i) => done(i)).concat([{ id: "r", state: "running", text: "Querying latency" }], [7, 8, 9, 10].map((i) => done(i))); + const SIZES = [[1440, 1000], [390, 390]]; + + // What the edge has written and what paints: every row with data-cut (its --_cut and its visible height under the window's top edge), and every + // element on the page whose computed mask is not none. + const edgeState = (page) => page.evaluate(() => { + const win = document.querySelector(".basalt-run-steps-window"); + const top = win?.getBoundingClientRect().top ?? 0; + const rows = [...document.querySelectorAll(".basalt-run-step")]; + return { + cut: rows.filter((li) => li.hasAttribute("data-cut")).map((li) => ({ i: rows.indexOf(li), cut: li.style.getPropertyValue("--_cut"), visible: Math.round((li.getBoundingClientRect().bottom - top) * 100) / 100, depth: li.dataset.depth ?? null, state: li.dataset.state ?? null })), + masked: [...document.querySelectorAll("*")].filter((el) => { const m = getComputedStyle(el).maskImage; return m && m !== "none"; }).map((el) => (el.classList.contains("basalt-run-step") ? rows.indexOf(el) : el.className || el.tagName)), + }; + }); + // The window scrolled by the reader, then the frame after it (the edge runs in the scroll callback). + const scrollTo = async (page, y) => { await page.evaluate((y) => { document.querySelector(".basalt-run-steps-window").scrollTop = y; }, y); await frames(page); }; + // Today's edge on the same page: no mask anywhere. A picture taken with this on is today's, pixel for pixel. + const TODAY = ".basalt-run-step { mask-image: none !important; }"; + const shot = (page, clip) => pixels(page, clip); + const winClip = (page) => page.evaluate(() => { const r = document.querySelector(".basalt-run-steps-window").getBoundingClientRect(); const x = Math.floor(r.left); const y = Math.floor(r.top); return { x, y, width: Math.ceil(r.right) - x, height: Math.ceil(r.bottom) - y }; }); + // The hold stills the running ring and hides its running time, so two pictures of the same frame can be compared. + const hold = async (page) => { await page.evaluate(() => document.documentElement.setAttribute("data-loops", "held")); await frames(page); }; + const withToday = async (page, fn) => { const tag = await page.addStyleTag({ content: TODAY }); try { return await fn(); } finally { await tag.evaluate((el) => el.remove()); await frames(page); } }; + + // 1. + for (const [vw, w] of SIZES) { + for (const theme of ["dark", "light"]) { + for (const cut of ["failed", "passed"]) { + test(`1. at the shipped run's end the cut row has data-cut and --_cut is its visible height, 10px, and nothing else is masked (${vw}, ${theme}, ${cut} cut)`, async () => { + const page = await open(APP({ width: w }), { initial: SHIPPED(cut), width: vw, theme }); + const s = await edgeState(page); + assert.equal(s.cut.length, 1, JSON.stringify(s)); + assert.deepEqual(s.cut[0], { i: 2, cut: "10px", visible: 10, depth: "3", state: cut === "failed" ? "failed" : "success" }); + assert.deepEqual(s.masked, [2], "only the cut row is masked"); + const mask = await page.evaluate(() => getComputedStyle(document.querySelector(".basalt-run-step[data-cut]")).maskImage); + assert.match(mask, /linear-gradient\(to top, .+, (transparent|rgba\(0, 0, 0, 0\)) 10px\)/); + }); + } + } + } + + for (const [mode, options] of [["more contrast", { contrast: "more" }], ["forced colours", { forcedColors: "active" }], ["print", { print: true }]]) { + test(`1. no mask ${mode === "print" ? "in print" : `under ${mode}`}: the top edge is a plain cut`, async () => { + const { print, ...media } = options; + const page = await open(APP({ width: 1000 }), { initial: SHIPPED(), width: 1440, ...media }); + if (print) { await page.emulateMedia({ media: "print" }); await frames(page); } + assert.deepEqual((await edgeState(page)).masked, []); + }); + } + + test("1. no mask with the tail open, and no data-cut left behind", async () => { + const page = await open(APP({ width: 1000 }), { initial: SHIPPED(), width: 1440 }); + assert.equal((await edgeState(page)).cut.length, 1); + await page.locator(".basalt-run-steps-toggle").click(); + await settle(page); + assert.deepEqual(await edgeState(page), { cut: [], masked: [] }); + await page.locator(".basalt-run-steps-toggle").click(); + await settle(page); + assert.equal((await edgeState(page)).cut.length, 1, "closed again, the cut row has its fade"); + }); + + // 2. + for (const theme of ["dark", "light"]) { + test(`2. a running step scrolled 13px above the edge: no data-cut, and its ink is today's (${theme})`, async () => { + const page = await open(APP(), { initial: DEEP, theme }); + await hold(page); + const runningTop = await page.evaluate(() => document.querySelector(".basalt-run-step[data-state=running]").offsetTop - document.querySelector(".basalt-run-steps").offsetTop); + await scrollTo(page, runningTop + 13); + assert.deepEqual(await edgeState(page), { cut: [], masked: [] }); + const ink = () => page.evaluate(() => { const li = document.querySelector(".basalt-run-step[data-state=running]"); const s = getComputedStyle(li.querySelector(".basalt-run-step-sentence")); return [s.color, getComputedStyle(li).maskImage, getComputedStyle(li.querySelector(".basalt-run-step-line")).opacity]; }); + const clip = await winClip(page); + const now = await shot(page, clip); + const today = await withToday(page, () => shot(page, clip)); + assert.deepEqual(now, today, "the window paints today's pixels"); + const [color, mask, opacity] = await ink(); + assert.equal(mask, "none"); + assert.equal(opacity, "1"); + assert.equal(color, await page.evaluate(() => { const p = document.createElement("span"); p.style.color = "var(--basalt-text-primary)"; document.body.append(p); const c = getComputedStyle(p).color; p.remove(); return c; })); + }); + } + + // 3. + test("3. a depth-1 tail row at the edge, or an edge that crosses only a row's padding, has no data-cut", async () => { + const page = await open(APP(), { initial: DEEP }); + // Rows: depth 5 at 0, 4 at 20, 3 at 40, 2 at 60, 1 at 80 (20px each; space-0-5 is 2px). + await scrollTo(page, 90); + assert.deepEqual((await edgeState(page)).cut, [], "depth 1 cut through its words"); + for (const y of [41, 42, 58, 59]) { await scrollTo(page, y); assert.deepEqual((await edgeState(page)).cut, [], `${y}: the edge crosses only the padding`); } + for (const [y, cut] of [[43, "17px"], [50, "10px"], [57, "3px"]]) { await scrollTo(page, y); assert.deepEqual((await edgeState(page)).cut.map((c) => [c.i, c.cut]), [[2, cut]], `${y}`); } + }); + + test("3. a data-cut written by hand on a running row, a full row or a depth-1 row computes to mask none: the selector is the guard", async () => { + const page = await open(APP(), { initial: DEEP }); + const masks = await page.evaluate(() => { + const pick = { running: document.querySelector(".basalt-run-step[data-state=running]"), full: document.querySelector(".basalt-run-step:not([data-tail]):not([data-state=running])"), "depth 1": document.querySelector(".basalt-run-step[data-depth='1']") }; + return Object.fromEntries(Object.entries(pick).map(([k, li]) => { li.setAttribute("data-cut", ""); li.style.setProperty("--_cut", "10px"); return [k, getComputedStyle(li).maskImage]; })); + }); + assert.deepEqual(masks, { running: "none", full: "none", "depth 1": "none" }); + }); + + // 4. + for (const engine of ["chromium", "webkit"]) { + for (const theme of ["dark", "light"]) { + test(`4. the window's +2 ring is its own outline, today's top and side pixels, with the cut row masked; there is no frame (${engine}, ${theme})`, async (t) => { + let b = browser; + if (engine === "webkit") { try { b = await webkit.launch(); } catch { t.skip("WebKit is not installed"); return; } } + try { + const page = await open(APP({ width: 1000 }), { initial: SHIPPED(), width: 1440, theme, b }); + assert.equal(await page.locator(".basalt-run-steps-frame").count(), 0); + await page.locator(".basalt-run-steps-toggle").focus(); + await page.keyboard.press("Tab"); + await settle(page); + const r = await page.evaluate(() => { const w = document.querySelector(".basalt-run-steps-window"); const s = getComputedStyle(w); return { fv: w.matches(":focus-visible"), outline: s.outlineStyle, width: s.outlineWidth, offset: s.outlineOffset, mask: s.maskImage, cut: !!document.querySelector(".basalt-run-step[data-cut]") }; }); + assert.deepEqual(r, { fv: true, outline: "solid", width: "2px", offset: "2px", mask: "none", cut: true }); + // The ring's band: 4px outside the window on the top and the start side. + const box = await winClip(page); + const top = { x: box.x + 8, y: box.y - 4, width: box.width - 16, height: 4 }; + const side = { x: box.x - 4, y: box.y + 8, width: 4, height: box.height - 16 }; + const now = [await shot(page, top), await shot(page, side)]; + const today = await withToday(page, async () => [await shot(page, top), await shot(page, side)]); + assert.deepEqual(now, today); + } finally { if (b !== browser) await b.close(); } + }); + } + } + + // 5. + for (const [name, initial, vw, w] of [["the finding rolls", SHIPPED().slice(0, 7), 390, 390], ["the approval with its detail rolls", SHIPPED(), 1440, 1000]]) { + test(`5. ${name}: the card's bottom moves 0px, no row is masked while it rolls, and on the landing frame the new cut row has its --_cut`, async () => { + const page = await open(APP({ width: w }), { initial, width: vw }); + const bottom = () => page.evaluate(() => document.querySelector("#after").getBoundingClientRect().top); + const was = await bottom(); + const clock = await freezeAnimations(page); + await page.evaluate((s) => window.add(s), POST); + let rolled = false; + for (let t = 0; t < 400; t += 25) { + await clock.advance(25); + const rolling = await page.evaluate(() => document.querySelector(".basalt-run-steps-window").hasAttribute("data-rolling")); + if (rolling) { rolled = true; assert.deepEqual((await edgeState(page)).masked, [], `${t}ms: nothing is masked mid-roll`); } + assert.equal(await bottom(), was, `${t}ms: the card's bottom`); + } + assert.ok(rolled, "the change rolled"); + await clock.thaw(); + await settle(page); + await frames(page); + const s = await edgeState(page); + assert.equal(await bottom(), was); + for (const c of s.cut) assert.ok(Math.abs(Number.parseFloat(c.cut) - c.visible) < 0.5, JSON.stringify(s)); + assert.deepEqual(s.masked, s.cut.map((c) => c.i)); + }); + } + + test("5. under reduced motion the roll lands at once and the band is set on the same frame", async () => { + const page = await open(APP({ width: 1000 }), { initial: SHIPPED().slice(0, 7), width: 1440, reducedMotion: "reduce" }); + // Read in the commit itself (a MutationObserver's callback runs after React's layout effects and before any frame is painted). + const s = await page.evaluate((s) => new Promise((r) => { + const observer = new MutationObserver(() => { observer.disconnect(); r([...document.querySelectorAll(".basalt-run-step")].filter((li) => li.hasAttribute("data-cut")).map((li) => li.style.getPropertyValue("--_cut"))); }); + observer.observe(document.querySelector(".basalt-run-steps"), { childList: true }); + window.add(s); + }), POST); + assert.equal(s.length, 1, "a cut row on the landing commit"); + const settled = await edgeState(page); + assert.deepEqual(s, settled.cut.map((c) => c.cut)); + }); + + // 6. + test("6. focus inside the cut row clears its data-cut; leaving brings it back", async () => { + const page = await open(APP({ width: 1000 }), { initial: SHIPPED(), width: 1440 }); + assert.equal((await edgeState(page)).cut.length, 1); + await page.evaluate(() => document.querySelector(".basalt-run-step[data-cut] .basalt-run-step-sentence").focus({ preventScroll: true })); + await frames(page); + assert.deepEqual(await edgeState(page), { cut: [], masked: [] }); + await page.evaluate(() => document.activeElement.blur()); + await frames(page); + assert.equal((await edgeState(page)).cut.length, 1); + }); + + // 7. + test("7. the window is the same node when the counter first rolls, when keep changes and when the tail opens and closes; its scrollTop and the focus inside it survive", async () => { + const page = await open(APP({ props: "keep={window.KEEP ?? 3}" }), { initial: [1, 2, 3].map((i) => done(i)) }); + await page.evaluate(() => { window.__win = document.querySelector(".basalt-run-steps-window"); document.querySelector(".basalt-run-step-sentence").focus(); window.__focus = document.activeElement; }); + const same = () => page.evaluate(() => ({ node: document.querySelector(".basalt-run-steps-window") === window.__win, focus: document.activeElement === window.__focus, atEnd: (() => { const w = window.__win; return w.scrollHeight - w.scrollTop - w.clientHeight <= 2; })() })); + // The counter first rolls: two steps arrive and the oldest goes into the tail (the toggle's words appear). + await page.evaluate(() => { window.add({ id: "s4", state: "success", text: "Read file 4", meta: "4 lines" }); window.add({ id: "s5", state: "success", text: "Read file 5", meta: "5 lines" }); }); + await settle(page); + assert.equal(await page.locator(".basalt-run-steps-toggle").count(), 1); + assert.deepEqual(await same(), { node: true, focus: true, atEnd: true }, "the counter rolled"); + for (const i of [6, 7, 8]) await page.evaluate((i) => window.add({ id: `s${i}`, state: "success", text: `Read file ${i}`, meta: `${i} lines` }), i); + await settle(page); + await page.evaluate(() => { window.__win.scrollTop = 7; }); + await frames(page); + const top = await page.evaluate(() => window.__win.scrollTop); + await page.evaluate(() => { window.KEEP = 2; window.set((all) => [...all]); }); + await settle(page); + assert.deepEqual({ ...(await same()), atEnd: undefined }, { node: true, focus: true, atEnd: undefined }, "keep changed"); + await page.evaluate(() => { window.KEEP = 3; window.set((all) => [...all]); }); + await settle(page); + assert.equal(await page.evaluate(() => window.__win.scrollTop), top, "its scrollTop is kept"); + for (const click of [1, 2]) { await page.locator(".basalt-run-steps-toggle").click(); await settle(page); assert.equal((await same()).node, true, `toggle ${click}`); } + assert.deepEqual(page.errors, []); + }); + + // 8. + test("8. with 17px of a 20px tail row showing, --_cut is 17px and the row below is pixel-identical to today's", async () => { + const page = await open(APP(), { initial: DEEP }); + await hold(page); + await scrollTo(page, 43); + const s = await edgeState(page); + assert.deepEqual(s.cut.map((c) => [c.i, c.cut, c.visible]), [[2, "17px", 17]]); + const clip = await page.evaluate(() => { const r = document.querySelectorAll(".basalt-run-step")[3].getBoundingClientRect(); return { x: r.left, y: r.top, width: r.width, height: r.height }; }); + const now = await shot(page, clip); + const today = await withToday(page, () => shot(page, clip)); + assert.deepEqual(now, today); + }); + + // 9. + for (const [vw, w] of SIZES) { + for (const theme of ["dark", "light"]) { + test(`9. a frame painted mid-scroll before the edge runs matches today's outside the marked row: the running row, then a whole failure, arriving at the edge (${vw}, ${theme})`, async () => { + // R: the running row arrives 3px past the edge. F: the jump lands at the end, a passed row cut and the failure whole under it. + for (const [name, initial, to] of [["the running row", DEEP, "running"], ["a whole failure", SHIPPED("passed"), "end"]]) { + const page = await open(APP({ width: w }), { initial, width: vw, theme }); + await hold(page); + await scrollTo(page, 3); + assert.deepEqual((await edgeState(page)).cut.map((c) => [c.i, c.cut]), [[0, "17px"]], `${name}: the first row is marked at 3px`); + // Stop the edge (no scroll callback reaches the window), jump by a Page Down's length or to the end, and paint. + const box = await page.evaluate((to) => { + window.__stop = (e) => e.stopImmediatePropagation(); + document.addEventListener("scroll", window.__stop, true); + const win = document.querySelector(".basalt-run-steps-window"); + const list = win.firstElementChild; + win.scrollTop = to === "running" ? document.querySelector(".basalt-run-step[data-state=running]").offsetTop - list.offsetTop + 3 : win.scrollHeight; + const r = document.querySelector(".basalt-run-step[data-cut]").getBoundingClientRect(); + return { top: r.top, bottom: r.bottom }; + }, to); + await frames(page); + const clip = await winClip(page); + const stale = await shot(page, clip); + const today = await withToday(page, () => shot(page, clip)); + const dpr = await page.evaluate(() => devicePixelRatio); + const width = Math.round(clip.width * dpr); + assert.equal(stale.length % width, 0); + const rowOf = (n) => clip.y + Math.floor(n / width) / dpr; + const differs = stale.map((p, n) => (p.join() === today[n].join() ? null : rowOf(n))).filter((y) => y !== null && !(y >= box.top && y < box.bottom)); + assert.deepEqual(differs, [], `${name}: no pixel differs outside the marked row`); + await page.evaluate(() => { document.removeEventListener("scroll", window.__stop, true); document.querySelector(".basalt-run-steps-window").dispatchEvent(new Event("scroll")); }); + await frames(page); + const settled = await edgeState(page); + assert.ok(settled.cut.every((c) => c.depth !== "1" && c.state !== "running"), JSON.stringify(settled)); + if (to === "end") assert.deepEqual(settled.cut.map((c) => [c.i, c.cut]), [[2, "10px"]], "settled, the new cut row"); + await page.close(); + } + }); + } + } +}); From a8c62c02b4eaf7ce51f0d791a61798f5e3cb9ce5 Mon Sep 17 00:00:00 2001 From: bailey <74082460+bmjcoding@users.noreply.github.com> Date: Mon, 23 Nov 2026 21:07:40 -0600 Subject: [PATCH 2/3] Round 70 walkthrough: the timeline's cut row fades (DECISIONS 337) The shipped agent run at its end, today's edge beside this build's, the failed row and a passed row as the cut row, at 1440 and 390 in both themes, with forced colours and more contrast. Co-Authored-By: Claude Opus 5.5 --- tools/review/round70.tsx | 109 +++++++++++++++++++++++++++++++++++++++ tools/review/rounds.tsx | 2 + 2 files changed, 111 insertions(+) create mode 100644 tools/review/round70.tsx diff --git a/tools/review/round70.tsx b/tools/review/round70.tsx new file mode 100644 index 00000000..658a937e --- /dev/null +++ b/tools/review/round70.tsx @@ -0,0 +1,109 @@ +// Round 70: the timeline's cut-off top row (DECISIONS 337, a light council round). The owner asked for a fade in place of the hard cut and handed it to +// the council ("Council picks"): Opus drafted, Astra checked, Opus decided and revised after the final positions. Built by Opus from the revised decision. +// The build has not been reviewed; the browser tests were written but not run (DECISIONS 330). +// +// Each step draws the shipped agent run twice, at its end: today's edge (main) and this build's. Today's is the same component with the mask taken off +// (the build's only paint is that mask; the attribute and the length it writes are read by nothing else), so the two sides differ only where the build +// does. Side by side from 720, today's above this build's under it. Media states are the build's own emulations. + +import { FlagIcon } from "@phosphor-icons/react/dist/csr/Flag"; +import * as React from "react"; + +import { Card, RunStep, RunTimeline, RunTimer, StageBadge } from "../../packages/react/src/index"; +import type { StageState } from "../../packages/react/src/index"; +import type { Round } from "./rounds"; + +interface Item { id: string; state?: StageState; word?: string; text: React.ReactNode; meta?: string; ms?: number; detail?: string } +const T0 = Date.UTC(2026, 10, 23, 14, 30); +const logs: Item = { id: "logs", state: "failed", text: <>Searched logs for "pool timeout", meta: "Timed out after 10 s", ms: 1500 }; +const deploys: Item = { id: "deploys", state: "success", text: <>Listed deploys of payments-api, meta: "4f2a1c0 at 14:02", ms: 800 }; +/** The run at its end. The failed step is the cut row (depth 3); `passed` swaps it with the deploys step, so a passed step is cut and the failure is whole at depth 2. */ +const run = (cut: "failed" | "passed"): Item[] => [ + { id: "read", state: "success", text: <>Read deploy/payments-api.yaml, meta: "84 lines", ms: 700 }, + { id: "p99", state: "success", text: <>Queried p99 latency · payments-api · 2 h, meta: "p99 1.8 s since 14:05", ms: 1400 }, + ...(cut === "failed" ? [logs, deploys] : [deploys, logs]), + { id: "finding", word: "Finding", text: "Connection pool exhausted after deploy 4f2a1c0", meta: "High confidence" }, + { id: "approve", state: "success", word: "Approved by Priya Shah", text: "Roll back payments-api to 4f29e0b", meta: "Medium risk", ms: 2600, detail: "kubectl rollout undo deployment/payments-api -n payments" }, + { id: "rollback", state: "success", text: <>Ran kubectl rollout undo deployment/payments-api, meta: "Rolled back to 4f29e0b", ms: 2200 }, + { id: "check", state: "success", text: <>Queried p99 latency · last 10 min, meta: "p99 240 ms", ms: 1100 }, +]; + +const head: React.CSSProperties = { display: "flex", flexWrap: "wrap", alignItems: "center", gap: "var(--basalt-space-2) var(--basalt-space-3)", marginBlockEnd: "var(--basalt-space-3)" }; +const title: React.CSSProperties = { margin: 0, font: "var(--basalt-font-weight-medium) var(--basalt-text-sm-size) / var(--basalt-text-sm-line-height) var(--basalt-font-family-sans)" }; +const line: React.CSSProperties = { margin: "0 0 var(--basalt-space-3)", fontSize: "var(--basalt-text-xs-size)", lineHeight: "var(--basalt-text-xs-line-height)", color: "var(--basalt-text-tertiary)" }; +const label: React.CSSProperties = { margin: "0 0 var(--basalt-space-2)", fontSize: "var(--basalt-text-xs-size)", lineHeight: "var(--basalt-text-xs-line-height)", color: "var(--basalt-text-secondary)" }; + +function Agent({ cut, today }: { cut: "failed" | "passed"; today: boolean }) { + let t = T0; + return ( +
+

{today ? "Today (main): the hard cut" : "This build: the cut row fades"}

+ +
+

INC-0042 · Payments API latency

+ + +
+

Rolled back; p99 is back to 240 ms.

+ + {run(cut).map((x) => { + const start = t; + t += x.ms ?? 0; + return ( + {x.detail} : undefined}> + {x.text} + + ); + })} + +
+
+ ); +} + +function Pair({ state }: { state: string }) { + const cut = state.startsWith("passed") ? "passed" : "failed"; + return ( +
+ {/* Today's edge: the build's one paint taken off, scoped to the left card. */} + + + +
+ ); +} + +const DECISIONS = [ + "The window's top edge fades the one tail row it cuts, over exactly the part that shows: transparent at the edge, opaque at the row's bottom (--_cut, its visible height, measured; 10px at the run's end). Nothing whole is ever faded.", + "Only a finished tail row at the second step or deeper (depth 2 to 5), only when the edge crosses its words (more than space-0-5 of it shows and more than space-0-5 is above), never a row holding focus, never while a step rolls in. Anything else at the top keeps today's hard cut.", + "The mask is on that row alone, so it moves with the row: a scroll frame painted before the component measures can misplace the fade only inside that one row. The stylesheet's selector is the guard, so no attribute can mask a running, waiting or retrying step, a full row or a depth-1 row.", + "The window keeps its own +2 focus ring (no mask is on it, no frame around it). Reduced motion and the hold keep the fade (it is still); more contrast, forced colours and print are a plain cut, and so is an open tail or keep={false}.", + "Where the failure is the cut row its red fragment dissolves into the edge; where it is whole (the passed-cut case) it keeps its muted red, untouched. The toggle still says \"Show 5 earlier steps, 1 failed\".", + "Not reviewed after the build. Tests 1 to 9 of the decision are written and not run (browser tests are paused, DECISIONS 330).", +]; +const TRY = [ + "Compare the two cards' top edges: the left is today's, the right this build's.", + "Scroll the right card's window: the fade follows the row the edge cuts, and goes when that row is depth 1, a full step or only its padding is cut.", + "Tab to the window: its ring is today's. Open the tail: no fade.", +]; + +export const ROUND_70: Round = { + id: "70", + title: "The timeline's cut-off top row (DECISIONS 337)", + reviewed: false, + summary: + "RunTimeline's window now fades the tail row its top edge cuts, from the second step, in place of the hard cut (the owner: \"this might look better if we fade the top of that last row rather than the hard cut off\", then \"Council picks\"). Decided by a light council round (Opus drafted, Astra checked, Opus decided and revised after the positions); built by Opus; not reviewed after the build; the browser tests are written and not run. Each step shows the shipped agent run at its end, today's edge beside this build's, at 1440 and 390 in both themes, with forced colours and more contrast.", + steps: [ + { + id: "failed-cut", + name: "The agent run at its end", + intro: "The run's end: by default the failed step (depth 3) is the row the window's top edge cuts; in the passed state a passed step is, and the failure is whole under it. Today's on the left (above on a phone), this build's on the right.", + decisions: DECISIONS, + tryIt: TRY, + states: ["passed", "forced-colours", "more-contrast"], + widths: [1440, 390], + height: 1200, + demo: ({ state }) => , + }, + ], +}; diff --git a/tools/review/rounds.tsx b/tools/review/rounds.tsx index 544f0e2f..1af4e9af 100644 --- a/tools/review/rounds.tsx +++ b/tools/review/rounds.tsx @@ -133,6 +133,7 @@ import { ROUND_64 } from "./round64"; import { ROUND_65 } from "./round65"; import { ROUND_67 } from "./round67"; import { ROUND_68 } from "./round68"; +import { ROUND_70 } from "./round70"; export interface Step { id: string; @@ -706,3 +707,4 @@ ROUNDS.push(ROUND_65); // Round 66 is left for diagram batch B (claude/diagrams-b), building beside this one. ROUNDS.push(ROUND_67); ROUNDS.push(ROUND_68); +ROUNDS.push(ROUND_70); From 375d55bcaae1d6d109aa61a5fea8113cc2de7d1f Mon Sep 17 00:00:00 2001 From: bailey <74082460+bmjcoding@users.noreply.github.com> Date: Mon, 23 Nov 2026 21:11:22 -0600 Subject: [PATCH 3/3] RunTimeline top edge tests: Astra's review of a8c62c02 Test 5 reads the landing in the task that takes data-rolling away and asserts one marked row, its band (10px and 4px at 1440) and its mask. Test 9's reference takes the mask off the box, the window and everything in it, checks the jump landed where it says, and checks the first row stayed marked through both pictures. Test 2 checks the 13px offset took, test 4 samples a ring pixel against the focus colour, and test 7 checks the 7px scroll after each keep change and a keep={false} round trip. Written, not run (browser tests paused, DECISIONS 330). Co-Authored-By: Claude Opus 5.5 --- packages/react/test/run-timeline.test.mjs | 71 ++++++++++++++++++----- 1 file changed, 55 insertions(+), 16 deletions(-) diff --git a/packages/react/test/run-timeline.test.mjs b/packages/react/test/run-timeline.test.mjs index afa5d44d..cdc1b5e1 100644 --- a/packages/react/test/run-timeline.test.mjs +++ b/packages/react/test/run-timeline.test.mjs @@ -570,8 +570,9 @@ describe("the top edge", () => { }); // The window scrolled by the reader, then the frame after it (the edge runs in the scroll callback). const scrollTo = async (page, y) => { await page.evaluate((y) => { document.querySelector(".basalt-run-steps-window").scrollTop = y; }, y); await frames(page); }; - // Today's edge on the same page: no mask anywhere. A picture taken with this on is today's, pixel for pixel. - const TODAY = ".basalt-run-step { mask-image: none !important; }"; + // Today's edge on the same page: no mask on the timeline's box, its window or anything in it, so a stale mask on the window (the decision as first + // written) would show as a difference too. A picture taken with this on is today's, pixel for pixel. + const TODAY = ".basalt-run-steps-box, .basalt-run-steps-box * { mask-image: none !important; }"; const shot = (page, clip) => pixels(page, clip); const winClip = (page) => page.evaluate(() => { const r = document.querySelector(".basalt-run-steps-window").getBoundingClientRect(); const x = Math.floor(r.left); const y = Math.floor(r.top); return { x, y, width: Math.ceil(r.right) - x, height: Math.ceil(r.bottom) - y }; }); // The hold stills the running ring and hides its running time, so two pictures of the same frame can be compared. @@ -622,6 +623,7 @@ describe("the top edge", () => { await hold(page); const runningTop = await page.evaluate(() => document.querySelector(".basalt-run-step[data-state=running]").offsetTop - document.querySelector(".basalt-run-steps").offsetTop); await scrollTo(page, runningTop + 13); + assert.equal(await page.evaluate(() => { const w = document.querySelector(".basalt-run-steps-window"); return Math.round(w.getBoundingClientRect().top - document.querySelector(".basalt-run-step[data-state=running]").getBoundingClientRect().top); }), 13, "the running row is 13px above the edge"); assert.deepEqual(await edgeState(page), { cut: [], masked: [] }); const ink = () => page.evaluate(() => { const li = document.querySelector(".basalt-run-step[data-state=running]"); const s = getComputedStyle(li.querySelector(".basalt-run-step-sentence")); return [s.color, getComputedStyle(li).maskImage, getComputedStyle(li.querySelector(".basalt-run-step-line")).opacity]; }); const clip = await winClip(page); @@ -675,18 +677,39 @@ describe("the top edge", () => { const now = [await shot(page, top), await shot(page, side)]; const today = await withToday(page, async () => [await shot(page, top), await shot(page, side)]); assert.deepEqual(now, today); + // And the ring is drawn: the middle of the top band's ring row (offset 2, width 2: the band's first two CSS rows; this samples its second, 3px above the window) is the focus colour. + const focus = await page.evaluate(() => { const p = document.createElement("span"); p.style.color = "var(--basalt-border-focus)"; document.body.append(p); const c = getComputedStyle(p).color.match(/[\d.]+/g).slice(0, 3).map(Number); p.remove(); return c; }); + const dpr = await page.evaluate(() => devicePixelRatio); + const ring = now[0][Math.floor(dpr) * Math.round(top.width * dpr) + Math.round((top.width * dpr) / 2)]; + assert.ok(ring.every((c, i) => Math.abs(c - focus[i]) <= 3), `the ring pixel ${ring} is the focus colour ${focus}`); } finally { if (b !== browser) await b.close(); } }); } } - // 5. - for (const [name, initial, vw, w] of [["the finding rolls", SHIPPED().slice(0, 7), 390, 390], ["the approval with its detail rolls", SHIPPED(), 1440, 1000]]) { + // 5. Both landings at 1440, where no full row wraps (the decision's fixtures: the finding lands with the failed row cut at depth 3, 10px; the + // approval and its detail land with a passed row cut at depth 5, 4px). The landing is read in the task that ends the roll: a MutationObserver's + // callback runs straight after the handler that takes data-rolling away, before any scroll callback could repair a missing update. + for (const [name, initial, expected] of [["the finding rolls", SHIPPED().slice(0, 7), { cut: "10px", depth: "3", state: "failed" }], ["the approval with its detail rolls", SHIPPED(), { cut: "4px", depth: "5", state: "success" }]]) { test(`5. ${name}: the card's bottom moves 0px, no row is masked while it rolls, and on the landing frame the new cut row has its --_cut`, async () => { - const page = await open(APP({ width: w }), { initial, width: vw }); + const page = await open(APP({ width: 1000 }), { initial, width: 1440 }); const bottom = () => page.evaluate(() => document.querySelector("#after").getBoundingClientRect().top); const was = await bottom(); const clock = await freezeAnimations(page); + await page.evaluate(() => { + const win = document.querySelector(".basalt-run-steps-window"); + let seen = false; + window.__landed = new Promise((resolve) => { + const observer = new MutationObserver(() => { + if (win.hasAttribute("data-rolling")) { seen = true; return; } + if (!seen) return; + observer.disconnect(); + const top = win.getBoundingClientRect().top; + resolve([...document.querySelectorAll(".basalt-run-step")].filter((li) => li.hasAttribute("data-cut")).map((li) => ({ cut: li.style.getPropertyValue("--_cut"), visible: Math.round((li.getBoundingClientRect().bottom - top) * 100) / 100, depth: li.dataset.depth, state: li.dataset.state, mask: getComputedStyle(li).maskImage }))); + }); + observer.observe(win, { attributes: true, attributeFilter: ["data-rolling"] }); + }); + }); await page.evaluate((s) => window.add(s), POST); let rolled = false; for (let t = 0; t < 400; t += 25) { @@ -696,13 +719,15 @@ describe("the top edge", () => { assert.equal(await bottom(), was, `${t}ms: the card's bottom`); } assert.ok(rolled, "the change rolled"); + const landed = await page.evaluate(() => window.__landed); + assert.equal(landed.length, 1, `one marked row on the landing: ${JSON.stringify(landed)}`); + const [row] = landed; + assert.deepEqual({ cut: row.cut, depth: row.depth, state: row.state }, expected); + assert.ok(Math.abs(Number.parseFloat(row.cut) - row.visible) < 0.5, `the band is the row's visible height: ${JSON.stringify(row)}`); + assert.match(row.mask, new RegExp(`linear-gradient\\(to top, .+ ${row.cut}\\)`), "its mask paints on the landing"); await clock.thaw(); await settle(page); - await frames(page); - const s = await edgeState(page); assert.equal(await bottom(), was); - for (const c of s.cut) assert.ok(Math.abs(Number.parseFloat(c.cut) - c.visible) < 0.5, JSON.stringify(s)); - assert.deepEqual(s.masked, s.cut.map((c) => c.i)); }); } @@ -745,14 +770,22 @@ describe("the top edge", () => { await settle(page); await page.evaluate(() => { window.__win.scrollTop = 7; }); await frames(page); - const top = await page.evaluate(() => window.__win.scrollTop); - await page.evaluate(() => { window.KEEP = 2; window.set((all) => [...all]); }); + const top = () => page.evaluate(() => window.__win.scrollTop); + assert.equal(await top(), 7, "the reader's scroll took"); + for (const keep of [2, 3]) { + await page.evaluate((keep) => { window.KEEP = keep; window.set((all) => [...all]); }, keep); + await settle(page); + assert.deepEqual({ ...(await same()), atEnd: undefined }, { node: true, focus: true, atEnd: undefined }, `keep changed to ${keep}`); + assert.equal(await top(), 7, `its scrollTop is kept at keep ${keep}`); + } + for (const click of [1, 2]) { await page.locator(".basalt-run-steps-toggle").click(); await settle(page); assert.equal((await same()).node, true, `toggle ${click}`); } + // keep={false} is the whole record with no window (the shipped rule, above): the window goes, and comes back clean, at its end, with a toggle. + await page.evaluate(() => { window.KEEP = false; window.set((all) => [...all]); }); await settle(page); - assert.deepEqual({ ...(await same()), atEnd: undefined }, { node: true, focus: true, atEnd: undefined }, "keep changed"); + assert.equal(await page.locator(".basalt-run-steps-window, .basalt-run-steps-toggle-line").count(), 0, "keep={false}: no window"); await page.evaluate(() => { window.KEEP = 3; window.set((all) => [...all]); }); await settle(page); - assert.equal(await page.evaluate(() => window.__win.scrollTop), top, "its scrollTop is kept"); - for (const click of [1, 2]) { await page.locator(".basalt-run-steps-toggle").click(); await settle(page); assert.equal((await same()).node, true, `toggle ${click}`); } + assert.deepEqual(await page.evaluate(() => { const w = document.querySelector(".basalt-run-steps-window"); return [!!w, w.scrollHeight - w.scrollTop - w.clientHeight <= 2, !!document.querySelector(".basalt-run-steps-toggle"), document.querySelectorAll(".basalt-run-step[data-cut]").length <= 1]; }), [true, true, true, true], "back to keep 3"); assert.deepEqual(page.errors, []); }); @@ -786,9 +819,14 @@ describe("the top edge", () => { const win = document.querySelector(".basalt-run-steps-window"); const list = win.firstElementChild; win.scrollTop = to === "running" ? document.querySelector(".basalt-run-step[data-state=running]").offsetTop - list.offsetTop + 3 : win.scrollHeight; - const r = document.querySelector(".basalt-run-step[data-cut]").getBoundingClientRect(); - return { top: r.top, bottom: r.bottom }; + window.__marked = document.querySelector(".basalt-run-step[data-cut]"); + const r = window.__marked.getBoundingClientRect(); + const w = win.getBoundingClientRect(); + const running = document.querySelector(".basalt-run-step[data-state=running]"); + return { top: r.top, bottom: r.bottom, arriving: running ? Math.round(w.top - running.getBoundingClientRect().top) : null, atEnd: win.scrollHeight - win.scrollTop - win.clientHeight <= 1 }; }, to); + if (to === "running") assert.equal(box.arriving, 3, `${name}: the running row is 3px past the edge`); + else assert.equal(box.atEnd, true, `${name}: the jump landed at the end`); await frames(page); const clip = await winClip(page); const stale = await shot(page, clip); @@ -799,6 +837,7 @@ describe("the top edge", () => { const rowOf = (n) => clip.y + Math.floor(n / width) / dpr; const differs = stale.map((p, n) => (p.join() === today[n].join() ? null : rowOf(n))).filter((y) => y !== null && !(y >= box.top && y < box.bottom)); assert.deepEqual(differs, [], `${name}: no pixel differs outside the marked row`); + assert.deepEqual(await page.evaluate(() => [window.__marked.hasAttribute("data-cut"), document.querySelectorAll(".basalt-run-step[data-cut]").length, window.__marked === document.querySelectorAll(".basalt-run-step")[0]]), [true, 1, true], `${name}: the first row stayed marked through both pictures (the edge did not run)`); await page.evaluate(() => { document.removeEventListener("scroll", window.__stop, true); document.querySelector(".basalt-run-steps-window").dispatchEvent(new Event("scroll")); }); await frames(page); const settled = await edgeState(page);