Watch
0
0
Fork
You've already forked hyperhive
0

frontend: remove the unused vanilla terminal and tab strip, and fix comments that describe removed UI

shared/src/terminal/terminal.js (and its index.js re-export and package export) had no importer: the Preact Row replaced it. The .tail-pill and .load-more-pill rules were only made by it, and the preview's own tail-pill override styled a pill that no longer exists. hive-tab-strip.js had no importer either. Four constants nobody imports are no longer exported. The shared terminal pane section of the web-ui shape doc now describes Row, linkify and markdown instead of the removed factory. Header comments that named removed components (StatusChips, MetaNav, Root.tsx, the cost badge, four folded sections, a detail dialog) now describe the current code.
This commit is contained in:
iris 2026-11-19 18:31:24 +01:00 • committed by mara
commit a1e5855859
30 changed files with 78 additions and 990 deletions

View file

@ -15,29 +15,14 @@
`extraFiles` overlay). `extraFiles` overlay).
- `GET /static/*` → bundled CSS + JS produced by esbuild - `GET /static/*` → bundled CSS + JS produced by esbuild
(`frontend/packages/{dashboard,agent}/build.mjs`). Both pages (`frontend/packages/{dashboard,agent}/build.mjs`). Both pages
pull the shared terminal pane + Catppuccin palette + typography pull the shared terminal rows + Catppuccin palette + typography
from `@hive/shared` (was `hive-fr0nt`); the dashboard ships from `@hive/shared` (was `hive-fr0nt`); the dashboard ships
`colors.css` + `theme.css` + `common.css` + `dashboard.css`; `colors.css` + `theme.css` + `common.css` + `dashboard.css`;
`common.css` inlines `@hive/shared`'s `common.css` inlines `@hive/shared`'s
`base.css` + `terminal.css` + `tabs.css` + `base.css` + `terminal.css` + `tabs.css` +
`pill.css` via esbuild's `@import` resolution. `pill.css` via esbuild's `@import` resolution.
`terminal.js` exports `{ create, linkify }` as ES module Terminal rows come from `@hive/shared`'s Preact `Row`, `linkify` and
members; a back-compat shim in the IIFE bodies still exposes `markdown` modules (see "Shared terminal pane" below).
a `window.HiveTerminal` global for callers that need it. The
per-agent `#live` log runs on
this terminal — sticky-bottom autoscroll, "↓ N new" pill,
history backfill, SSE plumbing all live there. Each page
registers a kind→renderer map; unknown kinds fall through to
a JSON-dump note row. Bare `http(s)://` URLs in row text are
turned into clickable new-tab links by `linkify` (text-node
based, no `innerHTML` — XSS-safe); markdown bodies go through
`marked` (npm dep, replacing the vendored UMD bundle) and then
`DOMPurify.sanitize()` before hitting `innerHTML` — untrusted row
text (peer-agent / matrix-relayed message bodies, agent-authored
state files) can carry arbitrary HTML/script via markdown, so
`DOMPurify.sanitize()` cleans the markdown path rather than it being
XSS-safe by construction the way the text-node `linkify` path is.
Rendered `<a>`s are rewritten to `target="_blank"`.
- `GET /api/state` → JSON snapshot the JS app renders into the - `GET /api/state` → JSON snapshot the JS app renders into the
DOM. DOM.
- `GET /api/dashboard/stream` (dashboard) / `GET /events/stream` - `GET /api/dashboard/stream` (dashboard) / `GET /events/stream`
@ -77,117 +62,24 @@
## Shared terminal pane ## Shared terminal pane
The shared terminal factory in `@hive/shared/terminal.js` backs the Preact components in `@hive/shared` draw the terminal log
scrollable log stream. The factory wires up (`frontend/packages/shared/src/terminal/`): `Row.tsx` draws one row, `linkify.tsx`
sticky-bottom autoscroll, a "↓ N new" pill, history backfill, and turns bare `http(s)://` URLs in row text into new-tab links (text nodes, so no
SSE replay. Pages register a `kind → renderer` map; unknown kinds `innerHTML`), and `markdown.ts` turns a markdown body into HTML with `marked`
fall through to a JSON-dump note row. The factory ships three row and then `DOMPurify.sanitize()` before `Row.tsx` assigns it. Untrusted row text
shapes the renderers call: (peer messages, agent-written state files) can carry raw HTML through markdown,
so the sanitiser is what keeps that path safe, where the text-node `linkify`
path is safe by construction. Links open in a new tab.
- `api.row(cls, text, icon?)` — single-line row with an inline `linkify` A row with a body is a collapsible `<details>` row, open by default when the
pass over the text; optional `icon` lands in a fixed-width `.row-glyph` operator's expand-tool-output preference is on. A row's `kind` (see `termMsg.ts`)
cell so glyphs of varying rendered width all align. picks its look, and `row-visibility.ts` decides which rows show given the "show
- `api.details(cls, summary, body, icon?)` — collapsible `<details>` with thinking" and "hide developer details" preferences.
a `<pre>` body (used by long tool-results and stack traces).
- `api.detailsDiff(cls, summary, body, icon?)` — same shape, splits the
body on newlines and tags each line as `diff-add` / `diff-del` /
`diff-ctx` so the renderer's diff bodies get coloured without
emitting raw HTML.
- `api.placeholder(text)` — replaces the log with a single muted row,
cleared automatically when the next real row arrives.
- `api.fromHistory` — `true` while backfill replay is running; renderers
use it to suppress live-only side effects.
<!-- vale write-good.Passive = NO --> The consumers are the swarm UI's `AgentTermPreview` (the card preview and the full
terminal tab) and `MessagesPage`. Each reads rows off a stream,
**`create(opts)` options:** `logEl` (log container element), `streamUrl` keeps the scroll pinned to the newest row until the operator scrolls more than
(SSE endpoint), `historyUrl?` (optional replay endpoint — skipped if absent 48 px up, and renders through `Row`.
or if the fetch fails), `renderers` (kind→fn map; unknown kinds fall through
to `renderers._default`, itself defaulting to a JSON-dump note row),
`onLiveEvent?(ev)` (live-only side effects), `onAnyEvent?(ev, {fromHistory})`
(runs for both replay and live — use for derived views that need the full
event picture), `onBackfillDone?(count)` (one-shot after replay; `count=0` on
failed/skipped fetch), `onStreamOpen?()` (fires on every EventSource
(re)connect — use to re-sync snapshot-derived state after a reconnect gap),
`pillAnchor?` (parent element for the "↓ N new" pill; defaults to
`logEl.parentElement`), `expandDetails?` (boolean or zero-arg function
returning one, re-read on every `api.details`/`api.detailsDiff` call rather
than captured once — lets a page default otherwise-collapsed panels open
per a live browser-local preference; renderers that force a row open
regardless, for example message-bearing tool_use, are unaffected either way).
<!-- vale write-good.Passive = YES -->
**Sticky-bottom + snap animation.** `stickToBottom` is the
operator's intent: true means "keep snapping to bottom on every
mutation," false means "the operator scrolled up, leave them alone." The flag
flips when a scroll event lands further than `NEAR_BOTTOM_PX = 48`
from the bottom. New rows then either snap to bottom (when sticky)
or bump the unseen-count and surface the "↓ N new" pill. The snap
is a brief 140ms ease-out (`SCROLL_ANIM_MS`) — the browser's
default `behavior: 'smooth'` ~500ms reads as "still smooth, but
visibly slow"; 140ms feels snap-y while still reading as motion
rather than a jump. Distances under `SCROLL_SNAP_PX = 24`
short-circuit to instant — animating a 12px nudge would just be
jitter. Each new snap cancels the previous `requestAnimationFrame`
so a burst of mutations coalesces into one ride to the latest
bottom; the per-frame step re-reads `scrollHeight - clientHeight`
so mutations landing mid-animation extend the destination smoothly
rather than land short.
**Mid-animation scroll-event guard.** The scroll handler's
`isNearBottom` check would flip `stickToBottom` false mid-snap as
the smooth animation eases through positions that are technically
"not near bottom yet," which would strand the operator partway. A
`smoothScrollingUntil` timestamp gates the scroll handler — set to
the animation end + ~80ms headroom, re-armed on each fresh snap.
Programmatic `scrollTop` writes (the animation's per-frame update)
fire scroll events that the gate swallows. One caveat: if live events
arrive faster than the animation window (< 220ms apart), the
MutationObserver keeps re-firing `snapToBottom()` which perpetually
re-arms the gate — trapping the operator at the bottom with no way
to scroll up or trigger `loadMore()`. Safety valve: even inside the
guard the handler checks `isNearBottom()`; if the operator has
scrolled away from the bottom, `stickToBottom` is immediately forced
false. The MO's `if (stickToBottom)` check then stops re-arming
snaps, and the gate expires within ≤220ms.
**Post-append `MutationObserver`.** Renderers commonly call
`api.row(cls, text)` to create the row shell then append more
children (badges, multi-line bodies, tool result panes) after the
factory returned. The initial sticky-snap fires off the row's
empty shape; the renderer's later appends grow the row past the
visible bottom. A `MutationObserver` on the log subtree fires once
per microtask after each batch of synchronous mutations and snaps
again when `stickToBottom` is true. Programmatic `scrollTop`
writes don't re-trigger the observer (scroll isn't a DOM
mutation), so no feedback loop. The pre-append
`nearBottomBeforeAppend` snapshot is still useful — it keeps the
initial visual lag to one frame instead of one microtask + frame.
**Backfill + SSE.** Cold load fetches `historyUrl` (replay), then
subscribes to `streamUrl` (live tail). Both endpoints return
`{ seq, events }` so the client can dedupe — the client silently
drops events with `seq <= snapshot.seq` from the SSE stream
(the snapshot already covers them). History rows render with a
`.no-anim` class so they don't stagger in like live events. The
optional `streamFactory(url)` callback lets the dashboard hand
the factory a `SharedWorker`-backed `EventSource` facade (so
multiple tabs share one upstream connection — see _SSE
multiplexing_ above); when omitted, the factory falls back to a
plain `new EventSource(url)`.
**`linkify` (text-node based).** Bare `http(s)://` URLs in row
text get wrapped in `<a target="_blank" rel="noopener noreferrer">`
inside a fresh text node, so the autolinker never touches
`innerHTML` and untrusted row content can't smuggle markup. The
trailing-punctuation strip keeps `.,;:` outside the link surface.
Markdown bodies go through `marked` separately, then
`DOMPurify.sanitize()` on the resulting HTML before it's assigned to
`innerHTML` (see `mdNode` in `app.js` / `common.js`) —
`DOMPurify.sanitize()` cleans this path rather than it being
text-node-safe like `linkify`, since markdown can carry raw HTML.
Rendered `<a>`s get the same target rewrite.
The JS app handles all `form[data-async]` submissions via a delegated The JS app handles all `form[data-async]` submissions via a delegated
listener: read `data-confirm`, swap the button to a spinner, POST listener: read `data-confirm`, swap the button to a spinner, POST

