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:
+69
-10
@@ -24,6 +24,8 @@ import {
|
||||
} from "./artifacts.js";
|
||||
import {
|
||||
PIPELINE_GRAPH_EMPTY,
|
||||
RUN_GRAPH_MISSING,
|
||||
RUN_GRAPH_NOTE,
|
||||
mount as mountGraph,
|
||||
} from "./graph.js";
|
||||
import {
|
||||
@@ -87,6 +89,7 @@ import {
|
||||
runLabelFor,
|
||||
runDurationText,
|
||||
runTimeline,
|
||||
runGraphState,
|
||||
nodeLabel,
|
||||
headlineFields,
|
||||
runStepFields,
|
||||
@@ -142,6 +145,10 @@ const state = {
|
||||
// handle is dropped on every re-render so its listeners can never leak.
|
||||
pipelineGraph: null,
|
||||
pipelineGraphExpanded: false,
|
||||
// The mounted run-mode graph (R5) on the run detail's Graph tab. Dropped on
|
||||
// every re-render and on a run change, so its wheel/pointer/resize listeners
|
||||
// and its elapsed timer can never leak.
|
||||
runGraph: null,
|
||||
versionsExpanded: false,
|
||||
pipelinesLoaded: false,
|
||||
runsLoaded: false,
|
||||
@@ -268,6 +275,10 @@ function renderContent() {
|
||||
state.pipelineGraph.unmount();
|
||||
state.pipelineGraph = null;
|
||||
}
|
||||
if (state.runGraph) {
|
||||
state.runGraph.unmount();
|
||||
state.runGraph = null;
|
||||
}
|
||||
const nodes = [];
|
||||
if (state.error) {
|
||||
nodes.push(h("div", { class: "banner error" }, h("strong", { text: "Error: " }), state.error));
|
||||
@@ -1081,12 +1092,13 @@ function closeMenu() {
|
||||
}
|
||||
|
||||
/**
|
||||
* The run detail: a tab strip (Summary / Input / Output / Timeline) over the
|
||||
* selected tab's body, wired from the pure helpers in runDetail.js. Summary is
|
||||
* the default and carries the run's identity, key/value rows and diagnostic;
|
||||
* Input/Output are one collapsed section per recorded field; the Timeline is one
|
||||
* compact row per visit that opens the stage pane. Every server string is set
|
||||
* with textContent, never innerHTML.
|
||||
* The run detail: a tab strip (Summary / Graph / Input / Output / Timeline) over
|
||||
* the selected tab's body, wired from the pure helpers in runDetail.js. Summary
|
||||
* is the default and carries the run's identity, key/value rows and diagnostic;
|
||||
* the Graph tab mounts the shared workflow graph in run mode; Input/Output are
|
||||
* one collapsed section per recorded field; the Timeline is one compact row per
|
||||
* visit that opens the stage pane. Every server string is set with textContent,
|
||||
* never innerHTML.
|
||||
*/
|
||||
function renderRunDetail() {
|
||||
const d = state.runDetail;
|
||||
@@ -1111,7 +1123,9 @@ function renderRunDetail() {
|
||||
),
|
||||
),
|
||||
);
|
||||
if (state.runTab === "input") {
|
||||
if (state.runTab === "graph") {
|
||||
pane.append(renderRunGraphTab(d));
|
||||
} else if (state.runTab === "input") {
|
||||
pane.append(renderRunFieldTab(d.input, "input", EMPTY_INPUT_MESSAGE));
|
||||
} else if (state.runTab === "output") {
|
||||
pane.append(renderRunFieldTab(d.output, "output", EMPTY_OUTPUT_MESSAGE));
|
||||
@@ -1124,6 +1138,41 @@ function renderRunDetail() {
|
||||
return pane;
|
||||
}
|
||||
|
||||
/**
|
||||
* The Graph tab (R5): the run's own guidance note plus the shared workflow graph
|
||||
* mounted in run mode, or the app's exact missing-graph sentence when the server
|
||||
* sent no stages. The active stage pulses with its elapsed time while the run
|
||||
* executes; clicking a stage opens the existing visit pane at that stage's most
|
||||
* recent visit. The mount handle is tracked in `state.runGraph` so a re-render
|
||||
* (or a tab/run change) always unmounts the previous wheel/pointer/resize
|
||||
* listeners and the elapsed timer.
|
||||
*/
|
||||
function renderRunGraphTab(d) {
|
||||
const wrap = h("div", { class: "run-tab-body" });
|
||||
const stages = d.graph?.stages ?? [];
|
||||
if (!stages.length) {
|
||||
wrap.append(h("div", { class: "run-empty muted", text: RUN_GRAPH_MISSING }));
|
||||
return wrap;
|
||||
}
|
||||
wrap.append(h("p", { class: "graph-note muted", text: RUN_GRAPH_NOTE }));
|
||||
const host = h("div", { class: "graph-host" });
|
||||
wrap.append(host);
|
||||
state.runGraph = mountGraph(host, d.graph, {
|
||||
runState: runGraphState(d),
|
||||
onStageTap: (key) => openStagePane(key, latestVisitIndex(d, key)),
|
||||
});
|
||||
return wrap;
|
||||
}
|
||||
|
||||
/**
|
||||
* The visit index the graph opens for a stage: its most recent recorded visit
|
||||
* (`visits.size - 1`, never negative), exactly as RunGraphTab computes it.
|
||||
*/
|
||||
function latestVisitIndex(d, key) {
|
||||
const visits = runTimeline(d.steps ?? []).visitsByStage.get(key) ?? [];
|
||||
return Math.max(0, visits.length - 1);
|
||||
}
|
||||
|
||||
/** The Summary tab: identity, chip row, key/value rows, diagnostic and gallery. */
|
||||
function renderRunSummaryTab(d) {
|
||||
const wrap = h("div", { class: "run-tab-body" });
|
||||
@@ -1488,7 +1537,14 @@ function closeStagePane() {
|
||||
const row = [...document.querySelectorAll(".timeline-row")].find(
|
||||
(node) => node.dataset.stageKey === closing.stageKey && node.dataset.visitIndex === String(closing.visitIndex),
|
||||
);
|
||||
row?.focus();
|
||||
// A pane opened from the Timeline returns to its row; one opened from the Graph
|
||||
// returns to the stage node that opened it (there is no timeline row then).
|
||||
const focusTarget =
|
||||
row ??
|
||||
[...document.querySelectorAll(".graph-node")].find(
|
||||
(candidate) => candidate.dataset.key === closing.stageKey,
|
||||
);
|
||||
focusTarget?.focus();
|
||||
}
|
||||
|
||||
/** Whether the configured server URL can resolve a server-relative artifact. */
|
||||
@@ -1963,9 +2019,12 @@ async function selectPipeline(summary) {
|
||||
async function selectRun(id, { silent = false } = {}) {
|
||||
state.selectedRunId = id;
|
||||
if (!silent) {
|
||||
state.runDetail = null;
|
||||
// A different run reseeds the detail: Summary tab, every section closed and
|
||||
// no stage pane left over from the run the operator navigated away from.
|
||||
// no stage pane left over from the run the operator navigated away from. Drop
|
||||
// the mounted run graph first so a live run's timer can never outlive it.
|
||||
state.runGraph?.unmount();
|
||||
state.runGraph = null;
|
||||
state.runDetail = null;
|
||||
state.runTab = "summary";
|
||||
state.runSections = new Set();
|
||||
state.runStagePane = null;
|
||||
|
||||
Reference in New Issue
Block a user