swarm ui: the agent card has a terminal icon beside the wanted menu
It opens the agent's terminal tab without opening the card.
This commit is contained in:
parent
0912e2ca06
commit
5b66a83112
1 changed files with 38 additions and 2 deletions
|
|
@ -6,17 +6,23 @@
|
|||
// shows the agent's status, message and wanted state, so the opened body is the
|
||||
// rest: `AgentDetail`'s folded sections (`inCard`).
|
||||
//
|
||||
// The terminal badge beside the wanted menu opens the agent's terminal tab, the
|
||||
// most common action, without opening the card.
|
||||
//
|
||||
// The `stopPropagation` wrappers around the login and `WantedMenu` controls
|
||||
// keep their own clicks (mouse or keyboard-synthesized, they host real
|
||||
// `<button>`s) from also toggling the card. The wanted menu carries the destroy
|
||||
// option here, since no detail row repeats it any more.
|
||||
import { useState } from "preact/hooks";
|
||||
import { Badge } from "@hive/shared/badge.js";
|
||||
import { TerminalIcon } from "@hive/shared/icons.js";
|
||||
import { Card } from "../../ui/card/Card.js";
|
||||
import { RelativeTime } from "../../ui/relative-time/RelativeTime.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 { termPaths } from "../terminal/AgentTermPreview.js";
|
||||
import { FRESHNESS, showsLoginNeeded, type AgentRow } from "../AgentTypes.js";
|
||||
import type { AgentActions } from "./AgentActions.js";
|
||||
import { WantedMenu } from "./WantedMenu.js";
|
||||
|
|
@ -34,6 +40,8 @@ export function AgentCard({
|
|||
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>
|
||||
<div
|
||||
|
|
@ -101,6 +109,12 @@ export function AgentCard({
|
|||
class="ui-agent-card-wanted"
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
>
|
||||
<Badge
|
||||
variant="quiet"
|
||||
value={<TerminalIcon />}
|
||||
title={`open ${row.name}'s terminal in its own tab`}
|
||||
onClick={() => openTab({ href: term.page, label: term.label })}
|
||||
/>
|
||||
<WantedMenu
|
||||
row={row}
|
||||
pending={actions.pendingAgents.has(row.name)}
|
||||
|
|
|
|||
Loading…
Reference in a new issue