diff --git a/docs/4-implementation/web-ui/swarm-ui.md b/docs/4-implementation/web-ui/swarm-ui.md index b34e03603..3d074f8fb 100644 --- a/docs/4-implementation/web-ui/swarm-ui.md +++ b/docs/4-implementation/web-ui/swarm-ui.md @@ -106,7 +106,9 @@ An opened card has six sections, and each reads nothing until you open it. of `GET /api/links`; the row stays hidden when the swarm lists none, and an agent built from an archetype has no config repo, so it gets no config repo link), and its open config PR. -- **terminal**: the live terminal with its message box. Typing `/` opens a menu +- **terminal**: the live terminal with its message box, a pill floating over the + terminal's bottom edge whose right end holds the send button, a circle with an + arrow. Typing `/` opens a menu filled from `GET /api/agents//commands`, which lists the swarm's own commands and the skills the agent published. Sending exactly `/clear` isn't a message: the box POSTs `/api/agents//new-session` instead of `/input` (see diff --git a/frontend/packages/shared/src/icons.tsx b/frontend/packages/shared/src/icons.tsx index cf0570a40..22deb364c 100644 --- a/frontend/packages/shared/src/icons.tsx +++ b/frontend/packages/shared/src/icons.tsx @@ -147,3 +147,23 @@ export function TerminalIcon() { ); } + +/** An arrow pointing up, for a send button: the message goes up into the terminal. */ +export function SendIcon() { + return ( + + ); +} diff --git a/frontend/packages/swarm-ui/src/agent/terminal/AgentInputForm.css b/frontend/packages/swarm-ui/src/agent/terminal/AgentInputForm.css index 8ed05e658..d5e19dd18 100644 --- a/frontend/packages/swarm-ui/src/agent/terminal/AgentInputForm.css +++ b/frontend/packages/swarm-ui/src/agent/terminal/AgentInputForm.css @@ -1,14 +1,81 @@ -/* — one row: the text field takes the width, the send - button sits at its baseline. The field is the anchor of the command menu. */ +/* — one floating pill over the terminal's bottom edge. The + whole pill is the text box; the send button is a circle inside its right end. + The pill is the anchor of the command menu, which opens above it across its + full width. A send error sits above the pill. */ .ui-agent-input { - margin-block-start: 0.5rem; -} -.ui-agent-input-form { + position: absolute; + inset-inline: 0.4em; + bottom: 0.4em; + z-index: 2; display: flex; - align-items: flex-end; - gap: 0.5em; + flex-direction: column; + gap: 0.4em; + pointer-events: none; } -.ui-agent-input-field { +.ui-agent-input > * { + pointer-events: auto; +} + +.ui-agent-input-form { position: relative; + display: flex; + align-items: center; + gap: 0.25em; + padding: 0.25em 0.25em 0.25em 1.1em; + border: 1px solid var(--purple-dim); + border-radius: 999px; + background: var(--bg-elev); + box-shadow: + 0 0.3em 1em rgba(0, 0, 0, 0.45), + 0 0 0 1px color-mix(in srgb, var(--purple) 12%, transparent); +} +.ui-agent-input-form:focus-within { + border-color: var(--purple); + box-shadow: + 0 0.3em 1em rgba(0, 0, 0, 0.45), + 0 0 0 3px color-mix(in srgb, var(--purple) 28%, transparent); +} + +/* The field is the pill itself: no box of its own. */ +.ui-agent-input-field { flex: 1; + min-width: 0; +} +.ui-agent-input-form .ui-form-control { + border: 0; + border-radius: 0; + background: transparent; + box-shadow: none; + outline: none; + padding-inline: 0; +} + +.ui-agent-input-send { + flex: none; + display: grid; + place-items: center; + width: 2.5em; + height: 2.5em; + padding: 0; + border: 0; + border-radius: 50%; + background: var(--purple); + color: var(--crust, var(--bg)); + font: inherit; + cursor: pointer; + transition: + background 0.15s, + opacity 0.15s; +} +.ui-agent-input-send:hover:not(:disabled) { + background: color-mix(in srgb, var(--purple) 82%, var(--fg)); +} +.ui-agent-input-send:focus-visible { + outline: 2px solid var(--fg); + outline-offset: 2px; +} +.ui-agent-input-send:disabled { + background: color-mix(in srgb, var(--purple) 30%, var(--bg-elev)); + color: var(--muted); + cursor: default; } diff --git a/frontend/packages/swarm-ui/src/agent/terminal/AgentInputForm.tsx b/frontend/packages/swarm-ui/src/agent/terminal/AgentInputForm.tsx index efa1f4e7d..3e3ad7cd6 100644 --- a/frontend/packages/swarm-ui/src/agent/terminal/AgentInputForm.tsx +++ b/frontend/packages/swarm-ui/src/agent/terminal/AgentInputForm.tsx @@ -8,6 +8,10 @@ // `/api/agents/{name}/new-session`, which queues a fresh claude session for the // agent's next turn (`controlRoute`). // +// The box is one floating pill over the terminal's bottom edge: the whole pill +// is the text field and the send button, a circle with an arrow, sits inside its +// right end. +// // 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 @@ -15,7 +19,8 @@ import { useEffect, useState } from "preact/hooks"; import { ApiErrorPanel } from "@hive/shared/api-error-panel.js"; import { TextField } from "../../ui/text-field/TextField.js"; -import { Button } from "../../ui/button/Button.js"; +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 { @@ -92,6 +97,9 @@ export function AgentInputForm({ agentName }: { agentName: string }) { return (
+ {state.status === "error" && ( + + )}
{open && ( @@ -122,13 +130,17 @@ export function AgentInputForm({ agentName }: { agentName: string }) { }} />
- +
- {state.status === "error" && ( - - )}
); } diff --git a/frontend/packages/swarm-ui/src/agent/terminal/AgentTermPreview.css b/frontend/packages/swarm-ui/src/agent/terminal/AgentTermPreview.css index f86682de5..724f1811b 100644 --- a/frontend/packages/swarm-ui/src/agent/terminal/AgentTermPreview.css +++ b/frontend/packages/swarm-ui/src/agent/terminal/AgentTermPreview.css @@ -5,8 +5,18 @@ @import "@hive/shared/terminal.css"; .ui-agent-term-preview { + position: relative; margin-block-start: 1rem; } +/* The message box floats over the terminal's bottom edge (AgentInputForm.css), + so the rows end above it: the pill is 3em tall with 0.4em around it. */ +.ui-agent-term-preview-with-input .live.terminal { + padding-block-end: 4em; +} +/* The "new rows" pill rides above the message box. */ +.ui-agent-term-preview-with-input .tail-pill { + bottom: 4.6em; +} .ui-agent-term-preview-wrap.terminal-wrap { max-height: 18em; @@ -16,8 +26,7 @@ `-full` modifier on the OUTER `.ui-agent-term-preview` root, not the wrap) — self-contained flex chain, not dependent on the page around it doing anything beyond giving this root a real height to fill (see - AgentTerminalPage.css). Column flex so the input row keeps its natural - height and the terminal-wrap above it takes the rest; `flex: 1` + + AgentTerminalPage.css). Column flex so the terminal-wrap takes all the height; `flex: 1` + `min-height: 0` on the wrap (not `height: 100%`) is deliberate — a flex item's `height` percentage doesn't account for a sibling (the input row) already consuming space the way `flex: 1` does, and @@ -45,14 +54,11 @@ /* One badge row: the full tab is wide enough that the badges never wrap. */ padding-block-start: 3.4em; } -/* Flush to the header bar and the viewport sides; the input row below - gets its own padding so it doesn't touch the screen edge. */ +/* Flush to the header bar and the viewport sides; the message box floats over + the bottom edge with its own small margin. */ .ui-agent-term-preview-full .ui-agent-term-preview-wrap.terminal-wrap { margin: 0; } -.ui-agent-term-preview-full .ui-agent-input { - padding: 0.4em 0.75em 0.6em; -} /* `box-sizing: border-box`, not the browser's default `content-box` — `.live.terminal`'s own `padding: 0.8em 1em 0.4em` (terminal.css) is diff --git a/frontend/packages/swarm-ui/src/agent/terminal/AgentTermPreview.tsx b/frontend/packages/swarm-ui/src/agent/terminal/AgentTermPreview.tsx index 096da6285..5759dd90e 100644 --- a/frontend/packages/swarm-ui/src/agent/terminal/AgentTermPreview.tsx +++ b/frontend/packages/swarm-ui/src/agent/terminal/AgentTermPreview.tsx @@ -119,7 +119,8 @@ export function AgentTermPreview({