From 48ce818bb7e6337067496295cf4b22ea78c8e96b Mon Sep 17 00:00:00 2001 From: iris Date: Wed, 25 Nov 2026 17:30:52 +0100 Subject: [PATCH] swarm-ui: replace an agent's message box with a reconnect bar when its terminal stream is closed A closed stream showed only a small red dot and a quiet badge in the top row, so a terminal that had given up looked like a live one. The pill the operator types in is now swapped for a red bar that says disconnected and holds the reconnect button; the form stays mounted underneath so an unsent message survives. A subagent terminal has no message box and keeps its reconnect badge. --- docs/4-implementation/web-ui/swarm-ui.md | 9 ++-- .../src/agent/terminal/AgentInputForm.css | 48 +++++++++++++++++++ .../src/agent/terminal/AgentInputForm.tsx | 38 ++++++++++++++- .../src/agent/terminal/AgentTermPreview.tsx | 16 +++++-- 4 files changed, 103 insertions(+), 8 deletions(-) diff --git a/docs/4-implementation/web-ui/swarm-ui.md b/docs/4-implementation/web-ui/swarm-ui.md index 9e20dd14d..f915d161a 100644 --- a/docs/4-implementation/web-ui/swarm-ui.md +++ b/docs/4-implementation/web-ui/swarm-ui.md @@ -283,9 +283,12 @@ An agent's terminal opens with its last 100 rows from the past 24 hours, then follows new ones; a reconnect picks up after the last row it showed. A subagent terminal does the same with that subagent's rows, and has no turn-state badges. The browser retries a dropped connection by itself. When the swarm answers the -stream with an error status, the browser gives up and the badge reads -**disconnected**. The **reconnect** button beside it opens the stream again, and -the stream replays the rows. The message log card works the same way. +stream with an error status, the browser gives up. An agent's terminal then +swaps its message box for a red bar that reads **disconnected**, with a +**reconnect** button that opens the stream again and replays the rows. The +unsent text in the box stays. A subagent terminal has no message box, so its +**reconnect** badge sits in the top row. The message log card works the same +way. The settings menu in the header has a **theme** select: **auto**, which follows the OS and picks hyperhive light or hyperhive dark, then hyperhive light, diff --git a/frontend/packages/swarm-ui/src/agent/terminal/AgentInputForm.css b/frontend/packages/swarm-ui/src/agent/terminal/AgentInputForm.css index f5eb8d82e..35a239979 100644 --- a/frontend/packages/swarm-ui/src/agent/terminal/AgentInputForm.css +++ b/frontend/packages/swarm-ui/src/agent/terminal/AgentInputForm.css @@ -101,3 +101,51 @@ color: var(--muted); cursor: default; } + +/* The stream closed: a bar of the pill's shape and place that says so, red + where the pill is purple, with the way back inside its right end. */ +.ui-agent-input-form[hidden] { + display: none; +} +.ui-agent-input-lost { + position: relative; + margin-block-start: auto; + display: flex; + align-items: center; + justify-content: space-between; + gap: 0.75em; + padding: 0.25em 0.25em 0.25em 1.1em; + border: 1px solid var(--red); + border-radius: 999px; + background: color-mix(in srgb, var(--red) 14%, var(--bg-elev)); + box-shadow: + 0 0.3em 1em rgba(0, 0, 0, 0.45), + 0 0 0 3px color-mix(in srgb, var(--red) 22%, transparent); +} +.ui-agent-input-lost-text { + display: inline-flex; + align-items: center; + gap: 0.55em; + min-width: 0; + color: var(--fg); +} +.ui-agent-input-reconnect { + flex: none; + height: 2.5em; + padding: 0 1.1em; + border: 0; + border-radius: 999px; + background: var(--red); + color: var(--crust, var(--bg)); + font: inherit; + font-weight: 600; + cursor: pointer; + transition: background 0.15s; +} +.ui-agent-input-reconnect:hover { + background: color-mix(in srgb, var(--red) 82%, var(--fg)); +} +.ui-agent-input-reconnect:focus-visible { + outline: 2px solid var(--fg); + outline-offset: 2px; +} diff --git a/frontend/packages/swarm-ui/src/agent/terminal/AgentInputForm.tsx b/frontend/packages/swarm-ui/src/agent/terminal/AgentInputForm.tsx index 8edb6dc40..6667e47a8 100644 --- a/frontend/packages/swarm-ui/src/agent/terminal/AgentInputForm.tsx +++ b/frontend/packages/swarm-ui/src/agent/terminal/AgentInputForm.tsx @@ -12,6 +12,10 @@ // is the text field and the send button, a circle with an arrow, sits inside its // right end. // +// While the terminal's stream is closed the pill is replaced by a bar that says +// so and holds the reconnect button (`disconnected`, `onReconnect`). The form +// stays mounted underneath, hidden, so a half-written message survives. +// // While the text is one `/word`, a menu of the agent's commands and skills // opens above the box (`CommandMenu`): the arrow keys move, Tab or Enter take // the selected one into the box, Esc closes it. The list is the agent's own @@ -23,6 +27,7 @@ import { SendIcon } from "@hive/shared/icons.js"; import { Spinner } from "../../ui/spinner/Spinner.js"; import { useSubmit } from "../../ui/submit/useSubmit.js"; import { CommandMenu } from "./CommandMenu.js"; +import { ConnectionDot } from "./ConnectionDot.js"; import { completion, controlRoute, @@ -38,7 +43,16 @@ import { useConfirm } from "../../ui/confirm-dialog/useConfirm.js"; import { useAgentCommands } from "./useAgentCommands.js"; import "./AgentInputForm.css"; -export function AgentInputForm({ agentName }: { agentName: string }) { +export function AgentInputForm({ + agentName, + disconnected = false, + onReconnect, +}: { + agentName: string; + // The terminal's stream is closed: show the reconnect bar, not the box. + disconnected?: boolean; + onReconnect?: () => void; +}) { const [body, setBody] = useState(""); const [selected, setSelected] = useState(0); const [closed, setClosed] = useState(false); @@ -120,7 +134,27 @@ export function AgentInputForm({ agentName }: { agentName: string }) { {state.status === "error" && ( )} -
+ {disconnected && onReconnect && ( + + )} +
{open && ( )} - {connection === "closed" && ( + {connection === "closed" && subagent !== undefined && ( )}
- {subagent === undefined && } + {subagent === undefined && ( + { + reconnect(); + reconnectState(); + }} + /> + )} ); }