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.
This commit is contained in:
2026-10-19 18:27:39 +01:00
parent 2503a38f50
commit b011f4ada4
7 changed files with 535 additions and 105 deletions
+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), "");
});