View file

@ -187,9 +187,7 @@
</button> </button>
</div> </div>
<!-- Single bundled entry — tabs.js is the dashboard tabs surface; <!-- Single bundled entry — tabs.js is the dashboard tabs surface. -->
esbuild folds
@hive/shared/terminal.js into tabs.js. -->
<script type="module" src="/static/tabs.js" defer></script> <script type="module" src="/static/tabs.js" defer></script>
</body> </body>
</html> </html>

View file

@ -2,24 +2,20 @@
"name": "@hive/shared", "name": "@hive/shared",
"version": "0.0.0", "version": "0.0.0",
"private": true, "private": true,
"description": "Shared frontend modules used by both the dashboard and the per-agent UI: terminal log pane, Catppuccin palette, base typography. Imported by sibling workspaces; not bundled standalone.", "description": "Shared frontend modules used by both the dashboard and the per-agent UI: terminal log rows, Catppuccin palette, base typography. Imported by sibling workspaces; not bundled standalone.",
"type": "module", "type": "module",
"main": "./src/index.js",
"dependencies": { "dependencies": {
"dompurify": "^3.2.4", "dompurify": "^3.2.4",
"marked": "18.1.3", "marked": "18.1.3",
"preact": "11.2.0" "preact": "11.2.0"
}, },
"exports": { "exports": {
".": "./src/index.js",
"./terminal.js": "./src/terminal/terminal.js",
"./term-msg.js": "./src/terminal/termMsg.ts", "./term-msg.js": "./src/terminal/termMsg.ts",
"./term-row.js": "./src/terminal/Row.tsx", "./term-row.js": "./src/terminal/Row.tsx",
"./term-linkify.js": "./src/terminal/linkify.tsx", "./term-linkify.js": "./src/terminal/linkify.tsx",
"./term-markdown.js": "./src/terminal/markdown.ts", "./term-markdown.js": "./src/terminal/markdown.ts",
"./tabs.js": "./src/tabs/tabs.js", "./tabs.js": "./src/tabs/tabs.js",
"./tabs.css": "./src/tabs/tabs.css", "./tabs.css": "./src/tabs/tabs.css",
"./hive-tab-strip.js": "./src/tabs/hive-tab-strip.js",
"./colors.css": "./src/colors.css", "./colors.css": "./src/colors.css",
"./theme.css": "./src/theme.css", "./theme.css": "./src/theme.css",
"./base.css": "./src/base.css", "./base.css": "./src/base.css",

View file

@ -31,10 +31,8 @@ export type BadgeTone =
* `'default'` — the filled pill every status/picker badge has always * `'default'` — the filled pill every status/picker badge has always
* been. `'quiet'` — no permanent fill, only a background on hover/ * been. `'quiet'` — no permanent fill, only a background on hover/
* `expanded`; for an icon-only trigger that should read as chrome (a * `expanded`; for an icon-only trigger that should read as chrome (a
* header button) rather than a status chip — mara: "link and settings * header button) rather than a status chip, as the shared
* button should not have the badge bg" against both the agent page's * `SettingsMenu` trigger does. Same `variant` naming/shape as `Button`'s
* `MetaNav` and the shared `SettingsMenu` (swarm-ui + agent both use
* it). Same `variant` naming/shape as `Button`'s
* `ButtonVariant` (`../../swarm-ui/src/ui/button/Button.tsx`) — visual * `ButtonVariant` (`../../swarm-ui/src/ui/button/Button.tsx`) — visual
* weight is orthogonal to `tone` (color semantics), so it's its own prop * weight is orthogonal to `tone` (color semantics), so it's its own prop
* rather than a new `tone` value. * rather than a new `tone` value.

View file

@ -139,8 +139,8 @@
} }
} }
/* Per-user override (swarm-ui's `SettingsMenu` / `lib/theme-apply.ts` /* Per-user override (`SettingsMenu` and `settings/theme-apply.ts`
sets `data-theme` on `<html>`; unset/`"system"` removes the set `data-theme` on `<html>`; unset/`"system"` removes the
attribute and lets the media query above decide, same as before this attribute and lets the media query above decide, same as before this
existed). `:root[data-theme='light']` has higher specificity than existed). `:root[data-theme='light']` has higher specificity than
the plain `:root` inside the media query above (an attribute the plain `:root` inside the media query above (an attribute

View file

@ -49,8 +49,7 @@ export interface DropdownProps {
* reopens it instead of closing it"). Passing the same ref the * reopens it instead of closing it"). Passing the same ref the
* caller's wrapper div already needs for CSS positioning excludes * caller's wrapper div already needs for CSS positioning excludes
* clicks on the trigger from the outside-click check, matching how * clicks on the trigger from the outside-click check, matching how
* `MetaNav`'s own hand-rolled popover (which wraps trigger+popover in * a popover that wraps its trigger and popup in one ref avoids this.
* one ref) already avoids this.
*/ */
anchorRef?: RefObject<HTMLElement | null>; anchorRef?: RefObject<HTMLElement | null>;
} }

