Watch
0
0
Fork
You've already forked hyperhive
0

swarm ui: the message box is a floating pill with a round send button

This commit is contained in:
iris 2026-11-16 18:09:30 +01:00
commit 58e7cbf261
5 changed files with 130 additions and 22 deletions

View file

@ -147,3 +147,23 @@ export function TerminalIcon() {
</svg>
);
}
/** An arrow pointing up, for a send button: the message goes up into the terminal. */
export function SendIcon() {
return (
<svg
width="1.2em"
height="1.2em"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2.4"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
>
<line x1="12" y1="19" x2="12" y2="5" />
<polyline points="5 12 12 5 19 12" />
</svg>
);
}

View file

@ -1,14 +1,81 @@
/* <AgentInputForm> — one row: the text field takes the width, the send
button sits at its baseline. The field is the anchor of the command menu. */
/* <AgentInputForm> — 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;
}

View file

@ -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 (
<div class="ui-agent-input">
{state.status === "error" && (
<ApiErrorPanel context="failed to send" problem={state.problem} />
)}
<form class="ui-agent-input-form" onSubmit={submit}>
<div class="ui-agent-input-field">
{open && (
@ -122,13 +130,17 @@ export function AgentInputForm({ agentName }: { agentName: string }) {
}}
/>
</div>
<Button variant="primary" type="submit" busy={submitting}>
send
</Button>
<button
class="ui-agent-input-send"
type="submit"
aria-label="send"
title="send"
disabled={submitting || body.trim() === ""}
aria-busy={submitting || undefined}
>
{submitting ? <Spinner /> : <SendIcon />}
</button>
</form>
{state.status === "error" && (
<ApiErrorPanel context="failed to send" problem={state.problem} />
)}
</div>
);
}

View file

@ -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

View file

@ -119,7 +119,8 @@ export function AgentTermPreview({
<div
class={
"ui-agent-term-preview" +
(fullHeight ? " ui-agent-term-preview-full" : "")
(fullHeight ? " ui-agent-term-preview-full" : "") +
(subagent === undefined ? " ui-agent-term-preview-with-input" : "")
}
>
<div class="terminal-wrap ui-agent-term-preview-wrap">