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:
+65
-5
@@ -36,9 +36,9 @@ import { effectiveStageType } from "./templates.js";
|
||||
|
||||
/**
|
||||
* The run-detail tabs, Summary first so it is the default selection. The Graph
|
||||
* tab is present (Android `runDetailTabs`) but has no rendered body yet — it is
|
||||
* the R5 item — so the renderer filters it out until then. The timeline keeps
|
||||
* Android's stable key `steps` with the visible title `Timeline`.
|
||||
* tab sits between Summary and Input (R5) and mounts the shared workflow graph
|
||||
* in run mode. The timeline keeps Android's stable key `steps` with the visible
|
||||
* title `Timeline`.
|
||||
*/
|
||||
export const RUN_DETAIL_TABS = [
|
||||
{ key: "summary", label: "Summary" },
|
||||
@@ -48,8 +48,8 @@ export const RUN_DETAIL_TABS = [
|
||||
{ key: "steps", label: "Timeline" },
|
||||
];
|
||||
|
||||
/** The tabs the browser currently renders (the Graph body is the R5 item). */
|
||||
export const RENDERED_RUN_TABS = RUN_DETAIL_TABS.filter((tab) => tab.key !== "graph");
|
||||
/** The tabs the browser renders: all of them, including the Graph body (R5). */
|
||||
export const RENDERED_RUN_TABS = RUN_DETAIL_TABS;
|
||||
|
||||
// The empty-state sentences, exactly as the app spells them.
|
||||
export const EMPTY_INPUT_MESSAGE = "No input recorded.";
|
||||
@@ -330,6 +330,66 @@ export function graphEdges(graph) {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Which stages and routes a run actually recorded, for the graph's execution
|
||||
* highlighting. Mirrors Android `RunGraphState.from` (GraphSemantics.kt:91-116):
|
||||
* every step's stage key is a visited stage (insertion order), a step with a
|
||||
* non-blank outcome and target contributes a taken route
|
||||
* `{source, outcome, resolvedTarget}` (recorded as a `source\0outcome\0target`
|
||||
* key the graph matches) and, when that resolved target is a terminal, marks the
|
||||
* terminal visited too. `currentStage` is the run's own stage, else the last
|
||||
* visit's stage, else null; `executing` mirrors the run; `currentStageStartedAt`
|
||||
* is the running visit's start for the active stage, only while executing. Pure
|
||||
* and DOM-free so the renderer and the tests share one definition.
|
||||
*/
|
||||
export function runGraphState(run) {
|
||||
const visitedStages = [];
|
||||
const seenStages = new Set();
|
||||
const takenRoutes = [];
|
||||
const seenRoutes = new Set();
|
||||
const steps = run?.steps ?? [];
|
||||
|
||||
const visit = (key) => {
|
||||
if (key == null || seenStages.has(key)) return;
|
||||
seenStages.add(key);
|
||||
visitedStages.push(key);
|
||||
};
|
||||
|
||||
for (const step of steps) {
|
||||
visit(step?.stage);
|
||||
const outcome = String(step?.outcome ?? "");
|
||||
const target = String(step?.target ?? "");
|
||||
if (target.trim() !== "" && outcome.trim() !== "") {
|
||||
const resolved = resolveTarget(outcome, target);
|
||||
const route = `${step?.stage}\u0000${outcome}\u0000${resolved}`;
|
||||
if (!seenRoutes.has(route)) {
|
||||
seenRoutes.add(route);
|
||||
takenRoutes.push(route);
|
||||
}
|
||||
if (isTerminal(resolved)) visit(resolved);
|
||||
}
|
||||
}
|
||||
|
||||
const lastStage = steps.length > 0 ? steps[steps.length - 1]?.stage : "";
|
||||
const rawCurrent = String(run?.current_stage ?? "").trim() !== "" ? run.current_stage : lastStage;
|
||||
const currentStage = String(rawCurrent ?? "").trim() !== "" ? String(rawCurrent) : null;
|
||||
|
||||
const executing = Boolean(run?.executing);
|
||||
let currentStageStartedAt = null;
|
||||
if (executing && currentStage != null) {
|
||||
for (let index = steps.length - 1; index >= 0; index -= 1) {
|
||||
const step = steps[index];
|
||||
if (step?.stage === currentStage && step?.status === "running") {
|
||||
const started = String(step?.started_at ?? "");
|
||||
if (started.trim() !== "") currentStageStartedAt = started;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return { visitedStages, takenRoutes, currentStage, executing, currentStageStartedAt };
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Stage pane (ui/graph/StageDetailPane.kt)
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user