Merge branch 'main' into theme
This commit is contained in:
+1
-1
@@ -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) |
|
| 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` |
|
| 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` |
|
| 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`) |
|
| 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. |
|
| 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) |
|
| 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) |
|
||||||
|
|||||||
@@ -422,3 +422,88 @@
|
|||||||
}
|
}
|
||||||
.rename-input:focus { outline: none; border-color: var(--accent); }
|
.rename-input:focus { outline: none; border-color: var(--accent); }
|
||||||
.rename-save { border-color: var(--accent); color: var(--accent); font-weight: 600; }
|
.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; }
|
||||||
|
}
|
||||||
|
|||||||
+40
-11
@@ -94,6 +94,9 @@ const DOCUMENT_EXTENSIONS = new Set([
|
|||||||
"txt", "md", "markdown", "rst", "doc", "docx", "odt", "rtf", "html", "htm",
|
"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([
|
const DOCUMENT_MIMES = new Set([
|
||||||
"application/msword",
|
"application/msword",
|
||||||
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
||||||
@@ -195,6 +198,31 @@ export function artifactKindLabel(kind) {
|
|||||||
return KIND_LABELS[kind] ?? "File";
|
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):
|
* Human-readable byte size, matching Android Format.kt humanBytes (and the TUI):
|
||||||
* whole bytes under 1 KiB, otherwise one decimal with a binary unit
|
* 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
|
* The artifacts `groups` hold that the full-screen viewer can page through, in
|
||||||
* (group by group, each group's images and videos in recorded order): the
|
* the exact order the gallery draws them (group by group, each group's images,
|
||||||
* neighbours the full-screen viewer pages through, so a swipe visits the same
|
* videos and markdown/text documents in recorded order): the neighbours a
|
||||||
* list the grid showed. Non-media artifacts open externally and are not part of
|
* swipe/keyboard step visits, so the viewer walks the same list the grid showed.
|
||||||
* it. Mirrors ArtifactViewer.kt pagedArtifacts.
|
* Other artifacts open externally and are not part of it. Mirrors
|
||||||
|
* ArtifactViewer.kt pagedArtifacts, extended for markdown-first stage turns.
|
||||||
*/
|
*/
|
||||||
export function pagedArtifacts(groups) {
|
export function pagedArtifacts(groups) {
|
||||||
const viewable = [];
|
const viewable = [];
|
||||||
for (const group of groups ?? []) {
|
for (const group of groups ?? []) {
|
||||||
for (const artifact of group?.artifacts ?? []) {
|
for (const artifact of group?.artifacts ?? []) {
|
||||||
const kind = artifactKind(artifact?.content_type, artifact?.name);
|
if (isViewerArtifact(artifact?.content_type, artifact?.name)) viewable.push(artifact);
|
||||||
if (kind === ArtifactKind.Image || kind === ArtifactKind.Video) viewable.push(artifact);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return viewable;
|
return viewable;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Each gallery media artifact's url mapped to its position in `pagedArtifacts`,
|
* Each viewer-selectable artifact's url mapped to its position in
|
||||||
* the same ordered list the viewer pages through. The grid's tiles resolve their
|
* `pagedArtifacts`, the same ordered list the viewer pages through. The grid's
|
||||||
* viewer index here, so tile and viewer derive from one source and cannot drift.
|
* tiles resolve their viewer index here, so tile and viewer derive from one
|
||||||
* The first occurrence of a url wins. Mirrors ArtifactViewer.kt viewerIndexByUrl.
|
* source and cannot drift. The first occurrence of a url wins. Mirrors
|
||||||
|
* ArtifactViewer.kt viewerIndexByUrl.
|
||||||
*/
|
*/
|
||||||
export function viewerIndexByUrl(groups) {
|
export function viewerIndexByUrl(groups) {
|
||||||
const indices = new Map();
|
const indices = new Map();
|
||||||
|
|||||||
+141
-13
@@ -23,6 +23,7 @@ import {
|
|||||||
ArtifactKind,
|
ArtifactKind,
|
||||||
artifactKind,
|
artifactKind,
|
||||||
artifactViewerPositionLabel,
|
artifactViewerPositionLabel,
|
||||||
|
isMarkdownArtifact,
|
||||||
pagedIndex,
|
pagedIndex,
|
||||||
resolvedArtifactUrl,
|
resolvedArtifactUrl,
|
||||||
} from "../artifacts.js";
|
} from "../artifacts.js";
|
||||||
@@ -538,42 +539,167 @@ function dismissActionError() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let viewerOverlay = null;
|
let viewerOverlay = null;
|
||||||
|
let viewerSession = null;
|
||||||
|
|
||||||
/** Close the full-screen viewer; the controller returns focus to its trigger. */
|
/** Close the full-screen viewer; the controller returns focus to its trigger. */
|
||||||
function closeArtifactViewer() {
|
function closeArtifactViewer() {
|
||||||
|
if (viewerSession) {
|
||||||
|
viewerSession.closed = true;
|
||||||
|
viewerSession.abort?.abort();
|
||||||
|
viewerSession = null;
|
||||||
|
}
|
||||||
modal.close("artifact-viewer");
|
modal.close("artifact-viewer");
|
||||||
viewerOverlay = null;
|
viewerOverlay = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Open the full-screen viewer at `startIndex` into `viewable`, the same ordered
|
* 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
|
* list the grid drew (images, videos and markdown/text documents). Previous/Next
|
||||||
* a single artifact; Escape and a backdrop click close it. Nothing autoplays: a
|
* are disabled at the ends; ArrowLeft/ArrowRight page the same list; Escape and a
|
||||||
* non-image artifact shows a still poster placeholder instead.
|
* 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) {
|
function openArtifactViewer(viewable, startIndex, trigger = null) {
|
||||||
closeArtifactViewer();
|
closeArtifactViewer();
|
||||||
if (!viewable?.length) return;
|
if (!viewable?.length) return;
|
||||||
let index = pagedIndex(startIndex, 0, viewable.length);
|
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", {
|
const overlay = h("div", {
|
||||||
class: "artifact-viewer",
|
class: "artifact-viewer",
|
||||||
role: "dialog",
|
role: "dialog",
|
||||||
"aria-modal": "true",
|
"aria-modal": "true",
|
||||||
"aria-label": "Artifact viewer",
|
"aria-label": "Artifact viewer",
|
||||||
});
|
});
|
||||||
|
const panel = h("div", { class: "viewer-panel", "data-viewer-focus": "panel", tabindex: "-1" });
|
||||||
|
overlay.append(panel);
|
||||||
overlay.addEventListener("click", (event) => {
|
overlay.addEventListener("click", (event) => {
|
||||||
if (event.target === overlay) closeArtifactViewer();
|
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 artifact = viewable[index] ?? {};
|
||||||
const resolved = resolvedArtifactUrl(artifact, state.url);
|
const resolved = resolvedArtifactUrl(artifact, state.url);
|
||||||
const kind = artifactKind(artifact.content_type, artifact.name);
|
const kind = artifactKind(artifact.content_type, artifact.name);
|
||||||
|
const markdown = isMarkdownArtifact(artifact.content_type, artifact.name);
|
||||||
const name = artifact.name || "(unnamed artifact)";
|
const name = artifact.name || "(unnamed artifact)";
|
||||||
|
|
||||||
const board = h("div", { class: "viewer-board" });
|
const board = h("div", { class: "viewer-board" });
|
||||||
if (kind === ArtifactKind.Image && resolved) {
|
if (kind === ArtifactKind.Image && resolved) {
|
||||||
board.append(h("img", { class: "viewer-image", src: resolved, alt: name }));
|
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 {
|
} else {
|
||||||
board.append(
|
board.append(
|
||||||
h(
|
h(
|
||||||
@@ -601,12 +727,14 @@ function openArtifactViewer(viewable, startIndex, trigger = null) {
|
|||||||
h("button", {
|
h("button", {
|
||||||
class: "viewer-action",
|
class: "viewer-action",
|
||||||
type: "button",
|
type: "button",
|
||||||
|
"data-viewer-focus": "open",
|
||||||
text: "Open",
|
text: "Open",
|
||||||
onclick: () => window.open(resolved, "_blank", "noopener,noreferrer"),
|
onclick: () => window.open(resolved, "_blank", "noopener,noreferrer"),
|
||||||
}),
|
}),
|
||||||
h("button", {
|
h("button", {
|
||||||
class: "viewer-action",
|
class: "viewer-action",
|
||||||
type: "button",
|
type: "button",
|
||||||
|
"data-viewer-focus": "copy",
|
||||||
text: "Copy link",
|
text: "Copy link",
|
||||||
disabled: !canCopyLink(),
|
disabled: !canCopyLink(),
|
||||||
onclick: () => copyArtifactLink(resolved),
|
onclick: () => copyArtifactLink(resolved),
|
||||||
@@ -614,6 +742,7 @@ function openArtifactViewer(viewable, startIndex, trigger = null) {
|
|||||||
h("button", {
|
h("button", {
|
||||||
class: "viewer-action",
|
class: "viewer-action",
|
||||||
type: "button",
|
type: "button",
|
||||||
|
"data-viewer-focus": "share",
|
||||||
text: "Share",
|
text: "Share",
|
||||||
disabled: !canShare(),
|
disabled: !canShare(),
|
||||||
onclick: () => shareArtifact(resolved),
|
onclick: () => shareArtifact(resolved),
|
||||||
@@ -624,6 +753,7 @@ function openArtifactViewer(viewable, startIndex, trigger = null) {
|
|||||||
h("button", {
|
h("button", {
|
||||||
class: "viewer-action viewer-close",
|
class: "viewer-action viewer-close",
|
||||||
type: "button",
|
type: "button",
|
||||||
|
"data-viewer-focus": "close",
|
||||||
text: "Close viewer",
|
text: "Close viewer",
|
||||||
onclick: closeArtifactViewer,
|
onclick: closeArtifactViewer,
|
||||||
}),
|
}),
|
||||||
@@ -638,32 +768,30 @@ function openArtifactViewer(viewable, startIndex, trigger = null) {
|
|||||||
h("button", {
|
h("button", {
|
||||||
class: "viewer-page",
|
class: "viewer-page",
|
||||||
type: "button",
|
type: "button",
|
||||||
|
"data-viewer-focus": "prev",
|
||||||
text: "Previous artifact",
|
text: "Previous artifact",
|
||||||
disabled: pagedIndex(index, -1, viewable.length) === index,
|
disabled: pagedIndex(index, -1, viewable.length) === index,
|
||||||
onclick: () => {
|
onclick: () => step(-1),
|
||||||
index = pagedIndex(index, -1, viewable.length);
|
|
||||||
renderViewer();
|
|
||||||
},
|
|
||||||
}),
|
}),
|
||||||
h("button", {
|
h("button", {
|
||||||
class: "viewer-page",
|
class: "viewer-page",
|
||||||
type: "button",
|
type: "button",
|
||||||
|
"data-viewer-focus": "next",
|
||||||
text: "Next artifact",
|
text: "Next artifact",
|
||||||
disabled: pagedIndex(index, 1, viewable.length) === index,
|
disabled: pagedIndex(index, 1, viewable.length) === index,
|
||||||
onclick: () => {
|
onclick: () => step(1),
|
||||||
index = pagedIndex(index, 1, viewable.length);
|
|
||||||
renderViewer();
|
|
||||||
},
|
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
nodes.push(actions);
|
nodes.push(actions);
|
||||||
overlay.replaceChildren(...nodes);
|
panel.replaceChildren(...nodes);
|
||||||
|
if (restore) restoreFocus(keepFocus ?? "panel");
|
||||||
};
|
};
|
||||||
|
|
||||||
renderViewer();
|
renderViewer();
|
||||||
viewerOverlay = overlay;
|
viewerOverlay = overlay;
|
||||||
|
viewerSession = session;
|
||||||
modal.open("artifact-viewer", overlay, {
|
modal.open("artifact-viewer", overlay, {
|
||||||
onClose: () => closeArtifactViewer(),
|
onClose: () => closeArtifactViewer(),
|
||||||
trigger,
|
trigger,
|
||||||
|
|||||||
+22
-10
@@ -43,6 +43,7 @@ import {
|
|||||||
artifactViewerPositionLabel,
|
artifactViewerPositionLabel,
|
||||||
displayVisit,
|
displayVisit,
|
||||||
humanBytes,
|
humanBytes,
|
||||||
|
isViewerArtifact,
|
||||||
pagedArtifacts,
|
pagedArtifacts,
|
||||||
presentedArtifacts,
|
presentedArtifacts,
|
||||||
resolvedArtifactUrl,
|
resolvedArtifactUrl,
|
||||||
@@ -580,7 +581,7 @@ function renderVerdictBlock(step) {
|
|||||||
return wrap;
|
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) {
|
function renderVerdictLink(text, artifact, step) {
|
||||||
const resolved = resolvedArtifactUrl(artifact, state.url);
|
const resolved = resolvedArtifactUrl(artifact, state.url);
|
||||||
if (!resolved) return h("span", { class: "verdict-link disabled", text });
|
if (!resolved) return h("span", { class: "verdict-link disabled", text });
|
||||||
@@ -604,17 +605,18 @@ function renderVerdictRef(artifact, step) {
|
|||||||
return chip;
|
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) {
|
function openArtifactFromVerdict(artifact, step, resolved, trigger = null) {
|
||||||
if (!resolved) return;
|
if (!resolved) return;
|
||||||
const group = { stageKey: step.stage, visit: displayVisit(step, 0), artifacts: presentedArtifacts(step) };
|
const group = { stageKey: step.stage, visit: displayVisit(step, 0), artifacts: presentedArtifacts(step) };
|
||||||
const viewable = pagedArtifacts([group]);
|
const viewable = pagedArtifacts([group]);
|
||||||
const viewerIndexOf = viewerIndexByUrl([group]);
|
const viewerIndexOf = viewerIndexByUrl([group]);
|
||||||
const at = viewerIndexOf.get(artifact.url);
|
const at = viewerIndexOf.get(artifact.url);
|
||||||
const kind = artifactKind(artifact.content_type, artifact.name);
|
if (isViewerArtifact(artifact.content_type, artifact.name) && at != null) {
|
||||||
const media = kind === ArtifactKind.Image || kind === ArtifactKind.Video;
|
openArtifactViewer(viewable, at, trigger);
|
||||||
if (media && at != null) openArtifactViewer(viewable, at, trigger);
|
} else {
|
||||||
else window.open(resolved, "_blank", "noopener,noreferrer");
|
window.open(resolved, "_blank", "noopener,noreferrer");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Open the stage pane for one visit of a stage; the controller moves focus in. */
|
/** Open the stage pane for one visit of a stage; the controller moves focus in. */
|
||||||
@@ -808,7 +810,8 @@ function renderArtifactGallery(steps) {
|
|||||||
* The per-visit artifacts section shown inside one step: the summary line, the
|
* 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
|
* 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
|
* 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) {
|
function renderVisitArtifacts(step) {
|
||||||
const wrap = h("div", { class: "artifacts" });
|
const wrap = h("div", { class: "artifacts" });
|
||||||
@@ -842,13 +845,15 @@ function renderArtifactGrid(artifacts, viewable, viewerIndexOf) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* One gallery tile: an image thumbnail, a video poster with a play marker (never
|
* 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
|
* a <video> element or autoplay), or a kind/name/size label. Markdown and text
|
||||||
* is set as text, never as markup.
|
* 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) {
|
function renderArtifactTile(artifact, viewable, viewerIndexOf) {
|
||||||
const resolved = resolvedArtifactUrl(artifact, state.url);
|
const resolved = resolvedArtifactUrl(artifact, state.url);
|
||||||
const kind = artifactKind(artifact.content_type, artifact.name);
|
const kind = artifactKind(artifact.content_type, artifact.name);
|
||||||
const media = kind === ArtifactKind.Image || kind === ArtifactKind.Video;
|
const media = kind === ArtifactKind.Image || kind === ArtifactKind.Video;
|
||||||
|
const opensViewer = isViewerArtifact(artifact.content_type, artifact.name);
|
||||||
const name = artifact.name || "(unnamed artifact)";
|
const name = artifact.name || "(unnamed artifact)";
|
||||||
// The tile is the native control (M5): Enter/Space activate it for free, and
|
// 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.
|
// the Copy link / Share buttons are siblings in the wrapper, never children.
|
||||||
@@ -857,6 +862,9 @@ function renderArtifactTile(artifact, viewable, viewerIndexOf) {
|
|||||||
class: "artifact-tile clickable",
|
class: "artifact-tile clickable",
|
||||||
type: "button",
|
type: "button",
|
||||||
"aria-label": `Open ${name}`,
|
"aria-label": `Open ${name}`,
|
||||||
|
"data-artifact-name": artifact.name ?? "",
|
||||||
|
"data-artifact-kind": kind,
|
||||||
|
"data-artifact-url": artifact.url ?? "",
|
||||||
});
|
});
|
||||||
const openViewer = () => {
|
const openViewer = () => {
|
||||||
const at = viewerIndexOf.get(artifact.url);
|
const at = viewerIndexOf.get(artifact.url);
|
||||||
@@ -881,12 +889,16 @@ function renderArtifactTile(artifact, viewable, viewerIndexOf) {
|
|||||||
tile.append(h("div", { class: "artifact-name", text: name }));
|
tile.append(h("div", { class: "artifact-name", text: name }));
|
||||||
tile.addEventListener("click", openViewer);
|
tile.addEventListener("click", openViewer);
|
||||||
} else {
|
} else {
|
||||||
|
if (opensViewer) {
|
||||||
|
tile.classList.add("artifact-document-tile");
|
||||||
|
tile.append(h("span", { class: "artifact-doc-glyph", "aria-hidden": "true" }));
|
||||||
|
}
|
||||||
tile.append(
|
tile.append(
|
||||||
h("div", { class: "artifact-kind", text: artifactKindLabel(kind) }),
|
h("div", { class: "artifact-kind", text: artifactKindLabel(kind) }),
|
||||||
h("div", { class: "artifact-name", text: name }),
|
h("div", { class: "artifact-name", text: name }),
|
||||||
h("div", { class: "artifact-size", text: humanBytes(artifact.size_bytes) }),
|
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));
|
wrap.append(tile, renderTileActions(resolved, media));
|
||||||
return wrap;
|
return wrap;
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ import {
|
|||||||
artifactViewerPositionLabel,
|
artifactViewerPositionLabel,
|
||||||
displayVisit,
|
displayVisit,
|
||||||
humanBytes,
|
humanBytes,
|
||||||
|
isMarkdownArtifact,
|
||||||
|
isViewerArtifact,
|
||||||
pagedArtifacts,
|
pagedArtifacts,
|
||||||
pagedIndex,
|
pagedIndex,
|
||||||
presentedArtifacts,
|
presentedArtifacts,
|
||||||
@@ -253,7 +255,83 @@ test("pagedArtifacts keeps only images and videos, in gallery order", () => {
|
|||||||
assert.deepEqual(pagedArtifacts([]), []);
|
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 = [
|
const groups = [
|
||||||
{
|
{
|
||||||
stageKey: "s",
|
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("note.txt", { contentType: "text/plain", url: "/artifacts/1/1/note.txt" }),
|
||||||
art("b.png", { contentType: "image/png", url: "/artifacts/1/1/b.png" }),
|
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("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);
|
const index = viewerIndexByUrl(groups);
|
||||||
assert.equal(index.get("/artifacts/1/1/a.png"), 0);
|
assert.equal(index.get("/artifacts/1/1/a.png"), 0);
|
||||||
assert.equal(index.get("/artifacts/1/1/b.png"), 1);
|
assert.equal(index.get("/artifacts/1/1/note.txt"), 1);
|
||||||
assert.equal(index.has("/artifacts/1/1/note.txt"), false);
|
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", () => {
|
test("pagedIndex clamps at both ends and never wraps", () => {
|
||||||
|
|||||||
Vendored
+7
@@ -0,0 +1,7 @@
|
|||||||
|
# Turn input
|
||||||
|
|
||||||
|
Plan the next small change.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
go test ./...
|
||||||
|
```
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
# Memory
|
||||||
|
|
||||||
|
The previous turn landed the artifact viewer.
|
||||||
+6
@@ -0,0 +1,6 @@
|
|||||||
|
# Output
|
||||||
|
|
||||||
|
The change is ready for review.
|
||||||
|
|
||||||
|
- viewer renders markdown
|
||||||
|
- keyboard paging works
|
||||||
Vendored
BIN
Binary file not shown.
|
After Width: | Height: | Size: 68 B |
+307
-10
@@ -15,6 +15,9 @@
|
|||||||
// real runs and chat session. The default run never sends a `submit`: the live
|
// real runs and chat session. The default run never sends a `submit`: the live
|
||||||
// server's pipeline list is never mutated.
|
// 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
|
// `--decide` drives ONLY R11's live human-decision flow: it reuses an existing
|
||||||
// entry-stage human pipeline or submits one uniquely named create-only
|
// entry-stage human pipeline or submits one uniquely named create-only
|
||||||
// definition, starts two throwaway runs in fresh temp workspaces, and presses
|
// 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");
|
const notifyOnly = process.argv.includes("--notify");
|
||||||
// Focused R11 evidence only; the one explicit mode allowed to submit a pipeline.
|
// Focused R11 evidence only; the one explicit mode allowed to submit a pipeline.
|
||||||
const decideOnly = process.argv.includes("--decide");
|
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
|
// Artifact URLs resolve against the configured server. Point them at the page's
|
||||||
// upgrade), but serve.mjs only proxies /connect — not /artifacts. Point the URL
|
// own proxy origin (serve.mjs forwards /artifacts/ and /connect), so the viewer's
|
||||||
// field at the real Pipelines server after connecting so artifact tiles and the
|
// markdown fetch and the image/video tiles are same-origin exactly as they are
|
||||||
// viewer resolve to real files; that is exactly the URL a correctly configured
|
// in a correctly configured deployment.
|
||||||
// page would carry.
|
const artifactServerUrl = `ws://127.0.0.1:${port}/connect`;
|
||||||
const artifactServerUrl = `ws://${pipelines}/connect`;
|
const pipelineUrl = `ws://${pipelines}/connect`;
|
||||||
const pipelineUrl = artifactServerUrl;
|
|
||||||
|
|
||||||
const shots = [];
|
const shots = [];
|
||||||
let serve = null;
|
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 {
|
try {
|
||||||
await mkdir(out, { recursive: true });
|
await mkdir(out, { recursive: true });
|
||||||
|
|
||||||
@@ -1862,6 +2153,10 @@ try {
|
|||||||
await runNotificationChecks();
|
await runNotificationChecks();
|
||||||
console.log("\nUI SMOKE PASS");
|
console.log("\nUI SMOKE PASS");
|
||||||
for (const shot of shots) console.log(` ${shot}`);
|
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) {
|
} else if (!scratch) {
|
||||||
const pipelineCount = await page.evaluate(
|
const pipelineCount = await page.evaluate(
|
||||||
`document.querySelectorAll("#pipelineRows button.row").length`,
|
`document.querySelectorAll("#pipelineRows button.row").length`,
|
||||||
@@ -2549,9 +2844,9 @@ try {
|
|||||||
shots.push(await page.screenshot(`${out}/19-template-source.png`));
|
shots.push(await page.screenshot(`${out}/19-template-source.png`));
|
||||||
|
|
||||||
// Artifact URLs resolve against whatever the URL field holds. Point it at the
|
// 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
|
// page's own proxy origin so tiles and the viewer load real files same-origin:
|
||||||
// and the viewer load real files rather than proxying a path serve.mjs does
|
// serve.mjs forwards /artifacts/ to the Pipelines server (the socket stays on
|
||||||
// not forward.
|
// that same proxy too).
|
||||||
step("returning to Runs and opening run 430 (Summary tab)");
|
step("returning to Runs and opening run 430 (Summary tab)");
|
||||||
await clickDestination("Settings");
|
await clickDestination("Settings");
|
||||||
await page.waitForSelector("#settingsServerUrl", { timeout: 15000 });
|
await page.waitForSelector("#settingsServerUrl", { timeout: 15000 });
|
||||||
@@ -7693,6 +7988,8 @@ try {
|
|||||||
);
|
);
|
||||||
console.log(` cleanup: /close closed the New-marker throwaway ${newMarkerId}`);
|
console.log(` cleanup: /close closed the New-marker throwaway ${newMarkerId}`);
|
||||||
|
|
||||||
|
await runMarkdownViewerChecks();
|
||||||
|
|
||||||
await runShellChecks();
|
await runShellChecks();
|
||||||
|
|
||||||
console.log("\nUI SMOKE PASS");
|
console.log("\nUI SMOKE PASS");
|
||||||
|
|||||||
Reference in New Issue
Block a user