From 5642058fd0866ae6c4791c2cfd59fec86be7c937 Mon Sep 17 00:00:00 2001 From: Sam Catlow Date: Thu, 19 Nov 2026 19:43:21 +1100 Subject: [PATCH] feat(ui): make the composer the chat with Archie (#2018) The composer is the chat again: the old dashboard's chat, copied from ui/src/chat and moved onto the chat module's API. It is the full /composer page and a dock on every other page, with the session list, session menu, left, right and floating positions and a full-screen sheet at phone width. A message carries the page it was asked from and the page's suggested prompts; a reply streams its thinking, tool calls and text, Stop cancels it, and a message sent meanwhile is queued by the server. Workflow notifications and approval requests show in the conversation as cards, and an approval is answered only with its card's Approve or Deny. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- ui/src/archie/App.vue | 93 +-- ui/src/archie/ComposerView.vue | 296 +--------- ui/src/archie/api.ts | 117 ++++ ui/src/archie/chat/ChatApprovalCard.vue | 94 +++ ui/src/archie/chat/ChatBar.vue | 59 ++ ui/src/archie/chat/ChatBubble.vue | 118 ++++ ui/src/archie/chat/ChatComposer.vue | 241 ++++++++ ui/src/archie/chat/ChatDock.vue | 579 ++++++++++++++++++ ui/src/archie/chat/ChatDockLayout.ts | 197 +++++++ ui/src/archie/chat/ChatEmptyState.vue | 32 + ui/src/archie/chat/ChatInline.vue | 35 ++ ui/src/archie/chat/ChatJumpButton.vue | 45 ++ ui/src/archie/chat/ChatMarkdown.vue | 100 ++++ ui/src/archie/chat/ChatNavChip.vue | 26 + ui/src/archie/chat/ChatNoticeCard.vue | 82 +++ ui/src/archie/chat/ChatPending.vue | 38 ++ ui/src/archie/chat/ChatSessionActions.vue | 159 +++++ ui/src/archie/chat/ChatSessionList.vue | 70 +++ ui/src/archie/chat/ChatSettings.vue | 21 + ui/src/archie/chat/ChatSlashPalette.vue | 71 +++ ui/src/archie/chat/ChatSuggestions.vue | 93 +++ ui/src/archie/chat/ChatThinking.vue | 50 ++ ui/src/archie/chat/ChatToolCall.vue | 110 ++++ ui/src/archie/chat/ChatToolGroup.vue | 47 ++ ui/src/archie/chat/ChatTopbarButton.vue | 42 ++ ui/src/archie/chat/ChatTranscript.vue | 98 ++++ ui/src/archie/chat/command-scroll.ts | 41 ++ ui/src/archie/chat/commands.ts | 88 +++ ui/src/archie/chat/markdown.ts | 191 ++++++ ui/src/archie/chat/session.ts | 30 + ui/src/archie/chat/state.ts | 677 ++++++++++++++++++++++ ui/src/archie/chat/suggestions.ts | 40 ++ ui/src/archie/chat/unseen.ts | 44 ++ ui/src/archie/router.ts | 28 +- 34 files changed, 3723 insertions(+), 329 deletions(-) create mode 100644 ui/src/archie/chat/ChatApprovalCard.vue create mode 100644 ui/src/archie/chat/ChatBar.vue create mode 100644 ui/src/archie/chat/ChatBubble.vue create mode 100644 ui/src/archie/chat/ChatComposer.vue create mode 100644 ui/src/archie/chat/ChatDock.vue create mode 100644 ui/src/archie/chat/ChatDockLayout.ts create mode 100644 ui/src/archie/chat/ChatEmptyState.vue create mode 100644 ui/src/archie/chat/ChatInline.vue create mode 100644 ui/src/archie/chat/ChatJumpButton.vue create mode 100644 ui/src/archie/chat/ChatMarkdown.vue create mode 100644 ui/src/archie/chat/ChatNavChip.vue create mode 100644 ui/src/archie/chat/ChatNoticeCard.vue create mode 100644 ui/src/archie/chat/ChatPending.vue create mode 100644 ui/src/archie/chat/ChatSessionActions.vue create mode 100644 ui/src/archie/chat/ChatSessionList.vue create mode 100644 ui/src/archie/chat/ChatSettings.vue create mode 100644 ui/src/archie/chat/ChatSlashPalette.vue create mode 100644 ui/src/archie/chat/ChatSuggestions.vue create mode 100644 ui/src/archie/chat/ChatThinking.vue create mode 100644 ui/src/archie/chat/ChatToolCall.vue create mode 100644 ui/src/archie/chat/ChatToolGroup.vue create mode 100644 ui/src/archie/chat/ChatTopbarButton.vue create mode 100644 ui/src/archie/chat/ChatTranscript.vue create mode 100644 ui/src/archie/chat/command-scroll.ts create mode 100644 ui/src/archie/chat/commands.ts create mode 100644 ui/src/archie/chat/markdown.ts create mode 100644 ui/src/archie/chat/session.ts create mode 100644 ui/src/archie/chat/state.ts create mode 100644 ui/src/archie/chat/suggestions.ts create mode 100644 ui/src/archie/chat/unseen.ts diff --git a/ui/src/archie/App.vue b/ui/src/archie/App.vue index 87fcc823a..ca2a40e98 100644 --- a/ui/src/archie/App.vue +++ b/ui/src/archie/App.vue @@ -1,16 +1,23 @@ diff --git a/ui/src/archie/ComposerView.vue b/ui/src/archie/ComposerView.vue index 181dfba67..80401cee5 100644 --- a/ui/src/archie/ComposerView.vue +++ b/ui/src/archie/ComposerView.vue @@ -1,287 +1,25 @@ diff --git a/ui/src/archie/api.ts b/ui/src/archie/api.ts index af38405ce..67663e369 100644 --- a/ui/src/archie/api.ts +++ b/ui/src/archie/api.ts @@ -688,3 +688,120 @@ export async function* composerStream(signal: AbortSignal, onConnected?: () => P reader.releaseLock(); } } + +/** One conversation, as GET /api/chat/sessions lists it. */ +export interface ChatSession { + session_id: string; + title: string; + created_at: string; + updated_at: string; +} + +export interface ChatSessions { + sessions: ChatSession[]; + active_model: string; + model_error?: string; +} + +/** A tool the agent called and what came of it. */ +export interface ChatToolCall { + id: string; + name: string; + parameters: string; + text: string; + failed?: boolean; + duration_ms: number; + text_offset: number; +} + +/** An action judgement held and put to people. */ +export interface ChatApproval { + request_id: string; + action: string; + summary: string; + level: string; + deadline: string; +} + +/** What became of a held action once its approval was answered. */ +export interface ChatActionDone { + request_id: string; + state: "succeeded" | "failed" | "unknown" | "denied" | "expired"; + result?: string; +} + +export interface ChatNavigation { + path: string; + label: string; +} + +/** One message and Archie's reply, with what the turn did. */ +export interface ChatTurn { + id: string; + session_id: string; + seq: number; + state: "queued" | "running" | "succeeded" | "failed" | "cancelled"; + text: string; + page?: string; + page_label?: string; + reply: string; + reasoning?: string; + error?: string; + tool_calls: ChatToolCall[]; + approvals: ChatApproval[]; + actions: ChatActionDone[]; + navigate: ChatNavigation[]; + created_at: string; + finished_at?: string; +} + +/** One recorded event of a turn, as its stream sends it. */ +export type ChatEvent = { seq: number } & ( + | { type: "reasoning" | "delta" | "done" | "error" | "cancelled"; text: string } + | ({ type: "tool" } & ChatToolCall) + | ({ type: "navigate" } & ChatNavigation) + | ({ type: "approval" } & ChatApproval) + | ({ type: "action" } & ChatActionDone) +); + +const sessionPath = (id: string) => `/api/chat/sessions/${encodeURIComponent(id)}`; +const turnPath = (id: string) => `/api/chat/turns/${encodeURIComponent(id)}`; + +export const chatSessions = (signal?: AbortSignal) => get("/api/chat/sessions", signal); +export const createChatSession = () => send("POST", "/api/chat/sessions"); +export const renameChatSession = (id: string, title: string) => send("PATCH", sessionPath(id), { title }); +export const deleteChatSession = (id: string) => send("DELETE", sessionPath(id)); +export const chatTurns = (id: string, signal?: AbortSignal) => get(`${sessionPath(id)}/turns`, signal); +export const chatTurn = (id: string, signal?: AbortSignal) => get(turnPath(id), signal); +export const sendChatTurn = (sessionID: string, text: string, page?: { page: string; page_label: string }) => + send("POST", `${sessionPath(sessionID)}/turns`, { text, ...page }); +export const cancelChatTurn = (id: string) => send("POST", `${turnPath(id)}/cancel`); + +/** + * Yields a turn's recorded events after the cursor until the turn ends. The + * stream ends after a done, error or cancelled event; a dropped connection + * ends it early, and the caller reconnects from the last seq it saw. + */ +export async function* chatTurnEvents(id: string, after: number, signal: AbortSignal): AsyncGenerator { + const res = await request(`${turnPath(id)}/events?after=${after}`, signal); + if (!res.body) return; + const reader = res.body.pipeThrough(new TextDecoderStream()).getReader(); + let buffered = ""; + try { + for (;;) { + const { value, done } = await reader.read(); + if (done) return; + buffered += value; + let end: number; + while ((end = buffered.indexOf("\n\n")) >= 0) { + const frame = buffered.slice(0, end); + buffered = buffered.slice(end + 2); + const data = frame.split("\n").find((line) => line.startsWith("data: ")); + if (data) yield JSON.parse(data.slice(6)) as ChatEvent; + } + } + } finally { + void reader.cancel().catch(() => undefined); + reader.releaseLock(); + } +} diff --git a/ui/src/archie/chat/ChatApprovalCard.vue b/ui/src/archie/chat/ChatApprovalCard.vue new file mode 100644 index 000000000..7eddc085b --- /dev/null +++ b/ui/src/archie/chat/ChatApprovalCard.vue @@ -0,0 +1,94 @@ + + + diff --git a/ui/src/archie/chat/ChatBar.vue b/ui/src/archie/chat/ChatBar.vue new file mode 100644 index 000000000..5d4ffd356 --- /dev/null +++ b/ui/src/archie/chat/ChatBar.vue @@ -0,0 +1,59 @@ + + + diff --git a/ui/src/archie/chat/ChatBubble.vue b/ui/src/archie/chat/ChatBubble.vue new file mode 100644 index 000000000..565213d8b --- /dev/null +++ b/ui/src/archie/chat/ChatBubble.vue @@ -0,0 +1,118 @@ + + + diff --git a/ui/src/archie/chat/ChatComposer.vue b/ui/src/archie/chat/ChatComposer.vue new file mode 100644 index 000000000..76746b708 --- /dev/null +++ b/ui/src/archie/chat/ChatComposer.vue @@ -0,0 +1,241 @@ + + +