web: chat reasoning block and tool calls for the whole lifecycle (C6)

This commit is contained in:
2026-10-19 06:14:48 +01:00
parent f48e53d5c8
commit 7df4891f14
6 changed files with 1200 additions and 17 deletions
+221 -1
View File
@@ -7,6 +7,9 @@ import assert from "node:assert/strict";
import {
CHAT_FOLLOW_THRESHOLD_PX,
ChatTurn,
MAX_RENDERED_DIFF_LINES,
TOOL_DETAIL_MAX_LENGTH,
TOOL_LONG_RUNNING_MILLIS,
chatBottomDistancePx,
chatFirstScroll,
chatFollowsAt,
@@ -17,10 +20,14 @@ import {
closeChatConfirmation,
directoryLabel,
filterSessions,
formatToolDuration,
groupSessionsByDirectory,
lineDiff,
mergeHistoryPage,
partRendering,
prettyToolInput,
reasoningLabel,
runningToolElapsedMillis,
sessionActivity,
sessionActivityBadge,
sessionChipLabel,
@@ -29,9 +36,23 @@ import {
sessionStatusLabel,
sessionTitle,
sessionWorkLabel,
toolCallCount,
toolCallRow,
toolCallsAnnouncement,
toolCallsLabel,
toolDetail,
toolDurationMillis,
toolEditDiff,
toolErrorText,
toolFailed,
toolLongRunning,
toolOutputText,
toolRunning,
toolsRunning,
transcriptRows,
turnElapsedMillis,
} from "../src/chat.js";
import { ChangeLineKind } from "../src/changes.js";
import { PipelinesClient, ProtocolError } from "../src/client.js";
import { PipelinesRepository } from "../src/repository.js";
@@ -97,11 +118,210 @@ test("toolCallsLabel never pluralises a count of one", () => {
assert.equal(toolCallsLabel(4), "4 tools called");
});
test("reasoningLabel keeps the one-block wording and counts multiple steps", () => {
test("reasoningLabel is Thinking/Reasoning with the step count and streaming word", () => {
assert.equal(reasoningLabel(1, false), "Reasoning");
assert.equal(reasoningLabel(1, true), "Thinking…");
assert.equal(reasoningLabel(3, false), "Reasoning · 3 steps");
assert.equal(reasoningLabel(3, true), "Thinking · 3 steps");
assert.equal(reasoningLabel(1), "Reasoning");
assert.equal(reasoningLabel(3), "Reasoning · 3 steps");
});
// --- Tool-call lifecycle, detail and the edit diff (C6) ---------------------
test("toolRunning treats streaming and running as in flight, completed/error as settled", () => {
assert.equal(toolRunning({ type: "tool", state: { status: "streaming" } }), true);
assert.equal(toolRunning({ type: "tool", state: { status: "running" } }), true);
assert.equal(toolRunning({ type: "tool", state: { status: "completed" } }), false);
assert.equal(toolRunning({ type: "tool", state: { status: "error" } }), false);
assert.equal(toolRunning({ type: "tool" }), false);
assert.equal(toolRunning({ type: "text", state: { status: "running" } }), false);
});
test("toolsRunning and toolFailed summarise the lifecycle", () => {
const call = (status) => ({ type: "tool", state: { status } });
assert.equal(toolsRunning([call("completed"), call("running")]), true);
assert.equal(toolsRunning([call("completed"), call("error")]), false);
assert.equal(toolsRunning([]), false);
assert.equal(toolFailed({ status: "error" }), true);
assert.equal(toolFailed({ status: "completed" }), false);
assert.equal(toolFailed(undefined), false);
});
test("toolCallCount counts only tool parts and toolCallsAnnouncement matches the plural", () => {
const parts = [{ type: "tool" }, { type: "text" }, { type: "reasoning" }, { type: "tool" }];
assert.equal(toolCallCount(parts), 2);
assert.equal(toolCallCount([]), 0);
assert.equal(toolCallsAnnouncement(1), "1 tool call, expand for details");
assert.equal(toolCallsAnnouncement(3), "3 tool calls, expand for details");
});
test("toolDetail takes the first present detail key, collapsed and trimmed to 72", () => {
const part = (input) => ({ type: "tool", state: { input } });
assert.equal(toolDetail(part({ command: "ls -la" })), "ls -la");
assert.equal(toolDetail(part({ description: "do a thing", command: "x" })), "do a thing");
assert.equal(toolDetail(part({ filePath: "/a/b.ts" })), "/a/b.ts");
assert.equal(toolDetail(part({ path: "p", command: "c" })), "c");
assert.equal(toolDetail(part({ command: " a b\tc\n d " })), "a b c d");
const detail = toolDetail(part({ command: "x".repeat(100) }));
assert.equal(detail.length, TOOL_DETAIL_MAX_LENGTH);
assert.ok(detail.endsWith("…"));
assert.equal(toolDetail(part({ other: "nope" })), null);
assert.equal(toolDetail(part("partial json")), null);
assert.equal(toolDetail(part({ command: 42 })), null);
assert.equal(toolDetail({ type: "tool" }), null);
});
test("formatToolDuration renders ms, one-decimal seconds and minutes", () => {
assert.equal(formatToolDuration(340), "340ms");
assert.equal(formatToolDuration(999), "999ms");
assert.equal(formatToolDuration(1000), "1.0s");
assert.equal(formatToolDuration(1200), "1.2s");
assert.equal(formatToolDuration(59600), "59.6s");
assert.equal(formatToolDuration(60000), "1m 0s");
assert.equal(formatToolDuration(123000), "2m 3s");
});
test("toolDurationMillis reads ran-else-created to completed, null when unusable", () => {
assert.equal(toolDurationMillis({ time: { created: 10, ran: 20, completed: 120 } }), 100);
assert.equal(toolDurationMillis({ time: { created: 10, ran: 0, completed: 110 } }), 100);
assert.equal(toolDurationMillis({ time: { created: 10, ran: 20 } }), null);
assert.equal(toolDurationMillis({ time: { created: 10, ran: 20, completed: 5 } }), null);
assert.equal(toolDurationMillis({}), null);
});
test("runningToolElapsedMillis prefers the protocol start and falls back to the local stamp", () => {
const part = { type: "tool", time: { created: 100, ran: 500 } };
assert.equal(runningToolElapsedMillis(part, 999, 1500), 1000);
assert.equal(runningToolElapsedMillis({ type: "tool" }, 1000, 4000), 3000);
assert.equal(runningToolElapsedMillis({ type: "tool" }, 0, 4000), 0);
assert.equal(toolLongRunning(TOOL_LONG_RUNNING_MILLIS), true);
assert.equal(toolLongRunning(TOOL_LONG_RUNNING_MILLIS - 1), false);
});
test("toolOutputText joins text content, (no output) when settled-empty and '' in flight", () => {
const state = (status, content) => ({ status, content });
assert.equal(
toolOutputText(state("completed", [{ type: "text", text: "a" }, { type: "text", text: "b" }])),
"a\nb",
);
assert.equal(toolOutputText(state("completed", [{ type: "text", text: " " }])), "(no output)");
assert.equal(toolOutputText(state("running", [])), "");
assert.equal(toolOutputText(state("streaming", [])), "");
assert.equal(toolOutputText(state("error", [])), "(no output)");
assert.equal(toolOutputText(null), "");
});
test("toolErrorText prefers the server's error message over the output", () => {
assert.equal(
toolErrorText({ status: "error", error: { message: "boom" }, content: [{ type: "text", text: "partial" }] }),
"boom",
);
assert.equal(toolErrorText({ status: "error", content: [{ type: "text", text: "partial" }] }), "partial");
assert.equal(toolErrorText({ status: "error", error: { message: " " }, content: [] }), "(no output)");
});
test("prettyToolInput pretty-prints objects, keeps a partial string and blanks nothing", () => {
assert.equal(prettyToolInput(null), "");
assert.equal(prettyToolInput("{\"a\":"), "{\"a\":");
assert.equal(prettyToolInput({ a: 1 }), '{\n "a": 1\n}');
assert.equal(prettyToolInput([1, 2]), "[\n 1,\n 2\n]");
});
test("lineDiff LCS marks only changed lines and carries ChangeLineKind values", () => {
const lines = lineDiff(["one", "two", "three"], ["one", "TWO", "three"]);
assert.deepEqual(lines, [
{ kind: ChangeLineKind.Context, text: "one" },
{ kind: ChangeLineKind.Remove, text: "two" },
{ kind: ChangeLineKind.Add, text: "TWO" },
{ kind: ChangeLineKind.Context, text: "three" },
]);
});
test("toolEditDiff derives the file, true counts and the LCS line kinds", () => {
const diff = toolEditDiff({ filePath: "a.ts", oldString: "one\ntwo\nthree", newString: "one\nTWO\nthree" });
assert.equal(diff.file, "a.ts");
assert.equal(diff.added, 1);
assert.equal(diff.removed, 1);
assert.equal(diff.omitted, 0);
assert.deepEqual(diff.lines, [
{ kind: ChangeLineKind.Context, text: "one" },
{ kind: ChangeLineKind.Remove, text: "two" },
{ kind: ChangeLineKind.Add, text: "TWO" },
{ kind: ChangeLineKind.Context, text: "three" },
]);
assert.equal(toolEditDiff({ oldString: "", newString: "" }), null);
assert.equal(toolEditDiff({ oldString: "x" }), null);
assert.equal(toolEditDiff({ command: "ls" }), null);
assert.equal(toolEditDiff("nope"), null);
});
test("toolEditDiff caps rendered lines at MAX_RENDERED_DIFF_LINES and counts the rest", () => {
const oldLines = Array.from({ length: 300 }, (_, i) => `old-${i}`);
const newLines = Array.from({ length: 300 }, (_, i) => `new-${i}`);
const diff = toolEditDiff({ oldString: oldLines.join("\n"), newString: newLines.join("\n") });
assert.equal(diff.lines.length, MAX_RENDERED_DIFF_LINES);
assert.equal(diff.added, 300);
assert.equal(diff.removed, 300);
assert.equal(diff.omitted, 600 - MAX_RENDERED_DIFF_LINES);
});
test("lineDiff falls back to remove-then-add past the algorithm guard", () => {
const lines = lineDiff(Array.from({ length: 401 }, () => "a"), ["b"]);
assert.equal(lines.length, 402);
assert.equal(lines[0].kind, ChangeLineKind.Remove);
assert.equal(lines.at(-1).kind, ChangeLineKind.Add);
});
test("toolCallRow composes the name, detail, duration, input, output, error and diff", () => {
const part = {
type: "tool",
id: "t1",
name: "edit",
state: {
status: "completed",
input: { filePath: "a.ts", oldString: "one", newString: "two" },
content: [{ type: "text", text: "done" }],
},
time: { created: 10, ran: 20, completed: 120 },
};
const row = toolCallRow(part);
assert.equal(row.name, "edit");
assert.equal(row.detail, "a.ts");
assert.equal(row.duration, "100ms");
assert.equal(row.input, '{\n "filePath": "a.ts",\n "oldString": "one",\n "newString": "two"\n}');
assert.equal(row.output, "done");
assert.equal(row.error, null);
assert.equal(row.diff.file, "a.ts");
assert.equal(row.diff.added, 1);
assert.equal(row.diff.removed, 1);
});
test("toolCallRow marks a failed call with its error text and no diff", () => {
const row = toolCallRow({
type: "tool",
id: "t2",
name: "shell",
state: { status: "error", input: { command: "false" }, error: { message: "exit 1" } },
});
assert.equal(row.name, "shell");
assert.equal(row.detail, "false");
assert.equal(row.duration, null);
assert.equal(row.error, "exit 1");
assert.equal(row.diff, null);
});
test("turnElapsedMillis spans earliest start to latest completion and is null when unusable", () => {
const parts = [
{ time: { created: 1000, ran: 1200, completed: 5000 } },
{ time: { created: 800, ran: 0, completed: 4000 } },
];
assert.equal(turnElapsedMillis(parts), 4200);
assert.equal(turnElapsedMillis([{ time: { created: 1000, ran: 1200 } }]), null);
assert.equal(turnElapsedMillis([{}]), null);
assert.equal(turnElapsedMillis([{ time: { created: 1000, ran: 1000, completed: 1000 } }]), null);
});
// --- Session identity -------------------------------------------------------
test("sessionTitle falls back from the title to the first 18 characters of the id", () => {
+248
View File
@@ -2344,6 +2344,254 @@ try {
await shot("47b-chat-markdown-code.png");
await page.evaluate(`document.querySelector("#markdownCodeSample")?.remove()`);
// C6: the turn's reasoning block and its tool-call chip + panel. The live
// operator session carries one folded agent turn with real reasoning and tool
// parts, so the chip, the panel and the rows are exercised against live data.
// Labels, aria names and the C14 scroll-invariance are asserted, not assumed.
step("C6: the reasoning block and the tool-call chip + panel");
const reasoningNow = await page.evaluate(`(() => {
const block = document.querySelector("#chatTranscript .chat-reasoning");
if (!block) return null;
const icon = block.querySelector(".chat-reasoning-icon");
const body = block.querySelector(".chat-reasoning-body");
return {
label: block.querySelector(".chat-reasoning-label")?.textContent ?? "",
aria: icon?.getAttribute("aria-label") ?? "",
expanded: body ? !body.hidden : false,
};
})()`);
if (!reasoningNow) throw new Error("C6: no reasoning block rendered in the live transcript");
if (reasoningNow.aria !== "Hide reasoning") {
throw new Error(`C6: the expanded reasoning chevron should read 'Hide reasoning', got ${reasoningNow.aria}`);
}
if (!/^Reasoning( · \d+ steps)?( · \d+[a-z].*)?$/.test(reasoningNow.label)) {
throw new Error(`C6: settled reasoning label: ${reasoningNow.label}`);
}
const reasoningCollapsed = await page.evaluate(`(() => {
const block = document.querySelector("#chatTranscript .chat-reasoning");
block.querySelector(".chat-reasoning-toggle").click();
const el = document.querySelector("#chatTranscript");
const br = block.getBoundingClientRect();
el.scrollTop = Math.max(0, el.scrollTop + Math.round(br.top - el.getBoundingClientRect().top) - 60);
return {
hidden: block.querySelector(".chat-reasoning-body").hidden,
aria: block.querySelector(".chat-reasoning-icon").getAttribute("aria-label"),
expanded: block.querySelector(".chat-reasoning-toggle").getAttribute("aria-expanded"),
};
})()`);
if (!reasoningCollapsed.hidden || reasoningCollapsed.aria !== "Show reasoning" || reasoningCollapsed.expanded !== "false") {
throw new Error(`C6: collapsing the reasoning block: ${JSON.stringify(reasoningCollapsed)}`);
}
console.log(` reasoning block "${reasoningNow.label}" collapsed (chevron "Show reasoning")`);
await shot("51-chat-reasoning-collapsed.png");
const expandedReasoning = await page.evaluate(`(() => {
const block = document.querySelector("#chatTranscript .chat-reasoning");
block.querySelector(".chat-reasoning-toggle").click();
const el = document.querySelector("#chatTranscript");
const br = block.getBoundingClientRect();
el.scrollTop = Math.max(0, el.scrollTop + Math.round(br.top - el.getBoundingClientRect().top) - 60);
return {
hidden: block.querySelector(".chat-reasoning-body").hidden,
aria: block.querySelector(".chat-reasoning-icon").getAttribute("aria-label"),
length: block.querySelector(".chat-reasoning-body").textContent.length,
};
})()`);
if (expandedReasoning.hidden || expandedReasoning.aria !== "Hide reasoning" || expandedReasoning.length === 0) {
throw new Error(`C6: expanding the reasoning block: ${JSON.stringify(expandedReasoning)}`);
}
console.log(` reasoning block expanded again (${expandedReasoning.length} chars, chevron "Hide reasoning")`);
await shot("52-chat-reasoning-expanded.png");
// The chip: its count, its screen-reader announcement and its chevron. The
// count is the number of rows the panel carries, so the two can never disagree.
const chipInfo = await page.evaluate(`(() => {
const chip = document.querySelector("#chatTranscript .chat-tool-chip");
if (!chip) return null;
chip.scrollIntoView({ block: "center" });
return {
text: chip.textContent ?? "",
aria: chip.getAttribute("aria-label") ?? "",
chevron: chip.querySelector(".chat-tool-chevron")?.getAttribute("aria-label") ?? "",
rows: document.querySelectorAll(".chat-tool-panel .chat-tool-row").length,
};
})()`);
if (!chipInfo) throw new Error("C6: no tool-call chip rendered in the live transcript");
const toolCount = chipInfo.rows;
const toolLabel = toolCount === 1 ? "1 tool called" : `${toolCount} tools called`;
const toolAria =
toolCount === 1 ? "1 tool call, expand for details" : `${toolCount} tool calls, expand for details`;
if (!chipInfo.text.includes(toolLabel)) {
throw new Error(`C6: the chip should read "${toolLabel}", got ${JSON.stringify(chipInfo.text)}`);
}
if (chipInfo.aria !== toolAria) {
throw new Error(`C6: chip aria-label ${chipInfo.aria} (expected ${toolAria})`);
}
if (chipInfo.chevron !== "Show tool calls") {
throw new Error(`C6: collapsed chip chevron: ${chipInfo.chevron}`);
}
console.log(` tool chip "${toolLabel}" (aria "${chipInfo.aria}", ${toolCount} live row(s))`);
await shot("53-chat-tool-chip.png");
// Open the panel by dispatching the chip's own click (not a synthetic scroll),
// then assert the header, the close control and the C14 invariant: opening the
// panel must not move the transcript behind it.
const scrollBeforePanel = await page.evaluate(
`Math.round(document.querySelector("#chatTranscript").scrollTop)`,
);
const openedPanel = await page.evaluate(`(() => {
const chip = document.querySelector("#chatTranscript .chat-tool-chip");
chip.click();
const panel = document.querySelector(".chat-tool-panel");
return {
hidden: panel?.hidden ?? true,
head: panel?.querySelector(".chat-tool-panel-count")?.textContent ?? "",
close: panel?.querySelector(".chat-tool-close")?.getAttribute("aria-label") ?? "",
chevron: chip.querySelector(".chat-tool-chevron")?.getAttribute("aria-label") ?? "",
rows: panel?.querySelectorAll(".chat-tool-row").length ?? 0,
};
})()`);
if (openedPanel.hidden) throw new Error("C6: the tool panel did not open");
if (openedPanel.head !== toolLabel) throw new Error(`C6: panel header ${openedPanel.head}`);
if (openedPanel.close !== "Close tool calls") {
throw new Error(`C6: panel close control ${openedPanel.close}`);
}
if (openedPanel.chevron !== "Hide tool calls") {
throw new Error(`C6: open chip chevron ${openedPanel.chevron}`);
}
if (openedPanel.rows !== toolCount) {
throw new Error(`C6: the panel lists ${openedPanel.rows} rows, the chip counts ${toolCount}`);
}
const scrollAfterOpen = await page.evaluate(
`Math.round(document.querySelector("#chatTranscript").scrollTop)`,
);
if (Math.abs(scrollAfterOpen - scrollBeforePanel) > 2) {
throw new Error(`C6: opening the tool panel moved the transcript (${scrollBeforePanel} -> ${scrollAfterOpen})`);
}
console.log(
` tool panel open: header "${openedPanel.head}", close "Close tool calls", ${openedPanel.rows} row(s)`,
);
// Expand the first row in place and assert its chevron name, its INPUT and its
// OUTPUT (the live first call is a settled `read` carrying both).
const firstToolRow = await page.evaluate(`(() => {
const panel = document.querySelector(".chat-tool-panel");
const list = panel.querySelector(".chat-tool-list");
list.scrollTop = 0;
const first = () => panel.querySelector(".chat-tool-row-head");
const name = first().querySelector(".chat-tool-name")?.textContent ?? "";
const chevronBefore = first().querySelector(".chat-tool-row-chevron")?.getAttribute("aria-label") ?? "";
first().click();
const head = first();
const row = head.closest(".chat-tool-row");
return {
name,
chevronBefore,
chevronAfter: head.querySelector(".chat-tool-row-chevron")?.getAttribute("aria-label") ?? "",
sections: [...row.querySelectorAll(".chat-tool-section-label")].map((n) => n.textContent),
bodies: [...row.querySelectorAll(".chat-tool-section-body")].map((n) => n.textContent),
};
})()`);
if (firstToolRow.chevronBefore !== `Expand ${firstToolRow.name}`) {
throw new Error(`C6: collapsed row chevron ${firstToolRow.chevronBefore} for ${firstToolRow.name}`);
}
if (firstToolRow.chevronAfter !== `Collapse ${firstToolRow.name}`) {
throw new Error(`C6: expanded row chevron ${firstToolRow.chevronAfter} for ${firstToolRow.name}`);
}
if (!firstToolRow.sections.includes("INPUT") || !firstToolRow.sections.includes("OUTPUT")) {
throw new Error(`C6: first row sections ${JSON.stringify(firstToolRow.sections)}`);
}
if (firstToolRow.bodies.some((body) => body.trim() === "")) {
throw new Error(`C6: a first-row section rendered blank: ${JSON.stringify(firstToolRow.bodies)}`);
}
console.log(
` first row "${firstToolRow.name}": ${firstToolRow.sections.join(" + ")} (chevron "${firstToolRow.chevronAfter}")`,
);
await shot("54-chat-tool-panel.png");
// Closing it must put the transcript back exactly where it was.
const closedPanel = await page.evaluate(`(() => {
document.querySelector(".chat-tool-close").click();
const panel = document.querySelector(".chat-tool-panel");
const chip = document.querySelector("#chatTranscript .chat-tool-chip");
return {
hidden: panel.hidden,
chevron: chip.querySelector(".chat-tool-chevron").getAttribute("aria-label"),
top: Math.round(document.querySelector("#chatTranscript").scrollTop),
};
})()`);
if (!closedPanel.hidden || closedPanel.chevron !== "Show tool calls") {
throw new Error(`C6: closing the tool panel: ${JSON.stringify(closedPanel)}`);
}
if (Math.abs(closedPanel.top - scrollBeforePanel) > 2) {
throw new Error(`C6: opening/closing the tool panel moved the transcript (${scrollBeforePanel} -> ${closedPanel.top})`);
}
console.log(
` the tool panel left the transcript where it was across open/close (top ${scrollBeforePanel} -> ${closedPanel.top})`,
);
// The live history carries no failed call and no edit-family call, so render
// both through the page's own row builder (the 47b precedent): a failed row
// marked "Failed tool call" with an ERROR section, and an edit row with the LCS
// diff and its true "+N -M" stat. The sample is removed straight after.
const sampleRows = await page.evaluate(`(async () => {
const app = await import("/src/app.js");
const host = document.createElement("div");
host.id = "chatToolSample";
host.className = "chat-tool-sample";
const note = document.createElement("div");
note.className = "chat-tool-sample-note";
note.textContent =
"Page-rendered sample — the live history carries no failed or edit call " +
"(the chip, panel and rows above are live)";
host.append(note);
const failedPart = {
type: "tool", id: "sample-failed", name: "shell",
state: { status: "error", input: { command: "false" }, error: { message: "exit status 1" } },
};
const failedRow = app.renderToolCallRow(failedPart, { expanded: true });
host.append(failedRow);
const editPart = {
type: "tool", id: "sample-edit", name: "edit",
state: {
status: "completed",
input: { filePath: "web/src/chat.js", oldString: "const a = 1;\\nconst b = 2;", newString: "const a = 1;\\nconst b = 3;\\nconst c = 4;" },
content: [{ type: "text", text: "applied" }],
},
time: { created: 1, ran: 2, completed: 103 },
};
const editRow = app.renderToolCallRow(editPart, { expanded: true });
host.append(editRow);
document.body.append(host);
return {
failedAria: failedRow.querySelector('.chat-tool-icon[aria-label="Failed tool call"]') ? "Failed tool call" : "",
failedSections: [...failedRow.querySelectorAll(".chat-tool-section-label")].map((n) => n.textContent),
editStat: editRow.querySelector(".chat-tool-stat")?.textContent ?? "",
diffLines: [...editRow.querySelectorAll(".chat-tool-diff-line")].map((n) => ({ cls: n.className, text: n.textContent })),
};
})()`);
if (!sampleRows) throw new Error("C6: could not render the page-rendered tool-row samples");
if (sampleRows.failedAria !== "Failed tool call") {
throw new Error(`C6: the failed row is not marked 'Failed tool call': ${JSON.stringify(sampleRows)}`);
}
if (!sampleRows.failedSections.includes("INPUT") || !sampleRows.failedSections.includes("ERROR")) {
throw new Error(`C6: failed row sections ${JSON.stringify(sampleRows.failedSections)}`);
}
if (sampleRows.editStat !== "+2 -1") {
throw new Error(`C6: edit diff stat ${sampleRows.editStat}`);
}
if (
!sampleRows.diffLines.some((line) => line.cls.includes("diff-remove") && line.text === "- const b = 2;") ||
!sampleRows.diffLines.some((line) => line.cls.includes("diff-add") && line.text === "+ const b = 3;")
) {
throw new Error(`C6: the edit diff lines: ${JSON.stringify(sampleRows.diffLines)}`);
}
console.log(
` page-rendered samples: failed row "Failed tool call" (${sampleRows.failedSections.join(" + ")}), ` +
`edit row stat ${sampleRows.editStat} with ${sampleRows.diffLines.length} diff line(s)`,
);
await shot("55-chat-edit-diff-sample.png");
await page.evaluate(`document.querySelector("#chatToolSample")?.remove()`);
if (transcript.hasLoadOlder) {
// The control was present in capture 45. Press it and capture the honest
// result: the live session's own cursor returns an empty older page, so the