From c77904362db848d4177eee54a918a8e0ca7afaa2 Mon Sep 17 00:00:00 2001 From: iris Date: Sat, 28 Nov 2026 02:24:37 +0100 Subject: [PATCH] swarm-ui: an agent card is no longer a button around buttons The card row had role=button and tabindex=0 and held the terminal button, the wanted menu and the login button, which axe reports as nested interactive controls and which a screen reader can't walk. The row is no control now; the agent's name is a real button, so Tab, Enter and Space open the agent, and a press anywhere on the card still does. Picking stays one checkbox per card. --- docs/4-implementation/web-ui/swarm-ui.md | 2 +- .../swarm-ui/src/agent/roster/AgentCard.css | 24 +++++++++-- .../swarm-ui/src/agent/roster/AgentCard.tsx | 43 +++++++++++++------ .../swarm-ui/src/pages/agents/AgentsPage.tsx | 10 +++-- 4 files changed, 60 insertions(+), 19 deletions(-) diff --git a/docs/4-implementation/web-ui/swarm-ui.md b/docs/4-implementation/web-ui/swarm-ui.md index e4608b42d..d2f5215f0 100644 --- a/docs/4-implementation/web-ui/swarm-ui.md +++ b/docs/4-implementation/web-ui/swarm-ui.md @@ -140,7 +140,7 @@ paused, destroy), a **paused by hive** badge when the agent's own harness paused its turn loop (hover for the reason; set the agent **up** to resume it), and a **login needed** badge with a **log in** button when its claude has no session. -Select a card to open the agent's details. The address becomes `/agents/`, +Select a card to open the agent's details; from the keyboard, **Tab** to the agent's name and press **Enter** or **Space**. The address becomes `/agents/`, so a link or a reload lands on the same agent, and the browser's back and forward buttons walk through the selections. Until you select an agent the list takes the whole width, in the shell's 90em column. Selecting one narrows the diff --git a/frontend/packages/swarm-ui/src/agent/roster/AgentCard.css b/frontend/packages/swarm-ui/src/agent/roster/AgentCard.css index c4a4ce3f6..546d870dd 100644 --- a/frontend/packages/swarm-ui/src/agent/roster/AgentCard.css +++ b/frontend/packages/swarm-ui/src/agent/roster/AgentCard.css @@ -10,6 +10,22 @@ .ui-agent-card-name { font-weight: 600; } +/* The name is the keyboard's way into the card: a button with no box. The ring + is the card's (below), not its own. A click on it reaches the row's handler. */ +.ui-agent-card-name-button { + appearance: none; + padding: 0; + border: 0; + background: none; + color: inherit; + font: inherit; + font-weight: 600; + text-align: left; + cursor: pointer; +} +.ui-agent-card-name-button:focus-visible { + outline: none; +} /* Pushes the wanted-state control to the row's trailing edge regardless of how wide the status badge next to it ends up. */ .ui-agent-card-wanted { @@ -49,15 +65,17 @@ /* The header is what opens the agent's details: it reads as a control without a box. */ -.ui-agent-card-row[role="button"] { +.ui-agent-card-row[data-opens] { cursor: pointer; } /* The card's own row takes the clicks, so the card shows the hover and the keyboard focus the way a `Card` with a click handler does. */ -.ui-card:has(> .ui-agent-card-row[role="button"]:hover) { +.ui-card:has(> .ui-agent-card-row[data-opens]:hover) { border-color: var(--purple); } -.ui-card:has(> .ui-agent-card-row[role="button"]:focus-visible) { +.ui-card:has( + > .ui-agent-card-row[data-opens] .ui-agent-card-name-button:focus-visible +) { border-color: var(--purple); outline: 2px solid var(--purple); outline-offset: 2px; diff --git a/frontend/packages/swarm-ui/src/agent/roster/AgentCard.tsx b/frontend/packages/swarm-ui/src/agent/roster/AgentCard.tsx index 5450dbba4..8ec212132 100644 --- a/frontend/packages/swarm-ui/src/agent/roster/AgentCard.tsx +++ b/frontend/packages/swarm-ui/src/agent/roster/AgentCard.tsx @@ -74,22 +74,29 @@ export function AgentCard({ return ( { + if (e.target !== e.currentTarget) return; + if (e.key === "Enter" || e.key === " ") { + e.preventDefault(); + choose(); + } + }, + } + : { "data-opens": "" }), "data-agent": row.name, - "aria-checked": selecting ? select.picked : undefined, - "aria-current": !selecting && selected ? "true" : undefined, onClick: () => { if (!press.shouldIgnoreClick()) choose(); }, - onKeyDown: (e) => { - if (e.target !== e.currentTarget) return; - if (e.key === "Enter" || e.key === " ") { - e.preventDefault(); - choose(); - } - }, ...press.handlers, }} icon={ @@ -114,7 +121,19 @@ export function AgentCard({ ) : null} } - name={{row.name}} + name={ + selecting ? ( + {row.name} + ) : ( + + ) + } status={ <> {row.freshness !== "fresh" ? ( diff --git a/frontend/packages/swarm-ui/src/pages/agents/AgentsPage.tsx b/frontend/packages/swarm-ui/src/pages/agents/AgentsPage.tsx index a8e6954ec..a989aa7e1 100644 --- a/frontend/packages/swarm-ui/src/pages/agents/AgentsPage.tsx +++ b/frontend/packages/swarm-ui/src/pages/agents/AgentsPage.tsx @@ -125,9 +125,13 @@ export function AgentsPage() { if (was === null || selected !== null) return; const inPane = document.activeElement?.closest("[inert]") != null; if (inPane || document.activeElement === document.body) { - document - .querySelector(`[data-agent="${CSS.escape(was)}"]`) - ?.focus({ preventScroll: true }); + // The name is the card's tab stop; while picking, the row is. + const row = document.querySelector( + `[data-agent="${CSS.escape(was)}"]`, + ); + ( + row?.querySelector(".ui-agent-card-name-button") ?? row + )?.focus({ preventScroll: true }); } }, [selected]); // The PUT response is the hive's whole declaration set (every agent's