Compare commits

..
Author SHA1 Message Date
Brent Vatne aa3665cb51 Merge remote-tracking branch 'origin/main' into devin/1792350000-max-sessions 2026-10-18 21:34:53 -07:00
Brent Vatne 2701d9bb0e capture.maxSessions defaults to 5, a typical plan's simulators, and may sit below the number of targets
Two per target asked an account for ten simulators at once for five targets. Unset, the ceiling is now 5 and each
target's share is floor(5 / targets), leftovers to foldables only: one target 5, two 2 each, five 1 each. A ceiling
below the number of targets (2 on a starter plan with an iOS and an Android target) gives each target one session,
and only that many target jobs run at once: config:targets reports maxParallel, the review, compare and baseline
workflows set their capture matrix's max-parallel from it, and a local review limits its targets the same way.
2026-10-18 21:34:48 -07:00
Brent VatneandDevin AI a90ed766df capture.maxSessions: a review-wide session ceiling, spent on separate light/dark sessions when that pays
- capture.maxSessions: a review-wide session ceiling and how a target's job shares it
- runCiMap: appearancePass names one session's share of the appearance passes
- appearancePass keeps its pass slots aligned and skips the health check of a secondary-only run
- A secondary-only appearancePass run is complete when its own @scheme frames are
- Merge a side's appearance-pass exports; after-capture stops per-pass sessions too
- capture:review divides capture.maxSessions over the targets and splits a side's appearance passes across sessions
- Test the export merge; document capture.maxSessions
- capture:baseline shares capture.maxSessions too; one helper runs a side's passes
- capture:baseline takes its target's share of capture.maxSessions
- Session state files stop in head, base order as before
- Appearance passes of one side share a build and repack
- Merged appearance exports recombine outcomes as one run's passes do
- capture.maxSessions is at least one session per target; docs carry the measured split
- Test two iOS targets for the maxSessions floor
- A capture waiting on a shared build starts its EAS session meanwhile
- Docs: the measured split side is 4:26 with the shared repack
- Plan a side's appearance sessions from eas config in a child, not the review's process
- A dark-only session keeps its pass's outcomes for the merge, which keeps open gaps partial
- A capture waiting on a shared build starts its session once the build is repacking
- ci:after-capture and the composite action stop per-appearance sessions; platforms count toward maxSessions
- capture.maxSessions stays out of the capture recipe: how many sessions capture the evidence does not change it
- Test that a split side merges into the export one run makes, each appearance a verified sibling

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-10-18 21:23:48 -07:00
Brent VatneandDevin AI 69d52661c1 Faster capture: parallel compare with early-abort region search, one Argent bridge thread per capture
- Compare screenshots in parallel and stop region-shift searches early
- Keep one Argent bridge on a worker thread for the whole capture
- Region shifts: stop a whole-pixel fit only past the margin of the fit a tie chooses, so the search finds what the exhaustive one did
- Compare: a pair whose turn comes after the budget is not started, every review in a process shares one limit, and a region-shift worker that fails measures on the calling thread
- Argent bridge thread: start again when the session's environment changes, stop serving when it crashes, and wait on the value it compared
- Argent bridge thread: recordings run per command in the session's directory, and a screenshot is taken only from a file that is a PNG or JPEG

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-10-18 21:23:48 -07:00
13 changed files with 229 additions and 497 deletions

No files matched your search

