diff --git a/web/PARITY.md b/web/PARITY.md
index 67d64de9..173385b7 100644
--- a/web/PARITY.md
+++ b/web/PARITY.md
@@ -99,7 +99,7 @@ the pipeline list already carries — rather than a pluralised verb.
| C9 | Slash commands | client-side | done — the palette appears above the composer only while the trimmed draft starts with `/` and has no whitespace, filtered case-insensitively by name prefix, each row showing `/name` and the summary and the highlighted row marked `aria-selected`; Up/Down move the highlight and Enter runs it, a tap runs a row directly, and running a command always consumes the draft and never reaches the prompt path. The five commands and their summaries are `CHAT_COMMANDS` (`/new`, `/close`, `/rename
`, `/stop`, `/help`), unit-tested verbatim, with `chatCommandHelp()` the `usage — summary` lines. Effects: `/new` sends `chat_create` directly (C2's item) and opens the created session, `/close` reuses the C3 `Close chat?` confirm, `/rename` is the local rename pending C13, `/stop` interrupts (`chat_interrupt`) and `/help` shows the command list. Error wording is the Android source verbatim: the unknown command reads `“{token}” is not a command, so nothing was sent to the agent. Send it as a message, or cancel.` with the draft offered back and `Send as message` / `Cancel`; an extra argument on an argument-less command reads `{usage} does not take an argument.`; `/rename` with no title reads `Usage: /rename — renames this session on this device.`; `/stop` with nothing running reads `No turn is running in this chat.`. A notice renders as a full-width line after the turns (not a bubble) with the label `Command` / `Command failed` and a terminal glyph, error-coloured when failed. Captured 2026-10-19: `captures/57-chat-command-palette.png`, `captures/58-chat-command-palette-selected.png` (ArrowDown moved the highlight), `captures/59-chat-command-unknown.png` (the failed notice and its offer, dismissed with Cancel), `captures/62-chat-new-session.png` (`/new`'s created session and its `Command` notice) |
| C10 | Permission/approval cards (allow once/always/reject) | `chat_permission`, `chat_reply` | done — captured 2026-10-19: `captures/65-chat-approval-pending.png` (the pending card as the transcript's last item: the amber outlined shield + `Approve bash`, `Waiting for your response`, the request's six monospace resource lines, the amber `RISK REVIEW` panel, the `Allow once` / `Always allow` / `Reject` controls, and the top bar's `Waiting for your approval` control, with `#chatRunning` stood down), `captures/66-chat-approval-answered.png` (`Allowed once` / `Waiting for the agent to continue…`, controls and top-bar control gone), `captures/67-chat-approval-resolved.png` (a server resolution: `Always allowed` with its note `Another client already allowed this.`, no controls, no risk panel) and `captures/68-chat-approval-rejected.png` (a blank-action request answered `Reject`: `Rejected` / `Waiting for the agent to continue…`, the risk panel kept with the fallback sentence, no controls). The pure model is `src/chat.js` (`approvalCard`/`applyChatPermission`/`permissionRiskText`/`decisionLabel`): while pending `Approve {action}` (blank action → `Approve tool call`), after answering the decision label (`Allowed once` / `Always allowed` / `Rejected`, an unknown decision → `Resolved`) and `Waiting for the agent to continue…`, and once the server reports `resolved`/a decision that label (else `Already resolved`) with its `message` as the status (else `Another client already answered this request.`); the amber `RISK REVIEW` box shows only while pending or after a reject. Resources drop blanks and cap at six visible lines: `approvalResourceText` caps the joined text at six lines with an ellipsis on the last kept line, and the rendered text is a padding-free `-webkit-line-clamp: 6` block inside a padded frame, so a long resource that wraps is elided at the content edge and no seventh line paints into the frame's padding — matching Android's `maxLines = 6, Ellipsis` (the smoke asserts six clipped lines, a hidden overflow and the block ending at the frame's content edge, with seven lines unclamped). `Allow once` is rendered as the browser's filled primary control, matching the app's filled `Button` versus its two `TextButton`s; the head and risk-panel shields are inline SVG stroked with `currentColor` so the warn hue actually tints them (a colour emoji cannot be tinted). A server resolution always outranks a local answer, a new request replaces the settled card and clears the answer, and the same request keeps it. `PipelinesRepository.chatReply` sends exactly `{type:'chat_reply',chat_reply:{session_id,request_id,decision,client}}` (`message` only when non-blank) and refuses blank ids or a decision outside once/always/reject; answering settles the card optimistically, and a refused send reopens the same request and reports the server's reason on the thread's error line (ignored if a different request has replaced the card), so an unaccepted decision is never shown as accepted. The card is fed by `chat_permission` frames through `client.js`'s unsolicited-frame path, folded only for sessions this client has open. **Replayed, not real**: no live pending approval was available, so the captures were driven by synthetic `chat_permission` frames replayed through the page's own socket handler against the live session; the page's real `chat_reply` path was exercised but the smoke's shim suppressed every reply for the synthetic request ids (suppressed 3, one of them answered with a server error to prove the reopen path, forwarded 0), so **no approval decision was sent to the operator's server**. Unit-tested in `test/chat.test.mjs` and the reply shape in `test/repository.test.mjs`; the DOM assertions and log lines are produced by `test/ui-smoke.mjs` |
| C11 | Background tasks bar: running shells only, capped + scrollable, bounded output page | `chat_shells`, `chat_shell_output` | todo |
-| C12 | Human-decision notices inside chat + dismiss | `chat_event` | todo |
+| C12 | Human-decision notices inside chat + dismiss | `chat_event` | done — the local command-notice surface is captured and dismissible per notice. Captured 2026-10-19: `captures/72-chat-command-notice.png` (a full-width `Command` line after the turns, never a message bubble: the shared terminal glyph `>_`, the `/help` command list and its own `Dismiss`), `captures/73-chat-command-failed-offer.png` (an unknown command: `Command failed` in the error tint, the exact Android sentence and the `Send as message` / `Cancel` pair) and `captures/74-chat-command-dismissed.png` (the `/help` notice dismissed; the failed offer line and its controls remain — exactly one notice removed). A notice is a local `ChatCommandNotice`, never a `ChatMessage`: it lives in that conversation's `state.chatThreads` entry, survives switching away and back while the page is open, and never enters the prompt path — the smoke's recorded sends show **no** `chat_prompt` for `/help` or an unknown command. `Send as message` takes the offered draft through the ordinary `postChatPrompt` path, removing the notice **before** sending, so a stale second tap sends nothing (the smoke verifies both on a throwaway session). The pure model lives in `src/chat.js` (`makeChatNotice`, `appendChatNotice`, `dismissChatNotice`, `takeChatNoticeOffer`, `chatNoticeLabel`) and is unit-tested (`test/chat.test.mjs`): append, dismiss one, take the offer, a stale/offerless offer returning null and leaving the list untouched, per-conversation scoping, and the failed label/tint flag. **Wire finding, not an invented source**: `chat_event` kinds are exactly `user`, `text`, `reasoning`, `tool`, `shell`, `step` and `usage` (`internal/protocol/chat.go` `ChatEvent*`), and `chat_permission` is the only approval frame — there is **no** in-chat run-decision notice on the wire. Run-level human decisions live on R11's run-detail decision sheet (`decide_run`) and C10's approval cards (`chat_permission` / `chat_reply`), exactly as the app does it. **Stated browser divergence**: Android's `ChatCommandNoticeItem` shows actions only when `offer != null`, so it cannot dismiss a `/help` or `/new` line; the browser adds a `Dismiss` control (accessible name `Dismiss command notice`) on offerless notices to meet "each is individually dismissible", keeping the app's `Send as message` / `Cancel` pair verbatim on offer notices. |
| C13 | Local rename/hide, seen state, persistence to `localStorage` | client-side | todo |
| C14 | Scroll behaviour: follow newest, "jump to newest", restored position | client-side | done — captured 2026-10-19: `captures/45-chat-transcript-newest.png` (the conversation opens at its newest content instantly — the only live session has no saved position, so it lands at the end rather than at the top of a turn taller than the viewport) and `captures/46-chat-transcript-top.png` (after a **real wheel gesture** on the transcript — the app's own listener, not a programmatic scroll, which by the implementation's own rule cannot change intent — `Jump to latest` is offered; the smoke asserts the control and performs the gesture, `ui-smoke` log line "after a real wheel gesture (scrollTop 0) 'Jump to latest' is offered at the top"). A thread with a saved position is restored to it (a saved top, index 0, is a real position and is never treated as "new"); while within the 32 px bottom threshold the view follows, and only the operator's own wheel/drag changes that intent (a programmatic placement or follow cannot); `Jump to latest` is offered only when not following and something is below the fold; the position is saved per session in `localStorage` (`pipelines.web.chatScroll.v1`). A re-render (opening/dismissing a dialog, a refresh, or the loading frame of a paging fetch) captures the live position first and puts the operator back exactly where they were — the smoke asserts the transcript stays put across the `Close chat?` dialog (`ui-smoke` log line "the transcript stayed put across the dialog (top 7141 -> 7141)"); the paging anchor is held until the frame that actually carries the older page, so a real prepend stays on the previously visible message. No auto-load on scroll. The pure decisions are unit-tested (`chatBottomDistancePx`, `chatFollowsAt`, `chatShowJumpToLatest`, `chatOpensAtNewest`, `chatFirstScroll`) in `test/chat.test.mjs`, and the live measurement uses `chatBottomDistancePx` itself |
diff --git a/web/src/app.js b/web/src/app.js
index 29d088f6..96682034 100644
--- a/web/src/app.js
+++ b/web/src/app.js
@@ -229,6 +229,7 @@ import {
import {
BACKGROUND_TASKS_TITLE,
CHAT_ATTACH_LABEL,
+ CHAT_COMMAND_DISMISS_LABEL,
CHAT_COMMAND_GLYPH,
CHAT_COMPOSER_PLACEHOLDER,
CHAT_EMPTY,
@@ -272,6 +273,7 @@ import {
SHELL_ROW_LABEL,
applyChatEvent,
applyChatPermission,
+ appendChatNotice,
approvalCard,
attachmentDisplayName,
attachmentError,
@@ -285,6 +287,7 @@ import {
chatFollowsAt,
chatHeaderMeta,
chatNoMatchMessage,
+ chatNoticeLabel,
chatOpensAtNewest,
chatShowJumpToLatest,
chatStreamState,
@@ -294,9 +297,11 @@ import {
composerSendEnabled,
composerSubmit,
directoryLabel,
+ dismissChatNotice as dismissChatNoticeModel,
filterSessions,
groupSessionsByDirectory,
historyResync,
+ makeChatNotice,
mergeHistoryPage,
mergeShellFrame,
newChatThread,
@@ -318,6 +323,7 @@ import {
shellCommandSummary,
shellOutputState,
shellsLoaded,
+ takeChatNoticeOffer as takeChatNoticeOfferModel,
formatToolDuration,
threadElapsedMillis,
threadPhase,
@@ -4408,15 +4414,15 @@ function addChatNotice(sessionId, text, { failed = false, offer = null } = {}) {
const thread = state.chatThreads.get(sessionId);
if (!thread) return;
chatNoticeSeq += 1;
- const notice = { id: `notice-${chatNoticeSeq}`, text, failed, offer };
- setThread(sessionId, { notices: [...(thread.notices ?? []), notice] });
+ const notice = makeChatNotice(`notice-${chatNoticeSeq}`, text, { failed, offer });
+ setThread(sessionId, { notices: appendChatNotice(thread.notices, notice) });
}
-/** Remove one local command line (the operator cancelled its offer). */
+/** Remove one local command line (the operator cancelled or dismissed it). */
function dismissChatNotice(sessionId, noticeId) {
const thread = state.chatThreads.get(sessionId);
if (!thread) return;
- setThread(sessionId, { notices: (thread.notices ?? []).filter((n) => n.id !== noticeId) });
+ setThread(sessionId, { notices: dismissChatNoticeModel(thread.notices, noticeId) });
renderContent();
}
@@ -4426,10 +4432,11 @@ function dismissChatNotice(sessionId, noticeId) {
*/
function takeChatNoticeOffer(sessionId, noticeId) {
const thread = state.chatThreads.get(sessionId);
- const notice = (thread?.notices ?? []).find((n) => n.id === noticeId);
- if (!notice || notice.offer == null) return null;
- setThread(sessionId, { notices: (thread.notices ?? []).filter((n) => n.id !== noticeId) });
- return notice.offer;
+ if (!thread) return null;
+ const taken = takeChatNoticeOfferModel(thread.notices, noticeId);
+ if (taken.offer == null) return null;
+ setThread(sessionId, { notices: taken.notices });
+ return taken.offer;
}
/**
@@ -5770,6 +5777,7 @@ function renderChatCommandNotice(sessionId, notice) {
const row = h("div", {
class: `chat-command-notice${failed ? " chat-command-notice-failed" : ""}`,
role: "note",
+ "data-notice-id": notice?.id ?? "",
});
const head = h("div", { class: "chat-command-notice-head" });
head.append(
@@ -5782,7 +5790,7 @@ function renderChatCommandNotice(sessionId, notice) {
}),
);
head.append(
- h("span", { class: "chat-command-notice-label", text: failed ? "Command failed" : "Command" }),
+ h("span", { class: "chat-command-notice-label", text: chatNoticeLabel(failed) }),
);
row.append(head);
row.append(h("div", { class: "chat-command-notice-text", text: notice?.text ?? "" }));
@@ -5805,6 +5813,22 @@ function renderChatCommandNotice(sessionId, notice) {
}),
);
row.append(actions);
+ } else {
+ // Android only offers the Send/Cancel pair on an offer-bearing notice, so a
+ // `/help` or `/new` line cannot be dismissed there. The browser item requires
+ // each notice to be individually dismissible; the wording and the offer pair
+ // still match the app verbatim, and this extra control is stated in PARITY.
+ const actions = h("div", { class: "chat-command-notice-actions" });
+ actions.append(
+ h("button", {
+ class: "ghost chat-command-dismiss",
+ type: "button",
+ text: "Dismiss",
+ "aria-label": CHAT_COMMAND_DISMISS_LABEL,
+ onclick: () => dismissChatNotice(sessionId, notice.id),
+ }),
+ );
+ row.append(actions);
}
return row;
}
diff --git a/web/src/chat.js b/web/src/chat.js
index 37b626ea..c42453a9 100644
--- a/web/src/chat.js
+++ b/web/src/chat.js
@@ -20,7 +20,11 @@
// chatShowJumpToLatest, chatOpensAtNewest,
// chatFirstScroll
// ui/chat/ChatStore.kt the history page merge (dedupe by id, prepend an
-// older page, replace nextCursor/hasMore)
+// older page, replace nextCursor/hasMore) and the
+// local command notices (append, dismiss one,
+// take an offer; ChatCommandNotice)
+// ui/chat/ChatCommandUi.kt the Command / Command failed labels and the
+// terminal glyph of one local notice line
// ui/chat/ChatComposer.kt composerAction, composerCanSend/composerSendEnabled,
// the submit routing (command vs prompt)
// ui/chat/ChatCommands.kt CHAT_COMMANDS, parseChatInput, chatCommandSuggestions,
@@ -1362,6 +1366,60 @@ export const CHAT_QUEUED_NOTICE = "Queued — it will send when the current turn
*/
export const CHAT_COMMAND_GLYPH = ">_";
+/** The two labels a local command line can carry (ChatCommandUi.kt). */
+export const CHAT_COMMAND_LABEL = "Command";
+export const CHAT_COMMAND_FAILED_LABEL = "Command failed";
+
+/** The accessible name of an offerless notice's dismiss control. */
+export const CHAT_COMMAND_DISMISS_LABEL = "Dismiss command notice";
+
+/**
+ * The label for one command notice: `Command failed` when the command could not
+ * be honoured, else `Command` (ChatCommandUi.kt's own choice). The same flag
+ * selects the error tint on the caller's row.
+ */
+export function chatNoticeLabel(failed) {
+ return failed === true ? CHAT_COMMAND_FAILED_LABEL : CHAT_COMMAND_LABEL;
+}
+
+/**
+ * One local command line, the app's `ChatCommandNotice` shape: it lives beside a
+ * conversation, never inside its messages, so it is never sent to the agent.
+ * [offer] is set only for an unrecognised command, whose draft the operator can
+ * still choose to send as a message.
+ */
+export function makeChatNotice(id, text, { failed = false, offer = null } = {}) {
+ return {
+ id: str(id),
+ text: str(text),
+ failed: failed === true,
+ offer: offer == null ? null : str(offer),
+ };
+}
+
+/** Append one notice to a conversation's list, preserving order. */
+export function appendChatNotice(notices, notice) {
+ return [...(notices ?? []), notice];
+}
+
+/** Drop one notice by id, leaving every other notice and its order untouched. */
+export function dismissChatNotice(notices, noticeId) {
+ return (notices ?? []).filter((notice) => notice?.id !== noticeId);
+}
+
+/**
+ * Take the draft an unrecognised-command notice offers, removing the notice
+ * first (mirrors `ChatStore.takeNoticeOffer`). Returns `{notices, offer}`:
+ * `offer` is null — and the list is returned untouched — when the notice is
+ * missing, already taken or carries no offer, so a stale tap sends nothing.
+ */
+export function takeChatNoticeOffer(notices, noticeId) {
+ const list = notices ?? [];
+ const notice = list.find((entry) => entry?.id === noticeId);
+ if (!notice || notice.offer == null) return { notices: list, offer: null };
+ return { notices: dismissChatNotice(list, noticeId), offer: notice.offer };
+}
+
/** The two values of [composerAction]. */
export const COMPOSER_SEND = "send";
export const COMPOSER_STOP = "stop";
diff --git a/web/test/chat.test.mjs b/web/test/chat.test.mjs
index fc252ab3..b87ee274 100644
--- a/web/test/chat.test.mjs
+++ b/web/test/chat.test.mjs
@@ -8,7 +8,10 @@ import {
BACKGROUND_TASKS_TITLE,
BACKGROUND_TASK_VISIBLE_ROWS,
CHAT_COMMANDS,
+ CHAT_COMMAND_DISMISS_LABEL,
+ CHAT_COMMAND_FAILED_LABEL,
CHAT_COMMAND_GLYPH,
+ CHAT_COMMAND_LABEL,
CHAT_FOLLOW_THRESHOLD_PX,
CHAT_QUEUED_NOTICE,
COMPOSER_SEND,
@@ -48,6 +51,7 @@ import {
TURN_PHASE_TOOL,
TURN_PHASE_WAITING,
TURN_THINKING_WINDOW_MILLIS,
+ appendChatNotice,
applyChatEvent,
applyChatPermission,
approvalCard,
@@ -66,6 +70,7 @@ import {
chatFollowsAt,
chatHeaderMeta,
chatNoMatchMessage,
+ chatNoticeLabel,
chatOpensAtNewest,
chatShowJumpToLatest,
chatStreamState,
@@ -77,11 +82,13 @@ import {
decisionLabel,
deltaPartId,
directoryLabel,
+ dismissChatNotice,
filterSessions,
formatToolDuration,
groupSessionsByDirectory,
historyResync,
lineDiff,
+ makeChatNotice,
mergeHistoryPage,
mergeShellFrame,
mergeToolPart,
@@ -109,6 +116,7 @@ import {
shellCommandSummary,
shellOutputState,
shellsLoaded,
+ takeChatNoticeOffer,
threadElapsedMillis,
threadPhase,
threadRunningTools,
@@ -833,6 +841,103 @@ test("a command notice carries one terminal glyph for both states", () => {
assert.equal(CHAT_COMMAND_GLYPH, ">_");
});
+// ---------------------------------------------------------------------------
+// Local command notices (C12) — ChatStore.kt notice/dismissNotice/takeNoticeOffer
+// and ChatCommandUi.kt's labels
+// ---------------------------------------------------------------------------
+
+test("chatNoticeLabel names a command and its failure", () => {
+ assert.equal(CHAT_COMMAND_LABEL, "Command");
+ assert.equal(CHAT_COMMAND_FAILED_LABEL, "Command failed");
+ assert.equal(chatNoticeLabel(false), "Command");
+ assert.equal(chatNoticeLabel(true), "Command failed");
+ // Anything that is not the literal failed flag keeps the ordinary label.
+ assert.equal(chatNoticeLabel(undefined), "Command");
+ assert.equal(chatNoticeLabel("failed"), "Command");
+});
+
+test("the offerless notice's dismiss control has an accessible name", () => {
+ assert.equal(CHAT_COMMAND_DISMISS_LABEL, "Dismiss command notice");
+});
+
+test("makeChatNotice keeps the id, text, failure flag and offer", () => {
+ assert.deepEqual(makeChatNotice("notice-1", "No turn is running in this chat."), {
+ id: "notice-1",
+ text: "No turn is running in this chat.",
+ failed: false,
+ offer: null,
+ });
+ assert.deepEqual(
+ makeChatNotice("notice-2", "Started a new session.", { failed: true, offer: "/nope" }),
+ { id: "notice-2", text: "Started a new session.", failed: true, offer: "/nope" },
+ );
+});
+
+test("appendChatNotice appends one notice and preserves order", () => {
+ const first = makeChatNotice("notice-1", "Command one");
+ const second = makeChatNotice("notice-2", "Command two", { failed: true });
+ const afterFirst = appendChatNotice([], first);
+ const afterSecond = appendChatNotice(afterFirst, second);
+ assert.deepEqual(afterSecond, [first, second]);
+ // The previous list is never mutated.
+ assert.deepEqual(afterFirst, [first]);
+ assert.deepEqual(appendChatNotice(undefined, first), [first]);
+});
+
+test("dismissChatNotice removes exactly the named notice", () => {
+ const first = makeChatNotice("notice-1", "Command one");
+ const second = makeChatNotice("notice-2", "Command two", { failed: true });
+ const third = makeChatNotice("notice-3", "Command three");
+ assert.deepEqual(dismissChatNotice([first, second, third], "notice-2"), [first, third]);
+ // An unknown id leaves the list as it was.
+ assert.deepEqual(dismissChatNotice([first, third], "notice-9"), [first, third]);
+ assert.deepEqual(dismissChatNotice(undefined, "notice-1"), []);
+});
+
+test("takeChatNoticeOffer removes the notice and returns its draft", () => {
+ const offerless = makeChatNotice("notice-1", "Command one");
+ const offered = makeChatNotice("notice-2", "Not a command.", { failed: true, offer: "/nope" });
+ const taken = takeChatNoticeOffer([offerless, offered], "notice-2");
+ assert.equal(taken.offer, "/nope");
+ assert.deepEqual(taken.notices, [offerless]);
+});
+
+test("takeChatNoticeOffer returns null and leaves the list for a stale or offerless notice", () => {
+ const offerless = makeChatNotice("notice-1", "Command one");
+ const offered = makeChatNotice("notice-2", "Not a command.", { failed: true, offer: "/nope" });
+ for (const id of ["notice-1", "notice-9"]) {
+ const taken = takeChatNoticeOffer([offerless, offered], id);
+ assert.equal(taken.offer, null);
+ assert.deepEqual(taken.notices, [offerless, offered]);
+ }
+ // A second take of an already-taken id is stale and sends nothing.
+ const firstTake = takeChatNoticeOffer([offered], "notice-2");
+ const secondTake = takeChatNoticeOffer(firstTake.notices, "notice-2");
+ assert.equal(secondTake.offer, null);
+ assert.deepEqual(secondTake.notices, []);
+});
+
+test("notice lists are scoped per conversation and never share state", () => {
+ // Two conversations' notice lists are independent arrays: appending or
+ // dismissing in one cannot touch the other (the app keeps one per thread).
+ const operator = [];
+ const throwaway = [];
+ const operatorNotice = makeChatNotice("notice-1", "Operator command");
+ const throwawayNotice = makeChatNotice("notice-2", "Throwaway command", { failed: true });
+ const operatorAfter = appendChatNotice(operator, operatorNotice);
+ const throwawayAfter = appendChatNotice(throwaway, throwawayNotice);
+ assert.deepEqual(operatorAfter, [operatorNotice]);
+ assert.deepEqual(throwawayAfter, [throwawayNotice]);
+ assert.deepEqual(dismissChatNotice(operatorAfter, "notice-1"), []);
+ assert.deepEqual(throwawayAfter, [throwawayNotice]);
+ const taken = takeChatNoticeOffer(
+ appendChatNotice(throwawayAfter, makeChatNotice("notice-3", "Offer", { offer: "/help" })),
+ "notice-3",
+ );
+ assert.equal(taken.offer, "/help");
+ assert.deepEqual(operatorAfter, [operatorNotice]);
+});
+
// ---------------------------------------------------------------------------
// Slash commands (C9)
// ---------------------------------------------------------------------------
diff --git a/web/test/ui-smoke.mjs b/web/test/ui-smoke.mjs
index f63d79c8..68eee472 100644
--- a/web/test/ui-smoke.mjs
+++ b/web/test/ui-smoke.mjs
@@ -102,6 +102,19 @@ const showComposer = () =>
requestAnimationFrame(() => requestAnimationFrame(() => resolve(true)));
})`);
+// Show the foot of an open conversation without scrolling the whole document.
+// The session list can be taller than the chat pane (the smoke leaves closed
+// throwaway rows behind), so scrolling to the document bottom would push the
+// conversation above the viewport and capture an empty pane. The transcript is
+// the only scroller that needs to move for a command-notice capture.
+const showChatNotice = () =>
+ page.evaluate(`new Promise((resolve) => {
+ window.scrollTo(0, 0);
+ const transcript = document.querySelector("#chatTranscript");
+ if (transcript) transcript.scrollTop = transcript.scrollHeight;
+ requestAnimationFrame(() => requestAnimationFrame(() => resolve(true)));
+ })`);
+
// The shared live server can drop a long-lived socket while the earlier screens
// are captured (observed as a spurious 1006 mid-run). A capture step must not
// depend on an unasserted connection, so this nudges the page's own recovery —
@@ -422,6 +435,14 @@ try {
}
if (frame) {
(window.__pipelinesSentTypes = window.__pipelinesSentTypes || []).push(frame.type);
+ // C12: the prompt bodies this page actually sent, so the smoke can prove
+ // the help command and an unknown command generate none, and that the
+ // offer path sends exactly the draft it offered.
+ if (frame.type === "chat_prompt") {
+ (window.__chatPromptTexts = window.__chatPromptTexts || []).push(
+ frame.chat_prompt?.text ?? "",
+ );
+ }
if (frame.type === "chat_reply") {
const requestId = frame.chat_reply && frame.chat_reply.request_id;
if (window.__suppressChatReplyIds.includes(requestId)) {
@@ -3075,27 +3096,116 @@ try {
throw new Error(`prefix filter: ${JSON.stringify(narrowedCommands)}`);
}
- // (c) An unknown command: its notice with the exact wording and the offer, then
- // Cancel. The composer is driven without submitting, so no prompt is sent.
- await page.fill("#chatInput", "/nope");
- await page.evaluate(
- `document.querySelector("#chatInput").dispatchEvent(new KeyboardEvent("keydown", { key: "Enter", bubbles: true, cancelable: true }))`,
+ // (c) C12: local command notices on this (read-only) conversation. A `/help`
+ // success line and an unknown command's failed line render full width after the
+ // turns, never as message bubbles; both are local, so the recorded send
+ // assertions below must show no chat_prompt for either. The failed one keeps
+ // Android's `Send as message` / `Cancel` pair; an offerless line is dismissible
+ // by its own `Dismiss` control (the browser completion recorded in PARITY).
+ await page.evaluate(`(() => {
+ window.__pipelinesSentTypes = [];
+ window.__chatPromptTexts = [];
+ return true;
+ })()`);
+ const runSlashDraft = async (text) => {
+ await page.fill("#chatInput", text);
+ await page.evaluate(
+ `document.querySelector("#chatInput").dispatchEvent(new KeyboardEvent("keydown", { key: "Enter", bubbles: true, cancelable: true }))`,
+ );
+ };
+
+ await runSlashDraft("/help");
+ const helpNotice = await eventually(
+ () =>
+ page.evaluate(`(() => {
+ const node = [...document.querySelectorAll("#chatTranscript .chat-command-notice:not(.chat-command-notice-failed)")]
+ .find((n) => (n.querySelector(".chat-command-notice-text")?.textContent ?? "").includes("/help — List every command"));
+ if (!node) return null;
+ node.scrollIntoView({ block: "center" });
+ const transcript = document.querySelector("#chatTranscript");
+ const children = [...transcript.children];
+ const index = children.indexOf(node);
+ const lastTurn = children.reduce(
+ (last, child, i) => (child.matches(".chat-turn-user, .chat-turn-agent") ? i : last),
+ -1,
+ );
+ return {
+ id: node.dataset.noticeId ?? "",
+ label: node.querySelector(".chat-command-notice-label")?.textContent ?? "",
+ glyph: node.querySelector(".chat-command-notice-glyph")?.textContent ?? "",
+ text: node.querySelector(".chat-command-notice-text")?.textContent ?? "",
+ buttons: [...node.querySelectorAll(".chat-command-notice-actions button")].map((b) => b.textContent),
+ dismissLabel: node.querySelector(".chat-command-dismiss")?.getAttribute("aria-label") ?? "",
+ bubble:
+ node.classList.contains("chat-turn-user") ||
+ node.classList.contains("chat-turn-agent") ||
+ !!node.closest(".chat-bubble"),
+ width: Math.round(node.getBoundingClientRect().width),
+ contentWidth: Math.round(transcript.clientWidth - 24),
+ afterTurns: index > lastTurn,
+ turns: children.filter((child) => child.matches(".chat-turn-user, .chat-turn-agent")).length,
+ };
+ })()`),
+ { timeout: 10000, what: "the /help command notice" },
);
+ if (helpNotice.label !== "Command") throw new Error(`/help notice label: ${helpNotice.label}`);
+ if (helpNotice.glyph !== ">_") throw new Error(`/help notice glyph: ${helpNotice.glyph}`);
+ if (!helpNotice.text.startsWith("/new — Start a fresh session in this directory")) {
+ throw new Error(`/help notice text: ${helpNotice.text}`);
+ }
+ if (!helpNotice.text.includes("/help — List every command")) {
+ throw new Error(`/help notice is missing its last command line: ${helpNotice.text}`);
+ }
+ if (helpNotice.buttons.join("|") !== "Dismiss") {
+ throw new Error(`offerless notice controls: ${JSON.stringify(helpNotice.buttons)}`);
+ }
+ if (helpNotice.dismissLabel !== "Dismiss command notice") {
+ throw new Error(`dismiss accessible name: ${helpNotice.dismissLabel}`);
+ }
+ if (helpNotice.bubble || !helpNotice.afterTurns || helpNotice.turns < 1) {
+ throw new Error(
+ `the /help line is not a full-width transcript line after the turns: ${JSON.stringify(helpNotice)}`,
+ );
+ }
+ if (helpNotice.width < helpNotice.contentWidth - 3) {
+ throw new Error(
+ `the /help line is not full width: ${helpNotice.width}px of ${helpNotice.contentWidth}px`,
+ );
+ }
+ const promptless = await page.evaluate(
+ `({ types: window.__pipelinesSentTypes || [], texts: window.__chatPromptTexts || [] })`,
+ );
+ if (promptless.types.includes("chat_prompt") || promptless.texts.length !== 0) {
+ throw new Error(`/help reached the prompt path: ${JSON.stringify(promptless)}`);
+ }
+ console.log(
+ ` /help: "${helpNotice.label}" line (${helpNotice.width}px of ${helpNotice.contentWidth}px, ` +
+ `${helpNotice.turns} turn(s) above it), no bubble; only a Dismiss control; no chat_prompt sent`,
+ );
+ await showChatNotice();
+ await shot("72-chat-command-notice.png");
+
+ // The unknown command's failed line: the app's wording, the shared terminal
+ // glyph and the error tint, with the offer's exact control pair.
+ await runSlashDraft("/nope");
await page.waitForSelector(".chat-command-notice-failed", { timeout: 10000 });
const notice = await page.evaluate(`(() => {
const node = document.querySelector(".chat-command-notice-failed");
node.scrollIntoView({ block: "center" });
return {
+ id: node.dataset.noticeId ?? "",
label: node.querySelector(".chat-command-notice-label")?.textContent ?? "",
glyph: node.querySelector(".chat-command-notice-glyph")?.textContent ?? "",
text: node.querySelector(".chat-command-notice-text")?.textContent ?? "",
buttons: [...node.querySelectorAll(".chat-command-notice-actions button")].map((b) => b.textContent),
+ failed: node.classList.contains("chat-command-notice-failed"),
draft: document.querySelector("#chatInput")?.value ?? null,
send: !!document.querySelector("#chatSend"),
stop: !!document.querySelector("#chatStop"),
};
})()`);
if (notice.label !== "Command failed") throw new Error(`notice label: ${notice.label}`);
+ if (notice.glyph !== ">_") throw new Error(`failed notice glyph: ${notice.glyph}`);
if (
notice.text !==
"“/nope” is not a command, so nothing was sent to the agent. Send it as a message, or cancel."
@@ -3105,14 +3215,79 @@ try {
if (notice.buttons.join("|") !== "Send as message|Cancel") {
throw new Error(`unknown-command offer buttons: ${JSON.stringify(notice.buttons)}`);
}
+ if (!notice.failed) throw new Error("the failed notice does not carry the error styling class");
if (notice.draft !== "") throw new Error(`the command did not consume the draft: ${JSON.stringify(notice.draft)}`);
+ const tint = await page.evaluate(`(() => {
+ const failedNode = document.querySelector('.chat-command-notice-failed[data-notice-id="${notice.id}"]');
+ const okNode = document.querySelector('.chat-command-notice[data-notice-id="${helpNotice.id}"]');
+ return {
+ failedBorder: failedNode ? getComputedStyle(failedNode).borderColor : "",
+ okBorder: okNode ? getComputedStyle(okNode).borderColor : "",
+ };
+ })()`);
+ if (!tint.failedBorder || tint.failedBorder === tint.okBorder) {
+ throw new Error(`the failed notice is not tinted differently from a command line: ${JSON.stringify(tint)}`);
+ }
+ const stillPromptless = await page.evaluate(`window.__chatPromptTexts || []`);
+ if (stillPromptless.length !== 0) {
+ throw new Error(`an unknown command reached the prompt path: ${JSON.stringify(stillPromptless)}`);
+ }
console.log(` unknown command: "${notice.text}" (offer: ${notice.buttons.join(" / ")})`);
+ console.log(
+ ` both command lines stayed local: no chat_prompt was sent (recorded types: ${JSON.stringify(
+ (await page.evaluate(`window.__pipelinesSentTypes || []`)).filter((type) => type.startsWith("chat_")),
+ )})`,
+ );
+ await showChatNotice();
await shot("59-chat-command-unknown.png");
- await page.clickText(".chat-command-notice-failed button", "Cancel");
- await eventually(() => page.evaluate(`!document.querySelector(".chat-command-notice-failed")`), {
- timeout: 5000,
- what: "the unknown-command notice to be dismissed",
- });
+ await showChatNotice();
+ await shot("73-chat-command-failed-offer.png");
+
+ // Dismissal removes exactly the named notice: the offerless `/help` line goes,
+ // the failed offer notice stays with its draft and controls.
+ const dismissed = await page.evaluate(`(() => {
+ const help = document.querySelector('.chat-command-notice[data-notice-id="${helpNotice.id}"]');
+ const idsBefore = [...document.querySelectorAll("#chatTranscript .chat-command-notice")].map(
+ (node) => node.dataset.noticeId,
+ );
+ help?.querySelector(".chat-command-dismiss")?.click();
+ return { idsBefore, clicked: !!help };
+ })()`);
+ if (!dismissed.clicked || !dismissed.idsBefore.includes(helpNotice.id)) {
+ throw new Error(`the /help notice was not dismissed: ${JSON.stringify(dismissed)}`);
+ }
+ await eventually(
+ () =>
+ page.evaluate(
+ `!document.querySelector('.chat-command-notice[data-notice-id="${helpNotice.id}"]')`,
+ ),
+ { timeout: 5000, what: "the dismissed /help notice to be gone" },
+ );
+ const noticeRemoval = await page.evaluate(`(() => ({
+ ids: [...document.querySelectorAll("#chatTranscript .chat-command-notice")].map((node) => node.dataset.noticeId),
+ failed: document.querySelector('.chat-command-notice-failed[data-notice-id="${notice.id}"] .chat-command-notice-text')?.textContent ?? "",
+ buttons: [...document.querySelectorAll('.chat-command-notice-failed[data-notice-id="${notice.id}"] .chat-command-notice-actions button')].map((b) => b.textContent),
+ }))()`);
+ if (
+ noticeRemoval.ids.includes(helpNotice.id) ||
+ !noticeRemoval.ids.includes(notice.id) ||
+ noticeRemoval.ids.length !== dismissed.idsBefore.length - 1 ||
+ noticeRemoval.failed !== notice.text ||
+ noticeRemoval.buttons.join("|") !== "Send as message|Cancel"
+ ) {
+ throw new Error(`dismissing one notice changed the wrong ones: ${JSON.stringify({ dismissed, noticeRemoval })}`);
+ }
+ console.log(
+ ` dismissed only ${helpNotice.id} (${dismissed.idsBefore.length} -> ${noticeRemoval.ids.length} notices; ` +
+ `${notice.id} and its offer remain)`,
+ );
+ await showChatNotice();
+ await shot("74-chat-command-dismissed.png");
+ await page.clickText(`.chat-command-notice-failed[data-notice-id="${notice.id}"] button`, "Cancel");
+ await eventually(
+ () => page.evaluate(`!document.querySelector('.chat-command-notice[data-notice-id="${notice.id}"]')`),
+ { timeout: 5000, what: "the unknown-command notice to be dismissed" },
+ );
// (d) Attachment chips: a small file with its size, and a file over the 25 MiB
// limit with its error. Driving the real file input (a DataTransfer) exercises
@@ -3222,6 +3397,131 @@ try {
await showComposer();
await shot("62-chat-new-session.png");
+ // C12: notices belong to one conversation and survive switching away and back.
+ // The offer notice is added on this throwaway session (never the operator's),
+ // then the pane switches to the operator session and back. Finally the offer is
+ // taken: the notice is gone before the prompt is sent, a stale second tap sends
+ // nothing, and the draft goes through the ordinary chat_prompt path. The shim
+ // answers that one prompt locally so this step does not add a live turn; the
+ // real prompt below still exercises the live turn and Stop.
+ await page.evaluate(`(() => {
+ window.__pipelinesSentTypes = [];
+ window.__chatPromptTexts = [];
+ return true;
+ })()`);
+ await page.fill("#chatInput", "/nope");
+ await page.evaluate(
+ `document.querySelector("#chatInput").dispatchEvent(new KeyboardEvent("keydown", { key: "Enter", bubbles: true, cancelable: true }))`,
+ );
+ const offerNotice = await eventually(
+ () =>
+ page.evaluate(`(() => {
+ const node = document.querySelector('#chatTranscript[data-session="${throwawayId}"] .chat-command-notice-failed');
+ if (!node) return null;
+ return {
+ id: node.dataset.noticeId ?? "",
+ text: node.querySelector(".chat-command-notice-text")?.textContent ?? "",
+ buttons: [...node.querySelectorAll(".chat-command-notice-actions button")].map((b) => b.textContent),
+ };
+ })()`),
+ { timeout: 10000, what: "the throwaway command notice" },
+ );
+ if (offerNotice.buttons.join("|") !== "Send as message|Cancel") {
+ throw new Error(`throwaway notice controls: ${JSON.stringify(offerNotice.buttons)}`);
+ }
+ const throwawayPromptless = await page.evaluate(`window.__chatPromptTexts || []`);
+ if (throwawayPromptless.length !== 0) {
+ throw new Error(`the unknown command on the throwaway reached the prompt path: ${JSON.stringify(throwawayPromptless)}`);
+ }
+
+ await page.evaluate(`document.querySelector('#chatRows .chat-row[data-session="${openedId}"]')?.click()`);
+ await page.waitForSelector(`#chatTranscript[data-session="${openedId}"]`, { timeout: 25000 });
+ const leaked = await page.evaluate(
+ `!!document.querySelector('.chat-command-notice[data-notice-id="${offerNotice.id}"]')`,
+ );
+ if (leaked) throw new Error("the throwaway's notice leaked into the operator's conversation");
+ await page.evaluate(`document.querySelector('#chatRows .chat-row[data-session="${throwawayId}"]')?.click()`);
+ await page.waitForSelector(`#chatTranscript[data-session="${throwawayId}"]`, { timeout: 25000 });
+ const survived = await eventually(
+ () =>
+ page.evaluate(`(() => {
+ const node = document.querySelector('#chatTranscript[data-session="${throwawayId}"] .chat-command-notice[data-notice-id="${offerNotice.id}"]');
+ if (!node) return null;
+ return {
+ text: node.querySelector(".chat-command-notice-text")?.textContent ?? "",
+ buttons: [...node.querySelectorAll(".chat-command-notice-actions button")].map((b) => b.textContent),
+ };
+ })()`),
+ { timeout: 15000, what: "the throwaway notice after switching away and back" },
+ );
+ if (survived.text !== offerNotice.text || survived.buttons.join("|") !== "Send as message|Cancel") {
+ throw new Error(`the notice did not survive the switch: ${JSON.stringify({ offerNotice, survived })}`);
+ }
+ console.log(
+ ` the notice survived a switch away and back on ${throwawayId} (absent from the operator's conversation)`,
+ );
+
+ const offerClicked = await page.evaluate(`(() => {
+ const node = document.querySelector('#chatTranscript[data-session="${throwawayId}"] .chat-command-notice[data-notice-id="${offerNotice.id}"]');
+ const button = node?.querySelector(".chat-command-send-as-message") ?? null;
+ window.__staleOfferButton = button;
+ window.__promptCountBeforeOffer = (window.__pipelinesSentTypes || []).length;
+ window.__pipelinesIntercept = (frame) =>
+ frame.type === "chat_prompt" ? { id: frame.id, type: "chat_prompt", chat_queued: false } : null;
+ button?.click();
+ return !!button;
+ })()`);
+ if (!offerClicked) throw new Error("the throwaway notice has no Send as message control");
+ await eventually(
+ () =>
+ page.evaluate(
+ `!document.querySelector('#chatTranscript[data-session="${throwawayId}"] .chat-command-notice[data-notice-id="${offerNotice.id}"]')`,
+ ),
+ { timeout: 10000, what: "the taken offer notice to be removed" },
+ );
+ const offeredSend = await page.evaluate(`(() => {
+ const types = (window.__pipelinesSentTypes || []).slice(window.__promptCountBeforeOffer);
+ return { chatPrompts: types.filter((type) => type === "chat_prompt").length, texts: window.__chatPromptTexts || [] };
+ })()`);
+ if (offeredSend.chatPrompts !== 1 || offeredSend.texts.length !== 1 || offeredSend.texts[0] !== "/nope") {
+ throw new Error(`the offer did not take the ordinary prompt path: ${JSON.stringify(offeredSend)}`);
+ }
+ const staleTap = await page.evaluate(`(() => {
+ const before = (window.__pipelinesSentTypes || []).length;
+ window.__staleOfferButton?.click();
+ return {
+ before,
+ after: (window.__pipelinesSentTypes || []).length,
+ texts: (window.__chatPromptTexts || []).length,
+ };
+ })()`);
+ if (staleTap.after !== staleTap.before || staleTap.texts !== 1) {
+ throw new Error(`a stale Send as message tap sent something: ${JSON.stringify(staleTap)}`);
+ }
+ console.log(
+ " Send as message removed the notice first, then sent /nope once through chat_prompt; " +
+ "a stale second tap sent nothing",
+ );
+ // Settle the (locally answered) prompt so the real turn below starts from Send,
+ // and drop the one-shot prompt interceptor.
+ const settledOffer = await page.evaluate(`(() => {
+ const ws = window.__pipelinesSocket;
+ if (!ws || typeof ws.onmessage !== "function") return false;
+ ws.onmessage({
+ data: JSON.stringify({
+ type: "chat_event",
+ chat_event: { session_id: "${throwawayId}", kind: "step", step: { status: "ended" } },
+ }),
+ });
+ return true;
+ })()`);
+ if (!settledOffer) throw new Error("the socket shim did not expose the live socket to settle the offered prompt");
+ await eventually(() => page.evaluate(`!document.querySelector("#chatStop")`), {
+ timeout: 10000,
+ what: "the offered prompt's running state to settle",
+ });
+ await page.evaluate(`(() => { window.__pipelinesIntercept = null; return true; })()`);
+
// A real prompt to the throwaway session turns the Send control into Stop.
await page.fill("#chatInput", "Reply with exactly one word: hi");
await page.evaluate(