From 2503a38f505831d23011485343d5d41a1472d267 Mon Sep 17 00:00:00 2001 From: Alan Silva Date: Mon, 19 Oct 2026 17:54:19 +0100 Subject: [PATCH 1/4] web: proxy /artifacts/ through serve.mjs so images actually load The page resolves artifact URLs against the configured server. In a proxied deployment that is the page's own origin, and serve.mjs only proxied /connect, so every artifact request 404'd: broken gallery thumbnails, a blank viewer and no session.html. Forward GET/HEAD /artifacts/ to the same upstream and stream the reply (status, headers, body). Verified: 10/10 thumbnails load on run 430 and the viewer's image has naturalWidth > 0. --- web/AGENTS.md | 4 +++- web/README.md | 11 +++++++---- web/serve.mjs | 38 ++++++++++++++++++++++++++++++++++---- 3 files changed, 44 insertions(+), 9 deletions(-) diff --git a/web/AGENTS.md b/web/AGENTS.md index 3027b45a..4d1468f1 100644 --- a/web/AGENTS.md +++ b/web/AGENTS.md @@ -80,7 +80,9 @@ default macOS location. an upgrade whose `Origin` host does not match the request `Host`. A page served from port 8090 opening `ws://HOST:8080/connect` is refused with **403**. The static server therefore also proxies `/connect` (dropping `Origin`), so the page -and the socket are one origin. **Do not "fix" this by relaxing the server's Origin +and the socket are one origin. It proxies `/artifacts/` too: artifact URLs resolve +against the configured server (the page origin when proxied), so without it images, +the viewer and `session.html` 404 even though the socket works. **Do not "fix" this by relaxing the server's Origin check** — that check is the only thing standing between a random web page and an unauthenticated control API. Keep the proxy. diff --git a/web/README.md b/web/README.md index 1b507ee1..7e2893ce 100644 --- a/web/README.md +++ b/web/README.md @@ -29,7 +29,7 @@ what is done; this file covers how to run, test and verify it. ```sh cd web -node serve.mjs # http://127.0.0.1:8090/ (proxies /connect -> 127.0.0.1:8080) +node serve.mjs # http://127.0.0.1:8090/ (proxies /connect and /artifacts/ -> 127.0.0.1:8080) node serve.mjs --host 0.0.0.0 # reachable from other devices (trusted LAN/VPN) node serve.mjs --port 8095 --pipelines 127.0.0.1:8080 ``` @@ -76,7 +76,7 @@ keeping them out of the tree keeps a delivery checkout clean. | Feature logic and models | `src/runs.js`, `src/runDetail.js`, `src/changes.js`, `src/artifacts.js`, `src/pipelines.js`, `src/templates.js`, `src/graph.js`, `src/chat.js`, `src/markdown.js`, `src/search.js`, `src/attention.js`, `src/actions.js`, `src/connection.js`, `src/settings.js`, `src/notify.js`, `src/runEvents.js`, `src/routes.js` | | Shell and views | `src/app.js` (boot, state, navigation, render dispatch), view modules under `src/views/` | | Styling | per-area stylesheets linked from `index.html` | -| Server + `/connect` proxy | `serve.mjs` | +| Server + `/connect` and `/artifacts/` proxy | `serve.mjs` | | Tests | `test/*.test.mjs`, `test/smoke.mjs`, `test/browser.mjs`, `test/ui-smoke.mjs` | | Acceptance gate | `PARITY.md` | | Working map | `AGENTS.md` | @@ -97,8 +97,11 @@ request Origin "HOST:8090" is not authorized for Host "HOST:8080" ``` A Node or `curl` client sends no `Origin` and is accepted — which is why the -protocol smoke can pass while a browser cannot. `serve.mjs` therefore also proxies -`/connect`, dropping `Origin`, so the page and the socket are one origin. +protocol smoke can pass while a browser cannot. `serve.mjs` therefore proxies `/connect` (dropping `Origin`) so the page and +the socket are one origin. It proxies `/artifacts/` for the same reason: artifact +URLs resolve against the configured server, which in a proxied deployment is the +page's own origin, so the gallery's images, the viewer, `session.html` and +downloads would otherwise 404 while the WebSocket worked. **Do not "fix" this by relaxing the server's Origin check** — that check is the only thing between a random web page and an unauthenticated control API. Keep the diff --git a/web/serve.mjs b/web/serve.mjs index 23c55e8d..0b12d85a 100644 --- a/web/serve.mjs +++ b/web/serve.mjs @@ -1,8 +1,10 @@ // Zero-dependency static file server + WebSocket proxy for the spike. // node serve.mjs [--port 8090] [--host 0.0.0.0] [--pipelines 127.0.0.1:8080] // -// Serves this directory and proxies GET/Upgrade /connect to the Pipelines -// server, so the page and the WebSocket share one origin. +// Serves this directory, proxies GET/Upgrade /connect and GET/HEAD /artifacts/ to +// the Pipelines server, so the page, the WebSocket and artifact files share one +// origin. The API and its artifacts live on the server's port; the page is served +// from another, so artifact URLs resolved against the page would 404 without this. // // Why the proxy exists: internal/server/websocket.go calls // `websocket.Accept(w, r, nil)` (github.com/coder/websocket), which rejects an @@ -13,7 +15,7 @@ // server has no authentication and needs none. // // The default host is 127.0.0.1. Use --host 0.0.0.0 only on a trusted LAN/VPN. -import { createServer } from "node:http"; +import { createServer, request } from "node:http"; import { readFile, stat } from "node:fs/promises"; import { extname, join, normalize, resolve, sep } from "node:path"; import { fileURLToPath } from "node:url"; @@ -94,8 +96,36 @@ async function serveIndex(res) { res.end(body); } +/** + * Proxy one artifact request to the Pipelines server. Artifact URLs are resolved + * against the configured server, which in a proxied deployment is the page's own + * origin, so without this the gallery's thumbnails, the viewer and the session + * export would all 404 while the WebSocket worked. + */ +function proxyArtifact(req, res) { + const headers = { ...req.headers }; + delete headers.origin; + headers.host = `${targetHost}:${targetPort}`; + const upstream = request( + { host: targetHost, port: targetPort, method: req.method, path: req.url, headers }, + (reply) => { + res.writeHead(reply.statusCode ?? 502, reply.headers); + reply.pipe(res); + }, + ); + upstream.on("error", () => { + if (!res.headersSent) res.writeHead(502, { "Content-Type": "text/plain; charset=utf-8" }); + res.end("Artifact unavailable"); + }); + req.pipe(upstream); +} + const server = createServer(async (req, res) => { const pathname = (req.url ?? "/").split("?")[0]; + if (pathname.startsWith("/artifacts/")) { + proxyArtifact(req, res); + return; + } if (pathname === "/favicon.ico") { res.writeHead(204).end(); // no icon; keeps the console free of a 404 return; @@ -189,5 +219,5 @@ const host = flag(process.argv, "--host", "127.0.0.1"); server.listen(port, host, () => { const shown = host === "0.0.0.0" ? "127.0.0.1" : host; console.log(`web spike: http://${shown}:${port}/ (bound ${host}:${port})`); - console.log(`proxying /connect -> ws://${targetHost}:${targetPort}/connect`); + console.log(`proxying /connect (ws) and /artifacts/ (http) -> ${targetHost}:${targetPort}`); }); From 3bd721bc93d99ae5891d11914a53fef960cdf3b5 Mon Sep 17 00:00:00 2001 From: Alan Silva Date: Mon, 19 Oct 2026 18:09:42 +0100 Subject: [PATCH 2/4] web: fix artifact, chat, attention and timeline accessibility findings --- web/PARITY.md | 2 +- web/chat.css | 20 ++++++++++- web/run-detail.css | 26 ++++++++++++++- web/src/views/attention.js | 18 +++++++--- web/src/views/chat.js | 68 ++++++++++++++++++++++++++------------ web/src/views/runDetail.js | 21 +++++++++--- 6 files changed, 122 insertions(+), 33 deletions(-) diff --git a/web/PARITY.md b/web/PARITY.md index 3274dbb8..20e2d809 100644 --- a/web/PARITY.md +++ b/web/PARITY.md @@ -155,7 +155,7 @@ to it, but the server never lists it and a reload drops it. | L4 | Responsive switch by viewport width (no hardcoded device) | `WindowSize.kt` analogue | todo | | L5 | Notifications for failed/waiting runs (browser Notification API; HTTPS/localhost only) | derived from `subscribe` / `run_event` | **partial** — the browser notification path is implemented and captured in Settings, but **no real OS notification was observed**, so the row is not `done`. The exact reason: headless Chrome cannot reliably show or capture an OS notification; the smoke stubs and records the `Notification` constructor, while the transition decisions run through the page's real socket `onmessage`/`frame` path. Pure logic lives in `src/notify.js` and mirrors `notify/RunAlerts.kt` + `ui/Attention.kt`: only a run becoming `failed` (headline `A run failed`) or `waiting` (headline `A run needs your decision`) notifies; `queued`, `running`, `succeeded`, `canceled`, `interrupted` and unknown statuses never do. Body is the attention label (trimmed title else pipeline) then ` · {pipeline}`, with no separator when the pipeline is blank or equal; identity/tag is the attention key `{runId}:{kind}` so one run+kind notifies once, duplicate frames repeat nothing, a key is forgotten when the run leaves that qualifying state, and a genuinely new transition may notify again. First-seen `failed`/`waiting` from the initial `list_runs` or the `subscribe` snapshot raises nothing (the snapshot is bracketed as a seed); a disconnect drops the baseline but keeps the page session's dedupe set and reseeds before resubscribing, so a gap never notifies. A key present in the attention surface's `dismissed` set (`state.attentionDismissed`) is suppressed. Settings now shows the Android rationale verbatim (`Pipelines can notify you when a run is waiting for your decision or has failed. Without it, those runs still appear in the in-app Needs you surface.`) and honest copy for unsupported, insecure context, default, granted and denied; only `default` on a supported secure page offers the explicit `Enable notifications` control, which is the only call to `Notification.requestPermission()` (never on load). Only `{asked:true|false}` is stored under `pipelines.web.notify.v1`; malformed storage decodes to never-asked and the wording never claims consent. Clicking a notification focuses the page and opens Runs with the run selected through the **existing** navigation; **L6's `/runs/:id` URL route is still `todo`**, so no URL route is invented. `subscribeRuns`/`unsubscribeRuns` send exactly `{type:'subscribe',workspace:''}` and `{type:'unsubscribe'}` (no `run_ids`, no polling timer) and are sent only after the page is connected. Unit-tested in `test/notify.test.mjs` (qualification, wording/body, per-run dedupe, seed/snapshot suppression, dismissed keys, permission copy, asked storage) and `test/repository.test.mjs` (both request shapes + the not-connected guard). Captured 2026-10-19: `captures/L5-notifications-settings.png` (default state, control offered, 0 requests on load), `captures/L5-notifications-granted.png` (after the one explicit grant) and `captures/L5-notifications-denied.png` (honest denied copy, no control). The same checks live in `test/ui-smoke.mjs` behind `--notify` (a focused mode that runs exactly this evidence); that run finished `UI SMOKE PASS` and logged: queued→failed and running→waiting each raised exactly one recorded notification, duplicates/terminal/unknown statuses/first-seen/dismissed raised none, and the click opened the run. **Not observed:** the OS notification itself. On 2026-10-19 the default full live suite reached and passed this block with the same logged assertions, then failed later in an unrelated C13 hit-test (`the last row's menu item is not clickable`, its centre at y=919.5 in a 900 px viewport after the list's re-render reset the scroll); the L5 captures and assertions above come from the focused `--notify` run, which finished `UI SMOKE PASS`. | | L6 | Deep links to a run (`pipelines://run/…` analogue → URL route) | — | done — the page's destinations are real URLs through a pure, total route model in `src/routes.js`: `/pipelines`, `/runs`, `/chat`, `/settings` and `/templates`; `/pipelines/:id` and `/pipelines/:id/:version` (version 0 or absent = latest); `/pipelines/:id[/:version]/stage/:key`; `/runs/:id` with `?action=decide`; `/runs/:id/stage/:key[?visit=N]`; `/settings/templates` and `/settings/templates/:key` parse as aliases of `/templates` and `/templates/:key`. `visit` is a zero-based index into that stage's visits, dropped when invalid while the stage route stays; a malformed or unknown path (a bad percent escape, a zero/negative run id, a non-numeric version or path, or a trailing extra segment on either stage branch, e.g. `/runs/440/stage/planner/extra`) resolves to the Pipelines list and never throws, and search/query state is never a route. The serialiser percent-encodes path segments, omits version 0 and an absent visit, and round-trips under `parse(serialize(…))`; an id, version or key the parser would reject is never emitted — it falls back to the nearest canonical route (an invalid id to the list, an invalid version to latest) so the address bar can never carry a path the parser would discard. `serve.mjs` serves `index.html` for any page route (a first segment naming a destination, so a stage key that ends in an extension — `plan.js`, `plan.v2` — still deep-links) or any non-asset GET, with a root `` so the shell's relative asset URLs resolve under a deep path, while an asset-looking path outside a page prefix such as `/nope.js` stays 404. Navigation moves the URL with `pushState` only on a real change (top-level tabs, pipeline/run/template selection, Settings' Browse templates, opening/closing either stage pane; a user click on a pipeline graph node pushes `/pipelines/:id/:version/stage/:key` through the shared graph's `onSelectionChange` (a synthetic click is never used); a deep-linked stage instead opens at mount through the graph's `selectedKey` option without notifying), and one `popstate` listener parses and applies Back/Forward without a reload; in-detail tabs (Summary/Graph/Source, run tabs) and search stay in-place. A deep link is parsed at boot, kept pending until the first successful connection, and then loaded list-first (later reconnects never replay it; any move made while still disconnected replaces the pending boot link, so the URL and the first connected view agree). An unknown or malformed boot path renders the Pipelines list and `replaceState`s the address bar to the canonical `/pipelines` so the URL and the view agree. A later reconnect refreshes the lists and re-applies the route: the URL and a detail already in hand survive the drop, while a detail that is not in hand (never loaded, or cleared while disconnected) is fetched again. Only a genuine server refusal — never a timeout or a socket drop — discards the deep link. A run link's `?action=decide` opens the existing decision sheet once, only when the run is genuinely waiting, then `replaceState`s to the action-free `/runs/:id`. A valid but out-of-range `?visit=N` is clamped to the stage's last visit and the entry is corrected, so the address bar and the pane agree; a pipeline-stage path naming a key the loaded graph does not declare falls back to `/pipelines/:id[/:version]` rather than leaving a pane-less stage URL, while a key the mounted graph can select — including its `#success`/`#failure` terminals — re-opens the same definition pane (the graph writes those URLs itself, so the loader accepts them). A run-stage path naming a stage that is neither visited nor a node of the run graph falls back to the plain run detail. A deep link to an executing run installs its 1 Hz refresh; leaving Runs for any other destination stops it, and a reply discarded for a view that no longer shows Runs stops it too, so no get_run loop survives the move (asserted in the smoke when an executing run is live). A deep-linked stage pane is revealed clear of the sticky top bar (its head and the Close control stay visible), which the smoke asserts. A run the server does not have falls back honestly to `/runs` — the real list, the server's own refusal in the banner and no stale pane or throw (the same for a missing pipeline → `/pipelines`). A run or run-stage route also loads the pipeline list when it has not been seen, so the nav badge stays honest (`Pipelines (29)` at capture time, never a false `Pipelines (0)`) — asserted in the smoke. Captured 2026-10-19: `captures/L6-deeplink-run-440.png` (a hard navigation to `/runs/440` opening run 440's detail), `captures/L6-deeplink-pipeline-24.png` (a hard navigation to `/pipelines/24` opening `Plan and land`), `captures/L6-deeplink-pipeline-24-stage.png` (a hard navigation to `/pipelines/24/stage/planner` opening the Graph tab and the stage's definition pane in view), `captures/L6-deeplink-pipeline-24-terminal.png` (a hard navigation to `/pipelines/24/stage/%23failure` re-opening the Failure terminal pane — the live graph's first terminal at capture time — with its URL unchanged), `captures/L6-history-back.png` (an in-page Pipelines→Runs→run-detail sequence, then `history.back()` restoring the Runs list, with a window marker proving no reload), `captures/L6-missing-run.png` (`/runs/900000000` landing on `/runs` with the real list — 407 rows at capture time — and the banner `run not found`) and `captures/L6-missing-pipeline.png` (`/pipelines/900000000` landing on `/pipelines` with the real pipeline rows and the server's refusal banner). Parsing, serialisation, version/visit semantics and round-tripping are unit-tested in `test/routes.test.mjs`. **The live server had no waiting run, so the `?action=decide` path was not exercised live**; `test/ui-smoke.mjs` captures the sheet automatically the moment a waiting run exists | -| L7 | Accessibility: focus order, labels, keyboard operation | — | todo | +| L7 | Accessibility: focus order, labels, keyboard operation | — | todo — **M5/M6/M7/M9 are fixed in the view modules** (artifact tiles are named `Open {artifact}`, keyboard-operable buttons with Copy link/Share as siblings; a chat row's session button is native and its `Chat actions for {title}` control is a sibling, with the id appended only for repeated titles; attention dismiss controls are named `Dismiss {run label}` with the run id only for repeated labels; timeline rows show a 2px accent focus ring at offset -2px). **Still open:** M1/M2 (dialog focus entry/trap/return and background inertness), M3 (tab roles and arrow keys), M4 (skip link plus list→detail focus order), M8 (one `h1` per route and list `h2`s), and the should-fix items (S1–S12) — the shell/dialog item owns those files. The whole row stays `todo` until they are fixed and a review stage captures the result | ## Deliberately out of scope - **Operator-only transport** — `inspect_resource`, `reconcile_resource`, diff --git a/web/chat.css b/web/chat.css index 226718d6..45aa74b1 100644 --- a/web/chat.css +++ b/web/chat.css @@ -91,7 +91,25 @@ align-items: start; cursor: pointer; } -.chat-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; } +/* M6: the session title/meta area is the button; the row is a plain container + and the Chat actions menu is a sibling of this button. */ +.chat-session-button { + grid-column: 1; + grid-row: 1 / span 2; + display: grid; + gap: 2px; + width: 100%; + min-width: 0; + margin: 0; + padding: 0; + border: 0; + background: none; + color: inherit; + font: inherit; + text-align: left; + cursor: pointer; +} +.chat-session-button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; } .chat-row .row-head { grid-column: 1; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; } .chat-row .row-title { min-width: 0; } .chat-row .row-meta { grid-column: 1; } diff --git a/web/run-detail.css b/web/run-detail.css index d6d24236..ad7daa16 100644 --- a/web/run-detail.css +++ b/web/run-detail.css @@ -45,7 +45,31 @@ cursor: pointer; } .timeline-row:last-child { border-bottom: 0; } -.timeline-row:hover, .timeline-row:focus-visible { background: var(--surface-2); outline: none; } +.timeline-row:hover { background: var(--surface-2); } +.timeline-row:focus-visible { + background: var(--surface-2); + outline: 2px solid var(--accent); + outline-offset: -2px; +} + +/* Artifact tiles (M5): the tile itself is a native button and Copy link/Share + are sibling controls. The grid is shared with the shell item, so the button + reset stays scoped here rather than editing base.css. */ +.artifact-tile-wrap { position: relative; display: flex; } +.artifact-tile-wrap > .artifact-tile { + flex: 1 1 auto; + width: 100%; + margin: 0; + font: inherit; + color: inherit; + appearance: none; + cursor: pointer; +} +.artifact-tile-wrap > .artifact-tile:focus-visible { + outline: 2px solid var(--accent); + outline-offset: -2px; +} +.artifact-tile-wrap .artifact-actions { z-index: 1; } .timeline-glyph { flex: none; width: 18px; text-align: center; font-size: 14px; line-height: 1.4; } .timeline-main { flex: 1; min-width: 0; display: grid; gap: 2px; } .timeline-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; } diff --git a/web/src/views/attention.js b/web/src/views/attention.js index 054b51e2..286e3108 100644 --- a/web/src/views/attention.js +++ b/web/src/views/attention.js @@ -145,6 +145,12 @@ function renderAttentionSheet() { ); const body = h("div", { class: "attention-sheet-body" }); + // One count for the whole open sheet: only repeated labels need the run id + // appended, so dismissing stays unambiguous without noisy names elsewhere. + const labelCounts = new Map(); + for (const entry of entries) { + labelCounts.set(entry.label, (labelCounts.get(entry.label) ?? 0) + 1); + } if (entries.length === 0) { body.append(h("p", { class: "attention-empty", text: "Nothing needs you right now." })); } else { @@ -156,7 +162,7 @@ function renderAttentionSheet() { onclick: clearAttentionSheet, }), ); - for (const entry of entries) body.append(renderAttentionRow(entry)); + for (const entry of entries) body.append(renderAttentionRow(entry, labelCounts)); } const sheet = h("div", { class: "attention-sheet-panel", tabindex: "-1" }, head, body); @@ -165,8 +171,12 @@ function renderAttentionSheet() { } /** One attention row: status icon, the two text lines, and a trailing Dismiss. */ -function renderAttentionRow(entry) { +function renderAttentionRow(entry, labelCounts = null) { const glyphState = entry.kind === AttentionKind.Decision ? "waiting" : "failed"; + const repeated = (labelCounts?.get(entry.label) ?? 0) > 1; + const dismissLabel = repeated + ? `Dismiss ${entry.label} (run ${entry.runId})` + : `Dismiss ${entry.label}`; const open = h( "button", { @@ -191,8 +201,8 @@ function renderAttentionRow(entry) { const dismiss = h("button", { class: "attention-dismiss", type: "button", - "aria-label": "Dismiss", - title: "Dismiss", + "aria-label": dismissLabel, + title: dismissLabel, onclick: (event) => { // The trailing control must never activate the row it sits in. event.stopPropagation(); diff --git a/web/src/views/chat.js b/web/src/views/chat.js index 62158253..8469b683 100644 --- a/web/src/views/chat.js +++ b/web/src/views/chat.js @@ -1498,24 +1498,39 @@ function fillChatRows(rows) { const active = filtered.filter((session) => !session.closed); const closed = filtered.filter((session) => session.closed); + // Titles are often repeated ("New chat"); compute the duplicates once so the + // per-row actions name can include the session id only when it is needed. + const duplicateTitles = duplicateChatTitles(filtered); const groups = groupSessionsByDirectory(active); if (groups.length > 1) { for (const group of groups) { rows.append(h("div", { class: "chat-group-header", text: directoryLabel(group.directory) })); - for (const session of group.sessions) rows.append(renderChatRow(session)); + for (const session of group.sessions) rows.append(renderChatRow(session, duplicateTitles)); } } else { - for (const session of active) rows.append(renderChatRow(session)); + for (const session of active) rows.append(renderChatRow(session, duplicateTitles)); } if (closed.length > 0) { rows.append(h("div", { class: "chat-group-header", text: CLOSED_SECTION_LABEL })); - for (const session of closed) rows.append(renderChatRow(session)); + for (const session of closed) rows.append(renderChatRow(session, duplicateTitles)); } if (state.chatError) { rows.append(h("div", { class: "chat-error muted", text: state.chatError })); } } +/** The titles shared by more than one rendered session, for unique action names. */ +function duplicateChatTitles(sessions) { + const counts = new Map(); + for (const session of sessions) { + const title = sessionTitle(session); + counts.set(title, (counts.get(title) ?? 0) + 1); + } + return new Set( + [...counts.entries()].filter(([, count]) => count > 1).map(([title]) => title), + ); +} + function chatEmpty(message) { return h("div", { class: "empty" }, h("span", { class: "muted", text: message })); } @@ -1525,7 +1540,7 @@ function chatEmpty(message) { * activity badge word, the work-label meta line and the close/reopen action. * Every server string is set with textContent. */ -function renderChatRow(session) { +function renderChatRow(session, duplicateTitles = new Set()) { const open = state.chatActiveId === session.id; const thread = state.chatThreads.get(session.id) ?? null; const unseen = @@ -1537,23 +1552,28 @@ function renderChatRow(session) { }); const activity = sessionActivity(thread?.running === true, unseen); const badge = sessionActivityBadge(activity, open); + // The row is a plain container (M6): the session title/meta area is the native + // button and the Chat actions control is its sibling, not a child. const row = h("div", { class: `row chat-row${open ? " selected" : ""}`, - role: "button", - tabindex: "0", "data-session": session.id, - onclick: () => openChatSession(session.id), - onkeydown: (event) => { - // Only the row itself opens on Enter/Space; the Chat actions menu handles - // its own keyboard activation (and must not double-fire). - if (event.target !== event.currentTarget) return; - if (event.key === "Enter" || event.key === " ") { - event.preventDefault(); - openChatSession(session.id); - } + }); + // Keep background and programmatic clicks opening the session, but never + // double-fire when a real control (session button or actions) was clicked. + row.addEventListener("click", (event) => { + const target = event.target; + if (target instanceof Element && target.closest("button, a")) return; + openChatSession(session.id); + }); + const sessionButton = h("button", { + class: "chat-session-button", + type: "button", + onclick: (event) => { + event.stopPropagation(); + openChatSession(session.id); }, }); - const head = h("div", { class: "row-head" }); + const head = h("span", { class: "row-head" }); head.append(h("span", { class: "row-title chat-row-title", text: sessionTitle(session) })); const chip = sessionChipLabel(session); if (chip) head.append(h("span", { class: "chip chat-kind-chip", text: chip })); @@ -1566,14 +1586,14 @@ function renderChatRow(session) { ), ); } - row.append(head); - row.append( + sessionButton.append(head); + sessionButton.append( h("span", { class: "row-meta chat-row-meta", text: sessionMeta(session, sessionWorkLabel(session.busy === true, thread)), }), ); - row.append(renderChatActionsMenu(session)); + row.append(sessionButton, renderChatActionsMenu(session, duplicateTitles)); return row; } @@ -1695,18 +1715,22 @@ function renderChatCreate() { * Close chat… (open) or Reopen (closed), then Hide on this device. Closing is the * shared, server-side finish; hiding only affects this device and says so. */ -function renderChatActionsMenu(session) { +function renderChatActionsMenu(session, duplicateTitles = new Set()) { const wrap = h("div", { class: "chat-row-actions chat-menu-wrap" }); const expanded = state.chatMenu === session.id; + const title = sessionTitle(session); + const actionLabel = duplicateTitles.has(title) + ? `${CHAT_ACTIONS_LABEL} for ${title} (${session.id})` + : `${CHAT_ACTIONS_LABEL} for ${title}`; wrap.append( h("button", { class: "ghost chat-menu-button", type: "button", text: "⋯", - "aria-label": CHAT_ACTIONS_LABEL, + "aria-label": actionLabel, "aria-haspopup": "menu", "aria-expanded": expanded ? "true" : "false", - title: CHAT_ACTIONS_LABEL, + title: actionLabel, onclick: (event) => { event.stopPropagation(); openChatMenu(session.id); diff --git a/web/src/views/runDetail.js b/web/src/views/runDetail.js index c6bdfcf0..2e387fd6 100644 --- a/web/src/views/runDetail.js +++ b/web/src/views/runDetail.js @@ -850,7 +850,14 @@ function renderArtifactTile(artifact, viewable, viewerIndexOf) { const kind = artifactKind(artifact.content_type, artifact.name); const media = kind === ArtifactKind.Image || kind === ArtifactKind.Video; const name = artifact.name || "(unnamed artifact)"; - const tile = h("div", { class: "artifact-tile clickable" }); + // 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. + const wrap = h("div", { class: "artifact-tile-wrap" }); + const tile = h("button", { + class: "artifact-tile clickable", + type: "button", + "aria-label": `Open ${name}`, + }); const openViewer = () => { const at = viewerIndexOf.get(artifact.url); if (at != null) openArtifactViewer(viewable, at); @@ -864,7 +871,13 @@ function renderArtifactTile(artifact, viewable, viewerIndexOf) { tile.append(img); tile.addEventListener("click", openViewer); } else if (kind === ArtifactKind.Video) { - tile.append(h("div", { class: "artifact-poster" }, h("span", { class: "artifact-play", text: "▶" }))); + tile.append( + h( + "div", + { class: "artifact-poster" }, + h("span", { class: "artifact-play", "aria-hidden": "true", text: "▶" }), + ), + ); tile.append(h("div", { class: "artifact-name", text: name })); tile.addEventListener("click", openViewer); } else { @@ -875,8 +888,8 @@ function renderArtifactTile(artifact, viewable, viewerIndexOf) { ); tile.addEventListener("click", openTab); } - tile.append(renderTileActions(resolved, media)); - return tile; + wrap.append(tile, renderTileActions(resolved, media)); + return wrap; } /** The compact per-tile actions: copy-link (non-media tiles) and share. */ From b011f4ada471939a66572cb10e2e6bcdd5e055e9 Mon Sep 17 00:00:00 2001 From: Alan Silva Date: Mon, 19 Oct 2026 18:27:39 +0100 Subject: [PATCH 3/4] web: show per-visit changes and last-visit summary Each visit's This run pane reports its own recorded capture: the File changes status line (with skipped/omitted counts and diagnostic) and its Changed files list with parseable stats. The Summary aggregate now keeps each path's last recorded step rather than summing visits, and is only rendered for a succeeded run; a failed run keeps its evidence in the visit panes. This is a deliberate divergence from Android, noted in R4. --- web/PARITY.md | 2 +- web/src/changes.js | 90 +++++++++------ web/src/runDetail.js | 37 +++++- web/src/views/runDetail.js | 16 ++- web/test/changes.test.mjs | 172 ++++++++++++++++++++++++---- web/test/runDetail.test.mjs | 107 +++++++++++++++++- web/test/ui-smoke.mjs | 216 ++++++++++++++++++++++++++++++------ 7 files changed, 535 insertions(+), 105 deletions(-) diff --git a/web/PARITY.md b/web/PARITY.md index 3274dbb8..d6e78f9f 100644 --- a/web/PARITY.md +++ b/web/PARITY.md @@ -34,7 +34,7 @@ Status legend: `todo` · `partial` (some of it works) · `done` (working + captu | R1 | Run history list with status roll-up | `list_runs` | done | | R2 | Filter by status, sort, "needs you" markers | client-side | done — status/pipeline/time filter + sort implemented and captured (`captures/09-runs-day-groups.png`–`captures/15-runs-sorted.png`); the "needs you" requirement is delivered exactly as the app does it: a bell/badge + sheet (R15), not a per-row mark. No other R2 work is outstanding | | R3 | Run detail: run fields, steps/visits, targets, sessions | `get_run` | done — tabbed Summary / Graph / Input / Output / Timeline; the Timeline opens a per-visit stage pane with the headline rows (Status, Outcome, Duration, Visit `{v} / {max}`, Model target, Target, Session), the Verdict block (option chip + reason with inline artifact links) and the visit sections Artifacts / Session / Output / Input / This run / Stage definition. Captured 2026-10-19: `captures/20-run-430-summary.png`, `captures/23-run-430-timeline.png`, `captures/24-run-430-stage-artifacts.png`, `captures/25-run-440-verdict.png` | -| R4 | Summary tab incl. collapsible **Changes** viewer (raw + rendered diff) | `get_run` file changes | done — a collapsed-by-default **Changes** section in the Summary tab (`{N} file(s) changed · ±stat · partial capture`; the empty variants read `Changes · capture unavailable` / `capture pending` / `partial capture` / `not recorded for this run` / `capture incomplete` / `no changes observed`) whose rows open a full-screen diff viewer with **Rendered** (each `@@` hunk header on a raised surface, old/new gutter numbers, the shared `+`/`-`/space line language) and **Raw patch** forms, Previous/Next file paging (disabled at the ends), a raw-patch copy control, Escape/backdrop/Close close, and honest binary/truncated/no-patch messages instead of a fabricated diff. Pure logic in `src/changes.js`. Captured 2026-10-19: `captures/28-run-438-changes-collapsed.png`, `captures/29-run-438-changes-expanded.png`, `captures/30-run-438-changes-diff-rendered.png`, `captures/31-run-438-changes-diff-raw.png`, `captures/32-run-442-changes-binary.png`, `captures/33-run-450-changes-truncated.png`, `captures/34-run-455-changes-pending.png` | +| R4 | Summary tab incl. collapsible **Changes** viewer (raw + rendered diff), plus each visit's own file-change record | `get_run` file changes | done — the Summary's collapsed-by-default **Changes** section describes the run's **final state**, not a sum: steps are read in numeric sequence order, each path keeps first-seen order and reports its **last recorded step's** kind, patch, `+A -D` stat, binary/truncated flags and before/after modes, while `changed by A → B` still lists every stage that touched it in run order. Header wording is unchanged (`{N} file(s) changed · ±stat · partial capture`; empty variants `Changes · capture unavailable` / `partial capture` / `not recorded for this run` / `capture incomplete` / `no changes observed`). The aggregate is rendered **only when the run status is `succeeded`**; a failed or running run has no settled final state and shows no Summary Changes section at all. This is a **deliberate divergence from Android**, which shows the aggregate for failed runs too — the browser keeps the evidence in each visit's pane instead. That pane's existing **This run** section now shows the selected visit's own capture: a `File changes` line with the honest status word, file count, skipped/omitted counts and diagnostic; a `Changed files` list of `{kind} {path}` plus the parseable `+A -D` stat and `(binary)`/`(truncated)` markers; and neither row when the step recorded no capture. Each visit therefore shows its own set even when a stage ran three times. Summary rows still open the full-screen diff viewer with **Rendered** (each `@@` hunk header on a raised surface, old/new gutter numbers, the shared `+`/`-`/space line language) and **Raw patch** forms, Previous/Next file paging (disabled at the ends), a raw-patch copy control, Escape/backdrop/Close close, and honest binary/truncated/no-patch messages instead of a fabricated diff. Pure logic in `src/changes.js` and `src/runDetail.js`; `showRunChangesSummary` gates the aggregate. Captured 2026-10-19: `captures/28-run-438-changes-collapsed.png`, `captures/29-run-438-changes-expanded.png` (final-state `+42 -12` for the twice-edited `internal/server/retry_test.go`, header `+934 -156`), `captures/30-run-438-changes-diff-rendered.png`, `captures/31-run-438-changes-diff-raw.png`, `captures/32-run-449-changes-binary.png`, `captures/33-run-450-changes-truncated.png`, `captures/78-run-438-implementer-visit-changes.png` (that visit's own `partial (1 files)` and one Changed files line), `captures/79-run-440-no-summary-changes.png` (failed run: no aggregate), `captures/80-run-440-visit-changes.png` (its visit's `File changes`, no recorded rows), `captures/81-run-442-failed-visit-changes.png` (a failed run's implementer visit keeps its own Changed files) and `captures/82-run--no-summary-changes.png` (a running run: no aggregate) | | 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` | diff --git a/web/src/changes.js b/web/src/changes.js index 82ae9603..728d8d5b 100644 --- a/web/src/changes.js +++ b/web/src/changes.js @@ -1,6 +1,6 @@ -// Pure, DOM-free logic for the run summary's Changes section and its diff -// viewer, ported from the Android client so the browser says and shows exactly -// the same things: +// Pure, DOM-free logic for the run summary's final-state Changes section and its +// diff viewer, ported from the Android client so the browser says and shows +// exactly the same things (the aggregate is last-visit-wins rather than a sum): // ui/changes/RunChanges.kt changeKind, changeKindLabel, parseUnifiedPatch, // runChanges, runChangesHeader, runChangesNote, // changesListSummary, noChangeDetail, @@ -249,14 +249,27 @@ export function gutterText(value, width) { // --------------------------------------------------------------------------- /** - * Aggregates a run's stage steps into its Changes state. Pure and total over its - * input: a null `file_changes` on a step is a historical (or non-capturing) step - * and contributes nothing (it is never "no changes"); a present capture with no - * files is a real, observed no-change. Files are keyed by path and keep + * Whether the Summary tab may present the run-wide aggregated Changes section. + * The operator decision is final-state-only: a failed run has no settled final + * workspace, so its evidence stays in each visit's own recorded capture. The + * Android client shows the aggregate for failed runs too; this is a deliberate + * browser divergence, recorded in PARITY.md R4. Pure. + */ +export function showRunChangesSummary(status) { + return str(status).trim().toLowerCase() === "succeeded"; +} + +/** + * Aggregates a run's stage steps into its final-state Changes view. Pure and + * total over its input: a null `file_changes` on a step is a historical (or + * non-capturing) step and contributes nothing (it is never "no changes"); a + * present capture with no files is a real, observed no-change. Steps are read in + * numeric sequence order (stable for ties), and files are keyed by path and keep * first-seen order, so a path several steps changed is one entry naming all of - * them. Later steps win the kind unless they only say "other", added/removed - * line counts sum, binary/truncated are OR'd, before_mode is first-seen and - * after_mode last-seen. + * them. The last recorded step for a path supplies its kind, patch, added/removed + * counts, binary/truncated flags and modes: the summary describes the state the + * run left, never a sum of intermediate visits. Run-wide capture counters and + * caveats still describe every contributing step. */ export function runChanges(steps) { const entries = new Map(); @@ -267,9 +280,14 @@ export function runChanges(steps) { let missingCaptures = 0; let skipped = 0; let omitted = 0; + let truncatedSeen = false; const diagnostics = new Set(); + const orderedSteps = (steps ?? []) + .map((step, index) => ({ step, index })) + .sort((a, b) => sequenceOf(a.step) - sequenceOf(b.step) || a.index - b.index) + .map((entry) => entry.step); - for (const step of steps ?? []) { + for (const step of orderedSteps) { const changes = step?.file_changes; if (changes == null) { if (step?.status === "running" || step?.status === "waiting") stepsPending++; @@ -287,47 +305,39 @@ export function runChanges(steps) { for (const file of changes.files ?? []) { const path = str(file?.path); if (path.trim() === "") continue; + if (file?.truncated === true) truncatedSeen = true; const kind = changeKind(file?.kind); const parsed = parseUnifiedPatch(file?.patch); const existing = entries.get(path); const mergedSteps = existing ? [...existing.steps] : []; if (!mergedSteps.includes(stage)) mergedSteps.push(stage); - const patchParts = []; - if (existing && existing.patch != null) patchParts.push(existing.patch); - if (typeof file?.patch === "string" && file.patch.trim() !== "") patchParts.push(file.patch); - const joinedPatch = patchParts.join("\n"); + // The last recorded step wins every per-file fact: the summary is the + // final state, not an accumulation of the visits on the way there. entries.set(path, { path, - // A later step wins the kind: it is the observed state the run left. - kind: existing == null || kind !== ChangeKind.Other ? kind : existing.kind, - added: (existing?.added ?? 0) + parsed.added, - removed: (existing?.removed ?? 0) + parsed.removed, - binary: existing?.binary === true || file?.binary === true, - truncated: existing?.truncated === true || file?.truncated === true, - // Keep the first-seen before-mode and the last-seen after-mode, so the - // pair describes the run's net effect on the file. - beforeMode: existing && existing.beforeMode != null ? existing.beforeMode : nullable(file?.before_mode), - afterMode: file?.after_mode != null ? file.after_mode : existing?.afterMode ?? null, + kind, + added: parsed.added, + removed: parsed.removed, + binary: file?.binary === true, + truncated: file?.truncated === true, + beforeMode: nullable(file?.before_mode), + afterMode: nullable(file?.after_mode), otherModeChange: - existing?.otherModeChange === true || - (file?.before_mode != null && - file?.after_mode != null && - file.before_mode !== file.after_mode && - !file.binary && - parsed.added === 0 && - parsed.removed === 0), + file?.before_mode != null && + file?.after_mode != null && + file.before_mode !== file.after_mode && + !file.binary && + parsed.added === 0 && + parsed.removed === 0, steps: mergedSteps, - // Preserve every recorded textual patch for a path. A file may be - // changed by several stages, and retaining only the first one would - // make the displayed hunks disagree with the aggregate stat. - patch: joinedPatch.trim() !== "" ? joinedPatch : null, + patch: typeof file?.patch === "string" && file.patch.trim() !== "" ? file.patch : null, }); } } const files = [...entries.values()]; const pending = stepsWithChanges === 0 && stepsPending > 0; - const totalPartial = partial || files.some((file) => file.truncated) || omitted > 0; + const totalPartial = partial || truncatedSeen || omitted > 0; return { files, stepsWithChanges, @@ -538,6 +548,12 @@ export function diffLineClass(kind) { // Internals // --------------------------------------------------------------------------- +/** A step's numeric sequence for ordering, with a missing/invalid value as 0. */ +function sequenceOf(step) { + const value = Number(step?.sequence); + return Number.isFinite(value) ? value : 0; +} + /** An integer parsed from a strictly-numeric string, or null. */ function intOrNull(text) { return /^[+-]?\d+$/.test(text) ? Number.parseInt(text, 10) : null; diff --git a/web/src/runDetail.js b/web/src/runDetail.js index e22c4384..3ccd8b35 100644 --- a/web/src/runDetail.js +++ b/web/src/runDetail.js @@ -28,6 +28,7 @@ import { runStateOf, } from "./runs.js"; import { presentedArtifacts, sessionExportArtifact, displayVisit } from "./artifacts.js"; +import { changeStat, parseUnifiedPatch } from "./changes.js"; import { effectiveStageType } from "./templates.js"; // --------------------------------------------------------------------------- @@ -696,14 +697,25 @@ export function artifactBaseName(name) { // --------------------------------------------------------------------------- /** - * One changed-file line, e.g. `modified src/a.kt (binary) (truncated)`. Mirrors - * Format.kt fileChangeLine. + * One changed-file line, e.g. `modified src/a.kt +3 -2 (truncated)`. The kind, + * path and binary/truncated markers are Format.kt's exact spelling; the `+N -M` + * stat is added when the recorded patch is readable (not binary) and parses to + * at least one hunk, so a line never claims a line count it could not read. A + * binary file keeps its marker and never gets a text stat. */ export function fileChangeLine(file) { const base = `${str(file?.kind)} ${str(file?.path)}`; const binary = file?.binary ? " (binary)" : ""; const truncated = file?.truncated ? " (truncated)" : ""; - return base + binary + truncated; + let stat = ""; + if (!file?.binary) { + const patch = str(file?.patch); + if (patch.trim() !== "") { + const parsed = parseUnifiedPatch(patch); + if (parsed.hunks.length > 0) stat = changeStat(parsed.added, parsed.removed); + } + } + return base + (stat !== "" ? ` ${stat}` : "") + binary + truncated; } /** One notification receipt, e.g. `delivered → ntfy · ok`, skipping a blank diagnostic. */ @@ -714,12 +726,16 @@ export function notificationLine(receipt) { } /** - * A compact file-change summary, e.g. `partial (2 files), 1 skipped`. Blank - * parts are omitted; an entirely blank change set renders as "". + * A compact file-change summary, e.g. + * `partial (2 files), 1 skipped, 3 omitted · Excluded protected files.`. + * The status word, file count, skipped and omitted counts are the capture's own + * honest facts; the trimmed diagnostic follows after ` · ` when present. Blank + * parts are omitted, and an entirely blank change set renders as "". */ export function fileChangesSummary(changes) { let text = ""; - if (str(changes?.status).trim() !== "") text += str(changes.status); + const status = str(changes?.status).trim(); + if (status !== "") text += status; const files = changes?.files ?? []; if (files.length > 0) { if (text !== "") text += " "; @@ -729,6 +745,15 @@ export function fileChangesSummary(changes) { if (text !== "") text += ", "; text += `${changes.skipped} skipped`; } + if (Number(changes?.omitted) > 0) { + if (text !== "") text += ", "; + text += `${changes.omitted} omitted`; + } + const diagnostic = str(changes?.diagnostic).trim(); + if (diagnostic !== "") { + if (text !== "") text += " · "; + text += diagnostic; + } return text; } diff --git a/web/src/views/runDetail.js b/web/src/views/runDetail.js index c6bdfcf0..e309c664 100644 --- a/web/src/views/runDetail.js +++ b/web/src/views/runDetail.js @@ -71,6 +71,7 @@ import { runChanges, runChangesHeader, runChangesNote, + showRunChangesSummary, } from "../changes.js"; import { DECISION_ACTION, @@ -225,12 +226,15 @@ function renderRunSummaryTab(d, now) { ); // The run-level Changes (parity R4), collapsed by default like the Android - // summary: the observed workspace diff. Its header alone states the file count - // and aggregate stat until expanded, and every file row opens the diff viewer. - const changes = runChanges(d.steps ?? []); - wrap.append( - renderCollapsible("summary-changes", runChangesHeader(changes), () => renderChangesBody(changes)), - ); + // summary: the observed final-state workspace diff. Only a succeeded run has a + // settled final state to present; a failed run keeps its evidence in each + // visit's own capture (a deliberate divergence from Android, see PARITY R4). + if (showRunChangesSummary(d.status)) { + const changes = runChanges(d.steps ?? []); + wrap.append( + renderCollapsible("summary-changes", runChangesHeader(changes), () => renderChangesBody(changes)), + ); + } return wrap; } diff --git a/web/test/changes.test.mjs b/web/test/changes.test.mjs index a15c3f96..69d84ac0 100644 --- a/web/test/changes.test.mjs +++ b/web/test/changes.test.mjs @@ -1,8 +1,9 @@ // Pure unit tests for the run summary's Changes section and its diff viewer: // the kind mapping and labels, the unified-patch parser (hunks, line numbers, // stat counts, the `\ No newline` marker and header closing), the cross-step -// aggregation (kind merge, stat sums, binary/truncated OR, mode first/last), -// every header/note/detail wording variant and the row/viewer helpers. +// final-state aggregation (last sequence wins every per-file fact, every +// touching stage retained), every header/note/detail wording variant and the +// row/viewer helpers. // No server, no DOM. import { test } from "node:test"; import assert from "node:assert/strict"; @@ -33,6 +34,7 @@ import { runChanges, runChangesHeader, runChangesNote, + showRunChangesSummary, } from "../src/changes.js"; // A step file-change with sane defaults, overridable per test. @@ -224,7 +226,7 @@ test("a present capture with no files is a captured no-change", () => { assert.equal(noChangeDetail(changes), "The captured snapshots were identical: the workspace was unchanged."); }); -test("the later step wins the kind, but `other` never downgrades it", () => { +test("a later step's kind wins, including an unrecognised later kind", () => { const changes = runChanges([ step({ stage: "a", file_changes: { status: "complete", files: [file({ path: "x", kind: "modified" })] } }), step({ stage: "b", file_changes: { status: "complete", files: [file({ path: "x", kind: "added" })] } }), @@ -233,14 +235,84 @@ test("the later step wins the kind, but `other` never downgrades it", () => { assert.equal(changes.files[0].kind, ChangeKind.Added); assert.deepEqual(changes.files[0].steps, ["a", "b"]); - const downgrade = runChanges([ + const unknown = runChanges([ step({ stage: "a", file_changes: { status: "complete", files: [file({ path: "x", kind: "added" })] } }), step({ stage: "b", file_changes: { status: "complete", files: [file({ path: "x", kind: "copied" })] } }), ]); - assert.equal(downgrade.files[0].kind, ChangeKind.Added); + // No downgrade heuristic: the final visit recorded an unrecognised kind, so + // the row says `changed` rather than guessing from the earlier visit. + assert.equal(unknown.files[0].kind, ChangeKind.Other); }); -test("stat sums, binary/truncated OR and mode first/last-seen across steps", () => { +test("a path changed in three visits reports only the last visit's facts", () => { + const changes = runChanges([ + step({ + stage: "a", + sequence: 1, + file_changes: { + status: "complete", + files: [ + file({ + path: "x", + kind: "modified", + patch: "@@ -1 +1 @@\n-old\n+one", + before_mode: "0644", + after_mode: "0644", + }), + ], + }, + }), + step({ + stage: "b", + sequence: 2, + file_changes: { + status: "complete", + files: [ + file({ + path: "x", + kind: "modified", + patch: "@@ -1 +1 @@\n-one\n+two", + before_mode: "0644", + after_mode: "0644", + }), + ], + }, + }), + step({ + stage: "c", + sequence: 3, + file_changes: { + status: "complete", + files: [ + file({ + path: "x", + kind: "added", + patch: "@@ -1 +2 @@\n-two\n+three\n+four", + before_mode: "0755", + after_mode: "0600", + }), + ], + }, + }), + ]); + const entry = changes.files[0]; + assert.equal(entry.kind, ChangeKind.Added); + assert.equal(entry.added, 2); + assert.equal(entry.removed, 1); + assert.equal(entry.patch, "@@ -1 +2 @@\n-two\n+three\n+four"); + assert.equal(entry.binary, false); + assert.equal(entry.truncated, false); + assert.equal(entry.beforeMode, "0755"); + assert.equal(entry.afterMode, "0600"); + assert.equal(entryModeChanged(entry), true); + assert.deepEqual(entry.steps, ["a", "b", "c"]); + assert.equal(changeRowMeta(entry), "changed by a → b → c · mode 0755→0600"); + // The run total is the final state's stat, not the three visits summed. + assert.equal(changes.added, 2); + assert.equal(changes.removed, 1); +}); + +test("later binary/truncated flags and modes replace the earlier rows", () => { const changes = runChanges([ step({ stage: "a", @@ -251,8 +323,10 @@ test("stat sums, binary/truncated OR and mode first/last-seen across steps", () path: "x", kind: "modified", patch: "@@ -1 +1 @@\n-old\n+new", + binary: true, + truncated: true, before_mode: "0644", - after_mode: "0644", + after_mode: "0755", }), ], }, @@ -265,9 +339,9 @@ test("stat sums, binary/truncated OR and mode first/last-seen across steps", () file({ path: "x", kind: "modified", - patch: "@@ -1 +1 @@\n-gone\n+kept", - binary: true, - truncated: true, + patch: "", + binary: false, + truncated: false, before_mode: "0755", after_mode: "0755", }), @@ -276,16 +350,55 @@ test("stat sums, binary/truncated OR and mode first/last-seen across steps", () }), ]); const entry = changes.files[0]; - assert.equal(entry.added, 2); - assert.equal(entry.removed, 2); - assert.equal(entry.binary, true); - assert.equal(entry.truncated, true); - assert.equal(entry.beforeMode, "0644"); // first-seen - assert.equal(entry.afterMode, "0755"); // last-seen - assert.equal(entryModeChanged(entry), true); - assert.equal(entryHasPatch(entry), false); // binary hides the patch - assert.equal(changes.added, 2); - assert.equal(changes.removed, 2); + assert.equal(entry.binary, false); + assert.equal(entry.truncated, false); + assert.equal(entry.patch, null); + assert.equal(entry.beforeMode, "0755"); + assert.equal(entry.afterMode, "0755"); + assert.equal(entryModeChanged(entry), false); + assert.equal(entry.added, 0); + assert.equal(entry.removed, 0); + // A truncated row anywhere in the run still makes the capture partial. + assert.equal(changes.partial, true); +}); + +test("an earlier-only path keeps its own values", () => { + const changes = runChanges([ + step({ + stage: "a", + file_changes: { + status: "complete", + files: [file({ path: "x", kind: "added", patch: "@@ -0,0 +1 @@\n+x" })], + }, + }), + step({ + stage: "b", + file_changes: { + status: "complete", + files: [file({ path: "y", kind: "deleted", patch: "@@ -1 +0,0 @@\n-y" })], + }, + }), + ]); + assert.deepEqual(changes.files.map((entry) => entry.path), ["x", "y"]); + assert.equal(changes.files[0].kind, ChangeKind.Added); + assert.equal(changes.files[0].added, 1); + assert.equal(changes.files[0].removed, 0); + assert.equal(changes.files[1].kind, ChangeKind.Deleted); + assert.equal(changes.files[1].added, 0); + assert.equal(changes.files[1].removed, 1); +}); + +test("ordering follows numeric sequence, not input order", () => { + const outOfOrder = runChanges([ + step({ stage: "c", sequence: 3, file_changes: { status: "complete", files: [file({ path: "y", kind: "added" })] } }), + step({ stage: "a", sequence: 1, file_changes: { status: "complete", files: [file({ path: "y", kind: "modified" })] } }), + step({ stage: "b", sequence: 2, file_changes: { status: "complete", files: [file({ path: "x", kind: "added" })] } }), + ]); + assert.deepEqual(outOfOrder.files.map((entry) => entry.path), ["y", "x"]); + const y = outOfOrder.files.find((entry) => entry.path === "y"); + assert.equal(y.kind, ChangeKind.Added); + assert.deepEqual(y.steps, ["a", "c"]); + assert.equal(changeRowMeta(y), "changed by a → c"); }); test("changed-by lists the stage names in run order, deduped", () => { @@ -330,6 +443,16 @@ test("diagnostics from several captures are joined with a space, deduped", () => assert.equal(changes.diagnostic, "why one why two"); }); +test("showRunChangesSummary is true only for a settled succeeded run", () => { + assert.equal(showRunChangesSummary("succeeded"), true); + assert.equal(showRunChangesSummary(" Succeeded "), true); + for (const status of ["failed", "running", "waiting", "canceled", "interrupted", "blocked", ""]) { + assert.equal(showRunChangesSummary(status), false, `${status} must not show an aggregate`); + } + assert.equal(showRunChangesSummary(null), false); + assert.equal(showRunChangesSummary(undefined), false); +}); + // --------------------------------------------------------------------------- // Header, note and detail wording // --------------------------------------------------------------------------- @@ -552,10 +675,15 @@ test("runChanges derives run 438's shape: 22 files, partial, one missing capture assert.equal(changes.unavailable, false); assert.equal(changes.pending, false); assert.equal(changes.skipped, 10); - assert.equal(changes.files.find((f) => f.path === "internal/server/retry_test.go").added, 2); + // The retry test was modified by two implementer visits; only the last one's + // stat counts (the earlier patch must not be added to it). + assert.equal(changes.files.find((f) => f.path === "internal/server/retry_test.go").added, 1); + assert.equal(changes.files.find((f) => f.path === "internal/server/retry_test.go").removed, 1); + assert.equal(changes.added, 22); + assert.equal(changes.removed, 22); assert.equal( runChangesHeader(changes), - `22 files changed · +23 -23 · partial capture`, + `22 files changed · +22 -22 · partial capture`, ); assert.ok(runChangesNote(changes).startsWith("Partial capture: some changes may be missing. (10 files skipped)")); assert.ok(runChangesNote(changes).endsWith("Missing capture: 1 stage did not record changes.")); diff --git a/web/test/runDetail.test.mjs b/web/test/runDetail.test.mjs index 76f40c7a..290e4085 100644 --- a/web/test/runDetail.test.mjs +++ b/web/test/runDetail.test.mjs @@ -47,6 +47,7 @@ import { outcomeColorToken, stateGlyph, } from "../src/runDetail.js"; +import { showRunChangesSummary } from "../src/changes.js"; function step(overrides = {}) { return { @@ -315,6 +316,68 @@ test("runStepFields carries every evidence kind the timeline dropped", () => { assert.equal(fields.find((f) => f.label === "Input").block, true); }); +test("each visit's pane formats its own capture, never the run aggregate", () => { + const first = step({ + sequence: 1, + file_changes: { + status: "partial", + skipped: 2, + diagnostic: "Excluded protected files.", + files: [ + { kind: "added", path: "docs/one.md", patch: "@@ -0,0 +1 @@\n+one" }, + { kind: "modified", path: "src/runner.go", patch: "@@ -1 +1 @@\n-old\n+new" }, + ], + }, + }); + const second = step({ + sequence: 2, + file_changes: { + status: "complete", + files: [{ kind: "modified", path: "src/retry_test.go", patch: "@@ -1 +3 @@\n-old\n+a\n+b\n+c" }], + }, + }); + const third = step({ + sequence: 3, + file_changes: { status: "complete", files: [] }, + }); + + const firstFields = runStepFields(first); + assert.equal( + firstFields.find((field) => field.label === "File changes").value, + "partial (2 files), 2 skipped · Excluded protected files.", + ); + assert.equal( + firstFields.find((field) => field.label === "Changed files").value, + "added docs/one.md +1\nmodified src/runner.go +1 -1", + ); + + const secondFields = runStepFields(second); + assert.equal(secondFields.find((field) => field.label === "File changes").value, "complete (1 files)"); + assert.equal( + secondFields.find((field) => field.label === "Changed files").value, + "modified src/retry_test.go +3 -1", + ); + + // A captured no-change still shows its honest summary but has no file rows. + const thirdFields = runStepFields(third); + assert.equal(thirdFields.find((field) => field.label === "File changes").value, "complete"); + assert.equal(thirdFields.find((field) => field.label === "Changed files"), undefined); +}); + +test("a step that recorded no capture shows neither File changes nor Changed files", () => { + const fields = runStepFields(step({ file_changes: null })); + assert.ok(!fields.some((field) => field.label === "File changes")); + assert.ok(!fields.some((field) => field.label === "Changed files")); +}); + +test("showRunChangesSummary gates the Summary aggregate to succeeded only", () => { + assert.equal(showRunChangesSummary("succeeded"), true); + assert.equal(showRunChangesSummary(" SUCCEEDED "), true); + for (const status of ["failed", "running", "waiting", "canceled", "interrupted", ""]) { + assert.equal(showRunChangesSummary(status), false); + } +}); + test("headline and evidence split the visit's facts without duplication", () => { const fields = runStepFields({ status: "completed", @@ -473,12 +536,37 @@ test("referencedVerdictArtifacts resolves names to recorded files in recorded or // Formatters and colours // --------------------------------------------------------------------------- -test("fileChangeLine adds the binary and truncated markers", () => { +test("fileChangeLine adds a parseable stat, never a fabricated one", () => { assert.equal(fileChangeLine({ kind: "modified", path: "src/a.kt" }), "modified src/a.kt"); assert.equal( fileChangeLine({ kind: "modified", path: "src/a.kt", binary: true, truncated: true }), "modified src/a.kt (binary) (truncated)", ); + // A binary file keeps its marker and never gets a text stat, even if a patch + // string was recorded alongside it. + assert.equal( + fileChangeLine({ kind: "added", path: "shot.png", binary: true, patch: "@@ -1 +1 @@\n-a\n+b" }), + "added shot.png (binary)", + ); + assert.equal( + fileChangeLine({ + kind: "modified", + path: "src/a.kt", + patch: "@@ -1,2 +1,3 @@\n ctx\n-old\n+new\n+more", + }), + "modified src/a.kt +2 -1", + ); + assert.equal( + fileChangeLine({ + kind: "modified", + path: "src/a.kt", + truncated: true, + patch: "@@ -1 +1 @@\n-old\n+new", + }), + "modified src/a.kt +1 -1 (truncated)", + ); + // Header-only/unparseable text is not a diff and earns no stat. + assert.equal(fileChangeLine({ kind: "modified", path: "src/a.kt", patch: "not a patch" }), "modified src/a.kt"); }); test("notificationLine appends a non-blank diagnostic only", () => { @@ -489,8 +577,23 @@ test("notificationLine appends a non-blank diagnostic only", () => { ); }); -test("fileChangesSummary omits blank parts", () => { +test("fileChangesSummary carries status, count, skipped, omitted and diagnostic", () => { assert.equal(fileChangesSummary({ status: "partial", files: [{}, {}], skipped: 1 }), "partial (2 files), 1 skipped"); + assert.equal( + fileChangesSummary({ + status: "partial", + files: [{}, {}], + skipped: 1, + omitted: 3, + diagnostic: " Excluded protected files. ", + }), + "partial (2 files), 1 skipped, 3 omitted · Excluded protected files.", + ); + assert.equal( + fileChangesSummary({ status: "unavailable", files: [], diagnostic: "snapshot unreadable" }), + "unavailable · snapshot unreadable", + ); + assert.equal(fileChangesSummary({ status: "complete", files: [] }), "complete"); assert.equal(fileChangesSummary({}), ""); assert.equal(fileChangesSummary(null), ""); }); diff --git a/web/test/ui-smoke.mjs b/web/test/ui-smoke.mjs index abcd12b4..c5bff20a 100644 --- a/web/test/ui-smoke.mjs +++ b/web/test/ui-smoke.mjs @@ -2612,6 +2612,29 @@ try { console.log(` expanded: ${expanded.summary} — ${expanded.rows} row(s)`); console.log(` note: ${expanded.note}`); console.log(` kinds: ${[...new Set(expanded.kinds)].join(", ")}`); + // The summary is the final state: retry_test.go was modified in two + // implementer visits (+30 -12, then +42 -12). The row must show the last + // visit's +42 -12, not their +72 -24 sum, and only the one stage name. + const finalState = await page.evaluate(`(() => { + const row = [...document.querySelectorAll(".run-detail .changes-list .change-row")] + .find((n) => n.querySelector(".change-path")?.textContent === "internal/server/retry_test.go"); + if (!row) return null; + return { + stat: [...row.querySelectorAll(".change-stat span")].map((n) => n.textContent).join(" "), + meta: row.querySelector(".change-meta")?.textContent ?? "", + }; + })()`); + if (!finalState) throw new Error("run 438's Changes list lost internal/server/retry_test.go"); + if (finalState.stat !== "+42 -12") { + throw new Error(`run 438 did not show retry_test.go's final-visit stat: ${finalState.stat}`); + } + if (finalState.meta !== "changed by implementer") { + throw new Error(`run 438's retry_test.go stage list is wrong: ${finalState.meta}`); + } + if (!collapsed.title.includes("+934 -156")) { + throw new Error(`run 438's header is not the final-state stat: ${collapsed.title}`); + } + console.log(` final state: retry_test.go ${finalState.stat} — ${finalState.meta}`); await page.evaluate(`document.querySelector(".run-detail .changes-list .change-row")?.scrollIntoView({ block: "center" })`); shots.push(await page.screenshot(`${out}/29-run-438-changes-expanded.png`)); @@ -2710,13 +2733,64 @@ try { await page.waitForSelector(".change-viewer", { timeout: 15000 }); await closeChangeViewer("backdrop"); + // Part 1: each visit's "This run" carries its own capture. Run 438's second + // implementer visit changed only retry_test.go and must not show the run-wide + // aggregate (or the first visit's docs/runner rows). + step("opening run 438's second implementer visit: its own File changes"); + await page.clickText(".detail .detail-tabs .detail-tab", "Timeline"); + await page.waitForSelector(".detail .timeline-row", { timeout: 15000 }); + await page.click('.detail .timeline-row[data-stage-key="implementer"][data-visit-index="1"]'); + await page.waitForSelector(".stage-pane", { timeout: 15000 }); + await page.clickText(".stage-pane .section-toggle", "This run"); + await page.waitForSelector(".stage-pane .codeblock", { timeout: 15000 }); + const visitChanges = await page.evaluate(`(() => { + const row = [...document.querySelectorAll(".stage-pane .kv-row")] + .find((n) => n.querySelector(".kv-key")?.textContent === "File changes"); + const block = [...document.querySelectorAll(".stage-pane .codeblock")] + .find((n) => n.querySelector(".codeblock-label")?.textContent === "Changed files"); + return { + summary: row?.querySelector(".kv-val")?.textContent ?? "", + files: block?.querySelector(".codeblock-body")?.textContent ?? "", + labels: [...document.querySelectorAll(".stage-pane .codeblock-label")].map((n) => n.textContent), + }; + })()`); + if (!visitChanges.summary.startsWith("partial (1 files), 2 skipped · Excluded protected")) { + throw new Error(`the implementer visit's File changes is wrong: ${visitChanges.summary}`); + } + if (visitChanges.files !== "modified internal/server/retry_test.go +42 -12") { + throw new Error(`the implementer visit's Changed files is wrong: ${visitChanges.files}`); + } + if (visitChanges.files.includes("docs/notes") || visitChanges.files.includes("runner.go")) { + throw new Error(`the visit pane leaked another visit's files: ${visitChanges.files}`); + } + console.log(` implementer visit 2: ${visitChanges.summary}`); + console.log(` changed files: ${visitChanges.files}`); + await page.evaluate(`(() => { + const row = [...document.querySelectorAll(".stage-pane .kv-row")] + .find((n) => n.querySelector(".kv-key")?.textContent === "File changes"); + row?.scrollIntoView({ block: "center" }); + })()`); + shots.push(await page.screenshot(`${out}/78-run-438-implementer-visit-changes.png`)); + await page.click(".stage-pane-back"); + await eventually(() => page.evaluate(`!document.querySelector(".stage-pane")`), { + timeout: 5000, + what: "the implementer visit pane to close", + }); + // A binary capture: the honest message in place of a diff, and Raw disabled. - step("opening a binary capture (run 442): the honest message and a disabled Raw patch"); - await page.click('.list.runs .run-row-meta[data-run-id="442"]'); - await page.waitForText("run 442 ·", { timeout: 25000 }); - await page.waitForSelector(".detail .detail-tabs", { timeout: 25000 }); + // Run 449 succeeded and recorded binary captures; choose its binary row (its + // first row is a text file). + step("opening a binary capture (run 449): the honest message and a disabled Raw patch"); + await openRunDetail(449); await expandChanges(); - await page.click(".run-detail .changes-list .change-row"); + const openedBinary = await page.evaluate(`(() => { + const row = [...document.querySelectorAll(".run-detail .changes-list .change-row")] + .find((n) => (n.querySelector(".change-meta")?.textContent ?? "").includes("binary")); + if (!row) return false; + row.click(); + return true; + })()`); + if (!openedBinary) throw new Error("run 449's Changes list showed no binary row"); await page.waitForSelector(".change-viewer .change-honest", { timeout: 15000 }); const binary = await page.evaluate(`(() => ({ message: document.querySelector(".change-viewer .change-honest")?.textContent ?? "", @@ -2732,7 +2806,7 @@ try { if (binary.rawDisabled !== true) throw new Error("Raw patch should be disabled for a binary file"); if (binary.hunks !== 0) throw new Error("a binary file must not render a fabricated diff"); console.log(` binary: ${binary.message}`); - shots.push(await page.screenshot(`${out}/32-run-442-changes-binary.png`)); + shots.push(await page.screenshot(`${out}/32-run-449-changes-binary.png`)); await closeChangeViewer("close"); // A truncated capture: the truncation reason, still no fabricated diff. @@ -2763,38 +2837,118 @@ try { shots.push(await page.screenshot(`${out}/33-run-450-changes-truncated.png`)); await closeChangeViewer("close"); - // A still-running run: its Changes header must be one of the two valid shapes - // for an in-flight capture (the empty `Changes · …` variant, or a file-count - // header), never a fabricated complete diff. Its live state decides which, so - // the probe accepts either rather than pinning one. - step("opening a running run's Changes header"); - const pendingRunId = await page.evaluate(`(() => { + // Part 3: a failed run has no settled final state, so its Summary carries no + // aggregate Changes section at all. The visit pane still carries that visit's + // own capture. + step("opening failed run 440: no Summary Changes section"); + await openRunDetail(440); + const failedSummaryTitles = await page.evaluate( + `[...document.querySelectorAll(".run-detail .collapsible .section-title")].map((n) => n.textContent ?? "")`, + ); + const leakedAggregate = failedSummaryTitles.find( + (title) => /^Changes · /.test(title) || /^\d+ files? changed/.test(title), + ); + if (leakedAggregate) { + throw new Error(`failed run 440 still shows an aggregate Changes section: ${leakedAggregate}`); + } + console.log(` run 440 summary sections: ${failedSummaryTitles.join(" | ")}`); + shots.push(await page.screenshot(`${out}/79-run-440-no-summary-changes.png`)); + + step("run 440's visit pane keeps that visit's own File changes"); + await page.clickText(".detail .detail-tabs .detail-tab", "Timeline"); + await page.waitForSelector(".detail .timeline-row", { timeout: 15000 }); + await page.click(".detail .timeline-row"); + await page.waitForSelector(".stage-pane", { timeout: 15000 }); + await page.clickText(".stage-pane .section-toggle", "This run"); + await page.waitForSelector(".stage-pane .kv-row", { timeout: 15000 }); + const failedVisit = await page.evaluate(`(() => { + const row = [...document.querySelectorAll(".stage-pane .kv-row")] + .find((n) => n.querySelector(".kv-key")?.textContent === "File changes"); + const block = [...document.querySelectorAll(".stage-pane .codeblock")] + .find((n) => n.querySelector(".codeblock-label")?.textContent === "Changed files"); + return { + summary: row?.querySelector(".kv-val")?.textContent ?? "", + files: block?.querySelector(".codeblock-body")?.textContent ?? "", + }; + })()`); + // This visit's capture recorded no file rows (0 files, 2 skipped), so the + // honest summary is shown and Changed files is correctly absent. + if (!failedVisit.summary.startsWith("partial, 2 skipped · Excluded protected")) { + throw new Error(`run 440's visit File changes is wrong: ${failedVisit.summary}`); + } + if (failedVisit.files !== "") { + throw new Error(`run 440's visit invented Changed files with no recorded rows: ${failedVisit.files}`); + } + console.log(` run 440 visit: ${failedVisit.summary} (no recorded file rows)`); + await page.evaluate(`(() => { + const row = [...document.querySelectorAll(".stage-pane .kv-row")] + .find((n) => n.querySelector(".kv-key")?.textContent === "File changes"); + row?.scrollIntoView({ block: "center" }); + })()`); + shots.push(await page.screenshot(`${out}/80-run-440-visit-changes.png`)); + await page.click(".stage-pane-back"); + await eventually(() => page.evaluate(`!document.querySelector(".stage-pane")`), { + timeout: 5000, + what: "the run 440 visit pane to close", + }); + + // A failed run that did record file rows: run 442's implementer visit keeps + // its own Changed files even though the Summary aggregate is suppressed. + step("run 442's failed implementer visit keeps its Changed files"); + await openRunDetail(442); + await page.clickText(".detail .detail-tabs .detail-tab", "Timeline"); + await page.waitForSelector(".detail .timeline-row", { timeout: 15000 }); + await page.click('.detail .timeline-row[data-stage-key="implementer"][data-visit-index="0"]'); + await page.waitForSelector(".stage-pane", { timeout: 15000 }); + await page.clickText(".stage-pane .section-toggle", "This run"); + await page.waitForSelector(".stage-pane .codeblock", { timeout: 15000 }); + const failedFiles = await page.evaluate(`(() => { + const block = [...document.querySelectorAll(".stage-pane .codeblock")] + .find((n) => n.querySelector(".codeblock-label")?.textContent === "Changed files"); + return block?.querySelector(".codeblock-body")?.textContent ?? ""; + })()`); + if (!failedFiles.includes("web/src/")) { + throw new Error(`run 442's implementer visit lost its Changed files: ${failedFiles}`); + } + console.log(` run 442 implementer visit changed files: ${failedFiles.split("\n").length} rows`); + await page.evaluate(`(() => { + const block = [...document.querySelectorAll(".stage-pane .codeblock")] + .find((n) => n.querySelector(".codeblock-label")?.textContent === "Changed files"); + block?.scrollIntoView({ block: "center" }); + })()`); + shots.push(await page.screenshot(`${out}/81-run-442-failed-visit-changes.png`)); + await page.click(".stage-pane-back"); + await eventually(() => page.evaluate(`!document.querySelector(".stage-pane")`), { + timeout: 5000, + what: "the run 442 visit pane to close", + }); + + // A running run has no settled final state either: invert the old pending- + // header probe and assert the aggregate is absent while it executes. + step("a running run's Summary has no Changes section"); + await page.clickText("nav.tabs button.tab", "Runs"); + await page.waitForSelector(".list.runs .run-row", { timeout: 25000 }); + const runningRunId = await page.evaluate(`(() => { const row = [...document.querySelectorAll(".list.runs .run-row")] .find((n) => n.querySelector(".chip-running")); const meta = row?.querySelector(".run-row-meta[data-run-id]"); return meta ? Number(meta.getAttribute("data-run-id")) : null; })()`); - if (pendingRunId == null) { - console.log(" -- no running run available; skipped the pending Changes header"); + if (runningRunId == null) { + console.log(" -- no running run available; skipped the no-aggregate check"); } else { - await page.click(`.list.runs .run-row-meta[data-run-id="${pendingRunId}"]`); - await page.waitForSelector(".detail .detail-tabs", { timeout: 25000 }); - const pendingToggle = await page.evaluate(`(() => { - // A running run's Changes header has one of two valid shapes: the - // empty-capture form (Changes · capture pending / partial capture / - // capture incomplete) before any step has recorded files, or the - // file-count form ({N} file(s) changed · ±stat · …) once one has. Which - // one appears depends on how far the live capture has progressed, so the - // probe accepts either rather than assuming the empty variant. - return [...document.querySelectorAll(".run-detail .collapsible .section-toggle .section-title")] - .map((n) => n.textContent ?? "") - .find((t) => /^Changes · /.test(t) || /^\\d+ files? changed/.test(t)) ?? ""; - })()`); - if (!/^Changes · /.test(pendingToggle) && !/^\d+ files? changed/.test(pendingToggle)) { - throw new Error(`a running run's Changes header is wrong: ${pendingToggle}`); + await openRunDetail(runningRunId); + const runningTitles = await page.evaluate( + `[...document.querySelectorAll(".run-detail .collapsible .section-title")].map((n) => n.textContent ?? "")`, + ); + const runningAggregate = runningTitles.find( + (title) => /^Changes · /.test(title) || /^\d+ files? changed/.test(title), + ); + if (runningAggregate) { + throw new Error(`running run ${runningRunId} shows an aggregate Changes section: ${runningAggregate}`); } - console.log(` running run ${pendingRunId} changes header: ${pendingToggle}`); - shots.push(await page.screenshot(`${out}/34-run-${pendingRunId}-changes-pending.png`)); + console.log(` running run ${runningRunId}: no Summary Changes section`); + shots.push(await page.screenshot(`${out}/82-run-${runningRunId}-no-summary-changes.png`)); } // S1/S2: omni-search over the real server. The panel is opened from the top From 23809051e9a7541c6a37491dc367f4cbd8210ec8 Mon Sep 17 00:00:00 2001 From: Alan Silva Date: Mon, 19 Oct 2026 18:30:47 +0100 Subject: [PATCH 4/4] web: align smoke labels with the merged accessibility names The merged main branch names the attention dismiss and chat actions controls for their rows. Assert those prefixes instead of the old bare words so the live smoke exercises the current labels. --- web/test/ui-smoke.mjs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/web/test/ui-smoke.mjs b/web/test/ui-smoke.mjs index c5bff20a..1f41616f 100644 --- a/web/test/ui-smoke.mjs +++ b/web/test/ui-smoke.mjs @@ -1637,7 +1637,10 @@ try { if (!row.icon) throw new Error(`row ${row.runId} has no status icon`); if (!row.label) throw new Error(`row ${row.runId} has no primary label`); if (!row.desc.includes(" · ")) throw new Error(`row ${row.runId} description is wrong: ${row.desc}`); - if (row.dismissName !== "Dismiss") { + // The dismiss control is named for the row it clears (L7 M6), e.g. + // `Dismiss Web: live decision confirm (R11)`; the run id appears only for a + // repeated label, so assert the shared prefix rather than the old bare word. + if (!row.dismissName.startsWith("Dismiss ")) { throw new Error(`row ${row.runId}'s trailing control is not named Dismiss: ${row.dismissName}`); } const rank = kindRanks[row.kind]; @@ -3515,7 +3518,9 @@ try { if (!operatorRow.chips.includes("Operator")) { throw new Error(`chat kind chip: ${operatorRow.chips.join(", ")}`); } - if (!operatorRow.menu || operatorRow.menuLabel !== "Chat actions") { + // M6 names the control for its row: `Chat actions for {title}`, with the + // session id only when titles repeat. Assert the shared prefix and title. + if (!operatorRow.menu || !operatorRow.menuLabel.startsWith("Chat actions for ")) { throw new Error(`the open chat row's Chat actions menu: ${JSON.stringify(operatorRow)}`); } }