web: run detail Graph tab with executed styling and stage panes (R5)
Add the run detail's Graph tab (between Summary and Input), reusing the shared src/graph.js renderer (P6) rather than a second renderer. In run mode a visited stage is executed (solid fill + border), an unvisited one hollow with a dashed muted border; a terminal is executed only when a visit resolved to it; a route is executed only when a recorded visit produced that outcome (solid with an arrowhead, success first, error last, others alphabetical, `error*` for the fallback). The Executed / Not executed legend shows only for a run. While the run executes the current stage carries a pulsing halo (static under prefers-reduced-motion) and a ticking elapsed badge; a finished run shows neither. Clicking a stage opens the existing visit pane at that stage's latest visit, and Back/Escape return focus. The empty state is the exact "This server did not include the run graph." extend src/graph.js with the run-mode inputs (runState-driven executed styling, legend, active halo/elapsed badge); keep app.js to wiring. Extend graph.test.mjs with focused run-mode unit tests and ui-smoke.mjs with the run 438 / run 440 / live-run captures. Mark R5 done in web/PARITY.md. Checks: node --check on every touched file; cd web && node --test test/ (178 pass, 0 fail); cd web && node test/ui-smoke.mjs --out captures (UI SMOKE PASS, captures 28-31).
This commit is contained in:
@@ -14,6 +14,7 @@ import {
|
||||
MAX_SCALE,
|
||||
PIPELINE_GRAPH_EMPTY,
|
||||
RUN_GRAPH_MISSING,
|
||||
RUN_GRAPH_NOTE,
|
||||
NO_NODE_DETAILS,
|
||||
STAGE_DEFINITION_TITLE,
|
||||
configLabel,
|
||||
@@ -33,7 +34,11 @@ import {
|
||||
clampOffset,
|
||||
fitScale,
|
||||
zoomAbout,
|
||||
stageIsExecuted,
|
||||
edgeIsExecuted,
|
||||
activeStage,
|
||||
} from "../src/graph.js";
|
||||
import { runGraphState } from "../src/runDetail.js";
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Fixtures
|
||||
@@ -369,12 +374,119 @@ test("terminalFields lists the incoming routes into a terminal", () => {
|
||||
assert.deepEqual(terminalFields(twoStageGraph(), "#nope"), []);
|
||||
});
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Run-mode execution state (R5: GraphSemantics RunGraphState.from)
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
test("runGraphState resolves visited stages, taken routes and reached terminals", () => {
|
||||
const run = {
|
||||
executing: false,
|
||||
current_stage: "committer",
|
||||
steps: [
|
||||
{ stage: "implementer", sequence: 1, status: "completed", outcome: "success", target: "reviewer" },
|
||||
{ stage: "reviewer", sequence: 2, status: "completed", outcome: "rejected", target: "implementer" },
|
||||
{ stage: "implementer", sequence: 3, status: "completed", outcome: "success", target: "reviewer" },
|
||||
{ stage: "committer", sequence: 4, status: "completed", outcome: "success", target: "#success" },
|
||||
],
|
||||
};
|
||||
const state = runGraphState(run);
|
||||
assert.deepEqual(state.visitedStages, ["implementer", "reviewer", "committer", "#success"]);
|
||||
assert.equal(state.currentStage, "committer");
|
||||
assert.equal(state.executing, false);
|
||||
assert.equal(state.currentStageStartedAt, null);
|
||||
assert.deepEqual(state.takenRoutes, [
|
||||
"implementer\u0000success\u0000reviewer",
|
||||
"reviewer\u0000rejected\u0000implementer",
|
||||
"committer\u0000success\u0000#success",
|
||||
]);
|
||||
});
|
||||
|
||||
test("runGraphState marks a terminal only when a visit resolved to it", () => {
|
||||
// A `#` target resolves by outcome: error -> #failure, everything else -> #success.
|
||||
const failed = runGraphState({
|
||||
executing: false,
|
||||
steps: [{ stage: "impl", outcome: "error", target: "#" }],
|
||||
});
|
||||
assert.deepEqual(failed.visitedStages, ["impl", "#failure"]);
|
||||
assert.equal(stageIsExecuted("#failure", failed), true);
|
||||
assert.equal(stageIsExecuted("#success", failed), false);
|
||||
|
||||
const midRun = runGraphState({
|
||||
executing: false,
|
||||
steps: [{ stage: "impl", outcome: "success", target: "review" }],
|
||||
});
|
||||
assert.equal(stageIsExecuted("#success", midRun), false);
|
||||
assert.equal(stageIsExecuted("#failure", midRun), false);
|
||||
assert.equal(stageIsExecuted("review", midRun), false, "a target is not visited until a step lands on it");
|
||||
});
|
||||
|
||||
test("stageIsExecuted is true for a visited stage and for the definition view", () => {
|
||||
const state = runGraphState({
|
||||
executing: false,
|
||||
steps: [{ stage: "impl", outcome: "success", target: "review" }],
|
||||
});
|
||||
assert.equal(stageIsExecuted("impl", state), true);
|
||||
assert.equal(stageIsExecuted("review", state), false);
|
||||
// The definition view passes no runState, so every stage is executed.
|
||||
assert.equal(stageIsExecuted("review", null), true);
|
||||
});
|
||||
|
||||
test("edgeIsExecuted is true only for a route a recorded visit produced", () => {
|
||||
const state = runGraphState({
|
||||
executing: false,
|
||||
steps: [
|
||||
{ stage: "impl", outcome: "success", target: "review" },
|
||||
{ stage: "review", outcome: "error", target: "#" },
|
||||
],
|
||||
});
|
||||
const taken = { source: "impl", outcome: "success", target: "review" };
|
||||
const byFallback = { source: "review", outcome: "error", target: "#failure" };
|
||||
const untaken = { source: "impl", outcome: "blocked", target: "#failure" };
|
||||
assert.equal(edgeIsExecuted(taken, state), true);
|
||||
assert.equal(edgeIsExecuted(byFallback, state), true, "a resolved fallback route counts");
|
||||
assert.equal(edgeIsExecuted(untaken, state), false);
|
||||
// The definition view draws every route executed.
|
||||
assert.equal(edgeIsExecuted(untaken, null), true);
|
||||
});
|
||||
|
||||
test("activeStage resolves only while the run is executing", () => {
|
||||
const live = runGraphState({
|
||||
executing: true,
|
||||
current_stage: "review",
|
||||
steps: [
|
||||
{ stage: "review", status: "running", started_at: "2026-01-01T00:00:00Z" },
|
||||
],
|
||||
});
|
||||
assert.equal(activeStage(live), "review");
|
||||
assert.equal(live.currentStageStartedAt, "2026-01-01T00:00:00Z");
|
||||
|
||||
const settled = runGraphState({
|
||||
executing: false,
|
||||
current_stage: "review",
|
||||
steps: [
|
||||
{ stage: "review", status: "running", started_at: "2026-01-01T00:00:00Z" },
|
||||
],
|
||||
});
|
||||
assert.equal(activeStage(settled), null, "a finished run has no active stage");
|
||||
assert.equal(settled.currentStageStartedAt, null);
|
||||
assert.equal(activeStage(null), null, "the definition view has no active stage");
|
||||
});
|
||||
|
||||
test("runGraphState falls back to the last visit's stage, else null", () => {
|
||||
const state = runGraphState({ executing: false, steps: [{ stage: "a" }, { stage: "b" }] });
|
||||
assert.equal(state.currentStage, "b");
|
||||
assert.equal(runGraphState({ executing: false, steps: [] }).currentStage, null);
|
||||
assert.equal(runGraphState({}).currentStage, null);
|
||||
});
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Wording, exports and the no-innerHTML contract
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
test("the empty-state and pane wording matches the app's sentences", () => {
|
||||
assert.equal(RUN_GRAPH_MISSING, "This server did not include the run graph.");
|
||||
assert.ok(RUN_GRAPH_NOTE.includes("pulses"));
|
||||
assert.ok(RUN_GRAPH_NOTE.includes("Mouse wheel to zoom"));
|
||||
assert.equal(PIPELINE_GRAPH_EMPTY, "This pipeline has no stages.");
|
||||
assert.equal(NO_NODE_DETAILS, "No details recorded for this node.");
|
||||
assert.equal(STAGE_DEFINITION_TITLE, "Stage definition");
|
||||
|
||||
@@ -79,10 +79,10 @@ test("RUN_DETAIL_TABS is the Android order, Summary first, Timeline keyed 'steps
|
||||
RUN_DETAIL_TABS.map((tab) => tab.label),
|
||||
["Summary", "Graph", "Input", "Output", "Timeline"],
|
||||
);
|
||||
// The Graph body is the R5 item; only the other four render today.
|
||||
// The Graph body (R5) now renders too, so every tab is present.
|
||||
assert.deepEqual(
|
||||
RENDERED_RUN_TABS.map((tab) => tab.label),
|
||||
["Summary", "Input", "Output", "Timeline"],
|
||||
["Summary", "Graph", "Input", "Output", "Timeline"],
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
+136
-2
@@ -590,11 +590,14 @@ try {
|
||||
await page.click('.list.runs .run-row-meta[data-run-id="430"]');
|
||||
await page.waitForSelector(".detail .detail-tabs", { timeout: 25000 });
|
||||
|
||||
// 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(" / ")}`);
|
||||
@@ -784,6 +787,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(`(() => {
|
||||
|
||||
Reference in New Issue
Block a user