swarm ui: agents page opens an agent's details beside the list
Selecting an agent card opens its details in a column on the right of the agents list, at /agents/<name>, instead of unfolding the card in place. The list is full width until an agent is selected, then narrows and the details slide in. A narrow screen shows the details alone, with a back button. A card's message is cut to one line. The shell treats /agents/<name> as the agents page, so the nav tab stays lit and the page is not rebuilt on each selection.
This commit is contained in:
parent
2d3da56907
commit
7bdaea7954
4 changed files with 494 additions and 154 deletions
|
|
@ -25,10 +25,13 @@
|
|||
align-items: center;
|
||||
gap: 0.4em;
|
||||
}
|
||||
/* One line, cut with an ellipsis: the whole message is in the card's tooltip
|
||||
and in the details beside the list. */
|
||||
.ui-agent-card-message {
|
||||
color: var(--muted);
|
||||
white-space: normal;
|
||||
word-break: break-word;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
/* Icon (`AgentIcon`) beside the name/message. */
|
||||
.ui-agent-card-row {
|
||||
|
|
@ -44,38 +47,18 @@
|
|||
min-width: 0;
|
||||
}
|
||||
|
||||
/* The header is what opens the card: it reads as a control without a box. */
|
||||
/* The header is what opens the agent's details: it reads as a control without
|
||||
a box. */
|
||||
.ui-agent-card-row[role="button"] {
|
||||
cursor: pointer;
|
||||
}
|
||||
/* The opened body, set off from the header by a rule. */
|
||||
.ui-agent-card-detail {
|
||||
margin-block-start: 0.75em;
|
||||
padding-block-start: 0.75em;
|
||||
border-block-start: 1px solid var(--border);
|
||||
/* 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) {
|
||||
border-color: var(--purple);
|
||||
}
|
||||
|
||||
/* The same chevron as a folded card's (`ui/disclosure/`): right while shut,
|
||||
down while open, so the header reads as something that unfolds. */
|
||||
.ui-agent-card-chevron {
|
||||
align-self: center;
|
||||
width: 0.55em;
|
||||
height: 0.55em;
|
||||
flex: none;
|
||||
border-right: 2px solid var(--muted);
|
||||
border-bottom: 2px solid var(--muted);
|
||||
transform: rotate(-45deg);
|
||||
transition: transform 0.15s ease;
|
||||
}
|
||||
/* The placeholder card keeps the chevron's box without its arrow. */
|
||||
.ui-agent-card-chevron-blank {
|
||||
border-color: transparent;
|
||||
}
|
||||
.ui-agent-card-row[aria-expanded="true"] .ui-agent-card-chevron {
|
||||
transform: rotate(45deg);
|
||||
}
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.ui-agent-card-chevron {
|
||||
transition: none;
|
||||
}
|
||||
.ui-card:has(> .ui-agent-card-row[role="button"]:focus-visible) {
|
||||
border-color: var(--purple);
|
||||
outline: 2px solid var(--purple);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,9 @@
|
|||
// <AgentCard> — one card per roster agent (mara: "main view: name,
|
||||
// status, message, wanted" / "message as second line" / "more like
|
||||
// card per agent"). The header is those four things; selecting it opens the
|
||||
// card in place into the agent's details (mara: "one column of expandable
|
||||
// cards"), so there is no second panel to select into. The header already
|
||||
// shows the agent's status, message and wanted state, so the opened body is the
|
||||
// rest: `AgentDetail`'s folded sections (`inCard`).
|
||||
// card per agent"). The header is those four things, with the message cut to one
|
||||
// line. Selecting the card opens the agent's details beside the list (`onOpen`,
|
||||
// which the page turns into `/agents/<name>`); the card of the open agent is
|
||||
// marked `selected`.
|
||||
//
|
||||
// The terminal badge beside the wanted menu opens the agent's terminal tab, the
|
||||
// most common action, without opening the card.
|
||||
|
|
@ -21,8 +20,8 @@ import { Card } from "../../ui/card/Card.js";
|
|||
import { useDynamicTabs } from "../../shell/useDynamicTabs.js";
|
||||
import { AgentIcon } from "../AgentIcon.js";
|
||||
import { ClaudeLoginDialog } from "../claude-login/ClaudeLoginDialog.js";
|
||||
import { AgentDetail } from "../detail/AgentDetail.js";
|
||||
import { StatusMessage } from "../detail/StatusMessage.js";
|
||||
import { statusText } from "../detail/status-fields.js";
|
||||
import { termPaths } from "../terminal/term-paths.js";
|
||||
import { RelativeTime } from "../../ui/relative-time/RelativeTime.js";
|
||||
import {
|
||||
|
|
@ -40,29 +39,34 @@ import "./AgentCard.css";
|
|||
export function AgentCard({
|
||||
row,
|
||||
actions,
|
||||
selected = false,
|
||||
onOpen,
|
||||
}: {
|
||||
row: AgentRow;
|
||||
actions: AgentActions;
|
||||
/** This agent's details are open beside the list. */
|
||||
selected?: boolean;
|
||||
/** Called when the card is chosen, to open the agent's details. */
|
||||
onOpen: () => void;
|
||||
}) {
|
||||
const [loggingIn, setLoggingIn] = useState(false);
|
||||
const [open, setOpen] = useState(false);
|
||||
const error = actions.actionErrors.get(row.name);
|
||||
const toggle = () => setOpen((was) => !was);
|
||||
const { open: openTab } = useDynamicTabs();
|
||||
const term = termPaths(row.name);
|
||||
return (
|
||||
<Card>
|
||||
<Card selected={selected}>
|
||||
<AgentCardLayout
|
||||
rowProps={{
|
||||
role: "button",
|
||||
tabIndex: 0,
|
||||
"aria-expanded": open,
|
||||
onClick: toggle,
|
||||
"data-agent": row.name,
|
||||
"aria-current": selected ? "true" : undefined,
|
||||
onClick: onOpen,
|
||||
onKeyDown: (e) => {
|
||||
if (e.target !== e.currentTarget) return;
|
||||
if (e.key === "Enter" || e.key === " ") {
|
||||
e.preventDefault();
|
||||
toggle();
|
||||
onOpen();
|
||||
}
|
||||
},
|
||||
}}
|
||||
|
|
@ -157,7 +161,7 @@ export function AgentCard({
|
|||
</span>
|
||||
}
|
||||
message={<StatusMessage snapshot={row.snapshot} />}
|
||||
chevron={<span class="ui-agent-card-chevron" aria-hidden="true" />}
|
||||
messageTitle={statusText(row.snapshot)}
|
||||
/>
|
||||
{error ? (
|
||||
<ApiErrorPanel
|
||||
|
|
@ -165,11 +169,6 @@ export function AgentCard({
|
|||
problem={error}
|
||||
/>
|
||||
) : null}
|
||||
{open ? (
|
||||
<div class="ui-agent-card-detail">
|
||||
<AgentDetail row={row} actions={actions} withTerminal inCard />
|
||||
</div>
|
||||
) : null}
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// <AgentCardLayout> — the arrangement of an agent card's header, with a slot
|
||||
// for each part: the icon, the name, the status (freshness and login badges),
|
||||
// the trailing controls, the message line and the chevron. `AgentCard` fills
|
||||
// the trailing controls and the message line. `AgentCard` fills
|
||||
// the slots with the real sub components; `AgentCardSkeleton` fills the same
|
||||
// slots with placeholder shapes, so the card that replaces it lands in the same
|
||||
// place.
|
||||
|
|
@ -13,7 +13,7 @@ export function AgentCardLayout({
|
|||
status,
|
||||
trailing,
|
||||
message,
|
||||
chevron,
|
||||
messageTitle,
|
||||
rowProps,
|
||||
}: {
|
||||
icon: ComponentChildren;
|
||||
|
|
@ -21,9 +21,10 @@ export function AgentCardLayout({
|
|||
status: ComponentChildren;
|
||||
trailing: ComponentChildren;
|
||||
message: ComponentChildren;
|
||||
chevron?: ComponentChildren;
|
||||
/** The whole message as a tooltip, for the line that cuts it short. */
|
||||
messageTitle?: string;
|
||||
/** Attributes of the header row, for the card that opens on a click. */
|
||||
rowProps?: HTMLAttributes<HTMLDivElement>;
|
||||
rowProps?: HTMLAttributes<HTMLDivElement> & { "data-agent"?: string };
|
||||
}) {
|
||||
return (
|
||||
<div class="ui-agent-card-row" {...rowProps}>
|
||||
|
|
@ -34,9 +35,10 @@ export function AgentCardLayout({
|
|||
{status}
|
||||
{trailing}
|
||||
</div>
|
||||
<div class="ui-agent-card-message">{message}</div>
|
||||
<div class="ui-agent-card-message" title={messageTitle}>
|
||||
{message}
|
||||
</div>
|
||||
</div>
|
||||
{chevron}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,14 +22,6 @@ export function AgentCardSkeleton() {
|
|||
</span>
|
||||
}
|
||||
message={<Skeleton width="55%" />}
|
||||
// The real chevron's box with no arrow, so the trailing controls end at
|
||||
// the same x.
|
||||
chevron={
|
||||
<span
|
||||
class="ui-agent-card-chevron ui-agent-card-chevron-blank"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
}
|
||||
/>
|
||||
</Card>
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in a new issue