swarm UI: one request for every agent's linked accounts
GET /api/agents/linked-accounts returns one entry per agent that
/api/agents/status has a row for, as {hive, agent, accounts}, from one
store login. The agents page fetches it once (and again when a link dialog
closes) and hands each table row and the detail panel its agent's slice,
so the page makes no per-agent request. The per-agent route had no caller
left and is removed. The bao grant is unchanged: the same list on each
agent's matrix and forge metadata directories.
Refs #4855
This commit is contained in:
parent
4fd1380a5f
commit
7ccde4647b
1 changed files with 165 additions and 66 deletions
|
|
@ -33,7 +33,7 @@ import { LinkIcon } from "@hive/shared/icons.js";
|
|||
import { AgentCard } from "./AgentCard.js";
|
||||
import { AgentTermPreview } from "./AgentTermPreview.js";
|
||||
import { FRESHNESS, type AgentRow } from "./AgentTypes.js";
|
||||
import { LinkedAccounts } from "./LinkedAccounts.js";
|
||||
import { LinkedAccounts, useLinkedAccounts } from "./LinkedAccounts.js";
|
||||
import { Button } from "../../ui/button/Button.js";
|
||||
import { ConfirmDialog } from "../../ui/confirm-dialog/ConfirmDialog.js";
|
||||
import { Dialog } from "../../ui/dialog/Dialog.js";
|
||||
|
|
@ -159,9 +159,10 @@ export function AgentsPage() {
|
|||
const [matrixTarget, setMatrixTarget] = useState<AgentRow | null>(null);
|
||||
// The row showing the "link a forge account" dialog, same shape.
|
||||
const [forgeTarget, setForgeTarget] = useState<AgentRow | null>(null);
|
||||
// Bumped whenever a link dialog closes; every `LinkedAccounts` refetches
|
||||
// Bumped whenever a link dialog closes; `useLinkedAccounts` refetches
|
||||
// on a change, so a newly linked account shows without a reload.
|
||||
const [linkVersion, setLinkVersion] = useState(0);
|
||||
const linked = useLinkedAccounts(linkVersion);
|
||||
const linkClosed = () => setLinkVersion((v) => v + 1);
|
||||
const closeMatrix = () => {
|
||||
setMatrixTarget(null);
|
||||
|
|
@ -395,9 +396,8 @@ export function AgentsPage() {
|
|||
{a.hive ? (
|
||||
<LinkedAccounts
|
||||
key={`${a.hive}/${a.name}`}
|
||||
hive={a.hive}
|
||||
state={linked}
|
||||
agent={a.name}
|
||||
version={linkVersion}
|
||||
kinds={["matrix"]}
|
||||
/>
|
||||
) : null}
|
||||
|
|
@ -602,9 +602,8 @@ export function AgentsPage() {
|
|||
{detailTarget.hive ? (
|
||||
<LinkedAccounts
|
||||
key={`${detailTarget.hive}/${detailTarget.name}`}
|
||||
hive={detailTarget.hive}
|
||||
state={linked}
|
||||
agent={detailTarget.name}
|
||||
version={linkVersion}
|
||||
/>
|
||||
) : (
|
||||
"—"
|
||||
|
|
|
|||
Loading…
Reference in a new issue