web: chat composer review fixes — real Stop, /close leaves the pane

Address the review of C8/C9: the composer's Stop control now routes to
`chat_interrupt` (`onStop`) instead of the inert submit path, and the smoke
clicks it and asserts the page's own "Stopping the running turn…" notice with
no `Action failed` dialog (captures/63b). Accepting `/close` finishes the
session locally — the running/queued bits clear and the conversation leaves
the pane for the list, mirroring Android's `finishSession` — and the smoke
asserts the select hint returns. A command notice draws the one terminal
glyph (`CHAT_COMMAND_GLYPH`, `>_`) for both states, tinted only; the growing
textarea accounts for its padding and border so six rows are six whole lines;
remove a shadowed duplicate `chatSessionById`. Wording unchanged; every pure
helper and the wire shapes remain unit-tested.

The smoke creates a throwaway session via `/new`, really prompts, really
interrupts and closes it; the operator's session is never prompted.
This commit is contained in:
2026-10-19 07:26:25 +01:00
parent f660078173
commit d9f5ba6f75
6 changed files with 110 additions and 31 deletions
+7
View File
@@ -6,6 +6,7 @@ import assert from "node:assert/strict";
import {
CHAT_COMMANDS,
CHAT_COMMAND_GLYPH,
CHAT_FOLLOW_THRESHOLD_PX,
CHAT_QUEUED_NOTICE,
COMPOSER_SEND,
@@ -767,6 +768,12 @@ test("CHAT_QUEUED_NOTICE is the app's own queued sentence", () => {
assert.equal(CHAT_QUEUED_NOTICE, "Queued — it will send when the current turn finishes.");
});
test("a command notice carries one terminal glyph for both states", () => {
// Android draws Icons.Default.Terminal for a Command and a Command failed
// notice and only changes the tint, so the two share this glyph.
assert.equal(CHAT_COMMAND_GLYPH, ">_");
});
// ---------------------------------------------------------------------------
// Slash commands (C9)
// ---------------------------------------------------------------------------
+37 -1
View File
@@ -2942,6 +2942,27 @@ try {
await showComposer();
await shot("63-chat-composer-stop.png");
// The Stop control must really interrupt (chat_interrupt), not fall through the
// inert submit path: click it and observe the page's own interrupting notice,
// with no Action failed dialog. The throwaway turn is the only one stopped.
await page.click("#chatStop");
const stopNotice = await eventually(
async () => {
const notices = await page.evaluate(
`[...document.querySelectorAll(".chat-command-notice:not(.chat-command-notice-failed) .chat-command-notice-text")].map((node) => node.textContent)`,
);
return notices.includes("Stopping the running turn…") ? "Stopping the running turn…" : false;
},
{ timeout: 15000, what: "the interrupt notice after clicking Stop" },
);
const stopFailed = await page.evaluate(
`document.querySelector(".action-failed .action-failed-message")?.textContent ?? ""`,
);
if (stopFailed !== "") throw new Error(`clicking Stop failed: ${stopFailed}`);
console.log(` clicking Stop sent chat_interrupt: "${stopNotice}"`);
await showComposer();
await shot("63b-chat-stop-interrupt.png");
// Cleanup: `/close` the throwaway through the C3 confirm. It is the only session
// this stage mutates and it is closed again (any in-flight turn is stopped).
await page.fill("#chatInput", "/close");
@@ -2976,7 +2997,22 @@ try {
hasReopen: !!row?.querySelector(".chat-reopen"),
};
})()`);
console.log(` /close closed the throwaway session ${throwawayId} (${JSON.stringify(closedRow)})`);
// Closing finishes the session: the conversation leaves the pane (back to the
// list with the select hint) and no row stays selected, as Android's
// finishSession does.
const afterThrowawayClose = await page.evaluate(`(() => ({
selected: !!document.querySelector(".chat-row.selected"),
hint: document.querySelector(".chat-detail .empty .muted")?.textContent ?? "",
composer: !!document.querySelector("#chatComposer"),
}))()`);
if (
afterThrowawayClose.selected ||
afterThrowawayClose.composer ||
afterThrowawayClose.hint !== "Select a chat to open it."
) {
throw new Error(`/close did not leave the conversation: ${JSON.stringify(afterThrowawayClose)}`);
}
console.log(` /close closed the throwaway session ${throwawayId} (${JSON.stringify(closedRow)}) and left the pane`);
await shot("64-chat-throwaway-closed.png");
throwawaySessionId = null;