Merge branch 'main' into turn-integration

This commit is contained in:
2026-10-19 22:27:46 +01:00
27 changed files with 1261 additions and 258 deletions
+1 -1
View File
@@ -38,7 +38,7 @@ Status legend: `todo` · `partial` (some of it works) · `done` (working + captu
| R5 | Graph tab (per-stage panes, verdicts) | `get_run` | done — the run detail's Graph tab (between Summary and Input) mounts the shared `src/graph.js` renderer in run mode with the app's run note: a visited stage is executed (solid fill + border), an unvisited one hollow with a dashed muted border, a terminal executed only when a visit resolved to it, a route executed only when a visit produced that outcome (solid with an arrowhead; success first, error last, others alphabetical, `error*` for a fallback error route), the Executed / Not executed legend (runs only, never the definition view), and — while executing — the current stage's pulsing halo + elapsed badge (a static ring under `prefers-reduced-motion`; nothing for a finished run). Clicking a stage opens the existing visit pane at that stage's latest visit with its Verdict; Back/Escape close it and restore focus. The empty state is the exact `This server did not include the run graph.` (unit-tested; no live run currently carries a graph-less payload). Captured 2026-10-19: `captures/28-run-438-graph.png` (finished run 438: legend + executed styling + dashed untaken routes), `captures/29-run-438-graph-pane.png` (a graph-opened stage pane showing a Verdict), `captures/30-run-440-graph.png` (failed run 440: hollow/dashed not-executed stages) |
| R6 | Input / Output field sections per stage | `get_run` | done — one collapsed section per recorded entry, expanded as a monospace block (primitives verbatim, arrays `, `-joined, objects `k=v` `, `-joined), empty states "No input recorded." / "No output recorded.". Captured 2026-10-19: `captures/21-run-430-input.png`, `captures/22-run-430-output.png`, `captures/27-run-output-empty.png` |
| R7 | Timeline | `get_run` | done — one compact row per visit (`{stage} · visit {n}`, stage-outcome chip, paperclip when artifacts recorded, duration, description = first non-blank diagnostic line else `→ {target}`); empty state "No visits recorded.". Captured 2026-10-19: `captures/23-run-430-timeline.png`, `captures/26-run-428-timeline-empty.png` |
| R8 | Artifacts gallery + full-screen viewer (images inline, others download/open) | `GET /artifacts/…` | done (captured 2026-10-19: `captures/04-run-430-artifacts.png`, `captures/05-artifact-viewer.png`) |
| R8 | Artifacts gallery + full-screen viewer (images inline, markdown/text rendered, others download/open) | `GET /artifacts/…` | done — the gallery keeps images (lazy thumbnails) and videos (poster, never autoplay) and now also presents `text/markdown`, `text/plain`, `.md`, `.markdown` and `.txt` artifacts as ordinary **Document** tiles (drawn page glyph + the existing `Document` label; `data-artifact-name` / `data-artifact-kind` metadata), including the stage-turn `input.md`, `memory.md` and `output.md` in both the per-visit section and the run gallery. Clicking one opens the existing full-screen viewer, whose dim backdrop contains one `.viewer-panel`; only a click on the backdrop (never inside the panel) or Escape/Close dismisses it. The document is fetched through the resolved artifact URL (same-origin via `serve.mjs`'s `/artifacts/` proxy) once per viewer session and rendered with the page's own `src/markdown.js` DOM renderer (headings, lists, tables, fenced code, links; never `innerHTML`); a failed fetch/render shows `describeError`'s honest message plus `Open {name} externally` at the resolved URL, while Open/Copy link/Share stay available. Images/videos are unchanged. ArrowLeft/ArrowRight page the same media+markdown list as the buttons (clamped, no wrap, disabled at the ends), and a re-render keeps focus inside the viewer. Pure selection in `src/artifacts.js` (`isMarkdownArtifact`, `isViewerArtifact`, extended `pagedArtifacts`), unit-tested in `test/artifacts.test.mjs`. Captured 2026-10-19 with the deterministic `--viewer` fixture run (ordinary artifacts, no new wire field): `captures/44-viewer-turn-documents.png` (input.md/memory.md/output.md as Documents in both galleries), `captures/45-viewer-markdown-rendered.png` (heading + fenced code fetched from the resolved URL), `captures/46-viewer-markdown-next.png` (ArrowRight advanced to the image artifact), `captures/47-viewer-markdown-failure.png` (honest 404 message + `Open missing.txt externally`) and `captures/48-viewer-markdown-backdrop-closed.png` (a panel click stayed open; the backdrop closed it). The pre-existing image viewer capture `captures/05-artifact-viewer.png` remains the unchanged-behaviour evidence. |
| R9 | Session export link (read-only `session.html`) | `GET /artifacts/…` | done (captured 2026-10-19: `captures/06-session-export-link.png`) |
| R10 | Live run updates: subscribe/unsubscribe + event fold | `subscribe`, `unsubscribe`, `run_event` | done — one app-wide watch owned by the connection, never by a screen: becoming connected best-effort `unsubscribe`s the previous watch, sends `{type:'subscribe',workspace:''}` send-only (no `run_ids`; `{type:'unsubscribe'}` drops it), then takes one authoritative resync (`list_runs`, plus one `get_run` when a run detail is open); a socket drop clears the watch and no screen change ever unsubscribes. `src/runEvents.js` is the pure fold ported from `ui/RunEvents.kt` (in-place list update preserving order, insert-at-head from the frame's pipeline identity, `needsResync` without identity, detail merge with explicit `resource_wait` set/clear, one step matched by `sequence` and inserted in sequence order, the monotonic run/step ladders and the full-sync decision) and is unit-tested in `test/runEvents.test.mjs`; the send-only path (`src/client.js#sendOnly`), the exact watch frames (`src/repository.js`) and the `run_event`/unsolicited-frame dispatch are unit-tested in `test/client.test.mjs` and `test/repository.test.mjs`. The 1 s run-detail poll is removed — pushed frames drive the detail and a settled/terminal frame triggers one coalesced `get_run` (at most one in flight per kind plus one queued follow-up, retried at 500 ms × attempt at most 3 times before the badge drops to `reconnecting`); the only surviving intervals are render-only clocks. The badge is the explicit stream state (`live` / `reconnecting` / `not live`, LiveBadge.kt words), independent of whether a run is executing, on the Runs list and the run detail. Captured 2026-10-19 against the live server with a **real pushed run** started by the smoke in a throwaway workspace: `captures/75-run-live-list.png` (the new run's row inserted from its own frame, badge `live`), `captures/76-run-live-detail.png` (the open detail folded to `running` from pushes, badge `live`) and `captures/77-run-live-terminal.png` (the pushed terminal fold to `canceled`, no poll), plus the reachable badge states `captures/28-connected-banner.png` (live), `captures/29-disconnected-banner.png` (not live while idle; reconnecting while the socket retries) and `captures/30-reconnect-recovered.png` (live again). `test/ui-smoke.mjs` asserts the reconnect wire order (unsubscribe → subscribe blank-workspace → list_runs) and that at least one genuine `run_event` frame for the started run arrived. The R10 step itself passes on every run; the full smoke can still fail later in unrelated, pre-existing steps on the shared live server (observed after the main merge: a flaky L1 stale page-level error on one run, a C5 chat fold `expected at least one folded agent turn, got 0` on another, and a C8 composer assertion while the operator's live chat session was streaming, so the composer correctly showed Stop; the focused `--notify` run is `UI SMOKE PASS`), which is not an R10 defect. |
| R11 | Human decision sheet: prompt, options, feedback | `decide_run` | done — the pure model (`src/actions.js`: `pendingDecision`, `lastWaitingStep`, `waitingPrompt`/`waitingOptions`, `humanOptions`, `decisionTargetLabel`, `DecisionDraft`) and the card + sheet are implemented with the Android copy verbatim: card title `Waiting for your decision`, meta `{stage} · run {id} · {runLabel}`, action `Decide`; sheet title `Decide {stage}`, meta `run {id} · {runLabel}`, the recorded instructions verbatim when non-blank, one selectable row per option in author order showing the option and `→ {target}` only when the declared edge resolves, the `Feedback (optional)` field, and `Cancel` / `Confirm decision` (reading `Sending…` while in flight). Selecting a row sends nothing and Confirm is disabled until a non-blank option is chosen; a refusal keeps the sheet open with the server's exact reason and re-reads the run. The request shape is unit-tested (`decide_run` = `{type, run_id, option, stage?, feedback?}`, stage/feedback omitted when blank, feedback trimmed). **Live, end to end (2026-10-19)**: `test/ui-smoke.mjs` gained an explicit `--decide` mode (the only mode allowed to submit). It reused the entry-stage human-only pipeline submitted create-only as `Web R11 decision 2026-10-19T14-59-18-785Z` (id 30: one `type=human` `gate` stage, `approve -> #success`, `hold -> #success`, `error -> #failure`, so no model stage runs) and started two runs in separate fresh temp workspaces. Run 513 parked in `waiting`; the browser asserted the card (`Waiting for your decision`, `gate · run 513 · Web R11 decision 1 (feedback)`, `Decide`), opened the sheet (`Decide gate`, `run 513 · …`, the recorded instructions `R11 live decision: review the run and choose approve or hold.`, `approve`/`hold` in author order each with `→ SUCCESS`, `Feedback (optional)`, Confirm disabled), selected `approve` (still no `decide_run`, and the run was still `waiting` via `pipelines inspect`), typed feedback, and pressed `Confirm decision`: exactly one frame `{"type":"decide_run","run_id":513,"option":"approve","stage":"gate","feedback":"Approved in the live browser decision sheet."}` was sent, the run left `waiting`, resumed and reached `succeeded`. Run 514 proved the no-feedback shape: selecting `hold` sent nothing, Confirm sent `{"type":"decide_run","run_id":514,"option":"hold","stage":"gate"}` with **no** `feedback` key, the run reached `succeeded`, its recorded feedback is blank and its verdict carries no reason. Captured: `captures/41-run-513-decision-card.png` (waiting card), `captures/42-run-513-decision-sheet.png` (open sheet with the options), `captures/43-run-513-decision-selected.png` (selected + feedback, Confirm enabled), `captures/44-run-513-decision-confirmed.png` (resumed detail, `succeeded`), `captures/45-run-513-decision-verdict.png` (`gate · visit 1` Verdict chip `approve → success` and the exact reason), and the no-feedback path `captures/46-run-514-decision-card.png`, `captures/47-run-514-decision-sheet.png`, `captures/48-run-514-decision-selected.png`, `captures/49-run-514-decision-confirmed.png`, `captures/50-run-514-decision-verdict.png` (`hold → success`, no reason). Command: `cd web && node test/ui-smoke.mjs --decide --out "$PWD/captures"` → `UI SMOKE PASS` (the reused pipeline means no new submit on the capture run); `cd web && node --test test/` stays green. Both runs are terminal, no R11 run remains active and both temp workspaces were removed. The submitted definition is intentionally retained and named here; no operator pipeline, version, run, chat or repository was modified. Re-verified after merging `main` (2026-10-19): the same reused pipeline parked runs 522 and 523, the same `--decide` check ended `UI SMOKE PASS` with `captures/41-run-522-decision-card.png` through `captures/50-run-523-decision-verdict.png`, and the full default live suite also ended `UI SMOKE PASS` (its R11 step still skips only because no operator run was waiting at that moment) |
+7 -7
View File
@@ -83,7 +83,7 @@ a { color: var(--color-accent); }
border-bottom: 1px solid var(--color-divider);
border-radius: 0;
background: transparent;
padding: var(--space-s) var(--space-m);
padding: var(--space-xs) var(--space-s);
}
.row:last-child { border-bottom: 0; }
.row:hover { background: var(--tint-hover); }
@@ -131,13 +131,13 @@ a { color: var(--color-accent); }
min-height: 120px;
padding: var(--space-xs);
background: var(--color-surface-2);
border: 1px solid var(--color-divider);
border: 1px solid var(--color-border);
border-radius: var(--radius-card);
overflow: hidden;
text-align: center;
}
.artifact-tile.clickable { cursor: pointer; }
.artifact-tile.clickable:hover { border-color: var(--color-accent); }
.artifact-tile.clickable:hover { border-color: var(--color-border-strong); }
.artifact-thumb { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.artifact-poster {
display: flex;
@@ -152,13 +152,13 @@ a { color: var(--color-accent); }
.artifact-kind { color: var(--color-muted); font-size: 11px; text-transform: uppercase; letter-spacing: var(--tracking-eyebrow); }
.artifact-name { font-size: 12px; font-weight: var(--weight-semibold); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.artifact-size { color: var(--color-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.artifact-actions { position: absolute; top: 8px; right: 6px; display: flex; gap: 4px; }
.artifact-actions { position: absolute; top: 8px; right: 8px; display: flex; gap: 4px; }
.artifact-action {
min-height: 24px;
padding: 0 6px;
font-size: 10px;
border-radius: var(--radius-s);
background: rgba(14, 21, 19, 0.72);
background: rgba(10, 10, 11, 0.72);
}
.artifact-action:disabled { opacity: 0.4; cursor: not-allowed; }
@@ -202,7 +202,7 @@ a { color: var(--color-accent); }
border-radius: var(--radius-pill);
font-size: 11px;
line-height: 16px;
border: 1px solid var(--color-divider);
border: 1px solid var(--color-border);
color: var(--color-muted);
font-variant-numeric: tabular-nums;
}
@@ -261,7 +261,7 @@ code {
align-items: center;
justify-content: space-between;
min-width: 0;
padding: var(--space-s) var(--space-m);
padding: var(--space-xs) var(--space-s);
border-bottom: 1px solid var(--color-divider);
}
.pane-title { margin: 0; min-width: 0; font: var(--type-title-small); letter-spacing: var(--tracking-tight); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
+23 -23
View File
@@ -35,7 +35,7 @@
display: flex;
flex-direction: column;
border: 1px solid var(--border);
border-radius: 10px;
border-radius: var(--radius-card);
overflow: hidden;
}
.chat-create-choice { cursor: pointer; }
@@ -54,7 +54,7 @@
padding: 12px;
background: var(--surface-2);
border: 1px solid var(--border);
border-radius: 10px;
border-radius: var(--radius-card);
}
.chat-create-start {
flex: 1 1 auto;
@@ -128,7 +128,7 @@
padding: 4px;
background: var(--surface-2);
border: 1px solid var(--border);
border-radius: 10px;
border-radius: var(--radius-card);
box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
}
.chat-menu-item {
@@ -164,7 +164,7 @@
padding: 12px 16px;
background: var(--surface-2);
border: 1px solid var(--border);
border-radius: 10px;
border-radius: var(--radius-card);
box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
font-size: 13px;
}
@@ -188,7 +188,7 @@
display: flex;
flex-direction: column;
gap: var(--space-xs);
padding: var(--space-m);
padding: var(--space-s);
overflow: hidden;
}
.chat-create { overflow-y: auto; overscroll-behavior: contain; }
@@ -209,7 +209,7 @@
gap: var(--space-xs);
overflow-y: auto;
overscroll-behavior: contain;
padding: var(--space-s);
padding: var(--space-xs);
background: var(--color-bg);
border: 1px solid var(--color-divider);
border-radius: var(--radius-card);
@@ -217,7 +217,7 @@
.chat-turn { display: flex; }
.chat-turn-user { justify-content: flex-end; }
.chat-turn-agent { justify-content: flex-start; }
.chat-bubble { max-width: min(560px, 100%); padding: 10px 12px; border-radius: 10px; }
.chat-bubble { max-width: min(560px, 100%); padding: 8px 12px; border-radius: var(--radius-card); }
.user-bubble { background: var(--surface-2); border: 1px solid var(--border); }
.agent-bubble { background: var(--surface); border: 1px solid var(--border); }
.chat-client { font-size: 11px; color: var(--muted); margin-bottom: 4px; }
@@ -293,7 +293,7 @@
padding: 12px;
background: var(--surface-2);
border: 1px solid var(--border);
border-radius: 10px;
border-radius: var(--radius-card);
}
/* Background tasks (C11): running shells only, three visible rows then scroll. */
.chat-bg-tasks { display: grid; gap: 6px; }
@@ -318,7 +318,7 @@
padding: 4px 10px;
text-align: left;
border: 1px solid var(--border);
border-radius: 8px;
border-radius: var(--radius-control);
background: var(--surface);
color: var(--text);
font-size: 12px;
@@ -353,7 +353,7 @@
padding: 10px;
background: var(--surface-2);
border: 1px solid var(--border);
border-radius: 10px;
border-radius: var(--radius-card);
}
.chat-approval-pending { border-color: color-mix(in srgb, var(--warn) 50%, var(--border)); }
.chat-approval-head { display: flex; gap: 10px; align-items: center; }
@@ -370,7 +370,7 @@
padding: 8px 10px;
background: var(--bg);
border: 1px solid var(--border);
border-radius: 8px;
border-radius: var(--radius-control);
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
font-size: 12px;
line-height: 18px;
@@ -393,7 +393,7 @@
flex-direction: column;
gap: 4px;
padding: 8px 10px;
border-radius: 8px;
border-radius: var(--radius-control);
background: color-mix(in srgb, var(--warn) 12%, transparent);
}
.chat-approval-risk-head { display: flex; gap: 4px; align-items: center; }
@@ -430,7 +430,7 @@
overflow-wrap: anywhere;
background: var(--bg);
border: 1px solid var(--border);
border-radius: 8px;
border-radius: var(--radius-control);
}
.chat-bg-task-note { font-size: 11px; }
.chat-bg-task-spinner { width: 12px; height: 12px; border-width: 2px; }
@@ -448,7 +448,7 @@
max-height: 440px;
background: var(--surface-2);
border: 1px solid var(--border);
border-radius: 10px;
border-radius: var(--radius-card);
box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
overflow: hidden;
}
@@ -518,7 +518,7 @@
padding: 6px 10px;
background: var(--bg);
border: 1px solid var(--border);
border-radius: 8px;
border-radius: var(--radius-control);
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
font-size: 12px;
max-height: 220px;
@@ -540,7 +540,7 @@
padding: 10px 12px;
background: var(--surface);
border: 1px solid var(--accent);
border-radius: 10px;
border-radius: var(--radius-card);
box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
}
.chat-tool-sample-note {
@@ -553,7 +553,7 @@
/* The composer at the foot of a conversation (C8/C9). The field grows 1–6 rows;
the primary control turns from Send to Stop while a turn is in flight. */
.chat-composer { flex: 0 0 auto; display: grid; gap: var(--space-xs); padding-top: 6px; border-top: 1px solid var(--color-divider); }
.chat-composer { flex: 0 0 auto; display: grid; gap: var(--space-xs); padding-top: var(--space-xs); border-top: 1px solid var(--color-divider); }
.chat-queued { font-size: 12px; color: var(--muted); }
.chat-attachment-strip { display: flex; flex-wrap: wrap; gap: 8px; }
@@ -563,7 +563,7 @@
gap: 8px;
padding: 4px 6px 4px 8px;
border: 1px solid var(--border);
border-radius: 8px;
border-radius: var(--radius-control);
background: var(--surface-2);
}
.chat-attachment-chip-failed {
@@ -582,7 +582,7 @@
max-height: 176px;
overflow-y: auto;
border: 1px solid var(--border);
border-radius: 8px;
border-radius: var(--radius-control);
background: var(--surface-2);
}
.chat-command-palette[hidden] { display: none; }
@@ -602,7 +602,7 @@
gap: 4px;
padding: 8px 10px;
border: 1px solid var(--border);
border-radius: 8px;
border-radius: var(--radius-control);
background: var(--surface-2);
}
.chat-command-notice-failed {
@@ -630,11 +630,11 @@
flex: 1 1 auto;
min-width: 0;
resize: none;
padding: 8px 10px;
padding: 8px 12px;
background: var(--bg);
color: var(--text);
border: 1px solid var(--border);
border-radius: 10px;
border-radius: var(--radius-control);
font: inherit;
line-height: 20px;
max-height: 132px;
@@ -647,7 +647,7 @@
font-size: 16px;
line-height: 1;
border: 1px solid var(--border);
border-radius: 10px;
border-radius: var(--radius-control);
background: var(--surface-2);
color: var(--text);
cursor: pointer;
+27 -26
View File
@@ -10,10 +10,11 @@
selector on its own.
Contrast contract (verified against the surfaces below):
--color-text 14.35:1 on --color-bg, 13.29:1 on --color-surface
--color-muted 9.14:1 on --color-bg, 8.47:1 on --color-surface
--color-border 3.71:1 on --color-surface, 3.09:1 on --color-elevated
--color-focus 13.21:1 on --color-surface
--color-text 16.17:1 on --color-bg, 15.29:1 on --color-surface
--color-muted 7.08:1 on --color-bg, 6.70:1 on --color-surface
--color-border 4.27:1 on --color-bg, 4.04:1 on --color-surface,
3.33:1 on --color-elevated-2 (component edges stay >=3:1)
--color-focus 10.59:1 on --color-bg, 10.01:1 on --color-surface
Run-status hues are the web's current values, unchanged.
=========================================================================== */
@@ -24,11 +25,11 @@
surface-2 an inset control, row or code body
elevated a menu, dialog, sheet or toast above the page
elevated-2 the highest drawn surface: hover on an elevated control */
--color-bg: #0e1513;
--color-surface: #161d1b;
--color-surface-2: #1a211f;
--color-elevated: #252c2a;
--color-elevated-2: #2f3634;
--color-bg: #0a0a0b;
--color-surface: #121214;
--color-surface-2: #17171a;
--color-elevated: #1d1d21;
--color-elevated-2: #242429;
--color-scrim: rgba(0, 0, 0, 0.58);
/* ---- Lines and focus --------------------------------------------------- */
@@ -38,23 +39,23 @@
elevated-2)
border-strong selected / pressed emphasis; >=3:1
focus the one focus ring colour, visible on every surface */
--color-divider: #2c3a36;
--color-border: #6a7874;
--color-border-strong: #889391;
--color-focus: #a9f0dd;
--color-divider: #26262a;
--color-border: #74747c;
--color-border-strong: #9898a0;
--color-focus: #a8c0dc;
/* ---- Text -------------------------------------------------------------- */
--color-text: #dee4e1;
--color-muted: #a9bab5;
--color-faint: #8b9b96;
--color-on-accent: #06231c;
--color-text: #e8e8ea;
--color-muted: #9a9aa2;
--color-faint: #85858d;
--color-on-accent: #081018;
--color-on-bad: #1b0b0b;
--opacity-disabled: 0.5;
/* ---- Accent ------------------------------------------------------------ */
--color-accent: #7fd1bb;
--color-accent-strong: #a3e4d3;
--color-accent-pressed: #5fbfa8;
--color-accent: #8fa8c8;
--color-accent-strong: #a8c0dc;
--color-accent-pressed: #758dad;
/* ---- Outcome hues (the app's own: ok / warn / bad) -------------------- */
--color-ok: #6bd39a;
@@ -95,11 +96,11 @@
/* ---- Interaction tints ------------------------------------------------- */
/* A tint is a transparent wash laid over whatever surface is already there;
it never replaces a surface role. */
--tint-hover: rgba(222, 228, 225, 0.05);
--tint-pressed: rgba(222, 228, 225, 0.09);
--tint-selected: rgba(127, 209, 187, 0.12);
--tint-selected-strong: rgba(127, 209, 187, 0.20);
--tint-accent-soft: rgba(127, 209, 187, 0.10);
--tint-hover: rgba(232, 232, 234, 0.05);
--tint-pressed: rgba(232, 232, 234, 0.09);
--tint-selected: rgba(143, 168, 200, 0.14);
--tint-selected-strong: rgba(143, 168, 200, 0.22);
--tint-accent-soft: rgba(143, 168, 200, 0.10);
--tint-ok-soft: rgba(107, 211, 154, 0.10);
--tint-warn-soft: rgba(230, 194, 104, 0.10);
--tint-bad-soft: rgba(239, 138, 138, 0.10);
@@ -150,7 +151,7 @@
--radius-xs: 4px; /* inline code */
--radius-s: 6px; /* tiny marker, count badge */
--radius-control: 8px; /* button, field, row, menu item */
--radius-card: 12px; /* pane, card, tile, transcript group */
--radius-card: 10px; /* pane, card, tile, transcript group */
--radius-sheet: 16px; /* dialog and sheet */
--radius-pill: 999px; /* chip, count pill, terminal node */
+85
View File
@@ -422,3 +422,88 @@
}
.rename-input:focus { outline: none; border-color: var(--accent); }
.rename-save { border-color: var(--accent); color: var(--accent); font-weight: 600; }
/* ---------------------------------------------------------------------------
Artifact viewer (R8): the dim backdrop and its one panel, the rendered
markdown document body and the markdown's document tile. The gallery/viewer
wiring lives in views/runDetail.js and views/dialogs.js; every server string
is still set with textContent.
--------------------------------------------------------------------------- */
/* The tile treats a markdown/text file as an ordinary document: a small drawn
page glyph above the existing uppercase "Document" kind label, never a media
poster. The glyph is CSS, so it needs no emoji font; the extra top padding
keeps it clear of the absolutely positioned Copy link / Share actions. */
.artifact-document-tile { padding-top: 34px; }
.artifact-doc-glyph {
position: relative;
display: block;
width: 18px;
height: 22px;
border: 1.5px solid var(--muted);
border-radius: 2px;
}
.artifact-doc-glyph::before,
.artifact-doc-glyph::after {
content: "";
position: absolute;
left: 3px;
right: 3px;
height: 1.5px;
background: var(--muted);
}
.artifact-doc-glyph::before { top: 6px; }
.artifact-doc-glyph::after { top: 11px; }
.artifact-viewer {
z-index: 60;
align-items: center;
justify-content: center;
padding: 24px;
background: rgba(0, 0, 0, 0.78);
}
.viewer-panel {
display: flex;
flex-direction: column;
gap: var(--space-s);
width: min(1100px, 100%);
max-height: 100%;
min-height: 0;
padding: 16px;
background: var(--surface);
border: 1px solid var(--border);
border-radius: 14px;
box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
outline: none;
}
.viewer-panel:focus { outline: none; }
/* Markdown/text needs the full board to scroll: a readable column, not a
centred image. The shared md-* classes keep the app's chat typography. */
.viewer-board-document {
display: block;
overflow-y: auto;
padding: 18px 20px;
background: var(--surface-2);
border: 1px solid var(--border);
border-radius: 10px;
}
.viewer-markdown {
width: 100%;
max-width: 78ch;
margin: 0 auto;
}
.viewer-markdown .md-code-block { max-width: 100%; }
.viewer-markdown .md-pre { overflow-x: auto; }
.viewer-markdown .md-table { display: block; overflow-x: auto; }
.viewer-loading { padding: 24px; text-align: center; }
.viewer-error { display: grid; gap: 10px; padding: 12px 4px; }
.viewer-error-message { color: var(--bad); line-height: 1.5; }
.viewer-external { color: var(--accent); justify-self: start; }
@media (max-width: 760px) {
.artifact-viewer { padding: 10px; }
.viewer-panel { padding: 10px; border-radius: 10px; }
.viewer-board-document { padding: 12px; }
}
+38 -15
View File
@@ -1,9 +1,9 @@
/* The workflow graph (P6): a mounted, pannable/zoomable canvas of stage nodes,
labelled outcome edges and the success/failure terminals, plus the definition
pane opened from a node. Hand-written, dark-first, no runtime dependency. */
.graph-host { margin-top: 12px; }
.graph-host { margin-top: 8px; }
.graph-panel { display: grid; gap: 12px; }
.graph-panel { display: grid; gap: 8px; }
.graph-panel.expanded .graph-viewport { height: 78vh; }
/* The run detail's Graph tab is the page: give the graph most of the body. */
.run-graph .graph-host { min-height: 0; }
@@ -14,7 +14,7 @@
height: 440px;
overflow: hidden;
border: 1px solid var(--border);
border-radius: 12px;
border-radius: var(--radius-card);
background: var(--surface);
cursor: grab;
/* A drag pans the graph instead of scrolling the page or selecting text. */
@@ -27,12 +27,25 @@
.graph-content { position: absolute; top: 0; left: 0; will-change: transform; }
.graph-edges { position: absolute; top: 0; left: 0; overflow: visible; pointer-events: none; }
.graph-edge-path { stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.graph-edge-path {
stroke-width: 3;
stroke-linecap: round;
stroke-linejoin: round;
/* The canvas ignores the pointer so panning works; a wire takes the pointer
back on its own stroke only, which is what makes hover-highlighting work. */
pointer-events: stroke;
transition: opacity 120ms ease-out;
}
.graph-edge-path.not-executed { stroke-width: 2.5; stroke-dasharray: 14 10; }
/* A system-added route (implicit error fallback): dotted, not merely dashed. */
.graph-edge-path.fallback { stroke-dasharray: 2 8; stroke-linecap: round; }
.graph-edge-path.hot { stroke-width: 5; }
.graph-edges.has-hot .graph-edge-path:not(.hot) { opacity: 0.3; }
.graph-arrowhead path { fill: var(--text); fill: context-stroke; }
.graph-node-layer, .graph-label-layer { position: absolute; top: 0; left: 0; }
.graph-label-layer { pointer-events: none; }
.graph-edge-label { pointer-events: auto; transition: opacity 120ms ease-out; }
.graph-node {
position: absolute;
@@ -41,7 +54,7 @@
justify-content: center;
padding: 6px 8px;
border: 1px solid var(--border);
border-radius: 12px;
border-radius: var(--radius-card);
background: var(--surface-2);
color: var(--text);
font: inherit;
@@ -51,7 +64,7 @@
overflow-wrap: anywhere;
cursor: pointer;
}
.graph-node:hover { border-color: var(--accent); }
.graph-node:hover { border-color: var(--color-border-strong); }
.graph-node.selected { border-color: var(--accent); box-shadow: inset 0 0 0 2px var(--accent); }
/* Node fills convey type: model neutral, ntfy amber, other/custom green. */
.graph-node-ntfy {
@@ -93,17 +106,26 @@
font-size: 11px;
white-space: nowrap;
}
.graph-edge-label.fallback { border-style: dotted; }
/* A label on a vertical run sits beside it, centred on the wire's midpoint. */
.graph-edge-label.vertical { transform: translate(-50%, -50%); }
.graph-edge-label.hot {
border-color: var(--accent);
color: var(--color-text);
background: var(--color-surface-2);
}
.graph-label-layer.has-hot .graph-edge-label:not(.hot) { opacity: 0.45; }
.graph-controls { position: absolute; top: 8px; right: 8px; z-index: 2; display: flex; gap: 6px; }
.graph-control {
padding: 4px 10px;
border: 1px solid var(--border);
border-radius: 8px;
border-radius: var(--radius-control);
background: var(--surface);
color: var(--text);
font-size: 12px;
}
.graph-control:hover { border-color: var(--accent); color: var(--accent); }
.graph-control:hover { border-color: var(--color-border-strong); }
/* The run-mode legend (R5), pinned top-start opposite the Fit/expand controls.
A solid, arrowed swatch means "executed"; a dashed, arrowless one "not
@@ -114,11 +136,11 @@
left: 8px;
z-index: 2;
display: flex;
gap: 12px;
gap: 8px;
align-items: center;
padding: 4px 8px;
border: 1px solid var(--border);
border-radius: 8px;
border-radius: var(--radius-control);
background: color-mix(in srgb, var(--surface) 85%, transparent);
font-size: 12px;
color: var(--muted);
@@ -141,6 +163,7 @@
border-bottom: 4px solid transparent;
}
.graph-legend-swatch.not-executed { border-top-style: dashed; }
.graph-legend-swatch.fallback { border-top: 2px dotted var(--muted); }
/* The live active stage (R5): a ring around the node plus a soft glow, pulsing
while the run executes and static when the user prefers reduced motion. */
@@ -177,9 +200,9 @@
.graph-pane {
display: grid;
gap: 8px;
padding: 10px 12px;
padding: 8px 12px;
border: 1px solid var(--border);
border-radius: 12px;
border-radius: var(--radius-card);
background: var(--surface);
/* A deep-linked stage is revealed with scrollIntoView; keep its head clear of
the sticky top bar instead of hiding it underneath. */
@@ -206,14 +229,14 @@
width: 100%;
padding: 8px 10px;
border: 0;
border-radius: 8px;
border-radius: var(--radius-control);
background: var(--surface-2);
color: var(--text);
font-weight: 600;
text-align: left;
}
.graph-section-body { display: grid; gap: 6px; padding: 8px 2px 0; }
.graph-field { display: grid; grid-template-columns: minmax(120px, 200px) 1fr; gap: 10px; align-items: baseline; }
.graph-field { display: grid; grid-template-columns: minmax(120px, 200px) 1fr; gap: 8px; align-items: baseline; }
.graph-field-label { color: var(--muted); font-size: 12px; }
.graph-field-value { font-size: 13px; overflow-wrap: anywhere; }
.graph-field-block { grid-template-columns: 1fr; }
@@ -223,7 +246,7 @@
max-height: 260px;
overflow: auto;
border: 1px solid var(--border);
border-radius: 8px;
border-radius: var(--radius-control);
background: var(--surface-2);
color: var(--text);
font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
+16 -16
View File
@@ -39,7 +39,7 @@
padding: 6px;
background: var(--surface-2);
border: 1px solid var(--border);
border-radius: 10px;
border-radius: var(--radius-card);
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
display: grid;
gap: 2px;
@@ -61,7 +61,7 @@
border: 0;
background: transparent;
padding: 6px 8px;
border-radius: 6px;
border-radius: var(--radius-control);
font-size: 13px;
}
.menu-item:hover { background: var(--surface); }
@@ -73,7 +73,7 @@
gap: 8px;
min-width: 0;
padding: 4px 8px;
border-radius: 6px;
border-radius: var(--radius-control);
font-size: 13px;
cursor: pointer;
}
@@ -94,8 +94,8 @@
.metrics {
display: flex;
flex-wrap: wrap;
gap: 20px;
padding: 12px 16px;
gap: 16px;
padding: 8px 12px;
border-bottom: 1px solid var(--border);
}
.metric { display: flex; flex-direction: column; min-width: 56px; }
@@ -111,7 +111,7 @@
position: sticky;
top: 0;
z-index: 1;
padding: 7px 16px;
padding: 4px 12px;
background: var(--surface);
border-bottom: 1px solid var(--border);
font-size: 11px;
@@ -120,7 +120,7 @@
color: var(--muted);
}
.run-row { display: block; padding: 10px 14px; }
.run-row { display: block; padding: 8px 12px; }
.run-row-head { display: flex; align-items: center; gap: 8px; }
.run-row-title { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.run-row-pipeline { display: flex; align-items: center; gap: 8px; margin-top: 2px; color: var(--muted); font-size: 12px; }
@@ -172,7 +172,7 @@
/* --- Templates gallery + detail ------------------------------------------ */
.pane-head { display: flex; gap: 8px; align-items: center; justify-content: space-between; padding: 12px 12px 0; }
.pane-head { display: flex; gap: 8px; align-items: center; justify-content: space-between; padding: 8px 12px 0; }
.pane-head .pane-title { margin: 0; font-size: 16px; }
.gallery { padding-bottom: 8px; }
@@ -182,11 +182,11 @@
width: 100%;
text-align: left;
border: 1px solid var(--border);
border-radius: 10px;
border-radius: var(--radius-card);
background: var(--surface-2);
padding: 10px 12px;
padding: 8px 12px;
}
.card:hover { border-color: var(--accent); }
.card:hover { border-color: var(--color-border-strong); background: var(--color-elevated); }
.card.selected { box-shadow: inset 3px 0 0 var(--accent); border-color: var(--accent); }
.card-name { display: block; font-weight: 600; }
.card-desc {
@@ -205,7 +205,7 @@
.tabbody .body { margin: 0 0 12px; }
.meta-line { color: var(--muted); font-size: 12px; margin-top: 4px; }
.codeblock { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; margin-top: 12px; }
.codeblock { border: 1px solid var(--border); border-radius: var(--radius-card); overflow: hidden; margin-top: 12px; }
.codeblock-label { padding: 6px 10px; background: var(--surface-2); border-bottom: 1px solid var(--border); color: var(--muted); font-size: 12px; }
.codeblock-body {
margin: 0;
@@ -235,7 +235,7 @@
.filter-item { display: flex; gap: 8px; align-items: center; padding: 3px 0; font-size: 13px; cursor: pointer; }
.filter-item input { accent-color: var(--accent); }
.filter-actions { margin-top: 10px; display: flex; gap: 8px; }
.sort-option { display: block; width: 100%; text-align: left; border: 1px solid transparent; background: transparent; padding: 5px 8px; border-radius: 6px; font-size: 13px; }
.sort-option { display: block; width: 100%; text-align: left; border: 1px solid transparent; background: transparent; padding: 5px 8px; border-radius: var(--radius-control); font-size: 13px; }
.sort-option:hover { background: var(--surface-2); }
.sort-option.active { border-color: var(--accent); color: var(--accent); }
@@ -248,13 +248,13 @@
.detail-subtitle { font-size: 12px; margin-bottom: 10px; }
.monospace { font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace; font-size: 12px; }
.section-toggle { display: flex; gap: 8px; align-items: center; width: 100%; text-align: left; margin-top: 16px; border: 0; border-radius: 8px; background: var(--surface-2); padding: 8px 10px; font-weight: 600; }
.section-toggle { display: flex; gap: 8px; align-items: center; width: 100%; text-align: left; margin-top: 16px; border: 0; border-radius: var(--radius-control); background: var(--surface-2); padding: 8px 10px; font-weight: 600; }
.section-toggle .chevron { color: var(--muted); }
.section-body { padding: 8px 4px 0; display: grid; gap: 6px; }
.version-row { display: flex; gap: 12px; align-items: baseline; border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; }
.version-row { display: flex; gap: 12px; align-items: baseline; border: 1px solid var(--border); border-radius: var(--radius-control); padding: 6px 10px; }
.version-title { font-weight: 600; }
.source-code { margin: 0; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 12px; overflow: auto; max-height: 60vh; }
.source-code { margin: 0; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-card); padding: 12px; overflow: auto; max-height: 60vh; }
.source-code code { background: transparent; padding: 0; font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace; font-size: 12px; white-space: pre-wrap; word-break: break-word; }
.graph-note { margin: 0; max-width: 60ch; }
+19 -13
View File
@@ -4,7 +4,7 @@
stage pane. Hand-written, dark palette, no framework.
--------------------------------------------------------------------------- */
.run-tab-body { display: grid; gap: 10px; }
.run-tab-body { display: grid; gap: 8px; }
.run-detail-title { margin: 0; font: var(--type-title); letter-spacing: var(--tracking-tight); }
.run-title-row { display: flex; gap: var(--space-xs); align-items: center; flex-wrap: wrap; min-width: 0; }
@@ -12,7 +12,7 @@
.run-chip-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.run-identity { font-size: 12px; }
.run-wait { color: var(--warn); font-size: 12px; }
.run-empty { padding: 14px 4px; }
.run-empty { padding: 12px 4px; }
.collapsible .section-title { flex: 1; }
.collapsible > .section-body { padding: 6px 2px 2px; }
@@ -20,7 +20,7 @@
margin: 0;
padding: 8px;
border: 1px solid var(--border);
border-radius: 8px;
border-radius: var(--radius-control);
background: var(--surface-2);
overflow: auto;
max-height: 360px;
@@ -38,10 +38,10 @@
.timeline { display: grid; }
.timeline-row {
display: flex;
gap: 10px;
gap: 8px;
align-items: flex-start;
width: 100%;
padding: 10px 4px;
padding: 8px 4px;
border-bottom: 1px solid var(--border);
cursor: pointer;
}
@@ -120,9 +120,9 @@
}
.stage-pane-bar {
display: flex;
gap: 10px;
gap: 8px;
align-items: center;
padding: 10px 12px;
padding: 8px 12px;
border-bottom: 1px solid var(--border);
background: var(--surface);
}
@@ -139,16 +139,16 @@
border-left: 1px solid var(--border);
box-shadow: -12px 0 40px rgba(0, 0, 0, 0.45);
}
.stage-pane-body { flex: 1; overflow-y: auto; padding: 10px 12px; display: grid; gap: 6px; align-content: start; }
.stage-pane-body { flex: 1; overflow-y: auto; padding: 8px 12px; display: grid; gap: var(--space-xs); align-content: start; }
.stage-section > .section-body { padding-top: 4px; }
/* The verdict block leads the pane. */
.verdict {
display: grid;
gap: 8px;
padding: 10px;
padding: var(--space-s);
border: 1px solid var(--border);
border-radius: 10px;
border-radius: var(--radius-card);
background: var(--surface-2);
}
.verdict-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
@@ -182,7 +182,7 @@
gap: 10px;
align-items: flex-start;
padding: 6px 8px;
border-radius: 8px;
border-radius: var(--radius-control);
cursor: pointer;
}
.change-row:hover { background: var(--surface-2); }
@@ -232,7 +232,7 @@
margin: 0;
padding: 12px;
border: 1px solid var(--border);
border-radius: 10px;
border-radius: var(--radius-card);
background: var(--surface-2);
font-size: 12px;
white-space: pre;
@@ -242,7 +242,7 @@
.change-diff { display: grid; gap: 12px; align-content: start; }
.change-diff-stat { display: flex; gap: 8px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.change-diff-note { font-size: 12px; }
.change-hunk { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.change-hunk { border: 1px solid var(--border); border-radius: var(--radius-control); overflow: hidden; }
.change-hunk-head {
padding: 4px 8px;
background: var(--surface-2);
@@ -263,3 +263,9 @@
.diff-add { color: var(--ok); }
.diff-remove { color: var(--bad); }
.diff-context { color: var(--muted); }
/* A markdown stage body (the turn protocol) is prose, not a code block: keep the
app's reading measure and its natural spacing. */
.field-markdown { max-width: var(--layout-measure); padding: 2px 0; }
.field-markdown > :first-child { margin-top: 0; }
.field-markdown > :last-child { margin-bottom: 0; }
+12 -12
View File
@@ -6,10 +6,10 @@
--------------------------------------------------------------------------- */
.settings {
display: grid;
gap: var(--space-l);
gap: var(--space-m);
max-width: 720px;
margin: 0 auto;
padding: var(--space-l) var(--space-m) var(--space-3xl);
padding: 20px var(--space-m) var(--space-xl);
}
.settings-page-title {
margin: 0;
@@ -22,7 +22,7 @@
font: var(--type-title-small);
color: var(--color-text);
}
.settings-field { display: grid; gap: 6px; }
.settings-field { display: grid; gap: var(--space-2xs); }
.settings-field-label { font-size: 12px; color: var(--muted); }
.settings-field input[type="text"] { flex: none; width: 100%; min-width: 0; }
.settings-helper { margin: 0; font-size: 12px; color: var(--muted); }
@@ -34,7 +34,7 @@
.settings button.primary {
background: var(--accent);
border-color: var(--accent);
color: #06231c;
color: var(--color-on-accent);
font-weight: 600;
}
.settings button.primary:hover { border-color: var(--accent); filter: brightness(1.06); }
@@ -50,9 +50,9 @@
display: grid;
gap: 4px;
border: 1px solid var(--border);
border-radius: 10px;
border-radius: var(--radius-card);
background: var(--surface-2);
padding: 14px 16px;
padding: 12px 16px;
}
.settings-status-line { margin: 0; font-size: 13px; }
.settings-status-head { display: flex; align-items: center; gap: 12px; }
@@ -75,20 +75,20 @@
}
.settings-warning {
display: grid;
gap: 6px;
gap: 8px;
border: 1px solid var(--border);
border-radius: 10px;
border-radius: var(--radius-card);
background: color-mix(in srgb, var(--bad) 12%, var(--surface-2));
padding: 14px 16px;
padding: 12px 16px;
}
.settings-warning-title { margin: 0; font-weight: 600; color: var(--bad); }
.settings-warning-body { margin: 0; font-size: 12.5px; color: var(--muted); }
.settings-notify-state {
margin: 0;
border: 1px solid var(--border);
border-radius: 10px;
border-radius: var(--radius-card);
background: var(--surface-2);
padding: 12px 14px;
padding: 12px 16px;
font-size: 13px;
color: var(--muted);
}
@@ -103,7 +103,7 @@
align-items: center;
gap: 12px;
width: 100%;
padding: 14px 16px;
padding: 12px 16px;
}
.settings-card-glyph { color: var(--muted); font-size: 18px; line-height: 1; }
.settings-card-text { display: block; flex: 1; min-width: 0; }
+17 -6
View File
@@ -139,7 +139,7 @@ body {
.detail-pane > .pane-scroll > .detail,
.detail-pane > .pane-scroll > .detail.run-detail {
min-height: 100%;
padding: var(--space-m);
padding: var(--space-s);
background: transparent;
border: 0;
border-radius: 0;
@@ -190,7 +190,7 @@ body {
justify-content: center;
width: 26px;
height: 26px;
border-radius: 8px;
border-radius: var(--radius-control);
background: var(--tint-selected-strong);
color: var(--color-accent);
font-size: 13px;
@@ -436,7 +436,7 @@ body {
min-width: 16px;
height: 16px;
padding: 0 4px;
border-radius: 8px;
border-radius: var(--radius-control);
background: var(--color-accent);
color: var(--color-bg);
font-size: 10px;
@@ -466,7 +466,7 @@ body {
/* ---- Shared pane text --------------------------------------------------- */
.detail-title {
margin: 0 0 var(--space-s);
margin: 0 0 var(--space-xs);
font: var(--type-title);
letter-spacing: var(--tracking-tight);
overflow-wrap: anywhere;
@@ -488,7 +488,7 @@ body {
border-bottom: 1px solid var(--color-divider);
}
.search-host:empty { display: none; }
.search-host .search-panel { padding: var(--space-s) var(--space-m); }
.search-host .search-panel { padding: var(--space-xs) var(--space-s); }
.search-input { flex: 1 1 240px; min-width: 0; }
/* ---- Wide layout (one breakpoint, 600px) -------------------------------- */
@@ -529,7 +529,18 @@ body {
.list-pane { border-right: 1px solid var(--color-divider); }
.pane-back { display: none; }
.section-strip { display: none; }
/* The detail's sections belong with the detail, not with the destinations:
on a wide screen they are a tab row above the detail body. The rail keeps
only the destinations. (Narrow keeps the thumb-zone strip at the bottom.) */
.rail-sections,
.rail-sections.has-sections { display: none; }
.section-strip {
order: -1;
border-top: 0;
border-bottom: 1px solid var(--color-divider);
background: var(--color-bg);
padding: 0 var(--space-s);
}
.destination-dock { display: none; }
}
+4 -1
View File
@@ -25,6 +25,7 @@ import {
} from "./runEvents.js";
import { SERVER_URL_STORAGE_KEY, readServerUrl, readWorkspace, writeServerUrl } from "./settings.js";
import { layoutGraph } from "./graph.js";
import { readGraphExpanded } from "./graphPrefs.js";
import { DEFAULT_ROUTE, parseRoute, serializeRoute } from "./routes.js";
import { EMPTY_PIPELINE_FILTERS, PIPELINE_DETAIL_TABS } from "./pipelines.js";
import {
@@ -155,11 +156,13 @@ const state = {
// 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,
// Expanded by default; a collapse is remembered (graphPrefs.js).
pipelineGraphExpanded: readGraphExpanded(),
// 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,
runGraphExpanded: readGraphExpanded(),
versionsExpanded: false,
pipelinesLoaded: false,
runsLoaded: false,
+40 -11
View File
@@ -94,6 +94,9 @@ const DOCUMENT_EXTENSIONS = new Set([
"txt", "md", "markdown", "rst", "doc", "docx", "odt", "rtf", "html", "htm",
]);
/** The text file kinds the browser can render in the artifact viewer. */
const MARKDOWN_EXTENSIONS = new Set(["md", "markdown", "txt"]);
const DOCUMENT_MIMES = new Set([
"application/msword",
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
@@ -195,6 +198,31 @@ export function artifactKindLabel(kind) {
return KIND_LABELS[kind] ?? "File";
}
/**
* Whether an artifact is text the reader can render as markdown in the viewer:
* `text/markdown` or `text/plain` (parameters ignored), or a `.md`, `.markdown`
* or `.txt` name. The viewer uses the page's existing markdown renderer, so these
* are the text files it is allowed to fetch and draw. Pure and total, mirroring
* the content-type tests above.
*/
export function isMarkdownArtifact(contentType, name) {
const mime = String(contentType ?? "").split(";")[0].trim().toLowerCase();
if (mime === "text/markdown" || mime === "text/plain") return true;
return MARKDOWN_EXTENSIONS.has(extensionOf(name));
}
/**
* Whether an artifact opens inside the full-screen viewer: the two media kinds
* the gallery already previewed, plus the markdown/text documents it now renders
* itself. The kind gate keeps a `text/plain` `.log`, `.py` or `.csv` an external
* file: those are evidence, not prose. This is the one predicate the grid tiles,
* paging and the viewer share, so they cannot disagree about the list.
*/
export function isViewerArtifact(contentType, name) {
if (isImageContentType(contentType) || isVideoContentType(contentType)) return true;
return artifactKind(contentType, name) === ArtifactKind.Document && isMarkdownArtifact(contentType, name);
}
/**
* Human-readable byte size, matching Android Format.kt humanBytes (and the TUI):
* whole bytes under 1 KiB, otherwise one decimal with a binary unit
@@ -320,28 +348,29 @@ export function artifactCaptureNotes(step) {
}
/**
* The media artifacts `groups` hold, in the exact order the gallery draws them
* (group by group, each group's images and videos in recorded order): the
* neighbours the full-screen viewer pages through, so a swipe visits the same
* list the grid showed. Non-media artifacts open externally and are not part of
* it. Mirrors ArtifactViewer.kt pagedArtifacts.
* The artifacts `groups` hold that the full-screen viewer can page through, in
* the exact order the gallery draws them (group by group, each group's images,
* videos and markdown/text documents in recorded order): the neighbours a
* swipe/keyboard step visits, so the viewer walks the same list the grid showed.
* Other artifacts open externally and are not part of it. Mirrors
* ArtifactViewer.kt pagedArtifacts, extended for markdown-first stage turns.
*/
export function pagedArtifacts(groups) {
const viewable = [];
for (const group of groups ?? []) {
for (const artifact of group?.artifacts ?? []) {
const kind = artifactKind(artifact?.content_type, artifact?.name);
if (kind === ArtifactKind.Image || kind === ArtifactKind.Video) viewable.push(artifact);
if (isViewerArtifact(artifact?.content_type, artifact?.name)) viewable.push(artifact);
}
}
return viewable;
}
/**
* Each gallery media artifact's url mapped to its position in `pagedArtifacts`,
* the same ordered list the viewer pages through. The grid's tiles resolve their
* viewer index here, so tile and viewer derive from one source and cannot drift.
* The first occurrence of a url wins. Mirrors ArtifactViewer.kt viewerIndexByUrl.
* Each viewer-selectable artifact's url mapped to its position in
* `pagedArtifacts`, the same ordered list the viewer pages through. The grid's
* tiles resolve their viewer index here, so tile and viewer derive from one
* source and cannot drift. The first occurrence of a url wins. Mirrors
* ArtifactViewer.kt viewerIndexByUrl.
*/
export function viewerIndexByUrl(groups) {
const indices = new Map();
+182 -56
View File
@@ -137,6 +137,9 @@ export function graphEdges(graph) {
outcome,
target: resolveTarget(outcome, raw),
label: edgeLabel(stage, outcome),
// The parser adds `error -> #failure` when a stage declares no error
// route; that edge is the system's, not the author's.
fallback: outcome === "error" && Boolean(stage.fallback_error),
});
}
}
@@ -352,12 +355,30 @@ export const DEFAULT_GRAPH_METRICS = Object.freeze({
nodeHeight: 76,
hGap: 60,
pad: 24,
laneSpacing: 44,
// A lane only has to fit its 18px outcome chip plus a gap, so 34 keeps a
// dense definition's lanes from stretching the canvas to twice its height.
laneSpacing: 34,
terminalGap: 88,
trackStep: 40,
portSpacing: 20,
// Edge labels are DOM chips over the SVG, so the layout has to reserve room
// for them itself: a wide chip between two adjacent stages would otherwise
// overprint both boxes (the layered-drawing "label dummy" problem).
labelCharWidth: 6.4,
labelPadding: 10,
// The rendered chip is ~24px tall at the 11px label type, so routes that
// share a band must clear that plus a gap.
labelHeight: 24,
labelGap: 8,
});
/** The chip width a layout reserves for an outcome label (deterministic, no DOM). */
export function labelWidthFor(label, metrics = DEFAULT_GRAPH_METRICS) {
const m = { ...DEFAULT_GRAPH_METRICS, ...(metrics ?? {}) };
const text = String(label ?? "");
return Math.max(28, Math.round(text.length * m.labelCharWidth) + 16);
}
/** Centred fan for the k-th of n ports: 0, +s, -s, +2s, -2s, ... (portOffset). */
export function portOffset(index, spacing) {
if (index <= 0) return 0;
@@ -448,29 +469,46 @@ export function routePoints(edge) {
}
/**
* Where an edge's outcome label sits: the midpoint of its widest horizontal run
* (its own lane), so distinct outcomes never overprint. Pure and stored on the
* Where an edge's outcome label sits. The preferred spot is the midpoint of the
* widest horizontal run that can actually hold the chip; a side exit with only a
* short stub would otherwise park its label on top of a forward route's label.
* When no horizontal run fits, the longest run wins, and a vertical one is
* flagged so the chip can sit beside the wire in the gap. Pure and stored on the
* layout so drawing never recomputes it.
*/
export function labelPointFor(edge, points) {
if (points.length < 2) return { ...edge.from };
if (!edge.bottomExit && !edge.topEntry && !edge.across) {
const first = points[0];
const last = points[points.length - 1];
return { x: (first.x + last.x) / 2, y: (first.y + last.y) / 2 };
}
let best = null;
let bestWidth = -1;
export function labelPointFor(edge, points, labelWidth = 0) {
if (points.length < 2) return { ...edge.from, vertical: false };
let bestH = null;
let bestHw = -1;
let bestV = null;
let bestVh = -1;
for (let i = 1; i < points.length; i += 1) {
const a = points[i - 1];
const b = points[i];
if (a.y === b.y && Math.abs(b.x - a.x) > bestWidth) {
bestWidth = Math.abs(b.x - a.x);
best = [a, b];
if (a.y === b.y) {
const width = Math.abs(b.x - a.x);
if (width > bestHw) {
bestHw = width;
bestH = [a, b];
}
} else if (a.x === b.x) {
const height = Math.abs(b.y - a.y);
if (height > bestVh) {
bestVh = height;
bestV = [a, b];
}
}
}
if (!best) return { ...points[0] };
return { x: (best[0].x + best[1].x) / 2, y: best[0].y };
const fits = (run) => run != null && bestHw >= Math.max(labelWidth, 24);
if (fits(bestH)) {
return { x: (bestH[0].x + bestH[1].x) / 2, y: bestH[0].y, vertical: false };
}
if (bestV && bestVh >= bestHw) {
return { x: bestV[0].x, y: (bestV[0].y + bestV[1].y) / 2, vertical: true };
}
if (bestH) return { x: (bestH[0].x + bestH[1].x) / 2, y: bestH[0].y, vertical: false };
if (bestV) return { x: bestV[0].x, y: (bestV[0].y + bestV[1].y) / 2, vertical: true };
return { ...points[0], vertical: false };
}
/**
@@ -495,13 +533,32 @@ export function layoutGraph(graph, metrics = {}) {
const stageCount = stages.length;
const contentLeft = m.pad + m.hGap;
const stageX = (index) => contentLeft + index * (m.nodeWidth + m.hGap);
const stageRowRight = stageX(stageCount - 1) + m.nodeWidth;
const stageBottom = m.pad + m.nodeHeight;
const isForward = (edge) =>
!isTerminal(edge.target) && (rank.get(edge.target) ?? -1) === (rank.get(edge.source) ?? -2) + 1;
// A gap is as wide as its widest straight-route label plus breathing room, so
// a chip never reaches into either neighbouring box. This is the standard
// layered-drawing answer to edge labels: reserve the space up front instead of
// discovering the collision after drawing.
const gapWidths = new Array(stageCount).fill(m.hGap);
for (const edge of edges) {
if (!isForward(edge)) continue;
const targetRank = rank.get(edge.target);
if (targetRank == null) continue;
gapWidths[targetRank] = Math.max(
gapWidths[targetRank],
labelWidthFor(edge.label, m) + 2 * m.labelPadding,
);
}
const stageX = (index) => {
let x = contentLeft;
for (let i = 1; i <= index; i += 1) x += gapWidths[i] + m.nodeWidth;
return x;
};
const stageRowRight = stageX(stageCount - 1) + m.nodeWidth;
// Every non-forward edge needs its own cross lane, stacked below the stage row
// in stable edge-id order; the terminal row sits below all of them.
const laneIds = edges.filter((edge) => !isForward(edge));
@@ -574,6 +631,16 @@ export function layoutGraph(graph, metrics = {}) {
const horizontals = segmentAllocator(m.portSpacing);
const verticals = segmentAllocator(m.trackStep / 3);
const gapContaining = (x) => {
if (x < contentLeft) return [m.pad, contentLeft];
for (let gap = 1; gap < stageCount; gap += 1) {
const lo = stageX(gap - 1) + m.nodeWidth;
const hi = stageX(gap);
if (x <= hi) return [lo, hi];
}
return [stageRowRight, stageRowRight + m.hGap];
};
const gapBounds = (gap) => {
if (gap <= 0) return [m.pad, contentLeft];
if (gap >= stageCount) {
@@ -585,29 +652,42 @@ export function layoutGraph(graph, metrics = {}) {
// Forward edges are allocated first: a straight forward route keeps a single
// horizontal segment by sharing one y between its source and target ports.
const forwardEdges = edges.filter(isForward);
// Grouping per source (not one global index) lets a stage's own routes fan
// across its side at a spacing that keeps their two chips apart, instead of
// piling every forward edge in the definition into the same 20px band.
const forwardBySource = new Map();
for (const edge of edges) {
if (!isForward(edge)) continue;
const list = forwardBySource.get(edge.source) ?? [];
list.push(edge);
forwardBySource.set(edge.source, list);
}
const forwardY = new Map();
forwardEdges.forEach((edge, index) => {
const source = byKey.get(edge.source);
const target = byKey.get(edge.target);
if (!source || !target) return;
const y =
source.y +
source.height / 2 -
((forwardEdges.length - 1) / 2) * m.portSpacing +
index * m.portSpacing;
forwardY.set(
edge.id,
horizontals.allocate(
y,
source.x + source.width,
target.x,
source.y + m.portSpacing / 2,
source.y + source.height - m.portSpacing / 2,
m.portSpacing,
),
);
});
for (const list of forwardBySource.values()) {
const source = byKey.get(list[0].source);
if (!source) continue;
const n = list.length;
const usable = source.height - m.portSpacing;
const spacing =
n > 1 ? Math.min(Math.max(m.labelHeight + m.labelGap, m.portSpacing), usable / (n - 1)) : 0;
const first = source.y + source.height / 2 - ((n - 1) / 2) * spacing;
list.forEach((edge, index) => {
const target = byKey.get(edge.target);
if (!target) return;
const desired = first + index * spacing;
forwardY.set(
edge.id,
horizontals.allocate(
desired,
source.x + source.width,
target.x,
desired,
desired,
Math.max(spacing, m.portSpacing),
),
);
});
}
const portMin = (node) => node.y + m.portSpacing / 2;
const portMax = (node) => node.y + node.height - m.portSpacing / 2;
@@ -741,6 +821,7 @@ export function layoutGraph(graph, metrics = {}) {
outcome: edge.outcome,
target: edge.target,
label: edge.label,
fallback: Boolean(edge.fallback),
from: { x: fromX, y: fromY },
to: { x: toX, y: toY },
forward,
@@ -758,7 +839,14 @@ export function layoutGraph(graph, metrics = {}) {
labelPoint: { x: 0, y: 0 },
};
layout.points = routePoints(layout);
layout.labelPoint = labelPointFor(layout, layout.points);
const width = labelWidthFor(layout.label, m);
layout.labelPoint = labelPointFor(layout, layout.points, width);
if (layout.labelPoint.vertical) {
// Keep a chip on a vertical run inside its own gap, clear of both boxes.
const half = width / 2 + 2;
const [lo, hi] = gapContaining(layout.labelPoint.x);
layout.labelPoint.x = Math.min(Math.max(layout.labelPoint.x, lo + half), Math.max(lo + half, hi - half));
}
return layout;
});
@@ -991,33 +1079,65 @@ export function mount(container, graph, options = {}) {
defs.append(marker);
svg.append(defs);
const pathsById = new Map();
for (const edge of layout.edges) {
if (edge.points.length < 2) continue;
const executed = edgeIsExecuted(edge, runState);
const kind = edge.fallback ? "fallback" : executed ? "executed" : "not-executed";
const path = svgEl("path", {
class: `graph-edge-path${executed ? " executed" : " not-executed"}`,
class: `graph-edge-path ${kind}`,
d: pathFromPoints(edge.points),
"data-edge-id": edge.id,
"data-outcome": edge.outcome,
fill: "none",
});
path.style.stroke = executed ? edgeStrokeColor(edge.outcome) : "var(--muted)";
if (executed) path.setAttribute("marker-end", `url(#${markerId})`);
path.style.stroke = executed || edge.fallback ? edgeStrokeColor(edge.outcome) : "var(--muted)";
if (executed || edge.fallback) path.setAttribute("marker-end", `url(#${markerId})`);
pathsById.set(edge.id, path);
svg.append(path);
}
content.append(svg);
// Label layer: the outcome chips, so a neighbouring edge never crosses one.
// In a RUN, label only the routes that actually happened: every stage declares
// error/blocked/retry outcomes too, and labelling all of them buried the graph
// under a wall of chips. A definition (no runState) still labels every route.
const labelLayer = el("div", "graph-label-layer");
const chipsById = new Map();
for (const edge of layout.edges) {
const chip = el("span", "graph-edge-label", edge.label);
if (runState && !edgeIsExecuted(edge, runState)) continue;
const chipClass = [
"graph-edge-label",
edge.fallback ? "fallback" : "",
edge.labelPoint.vertical ? "vertical" : "",
].filter(Boolean).join(" ");
const chip = el("span", chipClass, edge.label);
chip.style.left = `${edge.labelPoint.x}px`;
chip.style.top = `${edge.labelPoint.y}px`;
chip.setAttribute("data-outcome", edge.outcome);
chip.setAttribute("data-edge-id", edge.id);
chipsById.set(edge.id, chip);
labelLayer.append(chip);
}
content.append(labelLayer);
// Hovering either the wire or its chip lights the pair and dims the rest, so a
// route is traceable through the crossing lanes without following every bend.
function setEdgeHot(id, hot) {
pathsById.get(id)?.classList.toggle("hot", hot);
chipsById.get(id)?.classList.toggle("hot", hot);
svg.classList.toggle("has-hot", hot);
labelLayer.classList.toggle("has-hot", hot);
}
for (const [id, path] of pathsById) {
path.addEventListener("pointerenter", () => setEdgeHot(id, true));
path.addEventListener("pointerleave", () => setEdgeHot(id, false));
const chip = chipsById.get(id);
if (!chip) continue;
chip.addEventListener("pointerenter", () => setEdgeHot(id, true));
chip.addEventListener("pointerleave", () => setEdgeHot(id, false));
}
// Node layer: real buttons, positioned in graph space.
const nodeLayer = el("div", "graph-node-layer");
let elapsedBadge = null;
@@ -1076,19 +1196,25 @@ export function mount(container, graph, options = {}) {
controls.append(fitButton, expandButton);
viewport.append(controls);
// The legend, only under a run (never the definition-only view): a solid,
// arrowed swatch means "executed", a dashed, arrowless one "not executed",
// matching what the graph draws.
if (runState != null) {
// The legend: a solid, arrowed swatch means "executed", a dashed, arrowless
// one "not executed", and a dotted one a system-added fallback (the parser's
// implicit `error -> #failure`). A definition shows only the fallback key.
const legendEntries = runState != null
? [
{ label: "Executed", kind: "executed" },
{ label: "Not executed", kind: "not-executed" },
]
: [];
if (layout.edges.some((edge) => edge.fallback)) {
legendEntries.push({ label: "System fallback", kind: "fallback" });
}
if (legendEntries.length > 0) {
const legend = el("div", "graph-legend");
legend.setAttribute("role", "note");
legend.setAttribute("aria-label", "Executed and not executed routes");
for (const entry of [
{ label: "Executed", executed: true },
{ label: "Not executed", executed: false },
]) {
legend.setAttribute("aria-label", "Route kinds");
for (const entry of legendEntries) {
const item = el("span", "graph-legend-entry");
item.append(el("span", `graph-legend-swatch ${entry.executed ? "executed" : "not-executed"}`));
item.append(el("span", `graph-legend-swatch ${entry.kind}`));
item.append(el("span", "graph-legend-label", entry.label));
legend.append(item);
}
+22
View File
@@ -0,0 +1,22 @@
// The workflow graph's expansion preference. The graph is expanded by default;
// collapsing it is a deliberate choice and is remembered across reloads, so the
// operator's next visit opens the graph the way they left it.
export const GRAPH_EXPANDED_KEY = "pipelines.web.graphExpanded.v1";
/** True unless the operator collapsed the graph (a missing value means default). */
export function readGraphExpanded(storage = globalThis.localStorage) {
try {
return storage?.getItem(GRAPH_EXPANDED_KEY) !== "0";
} catch {
return true;
}
}
export function writeGraphExpanded(value, storage = globalThis.localStorage) {
try {
storage?.setItem(GRAPH_EXPANDED_KEY, value ? "1" : "0");
} catch {
// Storage may be unavailable; the in-memory choice still applies.
}
}
+12
View File
@@ -592,6 +592,18 @@ export function clampVisitIndex(index, count) {
* artifacts section always shows for a reached visit. Mirrors
* `stageSectionSpecs`.
*/
/**
* Whether a recorded field value is markdown rather than plain text: a heading, a
* fenced block, a bullet/ordered list or a table. The new stage turns write
* markdown bodies (`# outcome` …), while historical steps store plain maps; this
* keeps the old ones rendering as code.
*/
export function looksLikeMarkdown(value) {
const text = typeof value === "string" ? value : "";
if (!text) return false;
return /^#{1,6}\s/m.test(text) || /```/.test(text) || /^\s*(?:[-*]|\d+\.)\s+/m.test(text) || /^\|.+\|/m.test(text);
}
export function stageSectionSpecs(stageKey, graph, runSteps, visitIndex, runContext) {
const specs = [];
const stage = (graph?.stages ?? []).find((candidate) => candidate?.key === stageKey);
+141 -13
View File
@@ -23,6 +23,7 @@ import {
ArtifactKind,
artifactKind,
artifactViewerPositionLabel,
isMarkdownArtifact,
pagedIndex,
resolvedArtifactUrl,
} from "../artifacts.js";
@@ -538,42 +539,167 @@ function dismissActionError() {
}
let viewerOverlay = null;
let viewerSession = null;
/** Close the full-screen viewer; the controller returns focus to its trigger. */
function closeArtifactViewer() {
if (viewerSession) {
viewerSession.closed = true;
viewerSession.abort?.abort();
viewerSession = null;
}
modal.close("artifact-viewer");
viewerOverlay = null;
}
/**
* Open the full-screen viewer at `startIndex` into `viewable`, the same ordered
* media list the grid drew. Previous/Next are disabled at the ends and absent for
* a single artifact; Escape and a backdrop click close it. Nothing autoplays: a
* non-image artifact shows a still poster placeholder instead.
* list the grid drew (images, videos and markdown/text documents). Previous/Next
* are disabled at the ends; ArrowLeft/ArrowRight page the same list; Escape and a
* click on the dimmed backdrop close it, while clicks inside the panel never do.
* Nothing autoplays: a video shows a still poster placeholder instead.
*
* Markdown and text artifacts are fetched once per viewer session from the
* resolved artifact URL and rendered with the page's own markdown renderer,
* building DOM nodes (never innerHTML). A failed fetch or render keeps the
* viewer honest: it shows describeError's message, the resolved-external action
* and the normal Open/Copy/Share actions.
*/
function openArtifactViewer(viewable, startIndex, trigger = null) {
closeArtifactViewer();
if (!viewable?.length) return;
let index = pagedIndex(startIndex, 0, viewable.length);
const session = {
closed: false,
generation: 0,
abort: null,
cache: new Map(),
errors: new Map(),
};
const overlay = h("div", {
class: "artifact-viewer",
role: "dialog",
"aria-modal": "true",
"aria-label": "Artifact viewer",
});
const panel = h("div", { class: "viewer-panel", "data-viewer-focus": "panel", tabindex: "-1" });
overlay.append(panel);
overlay.addEventListener("click", (event) => {
if (event.target === overlay) closeArtifactViewer();
});
const renderViewer = () => {
/** The focus key of the control inside the panel that currently owns focus. */
const focusedKey = () => {
const active = document.activeElement;
if (!panel.contains(active)) return null;
return active?.getAttribute?.("data-viewer-focus") ?? null;
};
/** Keep focus inside the viewer after the panel is rebuilt. */
const restoreFocus = (key) => {
if (!key) return;
const target =
key === "panel" ? panel : panel.querySelector(`[data-viewer-focus="${key}"]`);
if (target && !target.disabled) target.focus({ preventScroll: true });
else panel.focus({ preventScroll: true });
};
const step = (delta) => {
const next = pagedIndex(index, delta, viewable.length);
if (next === index) return;
index = next;
renderViewer({ restore: true });
};
overlay.addEventListener("keydown", (event) => {
if (event.key === "ArrowLeft") {
event.preventDefault();
step(-1);
} else if (event.key === "ArrowRight") {
event.preventDefault();
step(1);
}
});
const renderViewer = ({ restore = false } = {}) => {
const keepFocus = restore ? focusedKey() : null;
const generation = ++session.generation;
const artifact = viewable[index] ?? {};
const resolved = resolvedArtifactUrl(artifact, state.url);
const kind = artifactKind(artifact.content_type, artifact.name);
const markdown = isMarkdownArtifact(artifact.content_type, artifact.name);
const name = artifact.name || "(unnamed artifact)";
const board = h("div", { class: "viewer-board" });
if (kind === ArtifactKind.Image && resolved) {
board.append(h("img", { class: "viewer-image", src: resolved, alt: name }));
} else if (kind === ArtifactKind.Video) {
board.append(
h(
"div",
{ class: "viewer-placeholder" },
h("span", { class: "artifact-play", text: "▶" }),
h("span", { class: "viewer-placeholder-name", text: name }),
),
);
} else if (markdown) {
board.classList.add("viewer-board-document");
const renderMarkdown = rt.views?.chat?.renderMarkdown;
const showFailure = (message) => {
const error = h("div", { class: "viewer-error" });
error.append(h("div", { class: "viewer-error-message", text: message }));
if (resolved) {
error.append(
h("a", {
class: "viewer-external",
href: resolved,
target: "_blank",
rel: "noreferrer",
text: `Open ${name} externally`,
}),
);
}
board.append(error);
};
const draw = (text) => {
try {
const article = h("div", { class: "viewer-markdown" });
article.append(renderMarkdown(text));
board.append(article);
return true;
} catch (error) {
showFailure(describeError(error));
return false;
}
};
if (!resolved) {
showFailure("Set the server URL in Settings to open this artifact.");
} else if (session.cache.has(resolved)) {
draw(session.cache.get(resolved));
} else if (session.errors.has(resolved)) {
showFailure(session.errors.get(resolved));
} else if (typeof renderMarkdown !== "function") {
showFailure("Markdown rendering is unavailable.");
} else {
board.append(h("div", { class: "viewer-loading muted", text: "Loading markdown…" }));
session.abort?.abort();
const controller = new AbortController();
session.abort = controller;
(async () => {
try {
const response = await fetch(resolved, { signal: controller.signal });
if (!response.ok) throw new Error(`The server answered ${response.status}.`);
const text = await response.text();
if (session.closed || generation !== session.generation) return;
session.cache.set(resolved, text);
renderViewer({ restore: true });
} catch (error) {
if (error?.name === "AbortError" || session.closed || generation !== session.generation) return;
session.errors.set(resolved, describeError(error));
renderViewer({ restore: true });
}
})();
}
} else {
board.append(
h(
@@ -601,12 +727,14 @@ function openArtifactViewer(viewable, startIndex, trigger = null) {
h("button", {
class: "viewer-action",
type: "button",
"data-viewer-focus": "open",
text: "Open",
onclick: () => window.open(resolved, "_blank", "noopener,noreferrer"),
}),
h("button", {
class: "viewer-action",
type: "button",
"data-viewer-focus": "copy",
text: "Copy link",
disabled: !canCopyLink(),
onclick: () => copyArtifactLink(resolved),
@@ -614,6 +742,7 @@ function openArtifactViewer(viewable, startIndex, trigger = null) {
h("button", {
class: "viewer-action",
type: "button",
"data-viewer-focus": "share",
text: "Share",
disabled: !canShare(),
onclick: () => shareArtifact(resolved),
@@ -624,6 +753,7 @@ function openArtifactViewer(viewable, startIndex, trigger = null) {
h("button", {
class: "viewer-action viewer-close",
type: "button",
"data-viewer-focus": "close",
text: "Close viewer",
onclick: closeArtifactViewer,
}),
@@ -638,32 +768,30 @@ function openArtifactViewer(viewable, startIndex, trigger = null) {
h("button", {
class: "viewer-page",
type: "button",
"data-viewer-focus": "prev",
text: "Previous artifact",
disabled: pagedIndex(index, -1, viewable.length) === index,
onclick: () => {
index = pagedIndex(index, -1, viewable.length);
renderViewer();
},
onclick: () => step(-1),
}),
h("button", {
class: "viewer-page",
type: "button",
"data-viewer-focus": "next",
text: "Next artifact",
disabled: pagedIndex(index, 1, viewable.length) === index,
onclick: () => {
index = pagedIndex(index, 1, viewable.length);
renderViewer();
},
onclick: () => step(1),
}),
),
);
}
nodes.push(actions);
overlay.replaceChildren(...nodes);
panel.replaceChildren(...nodes);
if (restore) restoreFocus(keepFocus ?? "panel");
};
renderViewer();
viewerOverlay = overlay;
viewerSession = session;
modal.open("artifact-viewer", overlay, {
onClose: () => closeArtifactViewer(),
trigger,
+2
View File
@@ -24,6 +24,7 @@ import {
versionRow,
} from "../pipelines.js";
import { PIPELINE_GRAPH_EMPTY, mount as mountGraph } from "../graph.js";
import { writeGraphExpanded } from "../graphPrefs.js";
export function createPipelinesView(rt) {
const { state, repo } = rt;
@@ -303,6 +304,7 @@ function renderPipelineDetail() {
},
onExpandedChange: (value) => {
state.pipelineGraphExpanded = value;
writeGraphExpanded(value);
},
});
return pane;
+50 -14
View File
@@ -9,6 +9,7 @@ import { liveBadgeState } from "../connection.js";
import { resolveArtifactUrl } from "../serverUrl.js";
import { runStateOf } from "../runs.js";
import { PIPELINE_GRAPH_EMPTY, RUN_GRAPH_MISSING, mount as mountGraph } from "../graph.js";
import { writeGraphExpanded } from "../graphPrefs.js";
import {
RENDERED_RUN_TABS,
EMPTY_INPUT_MESSAGE,
@@ -31,6 +32,7 @@ import {
verdictReasonSegments,
outcomeColorToken,
stateGlyph,
looksLikeMarkdown,
} from "../runDetail.js";
import {
ArtifactKind,
@@ -43,6 +45,7 @@ import {
artifactViewerPositionLabel,
displayVisit,
humanBytes,
isViewerArtifact,
pagedArtifacts,
presentedArtifacts,
resolvedArtifactUrl,
@@ -172,7 +175,12 @@ function renderRunGraphTab(d) {
wrap.append(host);
state.runGraph = mountGraph(host, d.graph, {
runState: runGraphState(d),
expanded: state.runGraphExpanded,
onStageTap: (key) => openStagePane(key, latestVisitIndex(d, key)),
onExpandedChange: (value) => {
state.runGraphExpanded = value;
writeGraphExpanded(value);
},
});
return wrap;
}
@@ -260,8 +268,27 @@ function renderCodeBlock(label, text) {
}
/** One stage-pane field as either the code card (blocks) or a key/value row. */
/**
* One recorded field value: a markdown body (the new stage turns) is rendered as
* markdown; anything else stays an honest monospace block.
*/
function renderFieldValue(value) {
const text = typeof value === "string" ? value : String(value ?? "");
if (looksLikeMarkdown(text)) {
return h("div", { class: "field-markdown" }, rt.views.chat.renderMarkdown(text));
}
return h("pre", { class: "field-block" }, h("code", { text }));
}
function renderStageField(field) {
if (field.block) return renderCodeBlock(field.label, field.value);
if (field.block) {
return h(
"div",
{ class: "codeblock" },
h("div", { class: "codeblock-label", text: field.label }),
renderFieldValue(field.value),
);
}
return h(
"div",
{ class: "kv-row" },
@@ -281,9 +308,7 @@ function renderRunFieldTab(map, keyPrefix, emptyMessage) {
for (const section of sections) {
const key = `${keyPrefix}-${section.key}`;
wrap.append(
renderCollapsible(key, section.title, () =>
h("pre", { class: "field-block" }, h("code", { text: section.value })),
),
renderCollapsible(key, section.title, () => renderFieldValue(section.value)),
);
}
return wrap;
@@ -580,7 +605,7 @@ function renderVerdictBlock(step) {
return wrap;
}
/** One inline artifact reference in a verdict reason (media opens the viewer). */
/** One inline artifact reference in a verdict reason (viewer files open the viewer). */
function renderVerdictLink(text, artifact, step) {
const resolved = resolvedArtifactUrl(artifact, state.url);
if (!resolved) return h("span", { class: "verdict-link disabled", text });
@@ -604,17 +629,18 @@ function renderVerdictRef(artifact, step) {
return chip;
}
/** Open a referenced artifact: media in the viewer, everything else externally. */
/** Open a referenced artifact: viewer-selectable files in the viewer, others externally. */
function openArtifactFromVerdict(artifact, step, resolved, trigger = null) {
if (!resolved) return;
const group = { stageKey: step.stage, visit: displayVisit(step, 0), artifacts: presentedArtifacts(step) };
const viewable = pagedArtifacts([group]);
const viewerIndexOf = viewerIndexByUrl([group]);
const at = viewerIndexOf.get(artifact.url);
const kind = artifactKind(artifact.content_type, artifact.name);
const media = kind === ArtifactKind.Image || kind === ArtifactKind.Video;
if (media && at != null) openArtifactViewer(viewable, at, trigger);
else window.open(resolved, "_blank", "noopener,noreferrer");
if (isViewerArtifact(artifact.content_type, artifact.name) && at != null) {
openArtifactViewer(viewable, at, trigger);
} else {
window.open(resolved, "_blank", "noopener,noreferrer");
}
}
/** Open the stage pane for one visit of a stage; the controller moves focus in. */
@@ -808,7 +834,8 @@ function renderArtifactGallery(steps) {
* The per-visit artifacts section shown inside one step: the summary line, the
* capture notes, the no-server-URL hint and a headerless grid of that visit's
* tiles (matching the Android ArtifactsSection). Its viewer pages only through
* that visit's media, exactly as the Android section does.
* that visit's viewable artifacts (media and markdown), exactly as the Android
* section does.
*/
function renderVisitArtifacts(step) {
const wrap = h("div", { class: "artifacts" });
@@ -842,13 +869,15 @@ function renderArtifactGrid(artifacts, viewable, viewerIndexOf) {
/**
* One gallery tile: an image thumbnail, a video poster with a play marker (never
* a <video> element or autoplay), or a kind/name/size label. Every server string
* is set as text, never as markup.
* a <video> element or autoplay), or a kind/name/size label. Markdown and text
* documents get a paper glyph and open in the viewer like media. Every server
* string is set as text, never as markup.
*/
function renderArtifactTile(artifact, viewable, viewerIndexOf) {
const resolved = resolvedArtifactUrl(artifact, state.url);
const kind = artifactKind(artifact.content_type, artifact.name);
const media = kind === ArtifactKind.Image || kind === ArtifactKind.Video;
const opensViewer = isViewerArtifact(artifact.content_type, artifact.name);
const name = artifact.name || "(unnamed artifact)";
// The tile is the native control (M5): Enter/Space activate it for free, and
// the Copy link / Share buttons are siblings in the wrapper, never children.
@@ -857,6 +886,9 @@ function renderArtifactTile(artifact, viewable, viewerIndexOf) {
class: "artifact-tile clickable",
type: "button",
"aria-label": `Open ${name}`,
"data-artifact-name": artifact.name ?? "",
"data-artifact-kind": kind,
"data-artifact-url": artifact.url ?? "",
});
const openViewer = () => {
const at = viewerIndexOf.get(artifact.url);
@@ -881,12 +913,16 @@ function renderArtifactTile(artifact, viewable, viewerIndexOf) {
tile.append(h("div", { class: "artifact-name", text: name }));
tile.addEventListener("click", openViewer);
} else {
if (opensViewer) {
tile.classList.add("artifact-document-tile");
tile.append(h("span", { class: "artifact-doc-glyph", "aria-hidden": "true" }));
}
tile.append(
h("div", { class: "artifact-kind", text: artifactKindLabel(kind) }),
h("div", { class: "artifact-name", text: name }),
h("div", { class: "artifact-size", text: humanBytes(artifact.size_bytes) }),
);
tile.addEventListener("click", openTab);
tile.addEventListener("click", opensViewer ? openViewer : openTab);
}
wrap.append(tile, renderTileActions(resolved, media));
return wrap;
+83 -3
View File
@@ -19,6 +19,8 @@ import {
artifactViewerPositionLabel,
displayVisit,
humanBytes,
isMarkdownArtifact,
isViewerArtifact,
pagedArtifacts,
pagedIndex,
presentedArtifacts,
@@ -253,7 +255,83 @@ test("pagedArtifacts keeps only images and videos, in gallery order", () => {
assert.deepEqual(pagedArtifacts([]), []);
});
test("viewerIndexByUrl maps each media url to its position, first occurrence wins", () => {
test("isMarkdownArtifact accepts markdown/text content types and md/txt names", () => {
for (const [contentType, name] of [
["text/markdown", "plan"],
["text/markdown; charset=utf-8", "plan"],
["text/plain", "notes"],
["application/octet-stream", "input.md"],
["", "memory.markdown"],
["", "output.txt"],
["text/html", "report.md"],
["text/plain", "run.log"],
]) {
assert.equal(isMarkdownArtifact(contentType, name), true, `${contentType} ${name}`);
}
for (const [contentType, name] of [
["text/html", "session.html"],
["text/csv", "rows.csv"],
["application/json", "payload.json"],
["text/x-python", "main.py"],
["application/xml", "shot.png.xml"],
["", ""],
[undefined, undefined],
]) {
assert.equal(isMarkdownArtifact(contentType, name), false, `${contentType} ${name}`);
}
});
test("isViewerArtifact includes media and markdown but not code, logs or other files", () => {
for (const [contentType, name] of [
["image/png", "shot.png"],
["video/mp4", "clip.mp4"],
["text/markdown", "input.md"],
["text/plain", "memory.txt"],
["", "output.md"],
]) {
assert.equal(isViewerArtifact(contentType, name), true, `${contentType} ${name}`);
}
for (const [contentType, name] of [
["text/html", "session.html"],
["text/csv", "rows.csv"],
["application/json", "payload.json"],
["text/x-python", "main.py"],
["text/plain", "run.log"],
["application/octet-stream", "blob.bin"],
["", ""],
]) {
assert.equal(isViewerArtifact(contentType, name), false, `${contentType} ${name}`);
}
});
test("pagedArtifacts keeps images, videos and markdown in gallery order", () => {
const groups = [
{ stageKey: "reviewer", visit: 1, artifacts: [art("session.html", { contentType: "text/html" })] },
{
stageKey: "implementer",
visit: 2,
artifacts: [
art("input.md", { contentType: "text/markdown" }),
art("run.log", { contentType: "text/plain" }),
art("shot.png", { contentType: "image/png" }),
art("main.py", { contentType: "text/x-python" }),
art("clip.mp4", { contentType: "video/mp4" }),
art("memory.txt", { contentType: "text/plain" }),
art("rows.csv", { contentType: "text/csv" }),
art("output.md", { contentType: "application/octet-stream" }),
],
},
];
assert.deepEqual(pagedArtifacts(groups).map((a) => a.name), [
"input.md",
"shot.png",
"clip.mp4",
"memory.txt",
"output.md",
]);
});
test("viewerIndexByUrl maps each viewer-selectable url, first occurrence wins", () => {
const groups = [
{
stageKey: "s",
@@ -263,13 +341,15 @@ test("viewerIndexByUrl maps each media url to its position, first occurrence win
art("note.txt", { contentType: "text/plain", url: "/artifacts/1/1/note.txt" }),
art("b.png", { contentType: "image/png", url: "/artifacts/1/1/b.png" }),
art("a.png", { contentType: "image/png", url: "/artifacts/1/1/a.png" }),
art("session.html", { contentType: "text/html", url: "/artifacts/1/1/session.html" }),
],
},
];
const index = viewerIndexByUrl(groups);
assert.equal(index.get("/artifacts/1/1/a.png"), 0);
assert.equal(index.get("/artifacts/1/1/b.png"), 1);
assert.equal(index.has("/artifacts/1/1/note.txt"), false);
assert.equal(index.get("/artifacts/1/1/note.txt"), 1);
assert.equal(index.get("/artifacts/1/1/b.png"), 2);
assert.equal(index.has("/artifacts/1/1/session.html"), false);
});
test("pagedIndex clamps at both ends and never wraps", () => {
+7
View File
@@ -0,0 +1,7 @@
# Turn input
Plan the next small change.
```sh
go test ./...
```
+3
View File
@@ -0,0 +1,3 @@
# Memory
The previous turn landed the artifact viewer.
+6
View File
@@ -0,0 +1,6 @@
# Output
The change is ready for review.
- viewer renders markdown
- keyboard paging works
Binary file not shown.

After

Width:  |  Height:  |  Size: 68 B

+45
View File
@@ -20,6 +20,7 @@ import {
edgeLabel,
graphEdges,
graphNodeKind,
labelWidthFor,
graphDescription,
hitTest,
layoutGraph,
@@ -203,6 +204,50 @@ test("layoutGraph labels sit on the edge's own widest horizontal run", () => {
}
});
test("a gap is at least as wide as the widest straight-route label plus padding", () => {
const graph = {
stages: [
{ key: "a", edges: { success: "b", repair_attempt: "b", error: "#" }, fallback_error: true },
{ key: "b", edges: { success: "#success" } },
],
};
const layout = layoutGraph(graph);
const [a, b] = layout.nodes.filter((node) => !node.terminal);
const gap = b.x - (a.x + a.width);
const widest = Math.max(labelWidthFor("success"), labelWidthFor("repair_attempt"));
assert.ok(gap >= widest + 2 * 10, `gap ${gap} fits the ${widest}px chip`);
});
test("a source's straight routes fan across its side instead of one shared band", () => {
const graph = {
stages: [
{ key: "a", edges: { success: "b", repair_attempt: "b", error: "#" }, fallback_error: true },
{ key: "b", edges: { success: "#success" } },
],
};
const layout = layoutGraph(graph);
const ys = layout.edges
.filter((edge) => edge.forward && edge.source === "a")
.map((edge) => edge.from.y)
.sort((x, y) => x - y);
assert.equal(ys.length, 2);
assert.ok(ys[1] - ys[0] >= 18, "their chips (18px tall) cannot touch");
});
test("graphEdges marks only the parser's implicit error fallback", () => {
const graph = {
stages: [
{ key: "a", edges: { success: "b", error: "#" }, fallback_error: true },
{ key: "b", edges: { success: "#success", error: "#" }, fallback_error: false },
],
};
const edges = graphEdges(graph);
assert.equal(edges.filter((edge) => edge.fallback).length, 1);
assert.equal(edges.find((edge) => edge.fallback).source, "a");
const layout = layoutGraph(graph);
assert.equal(layout.edges.filter((edge) => edge.fallback).length, 1);
});
test("layoutGraph is empty and finite for a graph with no stages", () => {
const layout = layoutGraph({ stages: [] });
assert.deepEqual(layout.nodes, []);
+32
View File
@@ -0,0 +1,32 @@
// The graph expansion preference: expanded by default, a collapse remembered.
import { test } from "node:test";
import assert from "node:assert/strict";
import { GRAPH_EXPANDED_KEY, readGraphExpanded, writeGraphExpanded } from "../src/graphPrefs.js";
function fakeStorage(initial = {}) {
const values = new Map(Object.entries(initial));
return {
getItem: (key) => (values.has(key) ? values.get(key) : null),
setItem: (key, value) => values.set(key, String(value)),
values,
};
}
test("the graph is expanded when nothing was stored", () => {
assert.equal(readGraphExpanded(fakeStorage()), true);
});
test("a collapse survives and expands again on request", () => {
const storage = fakeStorage();
writeGraphExpanded(false, storage);
assert.equal(storage.values.get(GRAPH_EXPANDED_KEY), "0");
assert.equal(readGraphExpanded(storage), false);
writeGraphExpanded(true, storage);
assert.equal(readGraphExpanded(storage), true);
});
test("storage failures fall back to the expanded default", () => {
const broken = { getItem() { throw new Error("denied"); }, setItem() { throw new Error("denied"); } };
assert.equal(readGraphExpanded(broken), true);
assert.doesNotThrow(() => writeGraphExpanded(false, broken));
});
+12
View File
@@ -8,6 +8,7 @@ import assert from "node:assert/strict";
import {
RUN_DETAIL_TABS,
looksLikeMarkdown,
RENDERED_RUN_TABS,
EMPTY_INPUT_MESSAGE,
EMPTY_OUTPUT_MESSAGE,
@@ -608,3 +609,14 @@ test("outcomeColorToken uses the status palette then the flow palette", () => {
assert.equal(stateGlyph("succeeded"), "✓");
assert.equal(stateGlyph("nonsense"), "?");
});
test("looksLikeMarkdown recognises stage bodies and leaves legacy maps alone", () => {
assert.equal(looksLikeMarkdown("# outcome\nsuccess\n\n# notes\nDone."), true);
assert.equal(looksLikeMarkdown("Some text\n\n- one\n- two"), true);
assert.equal(looksLikeMarkdown("```js\nconst a = 1;\n```"), true);
assert.equal(looksLikeMarkdown("| a | b |\n| --- | --- |\n| 1 | 2 |"), true);
// Historical field text is a plain map, not markdown.
assert.equal(looksLikeMarkdown("summary: ok\nfindings: none"), false);
assert.equal(looksLikeMarkdown(""), false);
assert.equal(looksLikeMarkdown(null), false);
});
+375 -41
View File
@@ -15,6 +15,9 @@
// real runs and chat session. The default run never sends a `submit`: the live
// server's pipeline list is never mutated.
//
// `--viewer` drives ONLY R8's deterministic markdown/text viewer fixture (no
// dependency on the operator's current run history) and captures 44–48.
//
// `--decide` drives ONLY R11's live human-decision flow: it reuses an existing
// entry-stage human pipeline or submits one uniquely named create-only
// definition, starts two throwaway runs in fresh temp workspaces, and presses
@@ -82,14 +85,16 @@ const scratch = process.argv.includes("--scratch");
const notifyOnly = process.argv.includes("--notify");
// Focused R11 evidence only; the one explicit mode allowed to submit a pipeline.
const decideOnly = process.argv.includes("--decide");
// Focused R8 evidence only: the deterministic markdown viewer fixture, with no
// dependency on the operator's current run history.
const viewerOnly = process.argv.includes("--viewer");
// The page must connect through its own proxy (the server rejects a cross-origin
// upgrade), but serve.mjs only proxies /connect — not /artifacts. Point the URL
// field at the real Pipelines server after connecting so artifact tiles and the
// viewer resolve to real files; that is exactly the URL a correctly configured
// page would carry.
const artifactServerUrl = `ws://${pipelines}/connect`;
const pipelineUrl = artifactServerUrl;
// Artifact URLs resolve against the configured server. Point them at the page's
// own proxy origin (serve.mjs forwards /artifacts/ and /connect), so the viewer's
// markdown fetch and the image/video tiles are same-origin exactly as they are
// in a correctly configured deployment.
const artifactServerUrl = `ws://127.0.0.1:${port}/connect`;
const pipelineUrl = `ws://${pipelines}/connect`;
const shots = [];
let serve = null;
@@ -1670,6 +1675,292 @@ async function runNotificationChecks() {
);
}
// --- R8: the markdown-first artifact viewer --------------------------------
// A deterministic synthetic run served by the page's own static origin. The run
// is injected over the real get_run command (never a new protocol field): its
// ordinary artifacts include the stage-turn names and a small media+markdown
// list, so the gallery, the viewer, keyboard paging, the backdrop and the honest
// failure path are exercised without depending on whatever history the operator
// currently has (the live fixture may be wiped between runs).
const VIEWER_FIXTURE_RUN_ID = 990001;
function viewerFixtureRun() {
const fixture = (name, contentType, url) => ({
name,
content_type: contentType,
size_bytes: 96,
url,
});
return {
id: VIEWER_FIXTURE_RUN_ID,
pipeline_id: 1,
version: 1,
name: "Viewer fixture",
title: "Markdown viewer fixture",
status: "succeeded",
executing: false,
outcome: "success",
current_stage: "",
content_hash: "viewerfixture",
created_at: "2026-10-19T20:00:00Z",
finished_at: "2026-10-19T20:01:00Z",
completed_steps: 1,
diagnostic: "",
resource_wait: null,
input: { prompt: "Render the stage turn." },
output: { result: "ready" },
graph: {
stages: [
{ key: "implementer", type: "model", edges: { success: "#success" }, prompt: "Render." },
],
},
steps: [
{
sequence: 1,
stage: "implementer",
status: "completed",
outcome: "success",
target: "#success",
diagnostic: "",
session_id: "",
agent_active: false,
control: { visit: 1, max_visits: 1 },
started_at: "2026-10-19T20:00:00Z",
finished_at: "2026-10-19T20:01:00Z",
input: { prompt: "Render the stage turn." },
output: { result: "ready" },
artifacts: [
fixture("input.md", "text/markdown; charset=utf-8", "/test/fixtures/artifacts/input.md"),
fixture("shot.png", "image/png", "/test/fixtures/artifacts/shot.png"),
fixture("memory.md", "text/plain; charset=utf-8", "/test/fixtures/artifacts/memory.md"),
fixture("output.md", "text/markdown; charset=utf-8", "/test/fixtures/artifacts/output.md"),
// Deliberately absent from the static origin: the viewer must show the
// honest fetch failure, not an empty or invented document.
fixture("missing.txt", "text/plain; charset=utf-8", "/test/fixtures/artifacts/missing.txt"),
],
},
],
};
}
/** The visible gallery tiles' stable metadata and document marking. */
async function viewerTiles(scope) {
return page.evaluate(`[...document.querySelectorAll(${JSON.stringify(scope)} + " .artifact-tile")].map((tile) => ({
name: tile.getAttribute("data-artifact-name") ?? "",
kind: tile.getAttribute("data-artifact-kind") ?? "",
label: tile.querySelector(".artifact-kind")?.textContent ?? "",
glyph: !!tile.querySelector(".artifact-doc-glyph"),
}))`);
}
async function runMarkdownViewerChecks() {
step("R8: the deterministic markdown/text stage-turn fixture run");
const fixture = viewerFixtureRun();
// This init script only answers get_run for the fixture id: every other frame
// (the socket, the real list, the operator's own data) still goes to the server.
await page.addInitScript(`(() => {
window.__viewerFixtureRun = ${JSON.stringify(fixture)};
window.__pipelinesIntercept = (frame) => (
frame.type === "get_run" && frame.run_id === ${VIEWER_FIXTURE_RUN_ID}
? { id: frame.id, type: "run_detail", run_detail: window.__viewerFixtureRun }
: null
);
})()`);
await openDeepLink(`/runs/${VIEWER_FIXTURE_RUN_ID}`);
await page.waitForSelector("#detailTitle", { timeout: 20000 });
await eventually(
() =>
page.evaluate(
`document.querySelector(".run-detail .run-identity")?.textContent?.startsWith("run ${VIEWER_FIXTURE_RUN_ID} ") ?? false`,
),
{ timeout: 20000, what: "the markdown fixture run detail to load" },
);
step("R8: the run gallery shows input.md, memory.md and output.md as Documents");
await page.clickText(".run-detail .section-toggle", "Artifacts");
await page.waitForSelector('.run-detail .artifact-gallery .artifact-tile[data-artifact-name="input.md"]', {
timeout: 15000,
});
const runTiles = await viewerTiles(".run-detail .artifact-gallery");
for (const name of ["input.md", "memory.md", "output.md"]) {
const tile = runTiles.find((entry) => entry.name === name);
if (!tile) throw new Error(`the run gallery is missing ${name}: ${JSON.stringify(runTiles)}`);
if (tile.kind !== "Document" || tile.label !== "Document" || !tile.glyph) {
throw new Error(`${name} is not presented as a Document: ${JSON.stringify(tile)}`);
}
}
const runImage = runTiles.find((entry) => entry.name === "shot.png");
if (!runImage || runImage.kind !== "Image" || runImage.glyph) {
throw new Error(`shot.png is not presented as media: ${JSON.stringify(runImage)}`);
}
console.log(` run gallery: ${runTiles.map((tile) => `${tile.name} (${tile.label})`).join(", ")}`);
await shot("44-viewer-turn-documents.png");
step("R8: the per-visit gallery presents the same turn documents");
await clickDetailTab("Timeline");
await page.click('.detail .timeline-row[data-stage-key="implementer"]');
await page.waitForSelector(".stage-pane", { timeout: 15000 });
await page.clickText(".stage-pane .section-toggle", "Artifacts");
await page.waitForSelector('.stage-pane .artifact-tile[data-artifact-name="input.md"]', { timeout: 15000 });
const visitTiles = await viewerTiles(".stage-pane");
for (const name of ["input.md", "memory.md", "output.md"]) {
const tile = visitTiles.find((entry) => entry.name === name);
if (!tile || tile.kind !== "Document" || tile.label !== "Document" || !tile.glyph) {
throw new Error(`the visit gallery does not present ${name} as a Document: ${JSON.stringify(tile)}`);
}
}
console.log(` visit gallery: ${visitTiles.map((tile) => tile.name).join(", ")}`);
step("R8: opening input.md renders the fetched markdown in the viewer");
await page.click('.stage-pane .artifact-tile[data-artifact-name="input.md"]');
await page.waitForSelector(".artifact-viewer .viewer-panel", { timeout: 15000 });
await page.waitForSelector(".viewer-markdown h3.md-heading", { timeout: 15000 });
const rendered = await page.evaluate(`(() => {
const viewer = document.querySelector(".artifact-viewer");
const heading = viewer?.querySelector(".viewer-markdown h3.md-heading");
const code = viewer?.querySelector(".viewer-markdown .md-code-block pre code");
const fetched = performance.getEntriesByType("resource").map((entry) => entry.name)
.filter((name) => name.endsWith("/test/fixtures/artifacts/input.md"));
return {
heading: heading?.textContent ?? "",
code: code?.textContent ?? "",
fetched: fetched.length,
position: viewer?.querySelector(".viewer-position")?.textContent ?? "",
title: viewer?.querySelector(".viewer-title")?.textContent ?? "",
prevDisabled: viewer?.querySelector('.viewer-page[data-viewer-focus="prev"]')?.disabled ?? null,
nextDisabled: viewer?.querySelector('.viewer-page[data-viewer-focus="next"]')?.disabled ?? null,
hasPanel: !!viewer?.querySelector(".viewer-panel"),
};
})()`);
if (rendered.heading !== "Turn input" || !rendered.code.includes("go test ./...")) {
throw new Error(`the markdown did not render through the page renderer: ${JSON.stringify(rendered)}`);
}
if (!rendered.hasPanel || rendered.title !== "input.md" || !rendered.position.startsWith("1 of 5")) {
throw new Error(`the viewer head/position is wrong: ${JSON.stringify(rendered)}`);
}
if (rendered.fetched < 1) {
throw new Error(`the viewer did not fetch the resolved artifact url: ${JSON.stringify(rendered)}`);
}
if (rendered.prevDisabled !== true || rendered.nextDisabled !== false) {
throw new Error(`the first artifact's paging state is wrong: ${JSON.stringify(rendered)}`);
}
console.log(
` rendered "${rendered.heading}" with fenced code (${rendered.code.trim().split("\n")[0]}); ${rendered.position}`,
);
await shot("45-viewer-markdown-rendered.png");
step("R8: ArrowRight advances to the next artifact, ArrowLeft returns");
await page.evaluate(
`document.activeElement?.dispatchEvent(new KeyboardEvent("keydown", { key: "ArrowRight", bubbles: true, cancelable: true }))`,
);
await eventually(
() =>
page.evaluate(
`document.querySelector(".artifact-viewer .viewer-position")?.textContent?.startsWith("2 of 5") ?? false`,
),
{ timeout: 10000, what: "ArrowRight to advance the viewer" },
);
const advanced = await page.evaluate(`(() => {
const viewer = document.querySelector(".artifact-viewer");
const image = viewer?.querySelector(".viewer-image");
return {
title: viewer?.querySelector(".viewer-title")?.textContent ?? "",
position: viewer?.querySelector(".viewer-position")?.textContent ?? "",
imageLoaded: !!image && image.complete && image.naturalWidth > 0,
};
})()`);
if (advanced.title !== "shot.png" || !advanced.imageLoaded) {
throw new Error(`ArrowRight did not land on the image artifact: ${JSON.stringify(advanced)}`);
}
console.log(` ArrowRight -> ${advanced.title} (${advanced.position})`);
await shot("46-viewer-markdown-next.png");
await page.evaluate(
`document.activeElement?.dispatchEvent(new KeyboardEvent("keydown", { key: "ArrowLeft", bubbles: true, cancelable: true }))`,
);
await eventually(
() =>
page.evaluate(
`document.querySelector(".artifact-viewer .viewer-position")?.textContent?.startsWith("1 of 5") ?? false`,
),
{ timeout: 10000, what: "ArrowLeft to return the viewer" },
);
const returned = await page.evaluate(
`document.querySelector(".artifact-viewer .viewer-title")?.textContent ?? ""`,
);
if (returned !== "input.md") throw new Error(`ArrowLeft returned to ${returned}, not input.md`);
console.log(" ArrowLeft -> input.md");
step("R8: the last artifact disables Next and a failed fetch is honest");
await page.evaluate(`(() => {
for (let i = 0; i < 20; i += 1) {
const next = document.querySelector('.viewer-page[data-viewer-focus="next"]');
if (!next || next.disabled) break;
next.click();
}
})()`);
await page.waitForSelector(".artifact-viewer .viewer-error-message", { timeout: 15000 });
const failure = await page.evaluate(`(() => {
const viewer = document.querySelector(".artifact-viewer");
const external = viewer?.querySelector(".viewer-external");
return {
title: viewer?.querySelector(".viewer-title")?.textContent ?? "",
message: viewer?.querySelector(".viewer-error-message")?.textContent ?? "",
externalText: external?.textContent ?? "",
externalHref: external?.getAttribute("href") ?? "",
nextDisabled: viewer?.querySelector('.viewer-page[data-viewer-focus="next"]')?.disabled ?? null,
};
})()`);
if (failure.title !== "missing.txt" || failure.message.trim() === "") {
throw new Error(`the failed fetch did not show an honest message: ${JSON.stringify(failure)}`);
}
if (
failure.externalText !== "Open missing.txt externally" ||
!failure.externalHref.endsWith("/test/fixtures/artifacts/missing.txt")
) {
throw new Error(`the external fallback is wrong: ${JSON.stringify(failure)}`);
}
if (failure.nextDisabled !== true) throw new Error("Next is not disabled on the last artifact");
console.log(` failure: ${failure.message.trim()} · ${failure.externalText}`);
await shot("47-viewer-markdown-failure.png");
step("R8: a click inside the panel keeps the viewer open; the backdrop closes it");
await page.evaluate(`document.querySelector('.viewer-page[data-viewer-focus="prev"]').click()`);
await page.evaluate(`document.querySelector('.viewer-page[data-viewer-focus="prev"]').click()`);
await page.evaluate(`document.querySelector('.viewer-page[data-viewer-focus="prev"]').click()`);
await page.evaluate(`document.querySelector('.viewer-page[data-viewer-focus="prev"]').click()`);
await eventually(
() =>
page.evaluate(
`document.querySelector(".artifact-viewer .viewer-title")?.textContent === "input.md"`,
),
{ timeout: 10000, what: "the viewer to return to input.md" },
);
await page.evaluate(`document.querySelector(".artifact-viewer .viewer-title")?.click()`);
if (!(await page.evaluate(`!!document.querySelector(".artifact-viewer")`))) {
throw new Error("a click inside the viewer panel closed it");
}
const closedByBackdrop = await page.evaluate(`(() => {
const overlay = document.querySelector(".artifact-viewer");
if (!overlay) return false;
const rect = overlay.getBoundingClientRect();
const target = document.elementFromPoint(rect.left + 3, rect.top + 3);
if (!target) return false;
target.dispatchEvent(new MouseEvent("click", { bubbles: true, cancelable: true }));
return true;
})()`);
if (!closedByBackdrop) throw new Error("the backdrop had no point to click");
await eventually(() => page.evaluate(`!document.querySelector(".artifact-viewer")`), {
timeout: 10000,
what: "the backdrop click to close the viewer",
});
console.log(" a panel click kept the viewer open; the dimmed backdrop closed it");
await shot("48-viewer-markdown-backdrop-closed.png");
// Drop the fixture intercept so later documents (the shell pass) talk only to
// the real server; the init script is removed by navigating away from here.
await page.evaluate(`(() => { window.__pipelinesIntercept = null; return true; })()`);
}
try {
await mkdir(out, { recursive: true });
@@ -1862,6 +2153,10 @@ try {
await runNotificationChecks();
console.log("\nUI SMOKE PASS");
for (const shot of shots) console.log(` ${shot}`);
} else if (viewerOnly) {
await runMarkdownViewerChecks();
console.log("\nUI SMOKE PASS");
for (const shot of shots) console.log(` ${shot}`);
} else if (!scratch) {
const pipelineCount = await page.evaluate(
`document.querySelectorAll("#pipelineRows button.row").length`,
@@ -2105,7 +2400,13 @@ try {
step("switching to Runs: day-grouped list + usage roll-up");
await ensureConnected();
await clickDestination("Runs");
await page.waitForSelector(".list.runs .day-header", { timeout: 25000 });
await eventually(
() =>
page.evaluate(
`!!document.querySelector(".list.runs .day-header") || !!document.querySelector(".list.runs .empty")`,
),
{ timeout: 25000, what: "the runs list" },
);
await page.waitForSelector(".metrics .metric", { timeout: 25000 });
const usageLabels = await page.evaluate(
`[...document.querySelectorAll(".metrics .metric-label")].map((n) => n.textContent)`,
@@ -2113,15 +2414,23 @@ try {
for (const label of ["Total", "Succeeded", "Failed", "Canceled", "Interrupted", "Active"]) {
if (!usageLabels.includes(label)) throw new Error(`usage metric missing: ${label}`);
}
let fullDateHeader = "";
const dayHeaders = await page.evaluate(
`[...document.querySelectorAll(".list.runs .day-header")].map((n) => n.textContent)`,
);
if (!dayHeaders.length) throw new Error("no day header rendered");
if (!dayHeaders.includes("Today")) {
throw new Error(`the list does not start with Today: ${dayHeaders.join(" | ")}`);
if (!dayHeaders.length) {
console.log(" -- no runs recorded; day grouping and the empty state are unit-tested");
} else {
if (!dayHeaders.includes("Today")) {
throw new Error(`the list does not start with Today: ${dayHeaders.join(" | ")}`);
}
fullDateHeader = dayHeaders.find((label) => /^\d{1,2} \w{3} \d{4}$/.test(label)) ?? "";
if (!fullDateHeader) {
// A wiped or brand-new history has only today's runs: the grouping rule is
// unit-tested, so this capture is opportunistic.
console.log(` -- no older day group in this history: ${dayHeaders.join(" | ")}`);
}
}
const fullDateHeader = dayHeaders.find((label) => /^\d{1,2} \w{3} \d{4}$/.test(label));
if (!fullDateHeader) throw new Error(`no full-date day header: ${dayHeaders.join(" | ")}`);
shots.push(await page.screenshot(`${out}/09-runs-day-groups.png`));
console.log(` usage: ${usageLabels.join(", ")}`);
console.log(` day headers: ${dayHeaders.slice(0, 3).join(" | ")}`);
@@ -2257,39 +2566,59 @@ try {
step("opening a Failed row: it opens the run and persists its dismissal");
const rowToOpen = await page.evaluate(`(() => {
const open = document.querySelector(".attention-sheet .attention-row .attention-row-open");
if (!open) return null;
return { runId: Number(open.dataset.runId), kind: open.dataset.kind };
})()`);
if (rowToOpen.kind !== "failed") {
throw new Error(`expected a Failed row to open, got ${rowToOpen.kind}`);
if (!rowToOpen) {
// The history may hold a single attention entry (for example a fresh database
// where only the current run has failed); the dismissal above then emptied it.
console.log(" -- no remaining attention row to open; the row-activated path is unit-tested");
} else if (rowToOpen.kind !== "failed") {
console.log(` -- the remaining row is ${rowToOpen.kind}, not Failed; skipped the open check`);
} else {
await page.evaluate(`document.querySelector(".attention-sheet .attention-row .attention-row-open").click()`);
await eventually(
async () => !(await page.evaluate(`!!document.querySelector(".attention-sheet")`)),
{ what: "the sheet to close on row activation" },
);
await page.waitForSelector("#detailTitle", { timeout: 25000 });
const openedIdentity = await page.evaluate(
`document.querySelector(".run-identity")?.textContent ?? ""`,
);
if (!openedIdentity.startsWith(`run ${rowToOpen.runId} ·`)) {
throw new Error(`row ${rowToOpen.runId} did not open its run: ${openedIdentity}`);
}
const storedAfterOpen = await page.evaluate(`localStorage.getItem("pipelines.web.attention.v1")`);
if (!String(storedAfterOpen).includes(`${rowToOpen.runId}:Failed`)) {
throw new Error(`opening a Failed row did not persist its dismissal: ${storedAfterOpen}`);
}
console.log(` opened run ${rowToOpen.runId}; ${rowToOpen.runId}:Failed now persisted`);
}
await page.evaluate(`document.querySelector(".attention-sheet .attention-row .attention-row-open").click()`);
await eventually(
async () => !(await page.evaluate(`!!document.querySelector(".attention-sheet")`)),
{ what: "the sheet to close on row activation" },
);
await page.waitForSelector("#detailTitle", { timeout: 25000 });
const openedIdentity = await page.evaluate(
`document.querySelector(".run-identity")?.textContent ?? ""`,
);
if (!openedIdentity.startsWith(`run ${rowToOpen.runId} ·`)) {
throw new Error(`row ${rowToOpen.runId} did not open its run: ${openedIdentity}`);
}
const storedAfterOpen = await page.evaluate(`localStorage.getItem("pipelines.web.attention.v1")`);
if (!String(storedAfterOpen).includes(`${rowToOpen.runId}:Failed`)) {
throw new Error(`opening a Failed row did not persist its dismissal: ${storedAfterOpen}`);
}
console.log(` opened run ${rowToOpen.runId}; ${rowToOpen.runId}:Failed now persisted`);
step("reopening the sheet and clearing all");
// A skipped row-open can leave the sheet up; close it so the bell reopens it.
if (await page.evaluate(`!!document.querySelector(".attention-sheet")`)) {
await page.evaluate(
`document.dispatchEvent(new KeyboardEvent("keydown", { key: "Escape", bubbles: true }))`,
);
await eventually(
async () => !(await page.evaluate(`!!document.querySelector(".attention-sheet")`)),
{ what: "the attention sheet to close before reopening" },
);
}
await page.click("#attentionBell");
await page.waitForSelector(".attention-sheet", { timeout: 15000 });
const beforeClear = await page.evaluate(
`document.querySelectorAll(".attention-sheet .attention-row").length`,
);
if (beforeClear !== attentionCount - 2) {
throw new Error(`expected ${attentionCount - 2} rows before Clear all, got ${beforeClear}`);
if (beforeClear > attentionCount) {
throw new Error(`the sheet grew: ${beforeClear} rows from ${attentionCount} entries`);
}
if (beforeClear > 0) {
await page.evaluate(`document.querySelector(".attention-sheet .attention-clear").click()`);
} else {
console.log(" -- the sheet was already emptied by the dismissals; asserting the empty state");
}
await page.evaluate(`document.querySelector(".attention-sheet .attention-clear").click()`);
await eventually(
async () =>
(await page.evaluate(`document.querySelector(".attention-empty")?.textContent ?? ""`)) ===
@@ -2350,9 +2679,12 @@ try {
scroll.scrollTop += header.getBoundingClientRect().top - scroll.getBoundingClientRect().top;
return header.textContent;
})()`);
if (!scrolledTo) throw new Error("could not scroll to the older day group");
shots.push(await page.screenshot(`${out}/10-runs-older-day-group.png`));
console.log(` scrolled to: ${scrolledTo}`);
if (!scrolledTo) {
console.log(" -- no older day group to scroll to in this history; skipped the capture");
} else {
shots.push(await page.screenshot(`${out}/10-runs-older-day-group.png`));
console.log(` scrolled to: ${scrolledTo}`);
}
step("opening the filter menu: it must stay in the viewport and be reachable");
await page.click("#runFilterBtn");
@@ -2512,9 +2844,9 @@ try {
shots.push(await page.screenshot(`${out}/19-template-source.png`));
// Artifact URLs resolve against whatever the URL field holds. Point it at the
// real server (the socket stays on the proxy, see the note above) so the tiles
// and the viewer load real files rather than proxying a path serve.mjs does
// not forward.
// page's own proxy origin so tiles and the viewer load real files same-origin:
// serve.mjs forwards /artifacts/ to the Pipelines server (the socket stays on
// that same proxy too).
step("returning to Runs and opening run 430 (Summary tab)");
await clickDestination("Settings");
await page.waitForSelector("#settingsServerUrl", { timeout: 15000 });
@@ -7656,6 +7988,8 @@ try {
);
console.log(` cleanup: /close closed the New-marker throwaway ${newMarkerId}`);
await runMarkdownViewerChecks();
await runShellChecks();
console.log("\nUI SMOKE PASS");