From f6600781738080b8634c08572ce8c7f782689467 Mon Sep 17 00:00:00 2001 From: Alan Silva Date: Mon, 19 Oct 2026 06:53:30 +0100 Subject: [PATCH] =?UTF-8?q?web:=20chat=20composer=20=E2=80=94=20send,=20st?= =?UTF-8?q?op,=20attachments,=20draft=20and=20slash=20commands=20(C8/C9)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add the composer at the foot of an open conversation: a growing 1–6-row textarea (Enter sends, Shift+Enter newline), an Attach file control with removable attachment chips (25 MiB limit, failed attachments block sending), one send/stop control that turns to Stop while a turn runs, and the queued notice cleared on any incoming frame. Add the five slash commands with the palette, the pure chatCommand* helpers and the command notices. The prompt carries native_message_id so OpenCode accepts it, and a rejected prompt restores the draft and attachments with the server's message. Drafts persist per chat in memory and localStorage; attachments stay memory-only. Tests cover every pure helper and the exact chat_prompt/chat_interrupt/ chat_create wire shapes; ui-smoke captures the composer, palette, a failed command notice, the attachment chips and the Stop control (a real prompt to a throwaway session that is closed in cleanup). --- web/PARITY.md | 24 +- web/src/app.js | 760 ++++++++++++++++++++++++++++++++++- web/src/chat.js | 318 +++++++++++++++ web/src/client.js | 8 +- web/src/protocol.js | 15 + web/src/repository.js | 96 +++++ web/styles.css | 100 +++++ web/test/chat.test.mjs | 227 +++++++++++ web/test/repository.test.mjs | 80 +++- web/test/ui-smoke.mjs | 329 +++++++++++++++ 10 files changed, 1936 insertions(+), 21 deletions(-) diff --git a/web/PARITY.md b/web/PARITY.md index 4836d014..4f5f7405 100644 --- a/web/PARITY.md +++ b/web/PARITY.md @@ -95,8 +95,8 @@ the pipeline list already carries — rather than a pluralised verb. | C5 | Live transcript: user/assistant text, one reply = one turn | `chat_subscribe`, `chat_event` | todo | | C6 | Reasoning block + tool calls with name/input for the whole lifecycle | `chat_event` | done — the assistant turn draws, in order, its one collapsible reasoning block and its one tool-call chip (then the answer). Reasoning labels match the app: `Thinking…` / `Reasoning` for a single step and `Thinking · {N} steps` / `Reasoning · {N} steps` for several, with ` · {duration}` appended when the parts' timing gives a settled span (earliest start → latest completed), through chevrons named `Show reasoning` / `Hide reasoning`. The chip reads `1 tool called` / `{N} tools called`, announces `… expand for details`, wears the shared spinner while a call is in flight and an error tint once one failed, and opens a fixed overlay panel under the chip (flipped above / clamped into the viewport when there is no room) with the same count, a `Close tool calls` control and an internally scrolling, independently-expandable row per call: the name (else `tool`), the first of `description`/`command`/`filePath`/`file_path`/`path`/`pattern`/`query`/`url` collapsed and elided to 72 characters, the `+N -M` edit stat when present, the `formatToolDuration` value (`340ms`/`1.2s`/`2m 3s`), and `Expand {name}`/`Collapse {name}`; a failed row is marked `Failed tool call`. An expanded row shows INPUT (pretty-printed JSON, or the raw partial string), the LCS edit diff (at most 200 rendered lines with the remaining `… {N} more changed line(s) not shown`), then ERROR (the server's `error.message`, else the output) or OUTPUT (`(no output)` when settled and empty, nothing while in flight). Lifecycle words `streaming`/`running` are in flight and `completed`/`error` settled; a settled call never spins or wears the ` · long` mark. Because the panel is a fixed overlay, opening or closing it never re-flows the transcript nor moves its scroll (C14). Captured 2026-10-19 against `ses_eae413f50ffeLQDExlg8cYnscN` (one folded turn, 80 reasoning steps, 122 tool calls): `captures/51-chat-reasoning-collapsed.png`, `captures/52-chat-reasoning-expanded.png`, `captures/53-chat-tool-chip.png`, `captures/54-chat-tool-panel.png` (an opened `read` row showing INPUT + OUTPUT) and `captures/55-chat-edit-diff-sample.png`. The live history carries no failed or edit-family call, so that capture renders a labelled page-rendered sample — a `shell` row marked `Failed tool call` with INPUT + ERROR and an `edit` row with a `+2 -1` diff — through the page's own row builder; the transcript stayed put across open/close (top 43065 → 43065). **Live arrival over `chat_event` is C5**: the renderer is built from the same part shapes (`ChatPart{type,name,state{status,input,content,error},time}`) and takes a `streaming` flag plus a live elapsed source so C5 can drive in-flight calls; the chip's in-flight spinner, the ` · long` 60s mark, the panel flip-above and an edit-family call are not reachable against the live server, so they are unit-tested (`test/chat.test.mjs`) rather than claimed as captured | | C7 | Markdown rendering + code blocks | — | done — captured 2026-10-19: `captures/45-chat-transcript-newest.png` (opened at the newest content: bold, bullet lists, a `|` table with its `---` delimiter row and inline code spans from the live assistant answer), `captures/47b-chat-markdown-code.png` (a rendered fenced code block — label `js`, the pre body `const answer = 42;` — drawn in the live browser by the page's own `renderMarkdown`, the same function that renders the answer) and `captures/47-chat-reasoning-code.png`. The subset is exactly `Markdown.kt`: paragraphs, `#`–`######` headings, fenced code (```/~~~, the language label else `code`), block quotes, bullet/ordered lists, `|` tables with a `---` delimiter row, thematic rules, inline code, bold, italic (underscore only at word boundaries, so `snake_case` stays plain), `[label](url)` links and bare http(s) autolinks; HTML entities are decoded first in one pass, and HTML, reference links, strikethrough and nested lists render as plain text and are never dropped. **Code-block caveat, stated plainly**: the live assistant answer carries **no** fenced block — its four fences live in the reasoning transcript, which the app draws as plain text, not as markdown (`captures/47-chat-reasoning-code.png` shows one such fence as muted plain text; that is C6 material, not the markdown path). So the rendered `
` code block is captured from a labelled sample through the page's real renderer (`47b`), and the same path plus its `code`-else-language label is unit-tested in `test/markdown.test.mjs`. Only `http(s)` link targets become clickable — the transcript is untrusted model output, so a `javascript:`/`data:` target renders as its label, never as a live link |
-| C8 | Composer: send, stop, attachments, draft | `chat_prompt`, `chat_interrupt` | todo |
-| C9 | Slash commands | client-side | todo |
+| C8 | Composer: send, stop, attachments, draft | `chat_prompt`, `chat_interrupt` | done — the composer at the foot of an open conversation: a growing 1–6-row `