Merge branch 'main' into web-changes

Resolve the web/PARITY.md conflict by keeping main's R3 (now listing the
Graph tab) and R5 rows alongside this branch's R4 row; R4's Changes viewer
merges cleanly into app.js, styles.css and ui-smoke.mjs.
This commit is contained in:
2026-10-19 04:07:48 +01:00
8 changed files with 569 additions and 32 deletions
+69 -10
View File
@@ -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,
@@ -165,6 +168,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,
@@ -291,6 +298,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));
@@ -1104,12 +1115,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;
@@ -1134,7 +1146,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));
@@ -1147,6 +1161,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" });
@@ -1798,7 +1847,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. */
@@ -2273,9 +2329,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;