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.
This commit is contained in:
parent
d8ac52b77d
commit
48ce818bb7
4 changed files with 103 additions and 8 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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" && (
|
||||
<ApiErrorPanel context="failed to send" problem={state.problem} />
|
||||
)}
|
||||
<form class="ui-agent-input-form" onSubmit={submit}>
|
||||
{disconnected && onReconnect && (
|
||||
<div class="ui-agent-input-lost" role="alert">
|
||||
<span class="ui-agent-input-lost-text">
|
||||
<ConnectionDot connection="closed" />
|
||||
disconnected
|
||||
</span>
|
||||
<button
|
||||
class="ui-agent-input-reconnect"
|
||||
type="button"
|
||||
title={`open ${agentName}'s terminal stream again`}
|
||||
onClick={onReconnect}
|
||||
>
|
||||
reconnect
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
<form
|
||||
class="ui-agent-input-form"
|
||||
onSubmit={submit}
|
||||
hidden={disconnected && onReconnect !== undefined}
|
||||
>
|
||||
<div class="ui-agent-input-field">
|
||||
{open && (
|
||||
<CommandMenu
|
||||
|
|
|
|||
|
|
@ -10,7 +10,8 @@
|
|||
// **Floating controls** — one row pinned over the terminal's top edge, so the
|
||||
// terminal keeps the whole box. On the left, the `leading` slot (the page's
|
||||
// own badges, or the connection light by default), a "reconnect" badge when
|
||||
// the stream closed, and, on the full tab, the state badges from
|
||||
// a subagent's stream closed (an agent's own terminal has the bar in place of its
|
||||
// message box instead, `AgentInputForm`), and, on the full tab, the state badges from
|
||||
// `useSwarmAgentStateStream` (turn state, model and effort, context) and the
|
||||
// cancel-turn badge. On the right, the expand trigger and the `trailing` slot.
|
||||
// The card preview shows no state badges: it is small, and the card's overview
|
||||
|
|
@ -109,7 +110,7 @@ export function AgentTermPreview({
|
|||
) : (
|
||||
<ConnectionDot connection={connection} />
|
||||
)}
|
||||
{connection === "closed" && (
|
||||
{connection === "closed" && subagent !== undefined && (
|
||||
<Badge
|
||||
variant="quiet"
|
||||
value="reconnect"
|
||||
|
|
@ -191,7 +192,16 @@ export function AgentTermPreview({
|
|||
</div>
|
||||
)}
|
||||
</div>
|
||||
{subagent === undefined && <AgentInputForm agentName={agentName} />}
|
||||
{subagent === undefined && (
|
||||
<AgentInputForm
|
||||
agentName={agentName}
|
||||
disconnected={connection === "closed"}
|
||||
onReconnect={() => {
|
||||
reconnect();
|
||||
reconnectState();
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue