Watch
0
0
Fork
You've already forked hyperhive
0

swarm ui: landmarks, a skip link, a page heading, named repeated buttons and a log role on the terminal

The shell now has a main landmark that takes the focus when a page opens, a skip link as the first Tab stop, a labelled nav, aria-current on the active tab, and a hidden h1 with the page's name (no page drew one). The tab close button and tab link get a visible focus ring and a larger target. Repeated edit, remove, delete, fire now, pause, duplicate buttons and the icon-only terminal, expand and close badges get a name that says what they act on (Button gains ariaLabel). A badge can be pressed (aria-pressed), used for the internet modes and the SSH target form, whose fake tablist is now a labelled group. The terminal is a focusable role=log with live announcements off, and a latest badge scrolls back to the newest row once the operator has scrolled up and the terminal has stopped following.
This commit is contained in:
iris 2026-11-19 18:49:10 +01:00 • committed by mara
commit c9e6cd2e61
21 changed files with 218 additions and 17 deletions

View file

@ -153,6 +153,15 @@ the browser gives up on the stream, a **reconnect** badge opens it again. The
terminal's own tab keeps these badges, with the model, beside the agent's name;
the turn-state badge says how long the agent has been in that state.
The terminal is a `role="log"` that takes the keyboard focus, so the arrow keys
scroll it, and it doesn't announce new rows, since many can arrive in a second.
Once you scroll up it stops following the newest row, and a **latest** badge over
its bottom-right corner scrolls back and follows again.
The page around it has a skip link (**skip to content**, the first Tab stop), a
`<main>` landmark that takes the focus when a page opens, and a hidden `<h1>`
with the page's name. The active tab in the header carries `aria-current`.
The connection is a **light** on the agent's icon in the name badge: green when
the stream is live, amber while it connects or reconnects, red when it closes.
In the card's preview, which has no name badge, the light stands alone. The

View file

