diff --git a/web/PARITY.md b/web/PARITY.md index 5df4f4e4..11f3092a 100644 --- a/web/PARITY.md +++ b/web/PARITY.md @@ -38,8 +38,8 @@ Status legend: `todo` · `partial` (some of it works) · `done` (working + captu | R5 | Graph tab (per-stage panes, verdicts) | `get_run` | todo | | R6 | Input / Output field sections per stage | `get_run` | todo | | R7 | Timeline | `get_run` | todo | -| R8 | Artifacts gallery + full-screen viewer (images inline, others download/open) | `GET /artifacts/…` | todo | -| R9 | Session export link (read-only `session.html`) | `GET /artifacts/…` | todo | +| 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`) | +| 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` | todo | | R11 | Human decision sheet: prompt, options, feedback | `decide_run` | todo | | R12 | Cancel run | `cancel_run` | todo | diff --git a/web/src/app.js b/web/src/app.js index 1af401e1..8dedaf51 100644 --- a/web/src/app.js +++ b/web/src/app.js @@ -4,17 +4,30 @@ import { PipelinesClient } from "./client.js"; import { PipelinesRepository } from "./repository.js"; import { validateServerUrl, resolveArtifactUrl } from "./serverUrl.js"; +import { + ArtifactKind, + artifactCaptureNotes, + artifactGroups, + artifactKind, + artifactKindLabel, + artifactsHeader, + artifactsSummary, + artifactViewerPositionLabel, + displayVisit, + humanBytes, + pagedArtifacts, + pagedIndex, + presentedArtifacts, + resolvedArtifactUrl, + sessionExportArtifact, + viewerIndexByUrl, +} from "./artifacts.js"; const STORAGE_KEY = "pipelines.web.serverUrl.v2"; -/** - * The retired markdown session export. The server no longer writes it, but a run - * recorded before the HTML-only change still lists session.md among its stored - * artifacts. It is dated evidence the operator never sees, so every artifact - * listing hides it rather than showing it beside the session html (mirroring the - * app's presentedArtifacts). - */ -const LEGACY_SESSION_MARKDOWN_ARTIFACT = "session.md"; +/** Shown where tiles exist but the configured server URL cannot resolve them. */ +const ARTIFACT_SERVER_HINT = + "Set the server URL in Settings to open or copy artifact links."; /** * The page is normally served by serve.mjs, which also proxies /connect to the @@ -342,6 +355,14 @@ function renderRunDetail() { ); const steps = d.steps ?? []; + const executing = isExecuting(d); + + // Run-level artifacts gallery (parity R8). The header is the run summary line + // and the gallery below it draws one group per (stage, visit); all derivation + // lives in artifacts.js so the count can never disagree with the tiles. + pane.append(h("h3", { class: "artifacts-header", text: artifactsHeader(steps, executing) })); + pane.append(renderArtifactGallery(steps)); + pane.append(h("h3", { text: `Steps (${steps.length})` })); if (!steps.length) { pane.append(h("div", { class: "muted pad", text: "No steps recorded yet." })); @@ -369,7 +390,8 @@ function renderRunDetail() { kv("Session", s.session_id || "—"), s.diagnostic ? kv("Diagnostic", s.diagnostic) : null, ), - renderArtifacts(s), + renderVisitArtifacts(s), + renderSessionExport(s), ), ); } @@ -377,21 +399,333 @@ function renderRunDetail() { return pane; } -function renderArtifacts(step) { - const artifacts = (step.artifacts ?? []).filter((a) => a.name !== LEGACY_SESSION_MARKDOWN_ARTIFACT); - if (!artifacts.length) return null; - const wrap = h("div", { class: "artifacts" }, h("span", { class: "muted", text: "Artifacts: " })); - for (const a of artifacts) { - const href = resolveArtifactUrl(state.url, a.url); - if (href) { - wrap.append(h("a", { href, target: "_blank", rel: "noreferrer", text: a.name || a.url })); - } else { - wrap.append(h("span", { class: "muted", text: `${a.name || a.url} (no server URL)` })); - } +/** Whether the configured server URL can resolve a server-relative artifact. */ +function artifactsResolvable() { + return resolveArtifactUrl(state.url, "/artifacts/0/0/probe") != null; +} + +/** + * The run-level gallery: one header per (stage, visit) and one grid of tiles per + * visit, in the gallery order (stages first-appearance, visits by sequence). A + * run with no artifacts shows the header (which already says why) and nothing + * else, so the section is never blank. + */ +function renderArtifactGallery(steps) { + const wrap = h("div", { class: "artifact-gallery" }); + const groups = artifactGroups(steps); + if (!groups.length) return wrap; + if (!artifactsResolvable()) { + wrap.append(h("div", { class: "muted artifact-hint", text: ARTIFACT_SERVER_HINT })); + } + const viewable = pagedArtifacts(groups); + const viewerIndexOf = viewerIndexByUrl(groups); + for (const group of groups) { + wrap.append( + h("div", { class: "artifact-group-head", text: `${group.stageKey} · visit ${group.visit}` }), + renderArtifactGrid(group.artifacts, viewable, viewerIndexOf), + ); } return wrap; } +/** + * 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. + */ +function renderVisitArtifacts(step) { + const wrap = h("div", { class: "artifacts" }); + wrap.append(h("div", { class: "artifacts-summary", text: artifactsSummary(step) })); + for (const note of artifactCaptureNotes(step)) { + wrap.append(h("div", { class: "artifacts-note muted", text: note })); + } + const artifacts = presentedArtifacts(step); + if (artifacts.length) { + if (!artifactsResolvable()) { + wrap.append(h("div", { class: "muted artifact-hint", text: ARTIFACT_SERVER_HINT })); + } + const group = { stageKey: step.stage, visit: displayVisit(step, 0), artifacts }; + wrap.append( + renderArtifactGrid(artifacts, pagedArtifacts([group]), viewerIndexByUrl([group])), + ); + } + return wrap; +} + +/** One visit's tiles in a CSS grid. */ +function renderArtifactGrid(artifacts, viewable, viewerIndexOf) { + const grid = h("div", { class: "artifact-grid" }); + for (const artifact of artifacts) { + grid.append(renderArtifactTile(artifact, viewable, viewerIndexOf)); + } + return grid; +} + +/** + * One gallery tile: an image thumbnail, a video poster with a play marker (never + * a