+1 -1
View File
@@ -50,7 +50,7 @@
"test:node": "node --test test/node/*.test.mjs",
"test:hosting": "npm --prefix viewer-host run typecheck && npm --prefix viewer-host test",
"test:viewer:artifacts": "node --test test/browser/artifact-report.browser.mjs test/browser/artifact-cache.browser.mjs",
"test:viewer:browser": "node --test test/browser/screenshot-image.browser.mjs test/browser/swipe-outlines.browser.mjs test/browser/split-outlines.browser.mjs test/browser/inspector-notes.browser.mjs test/browser/inspector-variants.browser.mjs test/browser/inspector-source-navigation.browser.mjs test/browser/map-edge-presentation.browser.mjs test/browser/local-ci-view.browser.mjs test/browser/report-viewer.browser.mjs",
"test:viewer:browser": "node --test test/browser/screenshot-image.browser.mjs test/browser/swipe-outlines.browser.mjs test/browser/inspector-notes.browser.mjs test/browser/inspector-variants.browser.mjs test/browser/inspector-source-navigation.browser.mjs test/browser/map-edge-presentation.browser.mjs test/browser/local-ci-view.browser.mjs test/browser/report-viewer.browser.mjs",
"test:viewer:e2e": "npm run test:viewer:browser && playwright test",
"typecheck": "tsc -p tsconfig.json --noEmit && tsc -p viewer/tsconfig.json --noEmit",
"lint": "eslint .",
@@ -188,11 +188,12 @@ test("Map keeps selected elevated arrows behind screenshots without rendering na
await expect(sourceHitArea.locator("title")).toHaveText("Source navigation\npush · app/home.tsx");
await page.mouse.move(1320, 30);
const dimmedComparisons = [];
// Only the Changes filter dims a screen; a selection fades nothing.
for (const presentation of ["muted"]) {
for (const presentation of ["muted", "selection"]) {
await page.evaluate(mode => {
const profile = document.querySelector('.react-flow__node[data-id="profile"]');
const canvas = document.querySelector(".map-canvas");
profile.classList.toggle("graph-node-muted", mode === "muted");
canvas.classList.toggle("screen-selection-active", mode === "selection");
}, presentation);
const dimmedWithArrows = await profileImage.screenshot({ animations: "disabled" });
await page.locator(".map-surface .react-flow__edges").evaluate(node => { node.style.visibility = "hidden"; });
@@ -215,6 +216,7 @@ test("Map keeps selected elevated arrows behind screenshots without rendering na
}
await page.evaluate(() => {
document.querySelector('.react-flow__node[data-id="profile"]').classList.remove("graph-node-muted");
document.querySelector(".map-canvas").classList.remove("screen-selection-active");
});
await page.getByRole("button", { name: "Open Profile", exact: true }).click();
assert.equal(await page.evaluate(() => window.selectedScreen), "profile");
+1 -9
View File
@@ -155,7 +155,7 @@ test("Compare steps through changed screens and their changed areas", { timeout:
// A changed screen opens the same review in the Inspector on every canvas: Compare at sidebar
// size. CI compares the images pixel for pixel, so /games's four CI regions read as changed
// areas, outlined on After; Before keeps the same outlines unseen until one is hovered on After.
// areas, outlined at the same place on both sides.
await openChangedScreen(page, /, Modified, \/games$/);
const inspector = page.locator(".right-panel");
const review = inspector.getByRole("region", { name: "Changes in /games" });
@@ -166,8 +166,6 @@ test("Compare steps through changed screens and their changed areas", { timeout:
await expect.poll(() => outlineCount("after")).toBeGreaterThan(0);
const areas = await outlineCount("after");
assert.equal(await outlineCount("before"), areas);
await expect(review.locator('[data-side="after"] .visual-change-outlines')).toHaveClass(/linked/);
await expect(review.locator('[data-side="before"] .visual-change-outlines')).toHaveClass(/ghost/);
// Esc closes the Inspector; the selection stays, a second Esc clears it.
const selected = page.locator(".map-canvas .react-flow__node-screen.selected");
await page.keyboard.press("Escape");
@@ -227,12 +225,6 @@ test("Compare steps through changed screens and their changed areas", { timeout:
await expect.poll(() => compare.locator(`[data-side="${side}"] img`).first()
.evaluate(image => image.naturalWidth)).toBe(402);
}
// Hovering an outline on After lights the same area on Before, and only that one.
await compare.locator('[data-side="after"] .visual-change-outline').nth(1).hover();
await expect(compare.locator('[data-side="before"] .visual-change-outline.hovered')).toHaveCount(1);
await expect(compare.locator('[data-side="before"] .visual-change-outline').nth(1)).toHaveClass(/hovered/);
await page.mouse.move(0, 0);
await expect(compare.locator(".visual-change-outline.hovered")).toHaveCount(0);
// J and K step through the changed areas; Esc clears the highlight.
const outlines = compare.locator('[data-side="after"] .visual-change-outline');
-145
View File
@@ -1,145 +0,0 @@
import assert from "node:assert/strict";
import test from "node:test";
import { fileURLToPath } from "node:url";
import { chromium, expect } from "@playwright/test";
import { PNG } from "pngjs";
import { createBrowserVite } from "../helpers/browser-vite.mjs";
function png(width, height, color) {
const image = new PNG({ width, height });
for (let index = 0; index < image.data.length; index += 4) image.data.set([...color, 255], index);
return `data:image/png;base64,${PNG.sync.write(image).toString("base64")}`;
}
// Split over one screen with two changed areas and a card that moved 40% of the width right (at 60% in After, so
// at 20% in Before), and a second screen with one changed area elsewhere. The status bar CI left out is a foldable's
// rail pill, not a band across the top. Keys stand in for the controller's, so the pointer can stay where it is:
// 1 and 2 pick Split and Swipe, o toggles the outlines, n steps to the other screen, j selects the first area.
const entry = `
import { useState, useEffect } from "react";
import { createRoot } from "react-dom/client";
import { CompareStage } from "/src/components/compare/compare-section.tsx";
import "/src/styles.css";
const screens = [
[
{ x: 10, y: 20, width: 30, height: 20, share: 40, regionCount: 1 },
{ x: 60, y: 60, width: 30, height: 20, share: 30, regionCount: 1, move: { x: 40, y: 0, amount: { x: 400, y: 0 }, unit: "px" } },
{ x: 55, y: 20, width: 35, height: 20, share: 30, regionCount: 1 },
],
[{ x: 10, y: 85, width: 20, height: 10, share: 100, regionCount: 1 }],
];
const systemRegions = [{ kind: "status-bar", x: 40, y: 0, width: 20, height: 4 }];
function Harness() {
const [mode, setMode] = useState("split");
const [outlines, setOutlines] = useState(true);
const [screen, setScreen] = useState(0);
const [active, setActive] = useState();
useEffect(() => {
const onKey = (event) => {
if (event.key === "1") setMode("split");
if (event.key === "2") setMode("swipe");
if (event.key === "o") setOutlines((shown) => !shown);
if (event.key === "n") setScreen((index) => 1 - index);
if (event.key === "j") setActive(0);
};
window.addEventListener("keydown", onKey);
return () => window.removeEventListener("keydown", onKey);
}, []);
const diff = { id: "s" + screen, status: "modified", beforeScreenshot: window.before, afterScreenshot: window.after };
return (
<div className={"compare-stage mode-" + mode} style={{ width: 800, height: 500, display: "flex" }}>
<CompareStage key="stage" mode={mode} diff={diff} title="Share" areas={screens[screen]} activeArea={active}
showOutlines={outlines} systemRegions={systemRegions} overlay={null} flipSide="after" onFlip={() => {}}
swipePosition={50} onSwipePosition={() => {}} aspect={1} onAspect={() => {}} />
</div>
);
}
createRoot(document.getElementById("root")).render(<Harness />);
`;
async function openSplit(t, contextOptions = {}) {
const vite = await createBrowserVite(t, {
configFile: false, root: fileURLToPath(new URL("../../viewer", import.meta.url)),
logLevel: "error", esbuild: { jsx: "automatic" },
plugins: [{
name: "split-outlines-fixture",
resolveId: id => id === "/__split-outlines.tsx" ? id : undefined,
load: id => id === "/__split-outlines.tsx" ? entry : undefined,
configureServer(server) {
server.middlewares.use((request, response, next) => {
if (new URL(request.url, "http://localhost").pathname !== "/") return next();
response.setHeader("Content-Type", "text/html");
response.end('<!doctype html><html><body style="margin:0"><div id="root"></div><script type="module" src="/__split-outlines.tsx"></script></body></html>');
});
},
}],
server: { host: "127.0.0.1", port: 0 },
});
await vite.listen();
const browser = await chromium.launch({ headless: true });
t.after(() => browser.close());
const page = await browser.newPage({ viewport: { width: 900, height: 600 }, ...contextOptions });
const errors = [];
page.on("pageerror", error => errors.push(error.message));
t.after(() => assert.deepEqual(errors, []));
await page.addInitScript(images => Object.assign(window, images), { before: png(100, 100, [240, 240, 240]), after: png(100, 100, [230, 230, 230]) });
await page.goto(`http://127.0.0.1:${vite.httpServer.address().port}/`);
const outline = (side, index) => page.locator(`[data-side="${side}"] .visual-change-outline`).nth(index);
await expect(outline("after", 0)).toBeVisible();
return { page, outline };
}
const opacity = locator => locator.evaluate(element => Number(getComputedStyle(element).opacity));
test("Split keeps the ignored system regions the report names on both sides", { timeout: 30_000 }, async t => {
const { page } = await openSplit(t);
for (const side of ["before", "after"]) {
const band = page.locator(`[data-side="${side}"] .visual-system-region-status-bar`);
await expect(band).toHaveCount(1);
const [frame, box] = await Promise.all([page.locator(`[data-side="${side}"] .compare-frame`).boundingBox(), band.boundingBox()]);
assert.ok(Math.abs((box.x - frame.x) - 0.4 * frame.width) < 1, `${side}'s band sits where the report puts the rail pill`);
assert.ok(Math.abs(box.width - 0.2 * frame.width) < 1);
}
});
test("Split hides Before's changed outlines but keeps a moved area where its content was", { timeout: 30_000 }, async t => {
const { page, outline } = await openSplit(t);
await expect.poll(() => opacity(outline("before", 0))).toBe(0);
await expect.poll(() => opacity(outline("before", 1))).toBe(1);
await expect(outline("before", 1).locator(".visual-change-measure")).toHaveCount(1);
const frame = side => page.locator(`[data-side="${side}"] .compare-frame`).boundingBox();
const [before, after, beforeFrame, afterFrame] = await Promise.all([outline("before", 1).boundingBox(), outline("after", 1).boundingBox(),
frame("before"), frame("after")]);
assert.ok(Math.abs(((after.x - afterFrame.x) - (before.x - beforeFrame.x)) - 0.4 * afterFrame.width) < 1, "Before's moved outline is back by the move");
});
test("A hover is dropped when the screen, the mode or the outlines change under the pointer", { timeout: 30_000 }, async t => {
const { page, outline } = await openSplit(t);
const hovered = page.locator(".visual-change-outline.hovered");
for (const [away, back] of [["2", "1"], ["o", "o"], ["n", "n"]]) {
await outline("after", 0).hover();
await expect(outline("before", 0)).toHaveClass(/hovered/);
// The outline goes from under the pointer, which then moves off the frame before it comes back.
await page.keyboard.press(away);
await page.mouse.move(0, 0);
await page.keyboard.press(back);
await expect(outline("after", 0)).toBeVisible();
await expect(hovered).toHaveCount(0);
}
});
test("The hovered outline on After stays lit while another area is selected", { timeout: 30_000 }, async t => {
const { page, outline } = await openSplit(t);
await page.keyboard.press("j");
await outline("after", 2).hover();
await expect.poll(() => opacity(outline("after", 2))).toBe(1);
await expect.poll(() => opacity(outline("before", 2))).toBe(1);
await expect.poll(() => opacity(outline("after", 1))).toBe(0.35);
});
test("A screen without hover keeps Before's outlines, as it cannot reveal one", { timeout: 30_000 }, async t => {
const { page, outline } = await openSplit(t, { hasTouch: true, isMobile: true });
assert.equal(await page.evaluate(() => matchMedia("(hover: none)").matches), true);
await expect.poll(() => opacity(outline("before", 0))).toBe(1);
await expect.poll(() => opacity(outline("before", 2))).toBe(1);
});
+150 -185
View File
@@ -80,121 +80,136 @@ async function expectAutoHideScrollbar(
await expect(scrollbar).toHaveCSS("opacity", "0");
}
/** The Map's canvas tokens as computed colours, to compare with what a ring or an edge draws. */
async function mapCanvasColors(page: Page) {
return page.locator(".map-canvas").evaluate((canvas) => {
const resolve = (token: string) => {
const probe = document.createElement("span");
probe.style.color = `var(${token})`;
canvas.append(probe);
const color = getComputedStyle(probe).color;
probe.remove();
return color;
};
return {
accent: resolve("--accent"),
accentStrong: resolve("--accent-strong"),
hoverRing: resolve("--hover-ring"),
quiet: resolve("--border-subtle"),
hoverEdge: resolve("--tertiary"),
};
});
}
/** The screenshot frame's box shadow on a Map card: where its ring is drawn. */
function mapCardRing(node: Locator) {
return node.locator(".screen-node-image :is(img, .image-placeholder)").first()
.evaluate((frame) => getComputedStyle(frame).boxShadow);
}
/** Each Map edge's id, ends and drawn stroke. */
function mapEdgeStrokes(page: Page) {
return page.locator(".map-canvas .react-flow__edge").evaluateAll((edges) => edges.map((edge) => {
const match = /^Edge from (.+) to (.+)$/.exec(edge.getAttribute("aria-label") ?? "");
const path = getComputedStyle(edge.querySelector(".transition-edge-path")!);
return {
id: edge.getAttribute("data-id") ?? "",
from: match?.[1] ?? "",
to: match?.[2] ?? "",
stroke: path.stroke,
strokeWidth: Number.parseFloat(path.strokeWidth),
};
}));
}
/**
* A selected Map screen is ringed in the accent, its route turns accent and its transitions stay
* accent while every other transition quiets to a hairline. No card fades. Hovering another card
* rings it in grey beside the selection, with no tooltip, and darkens its own transitions;
* hovering the selected card keeps its accent ring.
*/
async function expectMapSelectionRing(page: Page) {
const screens = page.locator(".map-canvas .react-flow__node-screen:not(.canvas-node-exit)");
const selected = page.locator(".map-canvas .react-flow__node-screen.selected:not(.canvas-node-exit)");
async function expectMapScreenSelectionDimming(
page: Page,
options: { hoverTargetCount?: number } = {},
) {
const screens = page.locator(
".map-canvas .react-flow__node-screen:not(.canvas-node-exit)",
);
const selected = page.locator(
".map-canvas .react-flow__node-screen.selected:not(.canvas-node-exit)",
);
const dimmed = page.locator(
".map-canvas .react-flow__node-screen:not(.selected):not(.canvas-node-exit)",
);
await expect(page.locator(".map-canvas")).toHaveClass(/screen-selection-active/);
await expect(selected).toHaveCount(1);
const selectedId = (await selected.getAttribute("data-id"))!;
const colors = await mapCanvasColors(page);
await expect.poll(() => mapCardRing(selected)).toContain(colors.accent);
await expect(selected.locator(".screen-node-title")).toHaveCSS("color", colors.accentStrong);
// Nothing fades: every card and its frame stay at full strength.
await expect.poll(() => screens.evaluateAll((nodes) => nodes.every((node) => (
getComputedStyle(node).opacity === "1"
&& getComputedStyle(node.querySelector(":scope > .canvas-active-frame")!).opacity === "1"
&& ["", "1"].includes(getComputedStyle(node.querySelector(":scope > .canvas-active-frame")!).getPropertyValue("--map-card-opacity").trim())
)))).toBe(true);
const unselected = page.locator(".map-canvas .react-flow__node-screen:not(.selected):not(.canvas-node-exit)");
expect(await unselected.evaluateAll((nodes, accent) => nodes.every((node) => (
!getComputedStyle(node.querySelector(".screen-node-image :is(img, .image-placeholder)")!).boxShadow.includes(accent)
)), colors.accent)).toBe(true);
// The selection's transitions are accent and a little heavier; every other one is a hairline.
const edges = await mapEdgeStrokes(page);
const incident = edges.filter((edge) => edge.from === selectedId || edge.to === selectedId);
const others = edges.filter((edge) => edge.from !== selectedId && edge.to !== selectedId);
expect(incident.length).toBeGreaterThan(0);
expect(others.length).toBeGreaterThan(0);
expect(incident.every((edge) => edge.stroke === colors.accent && edge.strokeWidth === 2.5)).toBe(true);
expect(others.every((edge) => edge.stroke === colors.quiet && edge.strokeWidth === 1)).toBe(true);
await expect(page.locator(".map-canvas .react-flow__edge.graph-edge-quiet")).toHaveCount(others.length);
await expect.poll(async () => dimmed.count()).toBe((await screens.count()) - 1);
expect(await screens.evaluateAll(nodes => nodes.every(node => getComputedStyle(node).opacity === "1"))).toBe(true);
// Hover a card that shares no edge with the selection but has edges of its own.
await expect.poll(async () => {
const [selectedOpacity, dimmedOpacity] = await Promise.all([
selected.locator(":scope > .canvas-active-frame").evaluate((node) => Number.parseFloat(getComputedStyle(node).opacity)),
dimmed.first().locator(":scope > .canvas-active-frame").evaluate((node) => Number.parseFloat(getComputedStyle(node).opacity)),
]);
return dimmedOpacity < selectedOpacity;
}).toBe(true);
// Selection focus moves the canvas before hover affordances are exercised. Choose hover
// targets only after that flight settles so a node cannot move underneath the minimap between
// the hit-test below and Playwright's pointer action.
await expect(page.locator(".map-canvas.canvas-focus-animating")).toHaveCount(0);
const neighbours = new Set(incident.flatMap((edge) => [edge.from, edge.to]));
const hoverId = await unselected.evaluateAll((nodes, excluded) => nodes.find((node) => {
const id = node.getAttribute("data-id") ?? "";
const target = node.querySelector(".screen-screenshot-target")!.getBoundingClientRect();
const hit = document.elementFromPoint(target.left + target.width / 2, target.top + target.height / 3);
const linked = [...document.querySelectorAll(".map-canvas .react-flow__edge")].some((edge) => (
(edge.getAttribute("aria-label") ?? "").split(/ (?:from|to) /).slice(1).includes(id)
const hoverableDimmedIndexes = await dimmed.evaluateAll((nodes) => nodes.flatMap((node, index) => {
const bounds = node.getBoundingClientRect();
const centerTarget = document.elementFromPoint(
bounds.left + bounds.width / 2,
bounds.top + bounds.height / 2,
);
const nodeId = node.getAttribute("data-id");
const hasDirectEdge = nodeId !== null && [...document.querySelectorAll(".react-flow__edge")]
.some((edge) => {
const label = edge.getAttribute("aria-label") ?? "";
return label.startsWith(`Edge from ${nodeId} to `) || label.endsWith(` to ${nodeId}`);
});
return centerTarget !== null && node.contains(centerTarget) && hasDirectEdge ? [index] : [];
}));
const hoverTargetCount = options.hoverTargetCount ?? 1;
expect(hoverableDimmedIndexes.length).toBeGreaterThanOrEqual(hoverTargetCount);
// A card fades through its frame's --map-card-opacity (the node itself stays opaque over the
// connectors). The property is not animated, so it reads what hover asks for at once.
const cardOpacities = () => screens.evaluateAll((nodes) => Object.fromEntries(nodes.map((node) => [
node.getAttribute("data-id") ?? "",
getComputedStyle(node.querySelector(":scope > .canvas-active-frame")!).getPropertyValue("--map-card-opacity").trim(),
])));
const restingOpacities = await cardOpacities();
let lastHoverTarget = dimmed.nth(hoverableDimmedIndexes[0]!);
for (const index of hoverableDimmedIndexes.slice(0, hoverTargetCount)) {
const hoverTarget = dimmed.nth(index);
const hoverTargetId = await hoverTarget.getAttribute("data-id");
expect(hoverTargetId).not.toBeNull();
await hoverTarget.hover();
await expect.poll(() => hoverTarget.locator(":scope > .canvas-active-frame").evaluate(
(node) => Number.parseFloat(getComputedStyle(node).opacity),
)).toBe(1);
await expect(hoverTarget).toHaveCSS("filter", "none");
const hoverSubject = page.locator(
".map-canvas .react-flow__node-screen.graph-node-hover-subject",
);
await expect(hoverSubject).toHaveCount(1);
await expect(hoverSubject).toHaveAttribute("data-id", hoverTargetId!);
const allEdges = page.locator(".map-canvas .react-flow__edge");
const directEdgeCount = await allEdges.evaluateAll((edges, nodeId) => edges.filter((edge) => {
const label = edge.getAttribute("aria-label") ?? "";
return label.startsWith(`Edge from ${nodeId} to `) || label.endsWith(` to ${nodeId}`);
}).length, hoverTargetId!);
expect(directEdgeCount).toBeGreaterThan(0);
// The hovered screen and every screen it shares an edge with are marked related; nothing on
// the map recedes while hovering, so the only changes are the subject ring, the incident
// edges and the neighbours' frames.
const neighbourIds = await allEdges.evaluateAll((edges, nodeId) => {
const ids = new Set<string>([nodeId]);
for (const edge of edges) {
const match = /^Edge from (.+) to (.+)$/.exec(edge.getAttribute("aria-label") ?? "");
if (!match) continue;
if (match[1] === nodeId) ids.add(match[2]!);
if (match[2] === nodeId) ids.add(match[1]!);
}
return [...ids].sort();
}, hoverTargetId!);
const brightNodes = page.locator(
".map-canvas .react-flow__node-screen.graph-node-hover-related",
);
await expect.poll(() => brightNodes.evaluateAll((nodes) => (
nodes.map((node) => node.getAttribute("data-id") ?? "").sort()
))).toEqual(neighbourIds);
const unrelated = page.locator(
".map-canvas .react-flow__node-screen:not(.graph-node-hover-related):not(.canvas-node-exit)",
);
const unrelatedIds = await unrelated.evaluateAll((nodes) => nodes.map((node) => node.getAttribute("data-id") ?? ""));
expect(unrelatedIds.length).toBeGreaterThan(0);
const hoverOpacities = await cardOpacities();
expect(unrelatedIds.map((id) => hoverOpacities[id])).toEqual(unrelatedIds.map((id) => restingOpacities[id]));
expect(await unrelated.evaluateAll((nodes) => nodes.every((node) => getComputedStyle(node).filter === "none"))).toBe(true);
await expect(page.locator(".map-canvas .screen-open-hint:visible")).toHaveCount(0);
const activeEdges = page.locator(
".map-canvas .react-flow__edge.graph-edge-hover-related",
);
await expect(activeEdges).toHaveCount(directEdgeCount);
const activeEdgeLabels = await activeEdges.evaluateAll((edges) => (
edges.map((edge) => edge.getAttribute("aria-label") ?? "")
));
return !excluded.includes(id) && linked && hit !== null && node.contains(hit);
})?.getAttribute("data-id"), [...neighbours]);
expect(hoverId).toBeTruthy();
const hovered = page.locator(`.map-canvas .react-flow__node-screen[data-id="${hoverId}"]`);
const target = hovered.locator(".screen-screenshot-target");
const box = (await target.boundingBox())!;
await target.hover({ position: { x: box.width / 2, y: box.height / 3 } });
await expect(hovered).toHaveClass(/graph-node-hover-subject/);
await expect.poll(() => mapCardRing(hovered)).toContain(colors.hoverRing);
await expect.poll(() => mapCardRing(selected)).toContain(colors.accent);
// Past the tooltip delay, nothing says Open in Inspector.
await page.waitForTimeout(600);
await expect(page.locator(".tooltip")).toHaveCount(0);
// The hovered card's transitions darken to grey; the selection's stay accent; the rest stay quiet.
const hovering = await mapEdgeStrokes(page);
for (const edge of hovering) {
if (edge.from === selectedId || edge.to === selectedId) expect(edge.stroke, edge.id).toBe(colors.accent);
else if (edge.from === hoverId || edge.to === hoverId) expect(edge.stroke, edge.id).toBe(colors.hoverEdge);
else expect(edge.stroke, edge.id).toBe(colors.quiet);
expect(activeEdgeLabels.every((label) => (
label.startsWith(`Edge from ${hoverTargetId} to `)
|| label.endsWith(` to ${hoverTargetId}`)
))).toBe(true);
lastHoverTarget = hoverTarget;
if (index !== hoverableDimmedIndexes.slice(0, hoverTargetCount).at(-1)) {
await page.mouse.move(1, 1);
await page.waitForTimeout(160);
}
}
// Hovering the selected card keeps its accent ring.
const selectedTarget = selected.locator(".screen-screenshot-target");
const selectedBox = (await selectedTarget.boundingBox())!;
await selectedTarget.hover({ position: { x: selectedBox.width / 2, y: selectedBox.height / 3 } });
await expect(selected).toHaveClass(/graph-node-hover-subject/);
await expect.poll(() => mapCardRing(selected)).toContain(colors.accent);
expect(await mapCardRing(selected)).not.toContain(colors.hoverRing);
await expect.poll(() => mapCardRing(hovered)).not.toContain(colors.hoverRing);
await page.mouse.move(1, 1);
await expect.poll(async () => {
const [selectedOpacity, dimmedOpacity] = await Promise.all([
selected.locator(":scope > .canvas-active-frame").evaluate((node) => Number.parseFloat(getComputedStyle(node).opacity)),
lastHoverTarget.locator(":scope > .canvas-active-frame").evaluate((node) => Number.parseFloat(getComputedStyle(node).opacity)),
]);
return dimmedOpacity < selectedOpacity;
}).toBe(true);
}
/** The camera chrome's theme button steps Auto → Dark → Light; press it until the page shows the option. */
@@ -1514,59 +1529,6 @@ test("Esc closes the Inspector first, then deselects; arrows and hjkl walk the m
await expect(selected).toHaveAttribute("data-id", child!);
});
test("Return after the arrow keys opens the screen they reached, not the one clicked before, on the Map and on Screens", async ({ page }) => {
await serveSyntheticWorkspace(page);
const inspector = page.getByRole("complementary", { name: "Inspector panel" });
const accent = await page.evaluate(() => {
const probe = document.createElement("span");
probe.style.color = "#0588f0";
document.body.append(probe);
const color = getComputedStyle(probe).color;
probe.remove();
return color;
});
// Map: the click leaves the keyboard focus on the first screen's button; Return must not press it.
await page.goto("/map?screen=area-0-screen-1");
const selected = page.locator(".map-canvas .react-flow__node-screen.selected");
await expect(selected).toHaveAttribute("data-id", "area-0-screen-1");
await expectMapCameraAtRest(page);
await selected.locator(".screen-screenshot-target").click();
await expect(inspector).toBeVisible();
await page.keyboard.press("Escape");
await expect(inspector).toBeHidden();
await page.keyboard.press("ArrowDown");
await expect(selected).not.toHaveAttribute("data-id", "area-0-screen-1");
const reached = (await selected.getAttribute("data-id"))!;
// The ring went with the selection.
const ring = (id: string) => page.locator(`.map-canvas .react-flow__node-screen[data-id="${id}"] .screen-node-image img`)
.evaluate((image) => getComputedStyle(image).boxShadow);
await expect.poll(() => ring(reached)).toContain(accent);
await expect.poll(() => ring("area-0-screen-1")).not.toContain(accent);
const reachedPath = (await selected.locator(".screen-node-title").textContent())!;
await page.keyboard.press("Enter");
await expect(inspector).toBeVisible();
await expect(selected).toHaveAttribute("data-id", reached);
await expect(page).toHaveURL(new RegExp(`screen=${reached}`));
await expect(inspector).toContainText(reachedPath);
// Screens: the same walk, from a clicked card.
await chooseCanvasView(page, "Screens");
const grid = page.getByRole("main", { name: "Screens" });
await grid.getByRole("button", { name: /^All/ }).click();
const ids = await grid.locator(".screens-grid .screens-cell")
.evaluateAll((elements) => elements.map((element) => element.getAttribute("data-screen-id")!));
await grid.locator(`.screens-cell[data-screen-id="${ids[0]}"] .screen-screenshot-target`).click();
await expect(inspector).toBeVisible();
await page.keyboard.press("Escape");
await expect(inspector).toBeHidden();
await page.keyboard.press("ArrowRight");
await expect(grid.locator(`.screens-cell[data-screen-id="${ids[1]}"] .screen-screenshot-card`)).toHaveClass(/selected/);
await page.keyboard.press("Enter");
await expect(inspector).toBeVisible();
await expect(page).toHaveURL(new RegExp(`screen=${ids[1]}`));
});
test("a held key stops when Esc, another key or a dialog takes the keyboard; a menu keeps its own arrows", async ({ page }) => {
await page.goto("/map");
const selected = page.locator(".map-canvas .react-flow__node-screen.selected");
@@ -1993,7 +1955,7 @@ test("fits the visible Map screenshot frame to the capture's intrinsic ratio", a
const selected = page.locator(".map-canvas .react-flow__node-screen.selected");
const image = selected.locator(".screen-node-image img");
await expect(image).toBeVisible();
await expectMapSelectionRing(page);
await expectMapScreenSelectionDimming(page);
const pathStyle = await selected.locator(".screen-node-title").evaluate((element) => {
const style = getComputedStyle(element);
const bounds = element.getBoundingClientRect();
@@ -2080,18 +2042,13 @@ async function hoverableMapScreen(candidates: Locator, room = 80) {
return candidates.nth(index);
}
test("hovering a Map screen fades nothing, rings it in grey, darkens its transitions and shows no tooltip", async ({ page }) => {
test("hovering a Map screen fades nothing and says Open in Inspector in a tooltip below the card that keeps to it", async ({ page }) => {
await serveSyntheticWorkspace(page);
await page.goto("/map");
const screens = page.locator(".map-canvas .react-flow__node-screen:not(.canvas-node-exit)");
await expect(screens.first()).toBeVisible();
await expectMapCameraAtRest(page);
const colors = await mapCanvasColors(page);
const resting = await mapCardOpacities(page);
// With nothing selected no transition is quiet: they keep their own colours.
await expect(page.locator(".map-canvas .react-flow__edge.graph-edge-quiet")).toHaveCount(0);
const restingEdges = await mapEdgeStrokes(page);
expect(restingEdges.some((edge) => edge.stroke === colors.quiet)).toBe(false);
// A screen at one end of a secondary transition, which rests a little faded.
const secondaryEnds = await page.locator(".map-canvas .react-flow__edge.graph-edge-secondary").evaluateAll((edges) => (
[...new Set(edges.flatMap((edge) => /^Edge from (.+) to (.+)$/.exec(edge.getAttribute("aria-label") ?? "")?.slice(1) ?? []))]
@@ -2100,34 +2057,42 @@ test("hovering a Map screen fades nothing, rings it in grey, darkens its transit
const node = await hoverableMapScreen(page.locator(
secondaryEnds.map((id) => `.map-canvas .react-flow__node-screen[data-id="${id}"]`).join(", "),
));
const id = (await node.getAttribute("data-id"))!;
const target = node.locator(".screen-screenshot-target");
// No native title tooltip either; the heading names the screen.
const heading = node.locator(".screen-node-heading");
// The tooltip says what a click does; no native title tooltip joins it.
await expect(target).not.toHaveAttribute("title");
// Near the card's top, so the pan below keeps the pointer on it.
const box = (await target.boundingBox())!;
await target.hover({ position: { x: box.width / 2, y: box.height / 4 } });
await expect(page.locator(".connection-canvas-surface.canvas-hovering")).toHaveCount(1);
await expect.poll(() => mapCardRing(node)).toContain(colors.hoverRing);
expect(await mapCardRing(node)).not.toContain(colors.accent);
// Past the tooltip delay, nothing covers or labels the card.
await page.waitForTimeout(600);
await expect(page.locator(".tooltip")).toHaveCount(0);
await expect(page.locator(".map-canvas .screen-open-hint:visible")).toHaveCount(0);
const tooltip = page.locator(".tooltip", { hasText: "Open in Inspector" });
await expect(tooltip).toBeVisible();
const related = await page.locator(".map-canvas .react-flow__node-screen.graph-node-hover-related")
.evaluateAll((nodes) => nodes.map((element) => element.getAttribute("data-id") ?? ""));
const unrelated = Object.keys(resting).filter((other) => !related.includes(other));
const unrelated = Object.keys(resting).filter((id) => !related.includes(id));
expect(unrelated.length).toBeGreaterThan(0);
const hovering = await mapCardOpacities(page);
expect(unrelated.map((other) => hovering[other])).toEqual(unrelated.map((other) => resting[other]));
// The transitions into and out of it come fully up in a darker grey, the secondary one too; the rest stay as they were.
expect(unrelated.map((id) => hovering[id])).toEqual(unrelated.map((id) => resting[id]));
await expect(page.locator(".map-canvas .screen-open-hint:visible")).toHaveCount(0);
// The transitions into and out of it come fully up, the secondary one too.
const incident = page.locator(".map-canvas .react-flow__edge.graph-edge-hover-related");
await expect(incident.and(page.locator(".graph-edge-secondary"))).not.toHaveCount(0);
await expect.poll(() => incident.evaluateAll((edges) => edges.every((edge) => getComputedStyle(edge).opacity === "1"))).toBe(true);
const hoverEdges = await mapEdgeStrokes(page);
for (const edge of hoverEdges) {
if (edge.from === id || edge.to === id) expect(edge.stroke, edge.id).toBe(colors.hoverEdge);
else expect(edge.stroke, edge.id).toBe(restingEdges.find((resting) => resting.id === edge.id)!.stroke);
}
// The route heads a Map card, so the bubble sits below the screenshot, clear of both.
const clearance = async () => {
const [bubble, card, title] = await Promise.all([tooltip.boundingBox(), target.boundingBox(), heading.boundingBox()]);
if (!bubble || !card || !title) return Number.NaN;
const headingOverlap = bubble.y < title.y + title.height && title.y < bubble.y + bubble.height
&& bubble.x < title.x + title.width && title.x < bubble.x + bubble.width;
return headingOverlap ? -1 : bubble.y - (card.y + card.height);
};
expect(await clearance()).toBeGreaterThan(0);
// Panning with the pointer still on the card moves the card by transform; the bubble follows it
// rather than staying behind over the screenshot.
const before = await target.boundingBox();
await page.mouse.wheel(0, 40);
await expect.poll(async () => (await target.boundingBox())!.y).toBeLessThan(before!.y - 10);
await expect.poll(clearance).toBeGreaterThan(0);
});
test("hovering a Map screen the Changes filter muted brings it and its neighbours back up, and nothing else", async ({ page }) => {
@@ -31,8 +31,8 @@ export type ScreenScreenshotCardProps = {
loading?: "eager" | "lazy";
leading?: ReactNode;
trailing?: ReactNode;
/** Say "Open in Inspector" in a tooltip over the screenshot (Screens). The Map's cards go without. */
inspectorTooltip?: boolean;
/** Where the "Open in Inspector" tooltip sits: away from the route heading, which is above the screenshot on the Map. */
tooltipPlacement?: "top" | "bottom";
/** Short lines about the screen, inside the card after its screenshot (Screens: how it was reached, where else it changed). */
note?: ReactNode;
onClick: MouseEventHandler<HTMLButtonElement>;
@@ -92,10 +92,10 @@ export function ScreenScreenshotCard(props: ScreenScreenshotCardProps) {
free of block children. */}
<span className="screen-screenshot-slot">
{props.leading}
{/* On Screens, with a pointer, what a click does is said once in the shared tooltip after
its usual delay; the selected screen is already in the Inspector. The button has no
title of its own, so no native tooltip joins it; the heading names the screen. */}
<Tooltip label="Open in Inspector" placement="top" disabled={props.inspectorTooltip === false || Boolean(props.selected)}>
{/* With a pointer, what a click does is said once, zoom-independent, in the shared tooltip
after its usual delay; the selected screen is already in the Inspector. The button has
no title of its own, so no native tooltip joins it; the heading names the screen. */}
<Tooltip label="Open in Inspector" placement={props.tooltipPlacement ?? "top"} disabled={Boolean(props.selected)}>
<button
type="button"
className="screen-screenshot-target"
@@ -12,8 +12,7 @@ export type TransitionEdgeData = {
transitionCount: number;
active: boolean;
primary: boolean;
/** Another screen is selected: the edge steps back to a hairline, so the selection's own stand out. */
quiet: boolean;
dimmed: boolean;
sourceOnly?: boolean;
previousSource?: boolean;
tooltip?: string;
@@ -40,10 +39,9 @@ export function TransitionEdge(props: EdgeProps<TransitionGraphEdge>) {
curvature: 0.24,
});
const emphasized = Boolean(props.data?.active || props.selected || hovered);
const quiet = Boolean(props.data?.quiet && !emphasized);
const dimmed = Boolean(props.data?.dimmed && !emphasized);
const stroke = emphasized
? "var(--accent)"
: quiet ? "var(--border-subtle)"
: props.data?.previousSource ? "var(--danger)" : props.data?.primary ? "var(--graph-line)" : "var(--graph-line-soft)";
return (
@@ -68,8 +66,9 @@ export function TransitionEdge(props: EdgeProps<TransitionGraphEdge>) {
style={{
...props.style,
stroke,
strokeWidth: emphasized ? 2.5 : quiet ? 1 : props.data?.primary ? 1.15 : 0.9,
strokeWidth: emphasized ? 2.2 : props.data?.primary ? 1.15 : 0.9,
strokeDasharray: props.data?.sourceOnly ? "6 5" : emphasized || props.data?.primary ? undefined : "4 7",
opacity: dimmed ? 0.12 : 1,
}}
/>
</>
@@ -107,13 +107,6 @@ export function ZoomBridge(props: {
publishZoom(Math.round(zoom * 100) / 100);
}, [props.cameraReady, zoom]);
// What a stroke that must stay legible at any zoom divides by (the Map's selection ring). It
// moves in quarter-octave steps, so a pinch restyles the canvas a few times, not every frame.
const strokeZoom = 2 ** (Math.round(Math.log2(zoom) * 4) / 4);
useEffect(() => {
canvas?.style.setProperty("--canvas-zoom", String(strokeZoom));
}, [canvas, strokeZoom]);
useEffect(() => {
// Re-registering after selection changes publishes the new capability to the zoom menu.
// Reading through getNodes keeps the commands themselves on the latest canvas snapshot.
@@ -468,10 +468,6 @@ export function CompareStage(props: StageProps) {
const { diff } = props;
const before = diff.beforeScreenshot;
const after = diff.afterScreenshot;
const [hoverIndex, setHoverIndex] = useState<number>();
// An outline taken out from under the pointer reports no leave, so another screen, mode or outline
// toggle drops the hover rather than lighting an area the pointer is not on.
useLayoutEffect(() => setHoverIndex(undefined), [props.areas, props.mode, props.showOutlines]);
if (!before && !after) {
const reason = diff.captureNotes?.after ?? diff.captureNotes?.before;
return (
@@ -560,21 +556,6 @@ export function CompareStage(props: StageProps) {
const sides = (["before", "after"] as const).filter((side) => (
side === "before" ? diff.status !== "added" : diff.status !== "removed"
));
// Split outlines the changed areas on After, where the eye lands; Before keeps the same outlines
// unseen, and shows one while its twin on After is hovered or the area is selected (J, K). A moved area keeps
// its outline on Before, where its content was.
// One frame, or no outlines, takes the caller's overlay as the other modes do.
const paired = Boolean(before && after) && props.showOutlines && props.areas.length > 0;
const sideOverlay = (side: "before" | "after"): ReactNode => {
if (!paired) return props.overlay;
return (
<>
<ChangeOutlines changes={props.areas} activeIndex={props.activeArea} hoverIndex={hoverIndex}
reveal={side === "after" ? "linked" : "ghost"} onHover={side === "after" ? setHoverIndex : undefined} />
<SystemRegionBands regions={props.systemRegions} />
</>
);
};
return (
<>
{sides.map((side) => {
@@ -593,7 +574,7 @@ export function CompareStage(props: StageProps) {
) : (
<ScreenshotPlaceholder label={placeholderFor(side, diff.status, diff.captureNotes)} />
)}
{src ? sideOverlay(side) : null}
{src ? props.overlay : null}
</div>
{props.labels === "inside" ? (
<span className={`compare-side-label compare-side-tag ${side}`}>{label}{note}</span>
+1 -14
View File
@@ -18,20 +18,7 @@
background: color-mix(in srgb, var(--modified) 22%, transparent);
box-shadow: 0 0 0 3px color-mix(in srgb, var(--modified) 35%, transparent);
}
.visual-change-outlines.has-active .visual-change-outline:not(.active):not(.hovered) { opacity: 0.35; }
/* Split's pair: linked outlines (After) take the pointer, and the hovered one reads as the selected one
does; ghost outlines (Before) show nothing until their twin is hovered or the area is selected. An area
that only moved keeps its outline on Before, where its content was, and a screen without hover (touch)
keeps them all, as it has no way to reveal one. */
.visual-change-outlines.linked .visual-change-outline { pointer-events: auto; cursor: default; }
.visual-change-outline.hovered { background: color-mix(in srgb, var(--modified) 22%, transparent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--modified) 35%, transparent); }
.visual-change-outline.moved.hovered { background: color-mix(in srgb, var(--moved) 14%, transparent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--moved) 30%, transparent); }
@media (hover: hover) {
.visual-change-outlines.ghost .visual-change-outline:not(.moved) { opacity: 0; transition: opacity 120ms ease, box-shadow 120ms ease, background-color 120ms ease; }
.visual-change-outlines.ghost .visual-change-outline.hovered,
.visual-change-outlines.ghost .visual-change-outline.active { opacity: 1; }
.visual-change-outlines.ghost.has-active .visual-change-outline:not(.active):not(.hovered):not(.moved) { opacity: 0; }
}
.visual-change-outlines.has-active .visual-change-outline:not(.active) { opacity: 0.35; }
/* An area that only moved: dashed and quiet, in the slate of a measurement rather than the orange of a change. */
.visual-change-outline.moved {
border: 1.5px dashed var(--moved);
+2 -16
View File
@@ -15,23 +15,11 @@ import "./visual-diff.css";
export function ChangeOutlines(props: {
changes: readonly VisualChange[];
activeIndex?: number | undefined;
/** The outline under the pointer, on this frame or its twin; drawn as the selected one is. */
hoverIndex?: number | undefined;
/** Reports the outline under the pointer; with it the outlines take the pointer (see `reveal`). */
onHover?: ((index: number | undefined) => void) | undefined;
/**
* How Split pairs its two frames: `linked` outlines (on After) take the pointer and report hovers;
* `ghost` ones (on Before) sit at the same places unseen until one is hovered on After or selected; a moved
* area's stays, where its content was, and a screen without hover shows them all. Without it every outline
* shows, as on a single frame.
*/
reveal?: "all" | "ghost" | "linked";
}) {
const measurements = useMeasurementsShown();
const reveal = props.reveal ?? "all";
return (
<span
className={`visual-change-outlines${props.activeIndex !== undefined ? " has-active" : ""}${reveal !== "all" ? ` ${reveal}` : ""}`}
className={`visual-change-outlines${props.activeIndex !== undefined ? " has-active" : ""}`}
aria-hidden="true">
{props.changes.map((change, index) => {
const rect = outlineRect(change);
@@ -41,9 +29,7 @@ export function ChangeOutlines(props: {
return (
<span
key={index}
className={`visual-change-outline${change.move ? " moved" : ""}${props.activeIndex === index ? " active" : ""}${props.hoverIndex === index ? " hovered" : ""}`}
onPointerEnter={props.onHover ? () => props.onHover!(index) : undefined}
onPointerLeave={props.onHover ? () => props.onHover!(undefined) : undefined}
className={`visual-change-outline${change.move ? " moved" : ""}${props.activeIndex === index ? " active" : ""}`}
style={{
left: back(rect.x, change.move?.x),
top: back(rect.y, change.move?.y),
+19 -34
View File
@@ -31,7 +31,6 @@ import { arrowsOwnedBy, mapKeyDirection, mapKeyEntry, mapKeyTarget, type MapKeyD
import { createKeyHold } from "../../utils/key-hold";
const HOVER_CLEAR_DELAY = 180;
const PRESSABLE = 'button, a, summary, [role="button"]';
const MAP_LAYOUT_REVISION = "flat-v1";
const MAP_FIT_VIEW_OPTIONS = {
padding: 0.04,
@@ -116,8 +115,8 @@ function ScreenNodeCard({ data, selected }: NodeProps<ScreenGraphNode>) {
imageHeight={data.screenshotSize?.imageHeight ?? data.frame.screen.height}
placeholderSize={data.frame.screen}
loading="lazy"
// The ring says which screen is which; a click opening it in the Inspector needs no tooltip.
inspectorTooltip={false}
// The route heads the card, so the tooltip goes below it.
tooltipPlacement="bottom"
leading={<Handle type="target" position={horizontal ? Position.Left : Position.Top} className="graph-handle" />}
trailing={<Handle type="source" position={horizontal ? Position.Right : Position.Bottom} className="graph-handle" />}
onMouseEnter={() => data.onHover(data.screen.id)}
@@ -343,9 +342,8 @@ function projectionElements(
const edges: TransitionGraphEdge[] = structure.groups.map((group) => {
const hierarchyEdge = structure.primaryEdgeKeys.has(group.key);
const connected = group.from === selectedScreenId || group.to === selectedScreenId;
const dimmed = false;
const active = connected;
// While a screen is selected, every other transition quiets to a hairline; cards never fade.
const quiet = Boolean(selectedScreenId) && !connected;
const sourceOnly = group.transitionIds.length === 0 && Boolean(group.sourceEdges?.length);
const previousSource = group.sourceRevision === "baseline";
const removed = previousSource || (!group.synthetic && diff?.screens.get(group.to)?.status === "removed");
@@ -358,26 +356,25 @@ function projectionElements(
const primary = hierarchyEdge;
const stroke = active
? "var(--accent)"
: quiet ? "var(--border-subtle)"
: removed ? "var(--danger)" : primary ? "var(--graph-line)" : "var(--graph-line-soft)";
return {
id: edgeElementId(group.key),
source: group.from,
target: group.to,
type: "transition",
className: `${hierarchyEdge ? "graph-edge-primary" : "graph-edge-secondary"}${sourceOnly ? " graph-edge-source" : ""}${previousSource ? " graph-edge-source-baseline" : ""}${active ? " graph-edge-active" : ""}${quiet ? " graph-edge-quiet" : ""}`,
className: `${hierarchyEdge ? "graph-edge-primary" : "graph-edge-secondary"}${sourceOnly ? " graph-edge-source" : ""}${previousSource ? " graph-edge-source-baseline" : ""}${active ? " graph-edge-active" : ""}${dimmed ? " graph-edge-dimmed" : ""}`,
markerEnd: {
type: MarkerType.ArrowClosed,
width: active || (hierarchyEdge && !quiet) ? 14 : 11,
height: active || (hierarchyEdge && !quiet) ? 14 : 11,
width: active || hierarchyEdge ? 14 : 11,
height: active || hierarchyEdge ? 14 : 11,
color: stroke,
},
style: {
stroke,
strokeWidth: active ? 2.5 : quiet ? 1 : hierarchyEdge ? 1.15 : 0.9,
strokeWidth: active ? 2.2 : hierarchyEdge ? 1.15 : 0.9,
strokeDasharray: !hierarchyEdge && !active && !removed ? "4 7" : undefined,
},
data: { label, transitionCount: group.transitionIds.length, active, primary, quiet, sourceOnly, previousSource, ...(tooltip ? { tooltip } : {}) },
data: { label, transitionCount: group.transitionIds.length, active, primary, dimmed, sourceOnly, previousSource, ...(tooltip ? { tooltip } : {}) },
// React Flow renders a positive edge z-index above root nodes. Keep every connection in
// the base edge layer so selected/highlighted paths still pass behind screen imagery.
zIndex: 0,
@@ -436,7 +433,7 @@ function sameTransitionEdge(a: TransitionGraphEdge, b: TransitionGraphEdge) {
&& a.data?.transitionCount === b.data?.transitionCount
&& a.data?.active === b.data?.active
&& a.data?.primary === b.data?.primary
&& a.data?.quiet === b.data?.quiet;
&& a.data?.dimmed === b.data?.dimmed;
}
function reuseUnchangedElements(
@@ -560,8 +557,7 @@ function ConnectionCanvas(props: MapViewProps) {
}, [applyHover]);
// The arrow keys (or h j k l) walk the map from the selected screen: along an edge in the
// layout's flow, across to the neighbour on the same rank otherwise. With nothing selected they
// enter the map at its edge, as on the Screens page. A held key keeps walking. Return opens the
// selection in the Inspector.
// enter the map at its edge, as on the Screens page. A held key keeps walking.
const { selectedScreenId } = props;
const selectedRef = useRef(selectedScreenId);
selectedRef.current = selectedScreenId;
@@ -572,39 +568,22 @@ function ConnectionCanvas(props: MapViewProps) {
if (!structure) return undefined;
return from ? mapKeyTarget(structure, from, direction) : mapKeyEntry(structure, direction);
};
// A click leaves the keyboard focus on the clicked screen's button, where Return would press it
// and open that screen again. A walk lets go of it, so Return reaches the screen walked to.
const walkTo = (id: string) => {
const focused = document.activeElement;
if (focused instanceof HTMLElement && surfaceRef.current?.contains(focused)) focused.blur();
selectScreen(id);
};
const onKeyDown = (event: KeyboardEvent) => {
hold.interrupt(event);
if (event.repeat && hold.holding(event.code)) { event.preventDefault(); return; }
if (event.defaultPrevented || !shortcutsLive(event) || arrowsOwnedBy(event.target)) return;
if (event.key === "Enter") {
// A focused button or link keeps its own Return; elsewhere on the page it opens the selection.
const target = event.target instanceof Element ? event.target : null;
const selected = selectedRef.current;
if (!selected || event.isComposing || event.metaKey || event.ctrlKey || event.altKey || event.shiftKey) return;
if (target && target !== document.body && (target.closest(PRESSABLE) || !surfaceRef.current?.contains(target))) return;
event.preventDefault();
selectScreen(selected);
return;
}
const direction = mapKeyDirection(event);
if (!direction) return;
if (!structureRef.current) return;
event.preventDefault();
let at = move(direction, selectedRef.current);
if (!at) return;
walkTo(at);
selectScreen(at);
hold.begin(event.code, () => {
const target = move(direction, at);
if (!target) return false;
at = target;
walkTo(target);
selectScreen(target);
return true;
});
};
@@ -657,6 +636,9 @@ function ConnectionCanvas(props: MapViewProps) {
.sort((left, right) => left.depth - right.depth || left.y - right.y || left.x - right.x || left.index - right.index)
.map(({ id }) => id), [layout.nodes]);
const phone = usePhoneLayout();
const selectedScreenVisible = Boolean(
props.selectedScreenId && layout.nodes.some((node) => node.id === props.selectedScreenId),
);
if (props.map.screens.length === 0) {
const blockers = props.map.gaps.filter((gap) => gap.status === "open" && !gap.screenId).map((gap) => gap.message);
return (
@@ -674,7 +656,10 @@ function ConnectionCanvas(props: MapViewProps) {
<div ref={surfaceRef} className="connection-canvas-surface map-surface">
<CanvasStage
ariaLabel="Screen map"
className="map-canvas"
className={[
"map-canvas",
selectedScreenVisible ? "screen-selection-active" : "",
].filter(Boolean).join(" ")}
nodes={layout.nodes}
edges={layout.edges}
nodeTypes={NODE_TYPES}
+40 -53
View File
@@ -110,6 +110,7 @@
/* How far an item the Changes filter does not cover falls back. Low enough to read as
background at a glance, high enough that the canvas keeps its shape. */
--dim-out: 0.35;
--hover-neighbour-frame: color-mix(in srgb, var(--accent) 55%, var(--border-subtle));
--shadow-xs: 0 1px 3px rgba(0, 0, 0, 0.025), 0 1px 2px rgba(0, 0, 0, 0.05);
--shadow-md: 0 10px 20px rgba(0, 0, 0, 0.1), 0 3px 6px rgba(0, 0, 0, 0.05);
@@ -460,8 +461,6 @@ code {
--graph-line-soft: #c5c7ce;
/* One flat fill for a group — no border, no second tone inside it. */
--canvas-group: #f5f5f6;
/* The ring a hovered Map card takes: a step past the border scale, short of the connectors. */
--hover-ring: #b9bbc6;
color: var(--text);
background: var(--screen);
}
@@ -481,7 +480,6 @@ code {
--graph-line: #696e77;
--graph-line-soft: #3f4349;
--canvas-group: #18191b;
--hover-ring: #5a6169;
}
/* The canvas is a fixed map: dragging anywhere pans, while clicking an object selects it. */
.graph-canvas .canvas-tool-pan,
@@ -501,14 +499,27 @@ code {
.graph-canvas .transition-edge-hitarea { cursor: pointer; pointer-events: stroke; }
.graph-canvas .transition-edge-path { transition: stroke 100ms ease, stroke-width 100ms ease, opacity 140ms ease; }
.graph-canvas .graph-edge-secondary { opacity: 0.72; }
.graph-canvas .graph-edge-dimmed { opacity: 0.14; }
.graph-canvas .graph-edge-active { opacity: 1; }
.graph-canvas .react-flow__node { transition: opacity 180ms ease, filter 180ms ease; }
.graph-canvas .canvas-focus-animating .react-flow__node { transition: none; }
/* Focus: what the chosen state does not cover only steps back, so the map is still readable. */
.graph-canvas .react-flow__node.graph-node-muted { opacity: var(--dim-out); --map-card-opacity: var(--dim-out); }
/* Hover never recedes anything, but where the Changes filter has dimmed the map, the hovered
screen and the screens it connects to come back up, with the transitions between them, so the
neighbourhood reads. These come after the dimming rule so the pointer's context wins. */
/* A route-selected screenshot stays visually anchored while the surrounding screenshots recede.
They fade as focus dims them, by opacity alone: a filter would grey the card's opaque backing.
Summary cards retain their normal contrast so the selected screen's semantic context is legible. */
.map-canvas.screen-selection-active .react-flow__node-screen:not(.selected) {
opacity: var(--dim-out);
--map-card-opacity: var(--dim-out);
}
.map-canvas.screen-selection-active .react-flow__node-screen:not(.selected):hover,
.map-canvas.screen-selection-active .react-flow__node-screen:not(.selected):focus-within {
opacity: 1;
--map-card-opacity: 1;
}
/* Hover never recedes anything, but where focus or a selection has already dimmed the map, the
hovered screen and the screens it connects to come back up, with the transitions between them,
so the neighbourhood reads. These come after both dimming rules so the pointer's context wins. */
.connection-canvas-surface.canvas-hovering .react-flow__node-screen.graph-node-hover-related {
opacity: 1;
--map-card-opacity: 1;
@@ -676,7 +687,7 @@ code {
/* Hover and selection draw a 3px ring in the accent colour: the 1px border recoloured plus a 2px
shadow outside it, so the image keeps its size (a thicker border would shrink the picture inside
its box). Changed screens keep their own colour at the same weight: the diff rules below win on
specificity. The Map leaves the border to the status and rings the card from outside instead. */
specificity. */
.screen-node-image:hover img,
.screen-screenshot-card.selected .screen-node-image img { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.screen-node-image:hover > .image-placeholder,
@@ -696,8 +707,8 @@ code {
border-radius: 17px;
pointer-events: none;
}
/* Selection needs no overlay: the Map rings the screenshot and Screens frames the card. The
highlight ring stays for the transient pointer-over state that panels project onto the canvas. */
/* Selection needs no ring: the canvas dims every other screen. The highlight ring stays for the
transient pointer-over state that panels project onto the canvas. */
.canvas-active-frame.is-highlighted::after {
border-color: var(--accent);
box-shadow: 0 0 24px color-mix(in srgb, var(--accent) 24%, transparent);
@@ -712,9 +723,10 @@ code {
pointer-events: none;
}
/* A screen's handles are ports on its frame: they take the frame colour, whether that is the
status colour of a changed screen or the accent of a selected one, and a ring in the canvas
colour keeps them legible as connection points on the border. */
status colour of a changed screen or the accent of a hovered or selected one, and a ring in
the canvas colour keeps them legible as connection points on the border. */
.screen-screenshot-card { --screen-frame: var(--graph-line); }
.screen-screenshot-card:has(.screen-node-image:hover),
.screen-screenshot-card.selected,
.screen-screenshot-card.highlighted { --screen-frame: var(--accent); }
.screen-screenshot-card:is(.diff-added, .diff-modified, .diff-removed) { --screen-frame: var(--diff); }
@@ -726,48 +738,23 @@ code {
opacity: 1;
}
/* A Map card's border is its status alone. Selection rings it from outside instead: an accent
ring past a gap in the canvas colour, outside the status border, with a soft lift; hover draws
the same ring in grey. The ring scales with the canvas, so below a readable zoom its unit grows
to keep it about a screen pixel and a half wide (--canvas-zoom, set by the zoom bridge). */
.map-surface .screen-screenshot-card {
--ring-unit: clamp(1px, 0.6px / var(--canvas-zoom, 1), 6px);
--ring-status: 0px;
}
.map-surface .screen-screenshot-card:is(.diff-added, .diff-modified, .diff-removed) { --ring-status: 2px; }
.map-surface .screen-screenshot-card .screen-node-image :is(img, .image-placeholder) {
border-color: var(--border-subtle);
box-shadow: none;
}
.map-surface .react-flow__node-screen:is(.selected, .graph-node-hover-subject) .screen-screenshot-card .screen-node-image :is(img, .image-placeholder) {
box-shadow:
0 0 0 var(--ring-status) var(--diff, transparent),
0 0 0 calc(var(--ring-status) + 4 * var(--ring-unit)) var(--screen),
0 0 0 calc(var(--ring-status) + 6.5 * var(--ring-unit)) var(--ring-color),
var(--ring-lift, 0 0 transparent);
}
.map-surface .react-flow__node-screen.graph-node-hover-subject { --ring-color: var(--hover-ring); }
.map-surface .react-flow__node-screen.selected {
--ring-color: var(--accent);
--ring-lift: 0 calc(10 * var(--ring-unit)) calc(28 * var(--ring-unit)) color-mix(in srgb, var(--accent) 18%, transparent);
}
.map-surface .react-flow__node-screen.selected .screen-node-title { color: var(--accent-strong); }
/* Keyboard focus is dashed, past where a ring would sit, so it never reads as either. */
.map-surface .screen-screenshot-target:focus-visible {
outline: 2px dashed var(--accent-strong) !important;
outline-offset: calc(var(--ring-status) + 9 * var(--ring-unit)) !important;
filter: none !important;
}
/* Hover is transient canvas state. Nothing recedes: the pointer's screen takes its grey ring and
the transitions into and out of it darken. Only the symmetric difference of related
nodes/edges receives a class, avoiding a React commit across the graph. A selected screen's
transitions stay accent. */
.connection-canvas-surface.canvas-hovering .graph-edge-hover-related:not(.graph-edge-active) .transition-edge-path {
stroke: var(--tertiary) !important;
stroke-width: 2 !important;
/* Hover is transient canvas state. Nothing recedes: the pointer's screen gets its ring, the
transitions into and out of it turn accent, and the screens at their other ends take a tinted
frame, so the neighbourhood reads without the rest of the map changing. Only the symmetric
difference of related nodes/edges receives a class, avoiding a React commit across the graph. */
.connection-canvas-surface.canvas-hovering .graph-edge-hover-related .transition-edge-path {
stroke: var(--accent) !important;
stroke-width: 2.2 !important;
stroke-dasharray: none !important;
}
.connection-canvas-surface.canvas-hovering .react-flow__node-screen.graph-node-hover-related:not(.graph-node-hover-subject)
.screen-screenshot-card:not(.selected, .diff-added, .diff-modified, .diff-removed) {
--screen-frame: var(--hover-neighbour-frame);
}
.connection-canvas-surface.canvas-hovering .react-flow__node-screen.graph-node-hover-related:not(.graph-node-hover-subject)
.screen-screenshot-card:not(.selected, .diff-added, .diff-modified, .diff-removed) .screen-node-image :is(img, .image-placeholder) {
border-color: var(--hover-neighbour-frame);
}
/* Semantic Map: an area is a meaningful destination, never an anonymous "X states" step. */
.semantic-summary-node {
@@ -941,7 +928,7 @@ code {
/* The phone map's open hint. The first tap there only selects, so the pill sits in the middle of
the selected screenshot (always on the image whatever the slot's shape) and says what the next
tap does. In a wider window a click opens the Inspector at once and nothing covers the image. */
tap does. In a wider window the card's tooltip carries the message and nothing covers the image. */
.screen-screenshot-target { cursor: pointer; }
.screen-open-hint {
position: absolute;
@@ -967,7 +954,7 @@ code {
.screen-open-hint > svg { width: 14px; height: 14px; flex: none; }
/* Only the phone layout's map shows the pill, on the selected screen, where a second tap or click
opens the Inspector. That layout is a width, not a device, and has no tooltips, so a narrow
desktop window shows it too. */
desktop window shows it too. Elsewhere the screenshot button's tooltip says it instead. */
.phone-layout .map-canvas .screen-screenshot-card.selected .screen-open-hint {
display: inline-flex;
animation: screen-open-hint-in 140ms ease-out;