web: one chat activity line, clearer groups and paste attachments

Replace the reasoning, tool and bottom thinking rows with one stable activity
line and refresh Stop on the step frame. Make directory and Closed bands share
an elevated square surface, centred text and a collapse toggle. Read pasted
files into the composer attachment path and show sent files in user bubbles.
This commit is contained in:
2026-10-20 14:30:57 +01:00
parent f5ccec8e1f
commit 3799d37d7c
11 changed files with 583 additions and 306 deletions
+37
View File
@@ -136,6 +136,7 @@ import {
queuedAfterFrame,
readChatSeen,
reasoningLabel,
relativeSessionTime,
renameChatOverride,
restoreChatOverride,
resumedThread,
@@ -510,6 +511,18 @@ test("sessionActivity and its badge word follow streaming, unseen then open", ()
assert.equal(sessionActivityBadge("idle", false), "Idle");
});
test("relativeSessionTime names the latest chat update, not a meaningless idle state", () => {
const now = Date.UTC(2026, 9, 20, 12, 0, 0);
assert.equal(relativeSessionTime(0, now), "");
assert.equal(relativeSessionTime(now - 20_000, now), "just now");
assert.equal(relativeSessionTime(now - 50_000, now), "1 min ago");
assert.equal(relativeSessionTime(now - 2 * 60_000, now), "2 min ago");
assert.equal(relativeSessionTime(now - 3 * 60 * 60_000, now), "3 hr ago");
assert.equal(relativeSessionTime(now - 26 * 60 * 60_000, now), "1 day ago");
assert.equal(relativeSessionTime(now - 3 * 24 * 60 * 60_000, now), "3 days ago");
assert.equal(relativeSessionTime(Date.UTC(2026, 8, 12, 9, 0, 0), now), "12 Sept");
});
test("sessionStatusLabel reads Closed first, then Running or Idle", () => {
assert.equal(sessionStatusLabel(true, true), "Closed");
assert.equal(sessionStatusLabel(true, false), "Running");
@@ -1109,6 +1122,30 @@ test("a text delta appends to the part the first frame started", () => {
assert.equal(thread.lastDeltaAt, 1001);
});
test("a remote user turn carries its file attachments into the message", () => {
let thread = newChatThread("s1");
thread = applyChatEvent(
thread,
evt("user", {
message_id: "u1",
operation_id: "op1",
client: "Phone",
part: { type: "text", text: "See attached" },
attachments: [{ type: "file", name: "note.txt", mime: "text/plain", uri: "file:///tmp/note.txt" }],
}),
1000,
);
const message = thread.messages[0];
assert.equal(message.role, "user");
assert.equal(message.parts[0].text, "See attached");
assert.deepEqual(message.parts[1], {
type: "file",
name: "note.txt",
mime: "text/plain",
uri: "file:///tmp/note.txt",
});
});
test("a text delta and a reasoning delta sharing a bare id land in separate parts", () => {
let thread = newChatThread("s1");
thread = applyChatEvent(thread, evt("text", { message_id: "a1", part: { id: "x" }, delta: "answer" }), 1000);
+44 -47
View File
@@ -1404,7 +1404,9 @@ async function runDecisionChecks() {
/** Expand the CLOSED chats group so a just-closed row is in the DOM to inspect. */
async function expandClosedChats() {
await page.evaluate(`(() => {
const toggle = document.querySelector(".chat-group-toggle");
const toggle = [...document.querySelectorAll(".chat-group-toggle")].find((node) =>
node.textContent.trim().toLowerCase().startsWith("closed"),
);
if (toggle && toggle.getAttribute("aria-expanded") !== "true") toggle.click();
return !!toggle;
})()`);
@@ -4616,9 +4618,9 @@ try {
chatList.rows.find((row) => !row.closed && row.menu);
if (operatorRow) {
if (!operatorRow.title) throw new Error("the operator chat row has no title");
// The row leads with the title and its status word; directory and model are
// the two lines below, with no operator chip.
if (!["Idle", "Open", "Streaming", "New", "Closed"].includes(operatorRow.status)) {
// The row leads with the title; a live/unseen/closed row may carry a status
// badge, while an ordinary idle row shows only its recency and directory.
if (!["", "Streaming", "New", "Closed"].includes(operatorRow.status)) {
throw new Error(`chat row status: ${JSON.stringify(operatorRow)}`);
}
// M6 names the control for its row: `Chat actions for {title}`, with the
@@ -6173,19 +6175,19 @@ try {
return true;
})()`);
const agentCount = () => page.evaluate(`document.querySelectorAll("#chatTranscript .chat-turn-agent").length`);
const indicator = () =>
const activity = () =>
page.evaluate(`(() => {
const el = document.querySelector("#chatRunning");
const el = [...document.querySelectorAll("#chatTranscript .chat-activity")].at(-1);
if (!el) return null;
return {
spinner: !!el.querySelector(".spinner"),
label: el.querySelector(".chat-running-label")?.textContent ?? "",
elapsed: el.querySelector(".chat-running-elapsed")?.textContent ?? "",
tools: [...el.querySelectorAll(".chat-running-tool")].map((line) => ({
text: line.querySelector(".chat-running-tool-text")?.textContent ?? "",
long: line.querySelector(".chat-tool-long")?.textContent ?? "",
longTinted: line.classList.contains("chat-running-tool-long"),
})),
spinner: !!el.querySelector(".chat-activity-spinner"),
label: el.querySelector(".chat-reasoning-label")?.textContent ?? "",
phase: el.querySelector(".chat-activity-phase")?.textContent ?? "",
elapsed: el.querySelector(".chat-activity-elapsed")?.textContent ?? "",
chip: el.querySelector(".chat-tool-chip")?.textContent ?? "",
current: el.querySelector(".chat-tool-current")?.textContent ?? "",
long: el.querySelector(".chat-tool-long")?.textContent ?? "",
indicator: !!document.querySelector("#chatTranscript .chat-activity"),
};
})()`);
@@ -6241,23 +6243,17 @@ try {
"the running tool",
);
await new Promise((resolve) => setTimeout(resolve, 1300));
const runningChip = await page.evaluate(`(() => {
const chip = document.querySelector("#chatTranscript .chat-tool-chip");
return {
current: chip?.querySelector(".chat-tool-current")?.textContent ?? "",
spinner: !!chip?.querySelector(".chat-tool-spinner"),
indicator: !!document.querySelector("#chatRunning"),
};
})()`);
const runningChip = await activity();
if (
!runningChip ||
!runningChip.spinner ||
!runningChip.current.includes("shell") ||
!runningChip.current.includes("npm run build") ||
runningChip.indicator
) {
throw new Error(`C5: the current-tool chip is wrong: ${JSON.stringify(runningChip)}`);
throw new Error(`C5: the activity line is wrong: ${JSON.stringify(runningChip)}`);
}
console.log(` current tool on the count line: "${runningChip.current}" (no second indicator)`);
console.log(` one activity line: "${runningChip.label || runningChip.phase}" · "${runningChip.current}" ${runningChip.elapsed}`);
await shot("57-chat-running.png");
// 3. A second running tool that started 61 s ago (protocol `time.ran`): the
@@ -6279,14 +6275,8 @@ try {
],
"the long-running tool",
);
const longCall = await page.evaluate(`(() => {
const chip = document.querySelector("#chatTranscript .chat-tool-chip");
return {
current: chip?.querySelector(".chat-tool-current")?.textContent ?? "",
long: chip?.querySelector(".chat-tool-long")?.textContent ?? "",
};
})()`);
if (!longCall.current.includes("npm run long") || !longCall.long.includes("long")) {
const longCall = await activity();
if (!longCall?.current.includes("npm run long") || !longCall.long.includes("long")) {
throw new Error(`C5: the long-running tool is not on the count line: ${JSON.stringify(longCall)}`);
}
const agentsWithTwoIds = await agentCount();
@@ -6296,8 +6286,8 @@ try {
}
await shot("58-chat-long-call.png");
// 4. Finish the tools and end the step: the indicator disappears and the same
// single agent bubble stands, settled.
// 4. Finish the tools and end the step: the one activity line settles in place
// (no spinner) and the same single agent bubble stands.
await applyFrames(
[
sessionFrame({ message_id: "cap-live-1", kind: "tool", part: { type: "tool", id: "cap-tool-1", state: { status: "completed", content: [{ type: "text", text: "build ok" }] } } }),
@@ -6311,7 +6301,9 @@ try {
const bubbles = [...transcript.querySelectorAll(".chat-turn-agent")];
const answer = bubbles.find((b) => b.textContent.includes("The live turn is growing."));
return {
indicator: !!document.querySelector("#chatRunning"),
indicator: !!document.querySelector("#chatTranscript .chat-activity"),
activity: !!document.querySelector("#chatTranscript .chat-activity"),
spinner: !!document.querySelector("#chatTranscript .chat-activity-spinner"),
agents: bubbles.length,
answers: bubbles.filter((b) => b.textContent.includes("The live turn is growing.")).length,
// The one bubble that carries the live answer must also carry the replayed
@@ -6319,12 +6311,15 @@ try {
settledOneBubble: !!answer && answer.textContent.includes("Planning the live capture."),
};
})()`);
if (settled.indicator) throw new Error("C5: the running indicator survived the ended step");
if (settled.indicator) throw new Error("C5: a second running indicator survived the ended step");
if (!settled.activity || settled.spinner) {
throw new Error(`C5: the one activity line did not settle in place: ${JSON.stringify(settled)}`);
}
if (settled.agents - agentBefore > 1 || settled.answers !== 1 || !settled.settledOneBubble) {
throw new Error(`C5: the settled turn is not the same single agent bubble: ${JSON.stringify(settled)}`);
}
console.log(
` after the tools completed and the step ended: no indicator, still ${settled.agents} agent bubble ` +
` after the tools completed and the step ended: one settled activity line, still ${settled.agents} agent bubble ` +
`carrying the live answer (unchanged from ${agentBefore})`,
);
await shot("59-chat-settled.png");
@@ -6373,17 +6368,17 @@ try {
return true;
})()`);
// A synthetic in-flight turn, so the running indicator would be showing before
// A synthetic in-flight turn, so the activity row would be showing before
// the approval arrives — and must stand down while the request is pending.
await applyFrames(
[sessionFrame({ message_id: "cap-approval-turn", kind: "step", step: { status: "started" } })],
"the synthetic in-flight turn",
);
await eventually(() => page.evaluate(`!!document.querySelector("#chatRunning")`), {
await eventually(() => page.evaluate(`!!document.querySelector("#chatTranscript .chat-activity")`), {
timeout: 8000,
what: "the running indicator before the approval",
what: "the activity row before the approval",
});
const runningBeforeApproval = await page.evaluate(`!!document.querySelector("#chatRunning")`);
const runningBeforeApproval = await page.evaluate(`!!document.querySelector("#chatTranscript .chat-activity")`);
const readApproval = () =>
page.evaluate(`(() => {
@@ -6478,7 +6473,7 @@ try {
})(),
controls: [...(card?.querySelectorAll(".chat-approval-control") ?? [])].map((b) => b.textContent),
topControl: top?.textContent ?? "",
running: !!document.querySelector("#chatRunning"),
running: !!document.querySelector("#chatTranscript .chat-activity"),
};
})()`);
@@ -6567,13 +6562,13 @@ try {
throw new Error(`C10: top-bar control: ${JSON.stringify(pending.topControl)}`);
}
if (runningBeforeApproval && pending.running) {
throw new Error("C10: the running indicator did not stand down while the approval is pending");
throw new Error("C10: the activity row did not stand down while the approval is pending");
}
console.log(
` pending card: "${pending.headline}" / "${pending.status}", ${pending.resources.length} resource lines ` +
`(rendered ${pending.resourceLines} of ${pending.resourceFullLines} unclamped), risk "${pending.riskLabel}", ` +
`controls ${JSON.stringify(pending.controls)} (Allow once filled: ${pending.primaryFilled}), ` +
`top-bar "${pending.topControl}", #chatRunning ${pending.running ? "present" : "absent"}`,
`top-bar "${pending.topControl}", one activity row ${pending.running ? "present" : "absent"}`,
);
await shot("65-chat-approval-pending.png");
@@ -7957,9 +7952,11 @@ try {
{ timeout: 8000, what: "the renamed row to show its local title" },
);
console.log(` row ${throwawayId} shows the local title "${renamedTitle}"`);
// Refresh the list from the server (the same header Refresh the page offers);
// the local title must still win over the server's own.
await page.clickText(".pane-head button.ghost", "Refresh");
// Re-enter the destination to reload the list from the server (the list has no
// manual Refresh control); the local title must still win over the server's own.
await clickDestination("Pipelines");
await clickDestination("Chat");
await page.waitForSelector("#chatRows .chat-row", { timeout: 15000 });
await eventually(
() =>
page.evaluate(