Merge branch 'main' into web-layout

Take main's newer smoke behaviour where they met: the binary capture is run 449
(opened through openRunDetail), and a running run must show no aggregate Changes
section. Keep the layout's shell-aware checks and its L2-L4 rows; L7 stays todo
with the view-level fixes recorded.
This commit is contained in:
2026-10-19 20:06:25 +01:00
14 changed files with 709 additions and 150 deletions
+3 -1
View File
@@ -81,7 +81,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.
+3 -3
View File
File diff suppressed because one or more lines are too long
+7 -4
View File
@@ -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
```
@@ -77,7 +77,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` |
@@ -98,8 +98,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
+19 -1
View File
@@ -92,7 +92,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; }
+25 -1
View File
@@ -46,7 +46,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; }
+34 -4
View File
@@ -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}`);
});
+53 -37
View File
@@ -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;
+31 -6
View File
@@ -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;
}
+14 -4
View File
@@ -152,6 +152,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 {
@@ -163,7 +169,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);
@@ -172,8 +178,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",
{
@@ -198,8 +208,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();
+46 -22
View File
@@ -1504,24 +1504,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 }));
}
@@ -1531,7 +1546,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 =
@@ -1543,23 +1558,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 }));
@@ -1572,14 +1592,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;
}
@@ -1707,18 +1727,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);
+27 -10
View File
@@ -71,6 +71,7 @@ import {
runChanges,
runChangesHeader,
runChangesNote,
showRunChangesSummary,
} from "../changes.js";
import {
DECISION_ACTION,
@@ -217,12 +218,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;
}
@@ -841,7 +845,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);
@@ -855,7 +866,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 {
@@ -866,8 +883,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. */
+150 -22
View File
@@ -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."));
+105 -2
View File
@@ -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), "");
});
+192 -33
View File
@@ -2198,7 +2198,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];
@@ -3164,6 +3167,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`));
@@ -3262,13 +3288,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("#detailTitle", { 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 ?? "",
@@ -3284,7 +3361,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.
@@ -3315,38 +3392,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("#detailTitle", { 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
@@ -3913,7 +4070,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)}`);
}
}