View file

@ -12,13 +12,8 @@
// lucide-style line icons, `currentColor` stroke so they pick up // lucide-style line icons, `currentColor` stroke so they pick up
// whatever text colour the surrounding `Badge`/button already has. // whatever text colour the surrounding `Badge`/button already has.
// //
// Originated in swarm-ui's `shell/SettingsMenu.tsx` (gear) and // Shared here so `SettingsMenu`, `LinksMenu` and the swarm UI's shell draw the
// `shell/LinksMenu.tsx` (link chain) as separate inline copies; moved // settings gear and the link chain from one place.
// here once the agent page's `MetaNav`/`SettingsMenu` needed the exact
// same icons too (mara: the settings trigger went back to a text glyph
// when `SettingsMenu` was extracted into `@hive/shared`, undoing this
// fix — restoring the SVG here, in the shared component this time,
// fixes it for both pages at once instead of just one).
import type { ComponentChildren } from "preact"; import type { ComponentChildren } from "preact";
export function GearIcon() { export function GearIcon() {

View file

@ -1,3 +0,0 @@
// Convenience re-export so consumers can `import { create, linkify }
// from '@hive/shared'` without naming the sub-module path.
export { create, linkify } from "./terminal/terminal.js";

View file

@ -3,8 +3,8 @@
// exact same key name for free via the browser's shared per-origin // exact same key name for free via the browser's shared per-origin
// storage, rather than an independent copy that could drift. // storage, rather than an independent copy that could drift.
// `ExpandDetailsSetting` / `HideDebugSetting` / `ShowThinkingSetting` (the // `ExpandDetailsSetting` / `HideDebugSetting` / `ShowThinkingSetting` (the
// settings popover rows of the per-agent page and of the swarm UI) are the only // settings popover rows of the swarm UI) are the only writers today; `Row.tsx`
// writers today; `Row.tsx` is the only reader of any of them. // and the swarm UI's `useHideDebug` read them.
const EXPAND_DETAILS_KEY = "hive-agent-expand-details"; const EXPAND_DETAILS_KEY = "hive-agent-expand-details";

View file

@ -1,7 +1,6 @@
// Settings-menu row: "hide developer details". Rendered as a `<SettingsMenu>` // Settings-menu row: "hide developer details". Rendered as a `<SettingsMenu>`
// child (`./SettingsMenu.js`) by each page that has a terminal, the // child (`./SettingsMenu.js`) by the swarm UI's shell, rather than as a prop on
// per-agent page and the swarm UI, rather than as a prop on the menu: the // the menu: the caller owns its row. The preference (`../prefs.js`) is the one
// caller owns its row. Both read the same preference (`../prefs.js`), which
// `../terminal/Row.tsx` follows as it changes — mara: "add a setting to not // `../terminal/Row.tsx` follows as it changes — mara: "add a setting to not
// display verbose output... like the grey colored debug stuff." // display verbose output... like the grey colored debug stuff."
import { useState } from "preact/hooks"; import { useState } from "preact/hooks";

View file

@ -1,8 +1,7 @@
/* <SettingsMenu> popover — matches `@hive/shared`'s `Dropdown` /* <SettingsMenu> popover — matches `@hive/shared`'s `Dropdown`
(`../dropdown/Dropdown.css`, `.ui-dropdown`) values exactly (`../dropdown/Dropdown.css`, `.ui-dropdown`) values exactly
(background/border/radius/shadow), same "reuse the values, not the (background/border/radius/shadow): the values are reused, not the
component" call `MetaNav` already made for its own component, because this popover holds `<select>` rows, not `Dropdown`'s
popover: this one holds `<select>` rows, not `Dropdown`'s
command-dispatch `<button>`s. Right-anchored — this trigger lives at command-dispatch `<button>`s. Right-anchored — this trigger lives at
the end of a header's icon-trigger cluster in every page that mounts the end of a header's icon-trigger cluster in every page that mounts
it, so a left anchor would push it off-screen. */ it, so a left anchor would push it off-screen. */

View file

@ -46,7 +46,7 @@ export interface SettingsMenuProps {
* shared component." A caller owns its row(s) entirely (state, * shared component." A caller owns its row(s) entirely (state,
* storage key, markup); this component never learns they exist. Use * storage key, markup); this component never learns they exist. Use
* `settings-menu-row` (this file's CSS) on each row's outer element * `settings-menu-row` (this file's CSS) on each row's outer element
* to match spacing/typography — see `Root.tsx` for a worked example. * to match spacing/typography — `HideDebugSetting` is a worked example.
*/ */
children?: ComponentChildren; children?: ComponentChildren;
} }

View file

@ -3,10 +3,8 @@
// value, react to it changing, write a new one") rather than each // value, react to it changing, write a new one") rather than each
// caller reinventing its own key handling. Not settings-page-specific: // caller reinventing its own key handling. Not settings-page-specific:
// any client-local preference reaches for `useLocalSetting` directly. // any client-local preference reaches for `useLocalSetting` directly.
// Originated in swarm-ui's own `lib/settings-storage.ts`; moved here // Lives in `@hive/shared` so every package that needs a stored setting uses
// once the per-agent page needed the identical mechanism (mara: "i // the one mechanism (see `SettingsMenu.tsx`'s file comment).
// think the component should be shared" — see `SettingsMenu.tsx`'s
// file comment for the full story).
// //
// `localStorage`'s own `storage` event only fires in *other* tabs, never // `localStorage`'s own `storage` event only fires in *other* tabs, never
// the tab that made the write — so two components in the same tab both // the tab that made the write — so two components in the same tab both

View file

@ -1,61 +0,0 @@
// hive-tab-strip.js — <hive-tab-strip>, the markup-owning tab-strip custom
// element behind sub-page tabbars. Owns
// rendering the <a class="hive-tab"> markup from a declarative `tabs` list
// instead of every page hand-writing the same <nav><a>...</a></nav>
// boilerplate, then wires the existing createTabStrip() behaviour
// (@hive/shared/tabs.js) over what it just rendered — no behaviour
// duplication, this is markup only.
//
// Light-DOM (no shadow root): the existing .hive-tabbar/.hive-tab/
// CSS (tabs.css) already targets plain classes
// on the tabbar/tab elements directly, and tab *panes* stay page-owned
// content this element never touches — no slotting/scoping need the way
// <hive-menu>/<hive-side-panel> have.
//
// Host keeps its own id/class/role (same as the <nav> it replaces, so
// existing CSS selectors + #id lookups keep matching); pass a `prefix`
// attribute (e.g. `prefix="logs"`). `configure({ tabs, defaultId, onShow })`
// then renders one <a> per tab —
// <a class="hive-tab" id="${prefix}-tab-${id}" href="#${id}" role="tab"
// aria-controls="${prefix}-pane-${id}" data-tab="${id}">${label}</a>
// — same id/aria-controls scheme the hand-written markup used, so each
// page's panes (aria-labelledby="${prefix}-tab-${id}") don't need to
// change. It then wires up createTabStrip() and returns exactly what it
// returns ({ show, active }) — every existing `.active()`/`.show(id)`
// call site keeps working unchanged. Call configure() exactly once per
// element (throws if called twice), mirroring the old call sites.
import { el } from "../dom.js";
import { createTabStrip } from "./tabs.js";
class HiveTabStrip extends HTMLElement {
configure({ tabs, defaultId, onShow }) {
if (this._api) {
throw new Error(
"hive-tab-strip: configure() called twice on the same element",
);
}
const prefix = this.getAttribute("prefix");
if (!prefix) {
throw new Error("hive-tab-strip: missing required `prefix` attribute");
}
for (const tab of tabs) {
const a = el(
"a",
{
class: "hive-tab",
id: `${prefix}-tab-${tab.id}`,
href: `#${tab.id}`,
role: "tab",
"aria-controls": `${prefix}-pane-${tab.id}`,
"data-tab": tab.id,
},
tab.label,
);
this.append(a);
}
this._api = createTabStrip(this, { defaultId, onShow });
return this._api;
}
}
customElements.define("hive-tab-strip", HiveTabStrip);

View file

@ -1,6 +1,5 @@
// Auto-linkify bare http(s) URLs in plain (non-markdown) row text — // Auto-linkify bare http(s) URLs in plain (non-markdown) row text —
// Preact-node port of ./terminal.js's `linkify` (text-node output there, // a Preact-node linkify: the same URL regex with trailing punctuation stripped,
// JSX fragment here). Same regex + trailing-punctuation strip;
// deliberately text-only, never innerHTML, so untrusted row text // deliberately text-only, never innerHTML, so untrusted row text
// (matrix-relayed bodies, tool args) can't inject markup this way. // (matrix-relayed bodies, tool args) can't inject markup this way.
import type { JSX } from "preact"; import type { JSX } from "preact";

View file

@ -132,7 +132,7 @@
grid-column: 1; grid-column: 1;
} }
/* Content column — explicit, not left to grid auto-placement. Rows /* Content column — explicit, not left to grid auto-placement. Rows
built with an icon (see terminal.js `row()` / Row.tsx) wrap their built with an icon (see Row.tsx) wrap their
actual content in `.row-content` (a markdown body just uses its own actual content in `.row-content` (a markdown body just uses its own
`.md` class, styled the same way below) specifically so an icon-less `.md` class, styled the same way below) specifically so an icon-less
row's lone remaining child still lands in column 2: without an row's lone remaining child still lands in column 2: without an
@ -186,69 +186,6 @@
text-shadow: 0 0 14px color-mix(in srgb, var(--amber) 95%, transparent); text-shadow: 0 0 14px color-mix(in srgb, var(--amber) 95%, transparent);
} }
} }
/* "↓ N new" pill: shown when new rows arrive while the operator is
scrolled up; click to jump to bottom. Positioned by the wrapper's
`position: relative` (terminal-wrap supplies it; pages that skip the
wrapper must add their own positioned ancestor). */
.tail-pill {
position: absolute;
right: 1em;
bottom: 4.2em;
background: var(--amber);
color: var(--crust);
font-family: inherit;
font-size: 0.8em;
font-weight: bold;
letter-spacing: 0.08em;
border: 0;
border-radius: 999px;
padding: 0.35em 0.9em;
cursor: pointer;
box-shadow: 0 0 14px -2px color-mix(in srgb, var(--amber) 85%, transparent);
opacity: 0;
transform: translateY(6px);
pointer-events: none;
transition:
opacity 160ms ease,
transform 160ms ease;
}
.tail-pill.visible {
opacity: 1;
transform: translateY(0);
pointer-events: auto;
}
.tail-pill:hover {
filter: brightness(1.1);
}
/* "↑ load older" pill: sits inline at the top of the log (not
absolutely positioned) so it scrolls with the content. Appears
when `has_more` is true after initial history load. */
.load-more-pill {
display: block;
width: 100%;
background: transparent;
color: var(--muted);
font-family: inherit;
font-size: 0.8em;
font-weight: bold;
letter-spacing: 0.08em;
border: 0;
border-bottom: 1px dashed var(--purple-dim);
padding: 0.4em 1em;
cursor: pointer;
text-align: left;
transition:
color 120ms ease,
background 120ms ease;
}
.load-more-pill:hover:not(:disabled) {
color: var(--fg);
background: var(--border);
}
.load-more-pill:disabled {
cursor: default;
opacity: 0.6;
}
/* Expandable rows don't grid themselves the way a flat row does — a /* Expandable rows don't grid themselves the way a flat row does — a
`<details>` needs its `<summary>` and `<pre>` body to stack normally `<details>` needs its `<summary>` and `<pre>` body to stack normally
(full row width each), not sit side by side in the row's own 2 (full row width each), not sit side by side in the row's own 2

View file

@ -1,629 +0,0 @@
// Shared terminal pane: sticky-bottom log + "↓ N new" pill + history
// backfill + live SSE. Pages provide a kind→renderer map; this module
// owns scroll behaviour, animation suppression on backfill, and the
// EventSource lifecycle.
//
// create(opts) — full options list + renderer api (api.row, api.details,
// api.detailsDiff, api.placeholder, api.fromHistory) + behavioral notes:
// docs/4-implementation/web-ui/shape.md §Shared terminal pane.
const NEAR_BOTTOM_PX = 48;
// Scroll distance from the top of the log that triggers an automatic
// "load older" fetch — fires via the scroll event handler so the operator
// never has to click the pill; the pill stays as a visual indicator.
const LOAD_MORE_SCROLL_PX = 80;
// Snap-to-bottom animation duration. See docs/4-implementation/web-ui/shape.md::Shared
// terminal pane (Sticky-bottom + snap animation) for the 140ms-vs-
// 500ms-browser-default + 24px short-circuit rationale.
const SCROLL_ANIM_MS = 140;
const SCROLL_SNAP_PX = 24;
export function create(opts) {
// `log` is `let` not `const` so loadMore() can temporarily redirect
// row/details/etc. into a detached temp element while prepending older
// history (restored before any scrollTop adjustments).
let log = opts.logEl;
if (!log) throw new Error("HiveTerminal.create: logEl is required");
const rootLog = log; // always the real DOM element — never reassigned
const renderers = opts.renderers || {};
const defaultRender =
renderers._default || ((ev, api) => api.row("note", JSON.stringify(ev)));
const pillAnchor = opts.pillAnchor || log.parentElement || log;
let placeholderEl = null;
let pill = null;
let unseen = 0;
let currentNoAnim = false;
// Pagination state for the "load older" feature.
let histMinId = null;
let histHasMore = false;
let histLoading = false;
let loadMoreBtn = null;
// Sticky-bottom intent. True means "keep snapping to bottom on
// any mutation"; false means "the operator scrolled up — leave
// them alone". Updated synchronously from the scroll event
// handler so both programmatic scrollTop assignments and
// operator-driven wheel/drag stay in sync.
let stickToBottom = true;
// Scroll-handler gate during in-flight snap animations — see
// docs/4-implementation/web-ui/shape.md::Shared terminal pane (Mid-animation scroll-event
// guard) for the eased-through-not-near-bottom rationale.
let smoothScrollingUntil = 0;
// rAF id for the current snap animation. Cancelled when a new
// snap starts so we never have two animations fighting over
// scrollTop.
let scrollAnimRaf = 0;
function isNearBottom() {
return (
log.scrollHeight - log.scrollTop - log.clientHeight <= NEAR_BOTTOM_PX
);
}
// Snap the log to the bottom with a brief eased animation. Cancels
// any in-flight frame loop so back-to-back snaps coalesce; falls
// back to instant scroll during `currentNoAnim` backfill replay
// or under SCROLL_SNAP_PX. See docs/4-implementation/web-ui/shape.md::Shared terminal pane.
function snapToBottom(immediate) {
stickToBottom = true;
if (scrollAnimRaf) {
cancelAnimationFrame(scrollAnimRaf);
scrollAnimRaf = 0;
}
const target = log.scrollHeight - log.clientHeight;
const start = log.scrollTop;
const distance = target - start;
if (immediate || currentNoAnim || distance <= SCROLL_SNAP_PX) {
smoothScrollingUntil = 0;
log.scrollTop = target;
return;
}
smoothScrollingUntil = Date.now() + SCROLL_ANIM_MS + 80;
const t0 = performance.now();
const easeOut = (t) => 1 - Math.pow(1 - t, 3);
const step = (now) => {
const elapsed = now - t0;
const frac = Math.min(1, elapsed / SCROLL_ANIM_MS);
// Re-read target each frame so mutations landing mid-animation
// (the common case — a renderer appended badge / body bits
// after api.row returned) extend the destination smoothly
// rather than landing short.
const currentTarget = log.scrollHeight - log.clientHeight;
log.scrollTop = start + (currentTarget - start) * easeOut(frac);
if (frac < 1) {
scrollAnimRaf = requestAnimationFrame(step);
} else {
// Final exact settle on the as-of-now bottom.
log.scrollTop = log.scrollHeight - log.clientHeight;
scrollAnimRaf = 0;
}
};
scrollAnimRaf = requestAnimationFrame(step);
}
function ensurePill() {
if (pill) return pill;
pill = document.createElement("button");
pill.type = "button";
pill.className = "tail-pill";
pill.addEventListener("click", () => snapToBottom());
pillAnchor.appendChild(pill);
return pill;
}
function updatePill() {
if (unseen <= 0) {
if (pill) pill.classList.remove("visible");
return;
}
ensurePill();
pill.textContent = "↓ " + unseen + " new";
pill.classList.add("visible");
}
log.addEventListener("scroll", () => {
// Sticky-bottom intent tracking. Outside an animation this is
// straightforward — stickToBottom = isNearBottom(). During a
// smooth-snap animation we swallow most of the event to avoid a
// feedback loop (programmatic scrollTop changes → scroll events →
// new snap → cancels current rAF), but we MUST still let the user
// break out of sticky mode: if the user scrolls away from the
// bottom while a snap animation is in flight, honour that intent
// immediately so the MutationObserver stops re-firing snapToBottom()
// and the animation-guard window can expire naturally. Without this,
// live events arriving < 220ms apart permanently block scroll-to-top
// and loadMore() never fires. See docs/4-implementation/web-ui/shape.md::Shared terminal
// pane (Mid-animation scroll-event guard).
const inAnim = Date.now() < smoothScrollingUntil;
const nearBottom = isNearBottom();
if (!inAnim) {
stickToBottom = nearBottom;
} else if (!nearBottom) {
// User scrolled up during an animation — break sticky mode so the
// MO stops calling snapToBottom() and the gate expires.
stickToBottom = false;
}
if (stickToBottom) {
unseen = 0;
updatePill();
}
if (inAnim) return;
// Auto-fetch older history when the user scrolls near the top — no
// click required; the load-more pill stays as a visual indicator.
if (
rootLog.scrollTop <= LOAD_MORE_SCROLL_PX &&
histHasMore &&
!histLoading
) {
loadMore();
}
});
// Post-append mutation snap — catches renderer mutations that land
// after `api.row` returns (badges, multi-line bodies, tool
// panes). See docs/4-implementation/web-ui/shape.md::Shared terminal pane (Post-append
// MutationObserver) for why the pre-append `afterAppend` hop
// alone isn't enough.
const mo = new MutationObserver(() => {
if (stickToBottom) snapToBottom();
});
mo.observe(log, { childList: true, subtree: true, characterData: true });
// Pre-append nearBottom snapshot drives the initial snap decision —
// see docs/4-implementation/web-ui/shape.md::Shared terminal pane (Post-append
// MutationObserver) for why we need both this and the MO.
function afterAppend(wasNearBottom) {
if (currentNoAnim || wasNearBottom) {
snapToBottom();
} else {
unseen += 1;
updatePill();
}
}
function clearPlaceholder() {
if (placeholderEl && placeholderEl.parentElement === log) {
log.removeChild(placeholderEl);
}
placeholderEl = null;
}
function placeholder(text) {
clearPlaceholder();
const e = document.createElement("div");
e.className = "row note";
e.appendChild(contentSpan(document.createTextNode(text)));
log.appendChild(e);
placeholderEl = e;
}
// A leading icon (`→ ← 🧠 🖥️ …`) goes in a fixed-width `.row-glyph`
// element so every row's icon lands in one column regardless of the
// glyph's rendered width (emoji vary; some carry variation selectors).
// Optional: callers that pass no `icon` keep the bare first-character
// prefix the older rows rely on.
function glyphSpan(icon) {
const g = document.createElement("span");
g.className = "row-glyph";
g.textContent = icon;
return g;
}
// Wraps a flat row's actual content (text/links, or the mutable-row
// text node) in a real element the row's own grid can place by class
// (`grid-column: 2` in terminal.css) — `linkify()` returns a
// `DocumentFragment`, which doesn't persist as a node once appended,
// so without this wrapper an icon-less row's content has no element of
// its own for the grid to target and would auto-place into the icon
// column instead (see terminal.css's own comment on why that matters).
function contentSpan(node) {
const c = document.createElement("span");
c.className = "row-content";
c.appendChild(node);
return c;
}
// Build a <summary> whose icon (if any) sits in the shared `.row-glyph`
// column and whose text lives in a `.summary-text` span — the disclosure
// caret (CSS `.summary-text::before`) then leads the text, not the icon,
// so the icon stays aligned with flat-row icons.
function buildSummary(summary, icon) {
const s = document.createElement("summary");
if (icon != null && icon !== "") s.appendChild(glyphSpan(icon));
const st = document.createElement("span");
st.className = "summary-text";
st.textContent = summary;
s.appendChild(st);
return s;
}
function row(cls, text, icon) {
clearPlaceholder();
const wasNearBottom = isNearBottom();
const e = document.createElement("div");
e.className = "row " + (cls || "") + (currentNoAnim ? " no-anim" : "");
if (icon != null && icon !== "") e.appendChild(glyphSpan(icon));
e.appendChild(contentSpan(linkify(text)));
log.appendChild(e);
afterAppend(wasNearBottom);
return e;
}
// Like row(), but returns [element, textNode] so the caller can update
// the text in place via textNode.nodeValue. Use for rows whose content
// changes after initial render (e.g. live-updating counters).
// Text is stored as a plain text node — no linkify, no innerHTML.
function mutableRow(cls, text, icon) {
clearPlaceholder();
const wasNearBottom = isNearBottom();
const e = document.createElement("div");
e.className = "row " + (cls || "") + (currentNoAnim ? " no-anim" : "");
if (icon != null && icon !== "") e.appendChild(glyphSpan(icon));
const tn = document.createTextNode(text == null ? "" : String(text));
e.appendChild(contentSpan(tn));
log.appendChild(e);
afterAppend(wasNearBottom);
return [e, tn];
}
// `opts.expandDetails` (boolean or zero-arg function returning one) lets
// the caller default every otherwise-collapsed `<details>` row open —
// e.g. an "expand panels by default" browser-local preference. Read
// live (not captured once) so a mid-session preference flip takes
// effect on the next row without recreating the terminal. Renderers
// that need a row open regardless (message-bearing tool_use/tool_result)
// already set `d.open = true` themselves after calling this — this only
// changes the *default* for panels that would otherwise start closed.
function wantsExpandedDefault() {
return typeof opts.expandDetails === "function"
? !!opts.expandDetails()
: !!opts.expandDetails;
}
function details(cls, summary, body, icon) {
clearPlaceholder();
const wasNearBottom = isNearBottom();
const d = document.createElement("details");
d.className = "row " + (cls || "") + (currentNoAnim ? " no-anim" : "");
if (wantsExpandedDefault()) d.open = true;
d.appendChild(buildSummary(summary, icon));
const pre = document.createElement("pre");
pre.className = "tool-body";
pre.appendChild(linkify(body));
d.appendChild(pre);
log.appendChild(d);
afterAppend(wasNearBottom);
return d;
}
function detailsDiff(cls, summary, body, icon) {
clearPlaceholder();
const wasNearBottom = isNearBottom();
const d = document.createElement("details");
d.className = "row " + (cls || "") + (currentNoAnim ? " no-anim" : "");
if (wantsExpandedDefault()) d.open = true;
d.appendChild(buildSummary(summary, icon));
const pre = document.createElement("pre");
pre.className = "tool-body diff-body";
for (const line of String(body).split("\n")) {
const span = document.createElement("span");
if (line.startsWith("+ ")) span.className = "diff-add";
else if (line.startsWith("- ")) span.className = "diff-del";
else span.className = "diff-ctx";
span.textContent = line + "\n";
pre.appendChild(span);
}
d.appendChild(pre);
log.appendChild(d);
afterAppend(wasNearBottom);
return d;
}
function api(extra) {
return Object.assign(
{
row,
mutableRow,
details,
detailsDiff,
placeholder,
linkify,
fromHistory: false,
},
extra || {},
);
}
function dispatch(ev, fromHistory) {
const r = renderers[ev.kind] || defaultRender;
try {
r(ev, api({ fromHistory }));
} catch (err) {
console.error("terminal renderer threw", ev, err);
row("note", "[render err] " + (err && err.message ? err.message : err));
}
if (opts.onAnyEvent) {
try {
opts.onAnyEvent(ev, { fromHistory });
} catch (err) {
console.error("onAnyEvent threw", err);
}
}
}
// ── Load-older machinery ───────────────────────────────────────
//
// When the initial backfill response includes `has_more: true`, a
// "↑ load older" button appears at the top of the log. Clicking it
// fetches the next page (`?before=<min_id>`) and prepends the events
// while holding the viewport steady so the operator's reading position
// doesn't jump.
function updateLoadMoreBtn() {
if (!histHasMore || !opts.historyUrl) {
if (loadMoreBtn && loadMoreBtn.parentElement) {
loadMoreBtn.parentElement.removeChild(loadMoreBtn);
}
loadMoreBtn = null;
return;
}
if (!loadMoreBtn) {
loadMoreBtn = document.createElement("button");
loadMoreBtn.type = "button";
loadMoreBtn.className = "load-more-pill";
loadMoreBtn.addEventListener("click", loadMore);
rootLog.prepend(loadMoreBtn);
}
loadMoreBtn.textContent = "↑ load older";
loadMoreBtn.disabled = false;
}
async function loadMore() {
if (!histHasMore || histLoading || !opts.historyUrl || histMinId === null)
return;
histLoading = true;
if (loadMoreBtn) {
loadMoreBtn.textContent = "↑ loading…";
loadMoreBtn.disabled = true;
}
try {
const sep = opts.historyUrl.includes("?") ? "&" : "?";
const url = opts.historyUrl + sep + "before=" + histMinId;
const resp = await fetch(url);
if (!resp.ok) {
updateLoadMoreBtn();
return;
}
const body = await resp.json();
const events = Array.isArray(body) ? body : body.events || [];
histHasMore = body.has_more || false;
if (typeof body.min_id === "number") histMinId = body.min_id;
// Resolve load-more button state before capturing the scroll
// baseline so that any button removal is already reflected in
// beforeH — otherwise the button's height would be missing from
// the delta and the viewport would drift up by that amount.
updateLoadMoreBtn();
if (events.length > 0) {
// Render into a detached element; `log` is temporarily redirected
// so that row/details/etc. append there instead of rootLog.
const tempEl = document.createElement("div");
log = tempEl;
currentNoAnim = true;
for (const ev of events) dispatch(ev, true);
currentNoAnim = false;
log = rootLog;
// Separator to mark the boundary between loaded-older and newer.
const sepEl = document.createElement("div");
sepEl.className = "row note no-anim";
sepEl.textContent = "─── older above ───";
tempEl.appendChild(sepEl);
// Insert before the "live" divider (i.e. right after the load-more
// button if present, else at the very top of rootLog).
const anchor = loadMoreBtn
? loadMoreBtn.nextSibling
: rootLog.firstChild;
const beforeH = rootLog.scrollHeight;
while (tempEl.firstChild)
rootLog.insertBefore(tempEl.firstChild, anchor);
// Compensate scroll so the viewport stays on the same content.
// overflow-anchor: none on .live ensures the browser does not
// also auto-adjust scrollTop (which would double the delta).
rootLog.scrollTop += rootLog.scrollHeight - beforeH;
}
} catch (err) {
console.warn("loadMore failed", err);
updateLoadMoreBtn();
} finally {
histLoading = false;
}
}
// Subscribe → buffer → fetch history → dedupe → apply.
//
// Race the SSE subscription opens before the history fetch starts.
// Live events that land before history resolves are buffered, not
// rendered. Once the history response (`{ seq, events }`) arrives we:
// 1. Replay `events` (fromHistory=true).
// 2. Drop buffered events with `seq <= history.seq` — they're
// already reflected in the history rows above.
// 3. Apply remaining buffered events (fromHistory=false).
// 4. Switch to live mode: each new SSE event dispatches immediately.
//
// Without this dance an event that fires between history-fetch and
// SSE-subscribe goes missing; without seq dedupe the same event
// shows twice (once via history, once via live buffer). Both bugs
// were latent before.
//
// If `historyUrl` is unset we skip the dance: buffered events apply
// as live the moment the buffer flushes (no dedupe possible without
// a boundary seq).
function start() {
let live = false;
let buffered = [];
// Optional streamFactory(url) → EventSource-shaped facade. Lets
// the dashboard hand the factory a SharedWorker-backed source so
// open hyperhive tabs share one upstream — see
// docs/4-implementation/web-ui/shape.md::Shared terminal pane (Backfill + SSE). Default
// falls back to `new EventSource(url)`.
const es = opts.streamFactory
? opts.streamFactory(opts.streamUrl)
: new EventSource(opts.streamUrl);
es.onmessage = (e) => {
let ev;
try {
ev = JSON.parse(e.data);
} catch (err) {
row("note", "[parse err] " + e.data);
return;
}
if (!live) {
buffered.push(ev);
return;
}
dispatch(ev, false);
if (opts.onLiveEvent) {
try {
opts.onLiveEvent(ev);
} catch (err) {
console.error("onLiveEvent threw", err);
}
}
};
es.onerror = () => {
// SharedWorker-backed facades expose `readyState` mirroring the
// upstream EventSource state; the native EventSource exposes the
// same. Either way the CONNECTING vs. closed distinction works.
if (es.readyState === 0 /* CONNECTING */) row("note", "[reconnecting…]");
else row("note", "[disconnected]");
};
es.onopen = () => {
// Fires on the initial connect and on every automatic
// reconnect. EventSource never replays events that fired
// during a disconnect window, so a consumer with
// snapshot-derived state (the dashboard's /api/state stores)
// must re-sync here or it shows stale state until a manual
// reload.
if (opts.onStreamOpen) {
try {
opts.onStreamOpen();
} catch (err) {
console.error("onStreamOpen threw", err);
}
}
};
function flushBuffered(boundarySeq, historyKinds) {
const drained = buffered;
buffered = [];
live = true;
for (const ev of drained) {
// Seq-dedupe only events of a kind that actually appeared in
// the history replay — those are the only ones that could
// double (once via history, once via the live buffer).
// Mutation events (container/transient/…) are never
// carried by the history endpoint; deduping them against the
// broker-history seq would wrongly drop ones that fired
// between a consumer's own snapshot read and this history
// fetch. ev.seq absent/0 → no dedupe possible.
if (
boundarySeq != null &&
typeof ev.seq === "number" &&
ev.seq <= boundarySeq &&
historyKinds &&
historyKinds.has(ev.kind)
) {
continue;
}
dispatch(ev, false);
if (opts.onLiveEvent) {
try {
opts.onLiveEvent(ev);
} catch (err) {
console.error("onLiveEvent threw", err);
}
}
}
}
async function backfill() {
if (!opts.historyUrl) {
flushBuffered(null);
if (opts.onBackfillDone) opts.onBackfillDone(0);
return;
}
try {
const resp = await fetch(opts.historyUrl);
if (!resp.ok) {
flushBuffered(null);
if (opts.onBackfillDone) opts.onBackfillDone(0);
return;
}
const body = await resp.json();
// Accept the envelope `{ seq, events, min_id?, has_more? }`.
// A bare array means the server hasn't been updated — treat it
// as "no dedupe possible, no pagination."
const events = Array.isArray(body) ? body : body.events || [];
const boundarySeq = Array.isArray(body) ? null : (body.seq ?? null);
// Pagination cursors — set on the outer load-more state.
if (!Array.isArray(body)) {
histHasMore = body.has_more || false;
if (typeof body.min_id === "number") histMinId = body.min_id;
}
// Kinds present in the history replay — the only kinds that
// can double and therefore the only ones to seq-dedupe.
const historyKinds = new Set(events.map((ev) => ev.kind));
currentNoAnim = true;
for (const ev of events) dispatch(ev, true);
currentNoAnim = false;
if (events.length) row("note", "─── live (older above) ───");
else placeholder("(connected — waiting for events)");
flushBuffered(boundarySeq, historyKinds);
// Show load-older button if the server reports more history.
updateLoadMoreBtn();
if (opts.onBackfillDone) opts.onBackfillDone(events.length);
} catch (err) {
console.warn("history backfill failed", err);
flushBuffered(null);
if (opts.onBackfillDone) opts.onBackfillDone(0);
}
}
return backfill();
}
const ready = start();
return { row, mutableRow, details, detailsDiff, placeholder, ready };
}
// Build a DocumentFragment from `text`, turning bare http(s) URLs into
// clickable links that open in a new tab. See docs/4-implementation/web-ui/shape.md::Shared
// terminal pane (linkify) for the text-node-only / no-innerHTML
// XSS-safety + trailing-punctuation strip.
const LINKIFY_URL_RE = /https?:\/\/[^\s<>"']+/g;
export function linkify(text) {
const str = text == null ? "" : String(text);
const frag = document.createDocumentFragment();
if (str.indexOf("://") === -1) {
// fast path: no URLs
if (str) frag.appendChild(document.createTextNode(str));
return frag;
}
let last = 0;
let m;
LINKIFY_URL_RE.lastIndex = 0;
while ((m = LINKIFY_URL_RE.exec(str)) !== null) {
let url = m[0];
// Don't swallow trailing punctuation that's really sentence text.
const trail = url.match(/[.,;:!?)\]}'"]+$/);
const tail = trail ? trail[0] : "";
if (tail) url = url.slice(0, -tail.length);
if (m.index > last) {
frag.appendChild(document.createTextNode(str.slice(last, m.index)));
}
if (!url.slice(url.indexOf("://") + 3)) {
// Nothing past the scheme — not a real URL, emit verbatim.
frag.appendChild(document.createTextNode(m[0]));
} else {
const a = document.createElement("a");
a.href = url; // regex only matches https?:// — safe
a.textContent = url;
a.target = "_blank";
a.rel = "noopener noreferrer";
frag.appendChild(a);
if (tail) frag.appendChild(document.createTextNode(tail));
}
last = m.index + m[0].length;
}
if (last < str.length) {
frag.appendChild(document.createTextNode(str.slice(last)));
}
return frag;
}

