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
+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)}`);
}
}