From 426610dce99a8ccf1c7b32b238488892c3d2264f Mon Sep 17 00:00:00 2001 From: brettchien Date: Fri, 14 Aug 2026 17:54:58 +0800 Subject: [PATCH] =?UTF-8?q?feat(chat):=20Part=20C=20=E2=80=94=20vanilla-TS?= =?UTF-8?q?=20chat=20panel=20over=20the=20live=20/acp=20session?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The first visible, end-to-end-testable chat: type a prompt, watch the agent stream back, rendered as markdown. Consumes the Part B backend (agent_prompt / agent_cancel commands, agent-update events). - console/src/chat.ts: the transcript view-model + PURE render (mirrors render.ts). markdown-it (html:false, linkify) renders a finalized agent turn; a spinner + raw text while streaming; user text and chrome are escaped. Pure reducers (appendUser / appendChunk / endTurn) keep the render a function of ChatTurn[] and unit-testable without a DOM. - console/src/main.ts: turn wiring. Single-shot turn model (katashiro): a prompt typed mid-turn is queued and flushQueue releases the next only when the current turn ends — so two turns never overlap and the backend in-flight guard stays a safety net. agent-update (chunk/turn_end) drives the transcript; Stop → agent_cancel; per-turn Copy (raw text); a mid-turn socket drop finalizes the open turn so no spinner hangs. Agent markdown is DOMPurify-sanitized at the DOM-write boundary (markdown-it + DOMPurify, ADR). - source.ts: agentPrompt/agentCancel bridge (agent_prompt/agent_cancel); the browser build synthesizes a canned reply so the panel is demonstrable. - index.html + styles.css: the panel (transcript, input, Send/Stop), light/dark. - chat.test.ts: 14 tests — markdown, raw-HTML/js-link safety, reducers, render. Verified: tsc clean, 59 console tests green, vite build OK. End-to-end against a live gateway needs the desktop shell (as with Part B) — not runnable here. Co-Authored-By: Claude Opus 4.8 --- console/index.html | 14 +++ console/package-lock.json | 141 ++++++++++++++++++++++- console/package.json | 5 +- console/src/chat.test.ts | 109 ++++++++++++++++++ console/src/chat.ts | 139 +++++++++++++++++++++++ console/src/main.ts | 228 ++++++++++++++++++++++++++++++++++++++ console/src/source.ts | 15 +++ console/src/styles.css | 180 ++++++++++++++++++++++++++++++ 8 files changed, 829 insertions(+), 2 deletions(-) create mode 100644 console/src/chat.test.ts create mode 100644 console/src/chat.ts diff --git a/console/index.html b/console/index.html index f762355..05ef879 100644 --- a/console/index.html +++ b/console/index.html @@ -32,6 +32,20 @@
+
+
+ Agent chat + disconnected +
+
+
+ +
+ + +
+
+