web: chat composer — send, stop, attachments, draft and slash commands (C8/C9)
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).
This commit is contained in:
@@ -43,6 +43,14 @@ export const Protocol = Object.freeze({
|
||||
CHAT_MESSAGES: "chat_messages",
|
||||
CHAT_CLOSE: "chat_close",
|
||||
CHAT_REOPEN: "chat_reopen",
|
||||
// The composer's own commands (C8/C9). `chat_prompt` carries its body in
|
||||
// `chat_prompt` (`{session_id,text,files?,operation_id}`) and its reply echoes
|
||||
// `chat_queued` when the prompt waits behind an in-flight turn; `chat_interrupt`
|
||||
// carries the same `chat_query` body as the other session-scoped commands; and
|
||||
// `chat_create` carries `chat_create` and replies with `chat_session`.
|
||||
CHAT_PROMPT: "chat_prompt",
|
||||
CHAT_INTERRUPT: "chat_interrupt",
|
||||
CHAT_CREATE: "chat_create",
|
||||
|
||||
SUCCESS_END: "#success",
|
||||
FAILURE_END: "#failure",
|
||||
@@ -60,6 +68,13 @@ export const ChatKeys = Object.freeze({
|
||||
HISTORY: "chat_history",
|
||||
MESSAGES: "chat_messages",
|
||||
CLOSE: "chat_close",
|
||||
// The composer's payloads (C8/C9). `chat_interrupt` deliberately has no key of
|
||||
// its own: its body is the same `chat_query` the other session-scoped commands
|
||||
// carry (internal/protocol/chat.go ChatQuery, Chat.kt interruptRequest), so a
|
||||
// separate field name here would put it on the wrong part of the envelope.
|
||||
PROMPT: "chat_prompt",
|
||||
CREATE: "chat_create",
|
||||
QUEUED: "chat_queued",
|
||||
});
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user