View file

@ -1,11 +1,11 @@
// <AgentDetail> — one agent's details: its status, wanted state, hive, config // <AgentDetail> — one agent's details: its status, wanted state, hive, config
// PR, inference settings, resource caps and linked accounts, plus the actions on // PR, inference settings, resource caps and linked accounts, plus the actions on
// them. Two layouts. In an opened card on `/agents` (`inCard`) the card header // them. Two layouts. In an opened card on `/agents` (`inCard`) the card header
// already shows status, message and wanted state, so the body is four folded // already shows status, message and wanted state, so the body is folded
// sections (`sections.ts`): overview, settings, accounts, and the terminal with // sections (`sections.ts`): status, terminal, open todos, subagents, background
// its subagents, each built when first opened. In the detail dialog on a terminal // tasks and settings, each built when first opened. In the details popover on a
// page it is one flat list with those three rows, and no terminal, since the // terminal page (`AgentDetailPopover`) it is the status and the settings only,
// page is already beside one. // since the page is already beside a terminal.
// //
// Takes the agent's *live* row and the shared `AgentActions`, so a state // Takes the agent's *live* row and the shared `AgentActions`, so a state
// change or a link made here shows wherever else the same row is drawn. // change or a link made here shows wherever else the same row is drawn.

View file

@ -1,5 +1,5 @@
// <AgentStateRow> — an agent's turn state, whether it is paused, and the // <AgentStateRow> — an agent's turn state, whether it is paused, and the
// tokens in its context and billed, as the details table's "state" row. The // tokens in its context, as the details table's "state" row. The
// terminal preview below the table carries no badges of its own (the full // terminal preview below the table carries no badges of its own (the full
// terminal tab does), so this is where the panel says what the agent is doing. // terminal tab does), so this is where the panel says what the agent is doing.
// Follows the agent's state stream, which announces on a change and once a // Follows the agent's state stream, which announces on a change and once a

View file

@ -1,7 +1,7 @@
// useAgentActions — what can be done to an agent from the swarm UI: declare // useAgentActions — what can be done to an agent from the swarm UI: declare
// its wanted state (up / offline / paused / destroyed) and link an account to // its wanted state (up / offline / paused / destroyed) and link an account to
// it, with the confirm and form dialogs those need. Shared by the agent // it, with the confirm and form dialogs those need. Shared by the agent
// roster (`AgentsPage`) and the detail dialog on a terminal page // roster (`AgentsPage`) and the details popover on a terminal page
// (`AgentDetailPopover`), so a state change reads the same from either; each // (`AgentDetailPopover`), so a state change reads the same from either; each
// caller renders the returned `dialogs` once. // caller renders the returned `dialogs` once.
// //

Some files were not shown because too many files have changed in this diff Show more