@ -78,6 +78,11 @@ export interface BadgeProps {
* is an icon and a number, say.
*/
ariaLabel?: string;
/**
* A badge that is one choice of a few: whether it is the chosen one, said to a
* screen reader (`aria-pressed`). Its look already says it, by fill.
*/
pressed?: boolean;
}
export function Badge({
@ -92,13 +97,17 @@ export function Badge({
class: extraClass,
title,
ariaLabel,
pressed,
}: BadgeProps) {
// `disabled` alone still means "button, just not clickable right
// now" — see the prop's own doc above for why this can't just check
// `onClick`. Both the branch below and the interactive-styling class
// key off this one derived flag, not off `onClick` separately, so
// they can no longer drift apart the way they used to.
const interactive = Boolean(onClick) || Boolean(disabled);
// A `pressed` badge is a toggle, so it is a button even when it is the one
// already chosen and has nothing to do on a click.
const interactive =
Boolean(onClick) || Boolean(disabled) || pressed !== undefined;
const classes = [
"ui-badge",
`ui-badge-${tone}`,
@ -127,6 +136,7 @@ export function Badge({
onClick={onClick}
disabled={disabled}
aria-expanded={expanded}
aria-pressed={pressed}
aria-label={ariaLabel}
title={title}
>

View file

@ -238,3 +238,25 @@ export function GripIcon() {
</svg>
);
}
// An arrow pointing down at a line, for "scroll to the end". Same size and
// stroke as `ExpandIcon`.
export function ArrowDownIcon() {
return (
<svg
width="1.3em"
height="1.3em"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
>
<line x1="12" y1="4" x2="12" y2="16" />
<polyline points="6 11 12 17 18 11" />
<line x1="5" y1="21" x2="19" y2="21" />
</svg>
);
}

View file

@ -336,6 +336,7 @@ export function AgentInference({ agent }: { agent: string }) {
<Badge
variant="quiet"
value="edit"
ariaLabel={`edit ${agent}'s inference settings`}
title={`set the swarm's model, effort, subagent models, subagent cap and context limits for ${agent}`}
onClick={() => setEditing(true)}
/>

View file

@ -46,6 +46,7 @@ export function AgentInstructions({ agent }: { agent: string }) {
<Badge
variant="quiet"
value="edit"
ariaLabel={`edit ${agent}'s AGENTS.md`}
title={`read and change ${agent}'s AGENTS.md`}
onClick={() => setEditing(true)}
/>

View file

@ -149,6 +149,7 @@ export function AgentLimits({ agent }: { agent: string }) {
<Badge
variant="quiet"
value="edit"
ariaLabel={`edit ${agent}'s resource caps`}
title={`set the swarm's CPU and memory caps for ${agent}`}
onClick={() => setEditing(true)}
/>

View file

@ -280,6 +280,7 @@ export function AgentInternet({ agent, g }: { agent: string; g: GrantState }) {
<Badge
variant={m === mode ? "default" : "quiet"}
tone={m === mode ? "accent" : "neutral"}
pressed={m === mode}
value={label}
title={`${meaning} for ${agent}`}
disabled={busy}

View file

@ -139,12 +139,13 @@ export function AgentSsh({ agent, g }: { agent: string; g: GrantState }) {
<code>&lt;user&gt;</code> replaced by the account it logs in as.
The key is the swarm's CA, a public value.
</p>
<div role="tablist" aria-label="target kind">
<div role="group" aria-label="target kind">
{TARGET_FORMS.map(([f, label]) => (
<Badge
key={f}
variant={f === form ? "default" : "quiet"}
tone={f === form ? "accent" : "neutral"}
pressed={f === form}
value={label}
onClick={() => setForm(f)}
/>

View file

@ -109,6 +109,7 @@ export function AllowedDomains({ agent }: { agent: string }) {
<Badge
variant="quiet"
value="remove"
ariaLabel={`remove ${e.domain}`}
title={`stop allowing ${e.domain} for ${
e.agent === undefined ? "every agent" : agent
}`}

View file

@ -173,6 +173,7 @@ export function LinkedAccounts({
<Badge
variant="quiet"
value="delete"
ariaLabel={`delete the ${accountKindLabel(a.kind)} account ${a.name}`}
title={`delete the ${accountKindLabel(a.kind)} account ${a.name}`}
onClick={() => openDelete(a)}
/>

View file

@ -115,6 +115,7 @@ export function AgentCard({
<Badge
variant="quiet"
value={<TerminalIcon />}
ariaLabel={`open ${row.name}'s terminal`}
title={`open ${row.name}'s terminal in its own tab`}
onClick={() => openTab({ href: term.page, label: term.label })}
/>

View file

@ -14,6 +14,18 @@
padding-block-end: 4.8em;
}
/* The way back to the newest row, over the terminal's bottom-right corner,
above the message box where there is one. */
.ui-agent-term-preview-latest {
position: absolute;
right: 1.8em;
bottom: 1em;
z-index: 1;
}
.ui-agent-term-preview-with-input .ui-agent-term-preview-latest {
bottom: 5.4em;
}
.ui-agent-term-preview-wrap.terminal-wrap {
max-height: 18em;
}

View file

@ -22,7 +22,7 @@
import { useLayoutEffect, useRef, useState } from "preact/hooks";
import type { ComponentChildren } from "preact";
import { Badge } from "@hive/shared/badge.js";
import { ExpandIcon } from "@hive/shared/icons.js";
import { ArrowDownIcon, ExpandIcon } from "@hive/shared/icons.js";
import { Row } from "@hive/shared/term-row.js";
import { useDynamicTabs } from "../../shell/useDynamicTabs.js";
import {
@ -146,7 +146,18 @@ export function AgentTermPreview({
<div class="ui-agent-term-preview-trailing">{trailing}</div>
)}
</div>
<div class="live terminal" ref={logRef} onScroll={handleScroll}>
{/* A log, so a screen reader knows what it is; `aria-live="off"` as
rows can arrive many a second, and the operator reads them on
demand. Focusable, so the arrow keys scroll it. */}
<div
class="live terminal"
role="log"
aria-live="off"
aria-label={`${paths.label} terminal`}
tabIndex={0}
ref={logRef}
onScroll={handleScroll}
>
{rows.length === 0 ? (
<div class="row note">
{/* Explicit `.row-content` wrapper, not a bare text child —
@ -168,6 +179,17 @@ export function AgentTermPreview({
rows.map((row) => <Row key={row.key} row={row} />)
)}
</div>
{/* Scrolled up, the terminal stops following: this is the way back. */}
{!stickToBottom && rows.length > 0 && (
<div class="ui-agent-term-preview-latest">
<Badge
icon={<ArrowDownIcon />}
value="latest"
title="scroll to the newest row and follow it again"
onClick={() => setStickToBottom(true)}
/>
</div>
)}
</div>
{subagent === undefined && <AgentInputForm agentName={agentName} />}
</div>

View file

@ -149,6 +149,7 @@ export function AgentGroupPage({
<>
<Badge
value={<ExpandIcon />}
ariaLabel={`open ${key}'s terminal on its own`}
title={`maximize: open ${key}'s terminal on its own`}
onClick={() =>
open({
@ -159,6 +160,7 @@ export function AgentGroupPage({
/>
<Badge
value={<CloseIcon />}
ariaLabel={`take ${key} out of this group`}
title={`close: take ${key} out of this group`}
onClick={() =>
groups.update(id, (r) => removeAgent(r, key) ?? r)

View file

@ -159,7 +159,10 @@ export function NotificationRouter() {
onChange={(checked) => setBuiltin(flow.id, checked)}
/>
<ActionRow class="notify-flow-actions">
<Button onClick={() => draftFrom(flow.id)}>
<Button
onClick={() => draftFrom(flow.id)}
ariaLabel={`duplicate to edit ${flow.name}`}
>
duplicate to edit
</Button>
</ActionRow>
@ -188,7 +191,12 @@ export function NotificationRouter() {
onChange={(checked) => setBuiltin(af.key, checked)}
/>
<ActionRow class="notify-flow-actions">
<Button onClick={() => draftFrom(af.key)}>duplicate</Button>
<Button
onClick={() => draftFrom(af.key)}
ariaLabel={`duplicate ${af.key}`}
>
duplicate
</Button>
</ActionRow>
</div>
<div class="notify-flow-agents">
@ -232,13 +240,19 @@ export function NotificationRouter() {
</span>
<ActionRow class="notify-flow-actions">
<Button
ariaLabel={`edit ${flow.name}`}
onClick={() =>
navigate(`/notifications/${encodeURIComponent(flow.id)}`)
}
>
edit
</Button>
<Button onClick={() => draftFrom(flow.id)}>duplicate</Button>
<Button
onClick={() => draftFrom(flow.id)}
ariaLabel={`duplicate ${flow.name}`}
>
duplicate
</Button>
</ActionRow>
</div>
<FlowGraph flow={flow} hits={hitsOf(shown, flow.id)} />

View file

@ -77,7 +77,11 @@ export function ScheduleCard({
)}
</div>
<ActionRow align="end" class="ui-schedule-card-actions">
<Button onClick={onEdit} disabled={pending}>
<Button
onClick={onEdit}
disabled={pending}
ariaLabel={`edit ${schedule.name}`}
>
edit
</Button>
<span
@ -89,14 +93,26 @@ export function ScheduleCard({
: "fires it now: its start moves to this moment, so it repeats from now on"
}
>
<Button onClick={onFireNow} disabled={pending || schedule.paused}>
<Button
onClick={onFireNow}
disabled={pending || schedule.paused}
ariaLabel={`fire now ${schedule.name}`}
>
fire now
</Button>
</span>
<Button onClick={onTogglePaused} disabled={pending}>
<Button
onClick={onTogglePaused}
disabled={pending}
ariaLabel={`${schedule.paused ? "resume" : "pause"} ${schedule.name}`}
>
{schedule.paused ? "resume" : "pause"}
</Button>
<Button onClick={onRemove} disabled={pending}>
<Button
onClick={onRemove}
disabled={pending}
ariaLabel={`remove ${schedule.name}`}
>
remove
</Button>
</ActionRow>

View file

@ -91,7 +91,11 @@ function DomainSection({
{swarmWide.map((e) => (
<li key={e.domain}>
<code>{e.domain}</code>
<Button disabled={busy} onClick={() => void remove(e)}>
<Button
disabled={busy}
ariaLabel={`remove ${e.domain}`}
onClick={() => void remove(e)}
>
remove
</Button>
</li>

View file

@ -262,10 +262,36 @@
all: unset;
cursor: pointer;
line-height: 1;
padding: 0.1em 0.3em;
padding: 0.25em 0.45em;
border-radius: 0.2em;
color: var(--muted);
}
/* `all: unset` drops the browser's focus ring, and so does the tab link's
own reset, so both draw one. */
.shell-tab-close:focus-visible,
.shell-tab-link:focus-visible {
outline: 2px solid var(--purple);
outline-offset: 2px;
}
/* A skip link, drawn only while it has the keyboard focus. */
.shell-skip-link {
position: absolute;
left: 0.5em;
top: -4em;
z-index: 100;
padding: 0.5em 1em;
border-radius: 0.3em;
background: var(--bg-elev);
color: var(--fg);
border: 1px solid var(--purple);
}
.shell-skip-link:focus {
top: 0.5em;
}
/* The page container takes the focus when a page opens, and is not a control. */
.shell-body:focus {
outline: none;
}
.shell-tab-close:hover {
color: var(--fg);
background: color-mix(in srgb, var(--fg) 10%, transparent);

View file

@ -120,7 +120,11 @@ function NavLink({
textRef: (el: HTMLSpanElement | null) => void;
}) {
return (
<Link href={href} className="shell-nav-link">
<Link
href={href}
className="shell-nav-link"
aria-current={active ? "page" : undefined}
>
{/* Touch target (min-height) lives on the <a> so the whole row is
tappable. The underline lives on the shared
`.shell-nav-indicator`, not here — this span is still what
@ -216,6 +220,7 @@ function DynamicTabLink({
<Link
href={href}
className="shell-tab-link"
aria-current={active ? "page" : undefined}
draggable={false}
title={onRename === undefined ? undefined : "double click to rename"}
onDblClick={
@ -249,6 +254,7 @@ export function Shell({ children }: { children: ComponentChildren }) {
const swarmName = useSwarmName();
const [location] = useLocation();
const navRef = useRef<HTMLElement | null>(null);
const mainRef = useRef<HTMLElement | null>(null);
const textRefs = useRef<Record<string, HTMLSpanElement | null>>({});
const [indicator, setIndicator] = useState<IndicatorRect | null>(null);
// The nav-item index the indicator is currently sitting at (or mid-hop
@ -409,6 +415,17 @@ export function Shell({ children }: { children: ComponentChildren }) {
document.title = pageLabel ? `${pageLabel} · ${brand}` : brand;
}, [brand, pageLabel]);
// A new page starts at the top for the keyboard and a screen reader: the
// focus goes to the page's container, not left on the link that was used.
const firstPage = useRef(true);
useEffect(() => {
if (firstPage.current) {
firstPage.current = false;
return;
}
mainRef.current?.focus({ preventScroll: true });
}, [location]);
// Same value the indicator itself is drawn with, including mid-sweep —
// the brand text rides the identical hop sequence rather than
// computing its own, so "the header's accent" reads as one thing
@ -417,6 +434,18 @@ export function Shell({ children }: { children: ComponentChildren }) {
return (
<div class={"shell" + (isFullBleedRoute(location) ? " shell-full" : "")}>
<a
class="shell-skip-link"
href="#main"
onClick={(e) => {
// A plain hash would hand the click to the router; move the focus
// here instead.
e.preventDefault();
mainRef.current?.focus();
}}
>
skip to content
</a>
<header class="shell-header">
<Link href="/" class="shell-brand-link">
<span
@ -434,7 +463,7 @@ export function Shell({ children }: { children: ComponentChildren }) {
{brand}
</span>
</Link>
<nav class="shell-nav" ref={navRef}>
<nav class="shell-nav" aria-label="main" ref={navRef}>
{navItems.map((item) => (
<NavLink
key={item.href}
@ -522,14 +551,23 @@ export function Shell({ children }: { children: ComponentChildren }) {
</header>
{/* Keyed by route so it remounts (and replays its entrance
animation) on every navigation — see the file-top comment. */}
<div
<main
id="main"
tabIndex={-1}
ref={mainRef}
class={
"shell-body" + (isFullBleedRoute(location) ? " shell-body-full" : "")
}
key={location}
>
{/* The page's name for a screen reader. Only the start page draws an
`<h1>` of its own (the swarm's name), so it gets no second one;
the document title is the only other place the name shows. */}
{location !== "/" && (
<h1 class="ui-visually-hidden">{pageLabel ?? brand}</h1>
)}
{children}
</div>
</main>
</div>
);
}

View file

@ -12,3 +12,16 @@
a {
color: var(--blue);
}
/* Text for a screen reader that is not drawn: the page's `<h1>`. */
.ui-visually-hidden {
position: absolute;
width: 1px;
height: 1px;
margin: -1px;
padding: 0;
overflow: hidden;
clip-path: inset(50%);
white-space: nowrap;
border: 0;
}

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