Merge branch 'main' into web-connection

Integrate main's run-detail Changes (R4) and Graph (R5) work with the
connection banner/reconnect/foreground-recovery/live-badge work (T3/T4/T5).

Conflicts resolved by keeping both independent additions:
- web/styles.css: the .conn-*/.live-* rules and the .change-*/.diff-* rules
  are separate blocks; both retained under their own comment headers.
- web/test/ui-smoke.mjs: both capture sequences retained (T3/T4/T5 writes
  28-connected-banner/29-disconnected-banner/30-reconnect-recovered; R4/R5
  writes its own distinct 28-34 run-change captures), so no filename collides.

Checks after the merge: node --check on all touched JS/MJS; node --test test/
225 pass / 0 fail; node test/ui-smoke.mjs --out <worktree>/captures UI SMOKE
PASS against ws://127.0.0.1:8080/connect, including the connected banner +
build line + live badge, the disconnected retry banner, the online-event
recovery, and main's R4/R5 captures.
This commit is contained in:
2026-10-19 04:11:50 +01:00
10 changed files with 2381 additions and 37 deletions
+407 -2
View File
@@ -635,11 +635,14 @@ try {
await page.waitForSelector(".list.runs .run-row", { timeout: 25000 });
await openRunDetail(430);
// The run-detail tabs, in the app's order (the Graph body is the R5 item).
// The run-detail tabs, in the app's order (Summary / Graph / Input / Output /
// Timeline; the Graph body is R5 and now rendered).
const runTabs = await page.evaluate(
`[...document.querySelectorAll(".detail .detail-tabs .detail-tab")].map((n) => n.textContent)`,
);
if (JSON.stringify(runTabs) !== JSON.stringify(["Summary", "Input", "Output", "Timeline"])) {
if (
JSON.stringify(runTabs) !== JSON.stringify(["Summary", "Graph", "Input", "Output", "Timeline"])
) {
throw new Error(`run tabs are wrong: ${runTabs.join(",")}`);
}
console.log(` run tabs: ${runTabs.join(" / ")}`);
@@ -827,6 +830,137 @@ try {
console.log(` timeline empty state: ${emptyTimeline}`);
shots.push(await page.screenshot(`${out}/26-run-428-timeline-empty.png`));
// R5: the run-detail Graph tab — the shared workflow graph in run mode. Run 438
// is a finished run with several visits and the full outcome set: its graph
// shows the Executed / Not executed legend, solid executed nodes and arrowed
// executed routes, and dashed untaken routes. Clicking a stage opens the
// existing visit pane (with its Verdict) at that stage's latest visit. Run 440
// shows the hollow, dashed nodes for the stages the failed run never reached.
step("opening run 438 and capturing its Graph tab (R5)");
await page.click('.list.runs .run-row-meta[data-run-id="438"]');
await page.waitForSelector(".detail .detail-tabs", { timeout: 25000 });
await page.clickText(".detail .detail-tabs .detail-tab", "Graph");
await page.waitForSelector(".run-detail .graph-note", { timeout: 15000 });
const runGraphNote = await text(".run-detail .graph-note");
if (!runGraphNote.includes("pulses with its elapsed time")) {
throw new Error(`unexpected run graph note: ${runGraphNote}`);
}
await page.waitForSelector(".run-detail .graph-node", { timeout: 15000 });
await eventually(async () => {
const current = await graphState();
return current != null && current.scale > 0;
}, { what: "the run graph to lay out" });
const legend = await page.evaluate(
`[...document.querySelectorAll(".run-detail .graph-legend .graph-legend-label")].map((n) => n.textContent)`,
);
if (JSON.stringify(legend) !== JSON.stringify(["Executed", "Not executed"])) {
throw new Error(`the run graph legend is wrong: ${JSON.stringify(legend)}`);
}
const graph438 = await page.evaluate(`(() => ({
executedNodes: document.querySelectorAll(".run-detail .graph-node.executed").length,
notExecutedNodes: document.querySelectorAll(".run-detail .graph-node.not-executed").length,
executedEdges: document.querySelectorAll(".run-detail .graph-edge-path.executed").length,
notExecutedEdges: document.querySelectorAll(".run-detail .graph-edge-path.not-executed").length,
arrowedEdges: document.querySelectorAll('.run-detail .graph-edge-path[marker-end]').length,
active: document.querySelectorAll(".run-detail .graph-node.active").length,
}))()`);
if (!graph438.executedNodes || !graph438.executedEdges || !graph438.notExecutedEdges) {
throw new Error(`run 438 should show executed stages and both executed/untaken routes: ${JSON.stringify(graph438)}`);
}
if (graph438.arrowedEdges !== graph438.executedEdges) {
throw new Error(`only executed routes carry an arrowhead: ${JSON.stringify(graph438)}`);
}
if (graph438.active !== 0) {
throw new Error(`a finished run must have no active halo: ${JSON.stringify(graph438)}`);
}
console.log(
` run 438 graph: ${graph438.executedNodes} executed / ${graph438.notExecutedNodes} not-executed nodes, ` +
`${graph438.executedEdges} arrowed / ${graph438.notExecutedEdges} dashed routes, legend ${legend.join("/")}`,
);
await page.rect(".run-detail .graph-viewport");
shots.push(await page.screenshot(`${out}/28-run-438-graph.png`));
step("opening a stage's visit pane from the run 438 graph");
await page.evaluate(
`document.querySelector('.run-detail .graph-node[data-key="ui_reviewer"]').click()`,
);
await page.waitForSelector(".stage-pane", { timeout: 15000 });
await page.waitForText("Verdict", { timeout: 15000 });
const graphPane = await page.evaluate(`(() => ({
title: document.querySelector(".stage-pane-title")?.textContent ?? "",
verdict: document.querySelector(".stage-pane .verdict .outcome-chip")?.textContent ?? "",
}))()`);
if (graphPane.title !== "ui_reviewer") {
throw new Error(`the graph-opened pane named the wrong stage: ${graphPane.title}`);
}
if (!graphPane.verdict) throw new Error("the graph-opened pane did not show a verdict");
console.log(` graph-opened pane: ${graphPane.title} — verdict ${graphPane.verdict}`);
await page.rect(".stage-pane-sheet");
shots.push(await page.screenshot(`${out}/29-run-438-graph-pane.png`));
await page.click(".stage-pane-back");
await eventually(() => page.evaluate(`!document.querySelector(".stage-pane")`), {
timeout: 5000,
what: "the graph stage pane to close",
});
step("opening run 440 to capture the hollow, not-executed stages (R5)");
await page.click('.list.runs .run-row-meta[data-run-id="440"]');
await page.waitForSelector(".detail .detail-tabs", { timeout: 25000 });
await page.clickText(".detail .detail-tabs .detail-tab", "Graph");
await page.waitForSelector(".run-detail .graph-node", { timeout: 15000 });
const graph440 = await page.evaluate(`(() => ({
executedNodes: document.querySelectorAll(".run-detail .graph-node.executed").length,
notExecutedNodes: document.querySelectorAll(".run-detail .graph-node.not-executed").length,
hollow: [...document.querySelectorAll(".run-detail .graph-node.not-executed")].every(
(n) => getComputedStyle(n).borderStyle === "dashed",
),
}))()`);
if (!graph440.executedNodes || !graph440.notExecutedNodes) {
throw new Error(`run 440 should show visited and unvisited stages: ${JSON.stringify(graph440)}`);
}
if (!graph440.hollow) {
throw new Error(`an unvisited node is not hollow/dashed: ${JSON.stringify(graph440)}`);
}
console.log(` run 440 graph: ${graph440.executedNodes} executed / ${graph440.notExecutedNodes} not-executed (dashed) nodes`);
await page.rect(".run-detail .graph-viewport");
shots.push(await page.screenshot(`${out}/30-run-440-graph.png`));
// R5: a live run's Graph tab — the current stage carries the pulsing halo and
// a ticking elapsed badge; a finished run (above) carries neither. Best effort:
// the run may stop before we look, so skip rather than fail if none is running.
step("opening a live run's Graph tab (R5: halo + elapsed badge)");
const liveRunId = await page.evaluate(`(() => {
const row = [...document.querySelectorAll(".list.runs .run-row")].find((n) => n.querySelector(".chip-running"));
const meta = row?.querySelector(".run-row-meta[data-run-id]");
return meta ? Number(meta.getAttribute("data-run-id")) : null;
})()`);
if (liveRunId == null) {
console.log(" -- no running run available; skipped the live graph halo capture");
} else {
await page.click(`.list.runs .run-row-meta[data-run-id="${liveRunId}"]`);
await page.waitForSelector(".detail .detail-tabs", { timeout: 25000 });
await page.clickText(".detail .detail-tabs .detail-tab", "Graph");
await page.waitForSelector(".run-detail .graph-node", { timeout: 15000 });
const live = await eventually(
async () =>
page.evaluate(`(() => {
const active = document.querySelector(".run-detail .graph-node.active");
if (!active) return null;
return {
activeKey: active.dataset.key ?? "",
pulsing: active.classList.contains("pulsing"),
badge: active.querySelector(".graph-elapsed")?.textContent ?? "",
};
})()`),
{ timeout: 15000, what: "the live run's active stage" },
);
if (!live.badge) throw new Error(`the active stage showed no elapsed badge: ${JSON.stringify(live)}`);
console.log(` live run ${liveRunId}: active stage ${live.activeKey} (pulsing=${live.pulsing}), badge ${live.badge}`);
await page.rect(".run-detail .graph-viewport");
shots.push(await page.screenshot(`${out}/31-run-live-graph.png`));
}
// The Output empty state, on the running run that has not produced output yet.
step("opening the Output tab on a run with no output recorded");
const runningId = await page.evaluate(`(() => {
@@ -920,6 +1054,277 @@ try {
console.log(` recovered banner after window online: ${recoveredText}`);
await shot("30-reconnect-recovered.png");
// R4: the run Summary's collapsible Changes section and its rendered/raw diff
// viewer. Run 438 changed 22 unique files across 6 steps with every capture
// partial, so the header/row count are asserted against each other rather than
// against a hardcoded total.
const changesToggle = () =>
page.evaluate(`(() => {
const t = [...document.querySelectorAll(".run-detail .collapsible .section-toggle")]
.find((n) => /\\d+ files? changed/.test(n.querySelector(".section-title")?.textContent ?? ""));
if (!t) return null;
return {
title: t.querySelector(".section-title")?.textContent ?? "",
expanded: t.getAttribute("aria-expanded"),
rows: t.parentElement?.querySelectorAll(".change-row").length ?? 0,
};
})()`);
const expandChanges = async () => {
const marked = await page.evaluate(`(() => {
const t = [...document.querySelectorAll(".run-detail .collapsible .section-toggle")]
.find((n) => /\\d+ files? changed/.test(n.querySelector(".section-title")?.textContent ?? ""));
if (!t) return false;
t.scrollIntoView({ block: "center" });
t.setAttribute("data-test-changes-toggle", "1");
return true;
})()`);
if (!marked) throw new Error("no Changes section toggle rendered");
await page.click("[data-test-changes-toggle='1']");
await page.evaluate(
`document.querySelector("[data-test-changes-toggle='1']")?.removeAttribute("data-test-changes-toggle")`,
);
await page.waitForSelector(".run-detail .changes-list .change-row", { timeout: 15000 });
};
const closeChangeViewer = async (how) => {
if (how === "escape") {
await page.evaluate(
`document.dispatchEvent(new KeyboardEvent("keydown", { key: "Escape", bubbles: true }))`,
);
} else if (how === "backdrop") {
await page.evaluate(`document.querySelector(".change-viewer").click()`);
} else {
await page.click(".change-viewer-close");
}
await eventually(() => page.evaluate(`!document.querySelector(".change-viewer")`), {
timeout: 5000,
what: `the diff viewer to close (${how})`,
});
};
step("opening run 438: the collapsed Changes section (R4)");
await page.click('.list.runs .run-row-meta[data-run-id="438"]');
await page.waitForText("run 438 ·", { timeout: 25000 });
await page.waitForSelector(".detail .detail-tabs", { timeout: 25000 });
const collapsed = await changesToggle();
if (!collapsed) throw new Error("run 438's Summary rendered no Changes section");
if (collapsed.expanded !== "false") {
throw new Error(`the Changes section is not collapsed on first render: ${collapsed.expanded}`);
}
if (collapsed.rows !== 0) throw new Error(`a collapsed Changes section drew ${collapsed.rows} row(s)`);
const changesCount = Number((/^(\d+) files? changed/.exec(collapsed.title) ?? [])[1] ?? 0);
if (!changesCount) throw new Error(`the Changes header has no file count: ${collapsed.title}`);
if (!collapsed.title.includes("partial capture")) {
throw new Error(`run 438's Changes header should note the partial capture: ${collapsed.title}`);
}
console.log(` collapsed changes header: ${collapsed.title}`);
shots.push(await page.screenshot(`${out}/28-run-438-changes-collapsed.png`));
step("expanding the Changes section: the observed-file rows");
await expandChanges();
const expanded = await page.evaluate(`(() => ({
summary: document.querySelector(".run-detail .changes-summary")?.textContent ?? "",
note: document.querySelector(".run-detail .changes-note")?.textContent ?? "",
rows: document.querySelectorAll(".run-detail .changes-list .change-row").length,
kinds: [...document.querySelectorAll(".run-detail .changes-list .change-kind")].map((n) => n.textContent),
expanded: [...document.querySelectorAll(".run-detail .collapsible .section-toggle")]
.find((n) => /\\d+ files? changed/.test(n.querySelector(".section-title")?.textContent ?? ""))
?.getAttribute("aria-expanded"),
}))()`);
if (expanded.expanded !== "true") throw new Error("the Changes section did not expand");
if (expanded.rows !== changesCount) {
throw new Error(`the Changes section drew ${expanded.rows} rows for a header count of ${changesCount}`);
}
if (!expanded.note.startsWith("Partial capture: some changes may be missing.")) {
throw new Error(`the partial-capture note is missing: ${expanded.note}`);
}
console.log(` expanded: ${expanded.summary} — ${expanded.rows} row(s)`);
console.log(` note: ${expanded.note}`);
console.log(` kinds: ${[...new Set(expanded.kinds)].join(", ")}`);
await page.evaluate(`document.querySelector(".run-detail .changes-list .change-row")?.scrollIntoView({ block: "center" })`);
shots.push(await page.screenshot(`${out}/29-run-438-changes-expanded.png`));
step("opening the rendered diff viewer on the first changed file");
await page.click(".run-detail .changes-list .change-row");
await page.waitForSelector(".change-viewer", { timeout: 15000 });
const rendered = await page.evaluate(`(() => ({
kind: document.querySelector(".change-viewer .change-kind")?.textContent ?? "",
path: document.querySelector(".change-viewer-path")?.textContent ?? "",
position: document.querySelector(".change-viewer-position")?.textContent ?? "",
renderedActive: document.querySelector('.change-form[data-form="rendered"]')?.classList.contains("active") ?? false,
renderedDisabled: document.querySelector('.change-form[data-form="rendered"]')?.disabled ?? null,
rawDisabled: document.querySelector('.change-form[data-form="raw"]')?.disabled ?? null,
hunks: document.querySelectorAll(".change-viewer .change-hunk").length,
lines: document.querySelectorAll(".change-viewer .change-line").length,
gutter: document.querySelector(".change-viewer .change-gutter")?.textContent ?? "",
adds: document.querySelectorAll(".change-viewer .change-text.diff-add").length,
removes: document.querySelectorAll(".change-viewer .change-text.diff-remove").length,
prevDisabled: document.querySelector('.change-page[data-page="prev"]')?.disabled ?? null,
}))()`);
if (!rendered.renderedActive || rendered.renderedDisabled !== true) {
throw new Error(`Rendered is not the default selected form: ${JSON.stringify(rendered)}`);
}
if (!rendered.path || !rendered.position.includes("of ")) {
throw new Error(`the viewer did not identify its file: ${JSON.stringify(rendered)}`);
}
if (!rendered.hunks || !rendered.lines) {
throw new Error(`the rendered viewer drew no hunks/lines: ${JSON.stringify(rendered)}`);
}
if (rendered.gutter.trim() === "") throw new Error("the rendered viewer drew no gutter numbers");
if (rendered.prevDisabled !== true) throw new Error("Previous should be disabled on the first file");
console.log(
` rendered: ${rendered.kind} ${rendered.path} — ${rendered.position}; ` +
`${rendered.hunks} hunk(s), ${rendered.lines} line(s), ${rendered.adds}+/${rendered.removes}-`,
);
shots.push(await page.screenshot(`${out}/30-run-438-changes-diff-rendered.png`));
step("switching the diff viewer to the Raw patch");
await page.evaluate(`document.querySelector('.change-form[data-form="raw"]').click()`);
await page.waitForSelector(".change-viewer .change-raw", { timeout: 15000 });
const raw = await page.evaluate(`(() => ({
rawActive: document.querySelector('.change-form[data-form="raw"]')?.classList.contains("active") ?? false,
renderedDisabled: document.querySelector('.change-form[data-form="rendered"]')?.disabled ?? null,
text: document.querySelector(".change-viewer .change-raw")?.textContent ?? "",
}))()`);
if (!raw.rawActive) throw new Error("Raw patch did not become the selected form");
if (!raw.text.includes("@@")) {
throw new Error(`the raw patch does not look like a unified diff: ${raw.text.slice(0, 80)}`);
}
console.log(` raw patch: ${raw.text.split("\n")[0]} (${raw.text.length} chars)`);
shots.push(await page.screenshot(`${out}/31-run-438-changes-diff-raw.png`));
step("paging between files: Next to the last, then Previous");
await page.evaluate(`document.querySelector('.change-page[data-page="next"]').click()`);
await eventually(
async () => (await page.evaluate(`document.querySelector(".change-viewer-position")?.textContent ?? ""`)).startsWith("2 of "),
{ what: "the viewer to page to file 2" },
);
await page.evaluate(`(() => {
for (let i = 0; i < 500; i += 1) {
const next = document.querySelector('.change-page[data-page="next"]');
if (!next || next.disabled) break;
next.click();
}
})()`);
const last = await page.evaluate(`(() => ({
position: document.querySelector(".change-viewer-position")?.textContent ?? "",
nextDisabled: document.querySelector('.change-page[data-page="next"]')?.disabled ?? null,
prevDisabled: document.querySelector('.change-page[data-page="prev"]')?.disabled ?? null,
}))()`);
if (last.nextDisabled !== true) throw new Error("Next is not disabled on the last file");
if (!last.position.startsWith(`${changesCount} of `)) {
throw new Error(`the viewer did not reach the last file: ${last.position}`);
}
console.log(` paged to the last file: ${last.position}`);
await page.evaluate(`document.querySelector('.change-page[data-page="prev"]').click()`);
await eventually(
async () => (await page.evaluate(`document.querySelector(".change-viewer-position")?.textContent ?? ""`)).startsWith(`${changesCount - 1} of `),
{ what: "the viewer to page back" },
);
step("closing the diff viewer with Escape returns focus to the row");
await closeChangeViewer("escape");
const restoredFocus = await page.evaluate(
`document.activeElement?.getAttribute?.("data-change-index") ?? ""`,
);
// The viewer was paged back one file just before closing, so focus returns to
// that row (index changesCount - 2).
if (restoredFocus !== String(changesCount - 2)) {
throw new Error(`focus did not return to the opened row: ${restoredFocus}`);
}
console.log(` focus returned to change row ${restoredFocus}`);
step("reopening and closing the diff viewer by a backdrop click");
await page.click(".run-detail .changes-list .change-row");
await page.waitForSelector(".change-viewer", { timeout: 15000 });
await closeChangeViewer("backdrop");
// A binary capture: the honest message in place of a diff, and Raw disabled.
step("opening a binary capture (run 442): the honest message and a disabled Raw patch");
await page.click('.list.runs .run-row-meta[data-run-id="442"]');
await page.waitForText("run 442 ·", { timeout: 25000 });
await page.waitForSelector(".detail .detail-tabs", { timeout: 25000 });
await expandChanges();
await page.click(".run-detail .changes-list .change-row");
await page.waitForSelector(".change-viewer .change-honest", { timeout: 15000 });
const binary = await page.evaluate(`(() => ({
message: document.querySelector(".change-viewer .change-honest")?.textContent ?? "",
rawDisabled: document.querySelector('.change-form[data-form="raw"]')?.disabled ?? null,
hunks: document.querySelectorAll(".change-viewer .change-hunk").length,
}))()`);
if (
binary.message !==
"This is a binary file: the server recorded the change but has no textual diff to show."
) {
throw new Error(`the binary message is wrong: ${binary.message}`);
}
if (binary.rawDisabled !== true) throw new Error("Raw patch should be disabled for a binary file");
if (binary.hunks !== 0) throw new Error("a binary file must not render a fabricated diff");
console.log(` binary: ${binary.message}`);
shots.push(await page.screenshot(`${out}/32-run-442-changes-binary.png`));
await closeChangeViewer("close");
// A truncated capture: the truncation reason, still no fabricated diff.
step("opening a truncated capture (run 450): the truncation reason");
await page.click('.list.runs .run-row-meta[data-run-id="450"]');
await page.waitForText("run 450 ·", { timeout: 25000 });
await page.waitForSelector(".detail .detail-tabs", { timeout: 25000 });
await expandChanges();
const openedTruncated = await page.evaluate(`(() => {
const row = [...document.querySelectorAll(".run-detail .changes-list .change-row")]
.find((n) => (n.querySelector(".change-meta")?.textContent ?? "").includes("truncated"));
if (!row) return false;
row.click();
return true;
})()`);
if (!openedTruncated) throw new Error("run 450's Changes list showed no truncated row");
await page.waitForSelector(".change-viewer .change-honest", { timeout: 15000 });
const truncated = await page.evaluate(
`document.querySelector(".change-viewer .change-honest")?.textContent ?? ""`,
);
if (
truncated !==
"The server truncated this file's patch at its capture limit; no diff text was recorded."
) {
throw new Error(`the truncation reason is wrong: ${truncated}`);
}
console.log(` truncated: ${truncated}`);
shots.push(await page.screenshot(`${out}/33-run-450-changes-truncated.png`));
await closeChangeViewer("close");
// A still-running run: its Changes header must be one of the two valid shapes
// for an in-flight capture (the empty `Changes · …` variant, or a file-count
// header), never a fabricated complete diff. Its live state decides which, so
// the probe accepts either rather than pinning one.
step("opening a running run's Changes header");
const pendingRunId = await page.evaluate(`(() => {
const row = [...document.querySelectorAll(".list.runs .run-row")]
.find((n) => n.querySelector(".chip-running"));
const meta = row?.querySelector(".run-row-meta[data-run-id]");
return meta ? Number(meta.getAttribute("data-run-id")) : null;
})()`);
if (pendingRunId == null) {
console.log(" -- no running run available; skipped the pending Changes header");
} else {
await page.click(`.list.runs .run-row-meta[data-run-id="${pendingRunId}"]`);
await page.waitForSelector(".detail .detail-tabs", { timeout: 25000 });
const pendingToggle = await page.evaluate(`(() => {
// A running run's Changes header has one of two valid shapes: the
// empty-capture form (Changes · capture pending / partial capture /
// capture incomplete) before any step has recorded files, or the
// file-count form ({N} file(s) changed · ±stat · …) once one has. Which
// one appears depends on how far the live capture has progressed, so the
// probe accepts either rather than assuming the empty variant.
return [...document.querySelectorAll(".run-detail .collapsible .section-toggle .section-title")]
.map((n) => n.textContent ?? "")
.find((t) => /^Changes · /.test(t) || /^\\d+ files? changed/.test(t)) ?? "";
})()`);
if (!/^Changes · /.test(pendingToggle) && !/^\d+ files? changed/.test(pendingToggle)) {
throw new Error(`a running run's Changes header is wrong: ${pendingToggle}`);
}
console.log(` running run ${pendingRunId} changes header: ${pendingToggle}`);
shots.push(await page.screenshot(`${out}/34-run-${pendingRunId}-changes-pending.png`));
}
console.log("\nUI SMOKE PASS");
for (const shot of shots) console.log(` ${shot}`);
} catch (error) {