Watch
0
0
Fork
You've already forked hyperhive
0
hyperhive/frontend/packages/swarm-ui/src/agent/AgentIcon.tsx
iris 91cf4d2ae1 icons for the swarm's own forge accounts, and a default agent icon
The builder, ci-metrics and review-classifier forge accounts get an avatar: an
icon each in a hexagonal frame, the hyperhive logo when one is missing. The
controller sets them with a short-lived write:user token it mints for the
account, since only an account can set its own avatar.

An agent with no icon of its own shows a default agent icon in the swarm UI, a
robot head in a round frame, instead of the dimmed hyperhive mark.
2026-11-15 17:14:16 +01:00

39 lines
1.1 KiB
TypeScript

// <AgentIcon> — the agent's icon from swarm-controller's
// `GET /api/agents/{name}/icon`: an agent with no icon (404) or an unreachable
// controller shows the default agent icon, dimmed, instead of a broken image.
// It is a robot head in a round frame, so it is not mistaken for a swarm
// service, whose icons sit in a hexagon.
// Always an `<img>`: the body is an agent-authored SVG, and only an image load
// keeps its script from running.
import { useState } from "preact/hooks";
import "./AgentIcon.css";
export function AgentIcon({
name,
small = false,
}: {
name: string;
/** Badge-sized, for beside a line of text, rather than the card's square. */
small?: boolean;
}) {
const [fallback, setFallback] = useState(false);
return (
<div
class={
"ui-agent-icon" +
(small ? " ui-agent-icon-small" : "") +
(fallback ? " ui-agent-icon-default" : "")
}
>
<img
alt=""
src={
fallback
? "/agent-default.svg"
: `/api/agents/${encodeURIComponent(name)}/icon`
}
onError={() => setFallback(true)}
/>
</div>
);
}