diff --git a/web/PARITY.md b/web/PARITY.md index 4b989582..a2d8ab9d 100644 --- a/web/PARITY.md +++ b/web/PARITY.md @@ -23,10 +23,10 @@ Status legend: `todo` · `partial` (some of it works) · `done` (working + captu | --- | --- | --- | --- | | P1 | Pipeline list | `list_pipelines` | done — row: name; `id {id} · v{version} · {N stages}`; `updated d MMM HH:mm`; last-run line joined from `list_runs` (status chip + `{ago} · {duration} · run {id}`, or `no runs recorded`) | | P2 | Filter + sort (status/name/updated) | client-side | done — Filter menu (name contains, Runs Any/Has runs/No runs, Last run status over the 7 server states, Clear filters) + Sort menu (Server order default, Name A–Z/Z–A, Most recent run, Fewest/Most stages, Reset); server order preserved | -| P3 | Pipeline detail: stages, graph, versions, last run, content hash | `get_pipeline` | done — Summary/Graph/Source tabs; Summary shows content hash (monospace), latest version (`v{n}` or blank), created/updated, and a collapsed-by-default Versions section. Graph tab shows the browser guidance note only; the rendered graph is P6 | +| P3 | Pipeline detail: stages, graph, versions, last run, content hash | `get_pipeline` | done — Summary/Graph/Source tabs; Summary shows content hash (monospace), latest version (`v{n}` or blank), created/updated, and a collapsed-by-default Versions section. Graph tab shows the browser guidance note plus the rendered workflow graph (P6) | | P4 | Templates gallery + template detail | `list_templates`, `validate` | done | | P5 | Create pipeline from a template (validate then submit) | `validate`, `submit` | todo | -| P6 | Workflow graph rendering (nodes, edges, stage panes) | `get_pipeline` | todo | +| P6 | Workflow graph rendering (nodes, edges, stage panes) | `get_pipeline` | done (captured 2026-10-19: nodes + labelled outcome edges + success/failure terminals, an opened stage definition pane and the expanded view — `captures/08-pipeline-graph.png`, `captures/08a-pipeline-graph-stage-pane.png`, `captures/08b-pipeline-graph-expanded.png`). Reusable `src/graph.js` (`mount` + pure helpers: layout, edges, `error*`, lanes, fit/clamp/zoom, hit-test, stage-definition fields); definition view only, so R5's run-detail Graph tab stays todo. Pane labels match the app's own vocabulary (`Outcomes`, `Tools`) rather than the checklist's category words | ## Runs | # | Feature | Protocol | Status | diff --git a/web/src/app.js b/web/src/app.js index b8f456f6..7629227c 100644 --- a/web/src/app.js +++ b/web/src/app.js @@ -22,6 +22,10 @@ import { sessionExportArtifact, viewerIndexByUrl, } from "./artifacts.js"; +import { + PIPELINE_GRAPH_EMPTY, + mount as mountGraph, +} from "./graph.js"; import { PIPELINE_SORTS, PIPELINE_DETAIL_TABS, @@ -134,6 +138,10 @@ const state = { pipelineSort: "server_order", pipelineMenu: null, pipelineTab: "summary", + // The mounted workflow graph (P6) and whether its panel is expanded. The + // handle is dropped on every re-render so its listeners can never leak. + pipelineGraph: null, + pipelineGraphExpanded: false, versionsExpanded: false, pipelinesLoaded: false, runsLoaded: false, @@ -253,6 +261,13 @@ function render() { } function renderContent() { + // The graph owns wheel/pointer/resize listeners; drop the previous mount + // before rebuilding the DOM so a re-render, tab switch or view switch never + // leaves an observer or listener behind. + if (state.pipelineGraph) { + state.pipelineGraph.unmount(); + state.pipelineGraph = null; + } const nodes = []; if (state.error) { nodes.push(h("div", { class: "banner error" }, h("strong", { text: "Error: " }), state.error)); @@ -561,6 +576,19 @@ function renderPipelineDetail() { ); if (state.pipelineTab === "graph") { pane.append(h("p", { class: "graph-note muted", text: graphNote() })); + const stages = d.graph?.stages ?? []; + if (!stages.length) { + pane.append(h("div", { class: "muted pad", text: PIPELINE_GRAPH_EMPTY })); + return pane; + } + const host = h("div", { class: "graph-host" }); + pane.append(host); + state.pipelineGraph = mountGraph(host, d.graph, { + expanded: state.pipelineGraphExpanded, + onExpandedChange: (value) => { + state.pipelineGraphExpanded = value; + }, + }); return pane; } if (state.pipelineTab === "source") { diff --git a/web/src/graph.js b/web/src/graph.js new file mode 100644 index 00000000..1816ba43 --- /dev/null +++ b/web/src/graph.js @@ -0,0 +1,1245 @@ +// The workflow graph (P6): a reusable, DOM-light renderer for a pipeline's +// parsed definition plus the pure maths and semantics it is built from. +// +// Mirrors the Android app one-for-one so the browser reaches parity rather than +// re-inventing the picture: +// ui/graph/WorkflowGraph.kt (layoutGraph, fitScale, clampOffset, zoomAbout, +// hitTest, nodeDisplayLabel, rankStages) +// ui/graph/GraphPalette.kt (GraphNodeKind, node fills, tonal tint) +// data/protocol/GraphSemantics.kt (outcome order, `error*`, stable edge ids) +// ui/graph/StageDetailPane.kt (the definition-only stage pane) +// ui/screens/RunGraphTab.kt (the two empty states) +// +// Two deliberate shapes: +// +// * Everything above `mount` is pure: plain data in, plain data out, no DOM. +// `node --test test/graph.test.mjs` exercises it without a browser, and the +// run-detail graph (R5) reuses the same helpers when it lands. +// * `mount` is the only DOM touchpoint: it appends semantic DOM (a viewport, +// one inline for the edges, real