diff --git a/web/PARITY.md b/web/PARITY.md index 24a23e48..27435e80 100644 --- a/web/PARITY.md +++ b/web/PARITY.md @@ -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) | diff --git a/web/base.css b/web/base.css index 15b00e42..ad73c53c 100644 --- a/web/base.css +++ b/web/base.css @@ -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; } diff --git a/web/chat.css b/web/chat.css index 965c57c6..9eb0d1bb 100644 --- a/web/chat.css +++ b/web/chat.css @@ -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; diff --git a/web/design/tokens/tokens.css b/web/design/tokens/tokens.css index 006fedd8..8fcf6f6f 100644 --- a/web/design/tokens/tokens.css +++ b/web/design/tokens/tokens.css @@ -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 */ diff --git a/web/dialogs.css b/web/dialogs.css index 8b727828..aa69dd86 100644 --- a/web/dialogs.css +++ b/web/dialogs.css @@ -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; } +} diff --git a/web/graph.css b/web/graph.css index bc20af98..d9f15842 100644 --- a/web/graph.css +++ b/web/graph.css @@ -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; diff --git a/web/lists.css b/web/lists.css index 10cd5217..5852e0fb 100644 --- a/web/lists.css +++ b/web/lists.css @@ -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; } diff --git a/web/run-detail.css b/web/run-detail.css index 30739c75..bc2bdde2 100644 --- a/web/run-detail.css +++ b/web/run-detail.css @@ -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; } diff --git a/web/settings.css b/web/settings.css index e8ad1a09..adb75e34 100644 --- a/web/settings.css +++ b/web/settings.css @@ -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; } diff --git a/web/shell.css b/web/shell.css index 32a888fd..d1a45773 100644 --- a/web/shell.css +++ b/web/shell.css @@ -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; } } diff --git a/web/src/app.js b/web/src/app.js index 410ae738..a156ad6c 100644 --- a/web/src/app.js +++ b/web/src/app.js @@ -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, diff --git a/web/src/artifacts.js b/web/src/artifacts.js index bce21416..0d220add 100644 --- a/web/src/artifacts.js +++ b/web/src/artifacts.js @@ -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(); diff --git a/web/src/graph.js b/web/src/graph.js index 7aed5a14..9acbc767 100644 --- a/web/src/graph.js +++ b/web/src/graph.js @@ -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); } diff --git a/web/src/graphPrefs.js b/web/src/graphPrefs.js new file mode 100644 index 00000000..7ddc8e34 --- /dev/null +++ b/web/src/graphPrefs.js @@ -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. + } +} diff --git a/web/src/runDetail.js b/web/src/runDetail.js index 83779ea8..fffde545 100644 --- a/web/src/runDetail.js +++ b/web/src/runDetail.js @@ -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); diff --git a/web/src/views/dialogs.js b/web/src/views/dialogs.js index 4d77c4ba..c5fe4b95 100644 --- a/web/src/views/dialogs.js +++ b/web/src/views/dialogs.js @@ -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, diff --git a/web/src/views/pipelines.js b/web/src/views/pipelines.js index e4c9f734..16839777 100644 --- a/web/src/views/pipelines.js +++ b/web/src/views/pipelines.js @@ -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; diff --git a/web/src/views/runDetail.js b/web/src/views/runDetail.js index e2f08f0b..28eaf3ee 100644 --- a/web/src/views/runDetail.js +++ b/web/src/views/runDetail.js @@ -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