web: right-align list miniatures and color pinned run graphs
This commit is contained in:
@@ -8,6 +8,23 @@ test, or a code change without a capture, is `partial` at best.
|
||||
|
||||
Status legend: `todo` · `partial` (some of it works) · `done` (working + captured).
|
||||
|
||||
### List miniature follow-up (2026-10-20)
|
||||
|
||||
Workflow and run miniatures now share the existing graph layout, right-aligned
|
||||
inside their SVG as well as their row, with a 6px extra trailing inset. Runs use
|
||||
the shared status palette; recorded visits/routes override the aggregate tint,
|
||||
and known untaken branches are hollow/dashed. With summaries only, the tint is
|
||||
the **run status**, not a claim that every stage executed. Topology comes from
|
||||
the run's own graph, an exact-version pipeline summary, or one cached
|
||||
`get_pipeline(id, version)` read per endpoint/version (never `get_run` per row,
|
||||
never a fallback to latest). Unavailable graphs stay absent. No server changes.
|
||||
|
||||
Scratch browser extension `test/miniatures-browser.mjs` verifies 390/420/1100px
|
||||
alignment, distinct status colors, wrapped titles, separate applied filters and
|
||||
no document overflow; captures and `geometry.json` are in
|
||||
`/private/var/folders/jp/q0qvjyg54fl_c5vhhk1ylz2m0000gn/T/opencode/status-miniature-captures/`.
|
||||
These are deterministic fixture captures, not a new live-server parity claim.
|
||||
|
||||
### Chat audit follow-up (2026-10-20, partial — fresh UI captures pending)
|
||||
|
||||
Codex model follow-up (partial, fixture-tested; fresh UI captures pending):
|
||||
|
||||
+5
-1
@@ -410,7 +410,7 @@
|
||||
width: min(210px, 56%);
|
||||
height: 22px;
|
||||
/* A shape cue at the row's trailing edge, not a full-width block. */
|
||||
margin: 3px 0 1px auto;
|
||||
margin: 3px 6px 1px auto;
|
||||
color: var(--color-muted);
|
||||
}
|
||||
.pipeline-mini-graph { display: block; width: 100%; height: 100%; overflow: visible; }
|
||||
@@ -422,6 +422,10 @@
|
||||
vector-effect: non-scaling-stroke;
|
||||
}
|
||||
.pipeline-mini-node { fill: currentColor; opacity: 0.55; }
|
||||
.run-mini .pipeline-mini-node { opacity: 0.85; }
|
||||
.run-mini .pipeline-mini-edge { opacity: 0.8; }
|
||||
.run-mini .mini-untaken { color: var(--muted); opacity: 0.4; stroke-dasharray: 2 2; }
|
||||
.run-mini .pipeline-mini-node.mini-untaken { fill: none; stroke: currentColor; stroke-width: 1; }
|
||||
.row.selected .pipeline-mini { color: var(--color-accent); }
|
||||
.row:hover .pipeline-mini { color: var(--color-text); }
|
||||
@media (prefers-reduced-motion: no-preference) {
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
// Label-free list cue, sharing the detail graph's layout and route evidence.
|
||||
import { h } from "./dom.js";
|
||||
import { layoutGraph, edgeIsExecuted, edgeStrokeColor } from "./graph.js";
|
||||
import { runGraphState } from "./runDetail.js";
|
||||
|
||||
const METRICS = Object.freeze({ nodeWidth: 26, nodeHeight: 12, hGap: 12, pad: 2,
|
||||
laneSpacing: 8, terminalGap: 8, trackStep: 6, portSpacing: 4,
|
||||
labelCharWidth: 0, labelPadding: 0, labelHeight: 0, labelGap: 0 });
|
||||
const NS = "http://www.w3.org/2000/svg";
|
||||
const STATUSES = new Set(["succeeded", "failed", "running", "waiting", "queued",
|
||||
"interrupted", "canceled", "blocked", "skipped"]);
|
||||
export function miniatureColor(status) {
|
||||
return `var(--status-${STATUSES.has(status) ? status : "unknown"})`;
|
||||
}
|
||||
|
||||
export function miniatureModel(graph, run = null) {
|
||||
const stages = graph?.stages ?? [];
|
||||
const keys = new Set(stages.map((stage) => stage.key));
|
||||
const shape = { stages: stages.map((stage) => ({ ...stage,
|
||||
edges: Object.fromEntries(Object.entries(stage.edges ?? {}).filter(([, target]) => keys.has(target))),
|
||||
})) };
|
||||
const layout = layoutGraph(shape, METRICS);
|
||||
const evidence = run && Array.isArray(run.steps) ? runGraphState(run) : null;
|
||||
const visits = new Map((run?.steps ?? []).map((step) => [step.stage, step]));
|
||||
return { ...layout, evidence: evidence != null,
|
||||
nodes: layout.nodes.map((node) => {
|
||||
const step = visits.get(node.key);
|
||||
// A recorded current stage is evidence even in a compact list summary.
|
||||
const current = run?.executing && run.current_stage === node.key;
|
||||
const status = current ? run.status : step?.status;
|
||||
const color = status === "completed" ? edgeStrokeColor(step.outcome) : status ? miniatureColor(status) : null;
|
||||
return { ...node, color,
|
||||
untaken: evidence != null && !step && !current };
|
||||
}),
|
||||
edges: layout.edges.map((edge) => ({ ...edge,
|
||||
untaken: evidence != null && !edgeIsExecuted(edge, evidence),
|
||||
color: evidence && edgeIsExecuted(edge, evidence) ? edgeStrokeColor(edge.outcome) : null,
|
||||
})),
|
||||
};
|
||||
}
|
||||
|
||||
export function renderMiniGraph(graph, run = null) {
|
||||
if (!graph?.stages?.length) return null;
|
||||
const model = miniatureModel(graph, run);
|
||||
if (!model.nodes.length || !model.width || !model.height) return null;
|
||||
const svg = document.createElementNS(NS, "svg");
|
||||
svg.setAttribute("class", "pipeline-mini-graph");
|
||||
svg.setAttribute("viewBox", `0 0 ${Math.ceil(model.width)} ${Math.ceil(model.height)}`);
|
||||
svg.setAttribute("preserveAspectRatio", "xMaxYMid meet");
|
||||
svg.setAttribute("aria-hidden", "true");
|
||||
svg.setAttribute("focusable", "false");
|
||||
for (const edge of model.edges) {
|
||||
if (edge.points.length < 2) continue;
|
||||
const line = document.createElementNS(NS, "polyline");
|
||||
line.setAttribute("class", `pipeline-mini-edge${edge.untaken ? " mini-untaken" : ""}`);
|
||||
line.setAttribute("points", edge.points.map((p) => `${p.x},${p.y}`).join(" "));
|
||||
if (edge.color) line.style.color = edge.color;
|
||||
svg.append(line);
|
||||
}
|
||||
for (const node of model.nodes) {
|
||||
const rect = document.createElementNS(NS, "rect");
|
||||
rect.setAttribute("class", `pipeline-mini-node${node.untaken ? " mini-untaken" : ""}`);
|
||||
for (const key of ["x", "y", "width", "height"]) rect.setAttribute(key, String(node[key]));
|
||||
rect.setAttribute("rx", "3");
|
||||
if (node.color) rect.style.color = node.color;
|
||||
svg.append(rect);
|
||||
}
|
||||
const wrap = h("span", { class: `pipeline-mini${run ? " run-mini" : ""}`,
|
||||
"aria-hidden": "true", "data-evidence": model.evidence ? "visits" : "summary" }, svg);
|
||||
if (run) wrap.style.color = miniatureColor(run.status);
|
||||
return wrap;
|
||||
}
|
||||
|
||||
/** One read per pinned pipeline version, never get_run per row or latest fallback. */
|
||||
export function createMiniGraphCache(readPipeline, changed) {
|
||||
const cache = new Map();
|
||||
return (run, pipelines = [], scope = "") => {
|
||||
if (run.graph?.stages?.length) return run.graph;
|
||||
if (!(run.pipeline_id > 0 && run.version > 0)) return null;
|
||||
const summary = pipelines.find((p) => p.id === run.pipeline_id && p.version === run.version);
|
||||
if (summary?.shape?.stages?.length) return summary.shape;
|
||||
const key = JSON.stringify([scope, run.pipeline_id, run.version]);
|
||||
if (!cache.has(key)) {
|
||||
cache.set(key, null);
|
||||
Promise.resolve().then(() => readPipeline(run.pipeline_id, run.version)).then((detail) => {
|
||||
if (detail?.version !== run.version) return;
|
||||
cache.set(key, detail.graph ?? null);
|
||||
changed();
|
||||
}).catch(() => { /* Missing topology stays absent, never invented. */ });
|
||||
}
|
||||
return cache.get(key);
|
||||
};
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
// The pure models live in pipelines.js and graph.js; this module owns the DOM.
|
||||
|
||||
import { h } from "../dom.js";
|
||||
import { renderMiniGraph } from "../miniGraph.js";
|
||||
import { describeError } from "../format.js";
|
||||
import {
|
||||
PIPELINE_SORTS,
|
||||
@@ -240,67 +241,8 @@ function fillPipelineRows(rowsEl) {
|
||||
rowsEl.replaceChildren(...nodes);
|
||||
}
|
||||
|
||||
// A list row's graph is a shape cue, not a reading surface: tiny nodes and
|
||||
// straight routes, no labels or chips. The detail Graph tab is the real one.
|
||||
const MINI_GRAPH_METRICS = Object.freeze({
|
||||
nodeWidth: 26,
|
||||
nodeHeight: 12,
|
||||
hGap: 12,
|
||||
pad: 2,
|
||||
laneSpacing: 8,
|
||||
terminalGap: 8,
|
||||
trackStep: 6,
|
||||
portSpacing: 4,
|
||||
labelCharWidth: 0,
|
||||
labelPadding: 0,
|
||||
labelHeight: 0,
|
||||
labelGap: 0,
|
||||
});
|
||||
const SVG_NS = "http://www.w3.org/2000/svg";
|
||||
|
||||
/** The pipeline's stages and their stage-to-stage routes, without terminals. */
|
||||
function miniGraphShape(graph) {
|
||||
const stages = graph?.stages ?? [];
|
||||
const keys = new Set(stages.map((stage) => stage.key));
|
||||
return {
|
||||
stages: stages.map((stage) => ({
|
||||
...stage,
|
||||
edges: Object.fromEntries(
|
||||
Object.entries(stage.edges ?? {}).filter(([, target]) => keys.has(target)),
|
||||
),
|
||||
})),
|
||||
};
|
||||
}
|
||||
|
||||
function renderPipelineMiniGraph(pipeline) {
|
||||
const shape = pipeline.shape ?? pipeline.graph;
|
||||
if (!shape?.stages?.length) return null;
|
||||
const layout = layoutGraph(miniGraphShape(shape), MINI_GRAPH_METRICS);
|
||||
if (!layout.nodes.length || !layout.width || !layout.height) return null;
|
||||
const svg = document.createElementNS(SVG_NS, "svg");
|
||||
svg.setAttribute("class", "pipeline-mini-graph");
|
||||
svg.setAttribute("viewBox", `0 0 ${Math.ceil(layout.width)} ${Math.ceil(layout.height)}`);
|
||||
svg.setAttribute("preserveAspectRatio", "xMidYMid meet");
|
||||
svg.setAttribute("aria-hidden", "true");
|
||||
svg.setAttribute("focusable", "false");
|
||||
for (const edge of layout.edges) {
|
||||
if (edge.points.length < 2) continue;
|
||||
const line = document.createElementNS(SVG_NS, "polyline");
|
||||
line.setAttribute("class", "pipeline-mini-edge");
|
||||
line.setAttribute("points", edge.points.map((point) => `${point.x},${point.y}`).join(" "));
|
||||
svg.append(line);
|
||||
}
|
||||
for (const node of layout.nodes) {
|
||||
const rect = document.createElementNS(SVG_NS, "rect");
|
||||
rect.setAttribute("class", "pipeline-mini-node");
|
||||
rect.setAttribute("x", String(node.x));
|
||||
rect.setAttribute("y", String(node.y));
|
||||
rect.setAttribute("width", String(node.width));
|
||||
rect.setAttribute("height", String(node.height));
|
||||
rect.setAttribute("rx", "3");
|
||||
svg.append(rect);
|
||||
}
|
||||
return h("span", { class: "pipeline-mini", "aria-hidden": "true" }, svg);
|
||||
return renderMiniGraph(pipeline.shape ?? pipeline.graph);
|
||||
}
|
||||
|
||||
function renderPipelineRow(pipeline, latestRuns, runsKnown, now) {
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
import { h } from "../dom.js";
|
||||
import { statusIcon } from "../statusIcon.js";
|
||||
import { renderMiniGraph, createMiniGraphCache } from "../miniGraph.js";
|
||||
import {
|
||||
RUN_STATES,
|
||||
RUN_TIME_RANGES,
|
||||
@@ -31,6 +32,9 @@ export function createRunsView(rt) {
|
||||
const renderContent = (...args) => rt.renderContent(...args);
|
||||
const selectRun = (...args) => rt.selectRun(...args);
|
||||
const renderAttentionBell = () => rt.renderAttentionBell();
|
||||
const miniGraphFor = createMiniGraphCache((id, version) => rt.repo.getPipeline(id, version), () => {
|
||||
if (state.view === "runs") renderContent();
|
||||
});
|
||||
|
||||
|
||||
function renderRunList(now = Date.now()) {
|
||||
@@ -160,6 +164,10 @@ function renderRunRow(run, now) {
|
||||
}),
|
||||
);
|
||||
}
|
||||
const evidence = state.runDetail?.id === run.id ? state.runDetail : run;
|
||||
const graph = miniGraphFor(evidence, state.pipelines, state.url);
|
||||
const mini = renderMiniGraph(graph, evidence);
|
||||
if (mini) row.append(mini);
|
||||
return row;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { miniatureModel, miniatureColor, createMiniGraphCache } from "../src/miniGraph.js";
|
||||
|
||||
const graph = { stages: [
|
||||
{ key: "a", edges: { success: "b", error: "c" } },
|
||||
{ key: "b", edges: { success: "#success" } },
|
||||
{ key: "c", edges: { error: "#failure" } },
|
||||
] };
|
||||
test("miniatures retain real stage routes, without terminals or fabricated visits", () => {
|
||||
const model = miniatureModel(graph, { status: "failed" });
|
||||
assert.deepEqual(model.nodes.map((n) => n.key).sort(), ["a", "b", "c"]);
|
||||
assert.equal(model.edges.length, 2);
|
||||
assert.equal(model.evidence, false);
|
||||
assert.ok(model.nodes.every((n) => n.color === null && !n.untaken));
|
||||
});
|
||||
test("visited stages/routes use evidence; unvisited branches remain hollow", () => {
|
||||
const model = miniatureModel(graph, { status: "waiting", executing: true, current_stage: "b",
|
||||
steps: [{ stage: "a", status: "completed", outcome: "success", target: "b" }] });
|
||||
assert.equal(model.nodes.find((n) => n.key === "a").color, "var(--ok)");
|
||||
assert.equal(model.nodes.find((n) => n.key === "b").color, "var(--status-waiting)");
|
||||
assert.equal(model.nodes.find((n) => n.key === "c").untaken, true);
|
||||
assert.equal(model.edges.find((e) => e.outcome === "success").color, "var(--ok)");
|
||||
assert.equal(model.edges.find((e) => e.outcome === "error").untaken, true);
|
||||
for (const status of ["succeeded", "failed", "running", "waiting", "interrupted", "queued", "canceled"]) {
|
||||
assert.equal(miniatureColor(status), `var(--status-${status})`);
|
||||
}
|
||||
});
|
||||
test("cache deduplicates pinned reads, rejects latest mismatches and scopes by endpoint", async () => {
|
||||
const calls = [];
|
||||
const cached = createMiniGraphCache(async (id, version) => {
|
||||
calls.push([id, version]); return { version, graph };
|
||||
}, () => {});
|
||||
const run = { pipeline_id: 8, version: 2 };
|
||||
assert.equal(cached(run, [{ id: 8, version: 3, shape: graph }], "one"), null);
|
||||
cached(run, [], "one");
|
||||
await new Promise(setImmediate);
|
||||
assert.deepEqual(calls, [[8, 2]]);
|
||||
assert.equal(cached(run, [], "one"), graph);
|
||||
assert.equal(cached(run, [], "two"), null);
|
||||
assert.equal(cached({ pipeline_id: 8 }, []), null);
|
||||
const mismatch = createMiniGraphCache(async () => ({ version: 3, graph }), () => {});
|
||||
mismatch(run); await new Promise(setImmediate);
|
||||
assert.equal(mismatch(run), null);
|
||||
});
|
||||
@@ -0,0 +1,91 @@
|
||||
// Scratch-only extension of ui-smoke: real DOM/views, deterministic protocol-shaped
|
||||
// evidence; no backend connection, production reads, workflow creation or devices.
|
||||
import { createServer } from "node:http";
|
||||
import { readFile, mkdir, writeFile } from "node:fs/promises";
|
||||
import { resolve, extname } from "node:path";
|
||||
import assert from "node:assert/strict";
|
||||
import { launchChrome } from "./browser.mjs";
|
||||
|
||||
const root = resolve(import.meta.dirname, "..");
|
||||
const out = resolve(process.argv[2] ?? "captures-miniatures");
|
||||
await mkdir(out, { recursive: true });
|
||||
const server = createServer(async (req, res) => {
|
||||
try {
|
||||
const path = resolve(root, `.${req.url === "/" ? "/index.html" : req.url.split("?")[0]}`);
|
||||
if (!path.startsWith(root + "/")) throw new Error("outside root");
|
||||
const data = await readFile(path);
|
||||
res.setHeader("Content-Type", ({ ".js": "text/javascript", ".css": "text/css", ".html": "text/html", ".svg": "image/svg+xml" })[extname(path)] ?? "application/octet-stream");
|
||||
res.end(data);
|
||||
} catch { res.writeHead(404); res.end(); }
|
||||
});
|
||||
await new Promise((r) => server.listen(0, "127.0.0.1", r));
|
||||
const browser = await launchChrome();
|
||||
const results = [];
|
||||
try {
|
||||
const page = await browser.openPage(`http://127.0.0.1:${server.address().port}/`);
|
||||
await page.waitForSelector("#content");
|
||||
await page.evaluate(`(async () => {
|
||||
const { createRunsView } = await import('/src/views/runs.js');
|
||||
const { createPipelinesView } = await import('/src/views/pipelines.js');
|
||||
const { defaultRunFilters } = await import('/src/runs.js');
|
||||
const { EMPTY_PIPELINE_FILTERS } = await import('/src/pipelines.js');
|
||||
const graph = { stages: [{ key:'plan', edges:{success:'build',error:'reject'} },
|
||||
{key:'build',edges:{success:'finish'}},{key:'reject',edges:{error:'#failure'}},
|
||||
{key:'finish',edges:{success:'#success'}}] };
|
||||
const statuses = ['succeeded','failed','running','interrupted','waiting','queued'];
|
||||
const state = { view:'runs', url:'scratch', loading:false, selectedRunId:1,
|
||||
openMenu:null, runFilters:{...defaultRunFilters(),pipelineId:7}, runSort:'server_order',
|
||||
pipelineFilters:{...EMPTY_PIPELINE_FILTERS},pipelineSort:'server_order', pipelinesLoaded:true,
|
||||
runsLoaded:true, pipelines:[{id:7,name:'Pinned workflow',version:3,stages:4,shape:graph}],
|
||||
runs:statuses.map((status,i)=>({id:i+1,pipeline_id:7,version:2,name:'Pinned workflow',
|
||||
title:'A wrapped run title that preserves the complete task context across narrow screens '+status,
|
||||
status,executing:['running','waiting'].includes(status),current_stage:'build',
|
||||
created_at:new Date().toISOString(),steps:i===0?[
|
||||
{stage:'plan',status:'completed',outcome:'success',target:'build'},
|
||||
{stage:'build',status:'completed',outcome:'success',target:'finish'}]:undefined})) };
|
||||
let runs, pipelines;
|
||||
const renderContent=()=>document.querySelector('#content').replaceChildren(
|
||||
state.view==='runs'?runs.renderRunList():pipelines.renderPipelineList());
|
||||
const rt={state,repo:{getPipeline:async(id,version)=>{window.pinnedReads=(window.pinnedReads||0)+1;return {id,version,graph};}},
|
||||
renderContent,renderAttentionBell:()=>document.createElement('span'),selectRun:()=>{},pushRoute:()=>{}};
|
||||
runs=createRunsView(rt);pipelines=createPipelinesView(rt);
|
||||
window.fixtureState=state;window.paintFixture=renderContent;renderContent();
|
||||
})()`);
|
||||
await page.waitForSelector(".run-mini");
|
||||
for (const width of [390, 420, 1100]) {
|
||||
await page.resize(width, 1000);
|
||||
for (const view of ["runs", "pipelines"]) {
|
||||
await page.evaluate(`fixtureState.view=${JSON.stringify(view)};paintFixture()`);
|
||||
const geometry = await page.evaluate(`(() => {
|
||||
const rows=[...document.querySelectorAll('#content .row')];
|
||||
return { width:innerWidth, overflow:document.documentElement.scrollWidth>innerWidth,
|
||||
rows:rows.map(row=>{const mini=row.querySelector('.pipeline-mini');const r=row.getBoundingClientRect();
|
||||
const m=mini.getBoundingClientRect();const svg=mini.querySelector('svg');const node=svg.querySelector('rect');
|
||||
return {inset:r.right-m.right,align:svg.getAttribute('preserveAspectRatio'),
|
||||
color:getComputedStyle(mini).color,nodeColor:getComputedStyle(node).color,
|
||||
right:m.right,rowRight:r.right, rowWidth:r.width};}),
|
||||
reads:window.pinnedReads,filterSeparate:!document.querySelector('.run-toolbar .run-applied-filters'),
|
||||
titleWrap:[...document.querySelectorAll('.run-row-title')].every(el=>getComputedStyle(el).whiteSpace!=='nowrap')};
|
||||
})()`);
|
||||
assert.equal(geometry.overflow, false);
|
||||
assert.ok(geometry.rows.length > 0);
|
||||
assert.ok(geometry.rows.every((r)=>r.inset>=6 && r.inset<40 && r.align==='xMaxYMid meet'));
|
||||
assert.equal(geometry.reads, 1);
|
||||
if (view === 'runs') {
|
||||
assert.equal(geometry.titleWrap, true);
|
||||
assert.equal(geometry.filterSeparate, true);
|
||||
assert.notEqual(geometry.rows[0].color, geometry.rows[1].color);
|
||||
assert.notEqual(geometry.rows[2].color, geometry.rows[4].color);
|
||||
}
|
||||
results.push({view,...geometry});
|
||||
await page.screenshot(resolve(out, `${view}-${width}.png`));
|
||||
if (view === 'runs') {
|
||||
await page.evaluate(`document.querySelector('.run-row[data-run-id="1"]').scrollIntoView({block:'end'})`);
|
||||
await page.screenshot(resolve(out, `runs-evidence-${width}.png`));
|
||||
}
|
||||
}
|
||||
}
|
||||
await writeFile(resolve(out, 'geometry.json'), JSON.stringify(results,null,2));
|
||||
await page.close();
|
||||
} finally { await browser.close(); await new Promise((r)=>server.close(r)); }
|
||||
console.log(`Scratch captures and geometry: ${out}`);
|
||||
Reference in New Issue
Block a user