# Delegation board

Pigeonholes for delegated work, one per subagent: its task slip, a lamp and a word for its status, and its progress. Finished work rises out of its cubby.

- Category: Agents
- Built from: Name tag
- Docs: https://bevel-ui.vercel.app/components/delegation-board
- Import from: `@/components/ui/delegation-board`

## Install

```bash
npx shadcn@latest add @bevel/delegation-board
```

npm dependencies (installed by the CLI): `@base-ui/react`, `cn`.

## Anatomy

```tsx
<DelegationBoard aria-label="Subagents">
  <DelegationSlot status="active">
    <DelegationAgent>
      <NameTag variant="plain">…</NameTag>
    </DelegationAgent>
    <DelegationTask />
    <DelegationProgress value={40} aria-label="Research progress" />
  </DelegationSlot>
</DelegationBoard>
```

## Parts

| Part | Renders | Description |
| --- | --- | --- |
| `DelegationBoard` | ul | The board. Give it an aria-label. |
| `DelegationSlot` | li | One subagent. status: pending, active, awaiting, error or complete, shown as a lamp and in words. |
| `DelegationAgent` | div | Who it is, with the status lamp. Holds a Name tag. |
| `DelegationTask` | div | The task slip. Rises out of the cubby when complete. |
| `DelegationProgress` | Progress | value and max; name it after the agent. |

## Example: A coordinator's subagents

Four agents working in parallel. Drafting stops to ask you a question; answer it to unblock Review.

```tsx
"use client"

import * as React from "react"
import {
  DelegationAgent,
  DelegationBoard,
  DelegationProgress,
  DelegationSlot,
  DelegationTask,
  type DelegationStatus,
} from "@/components/ui/delegation-board"
import { NameTag, NameTagName } from "@/components/ui/name-tag"

type Agent = { name: string; task: string; progress: number; status: DelegationStatus }

const start: Agent[] = [
  { name: "Research", task: "Find cases on notice by email", progress: 35, status: "active" },
  { name: "Drafting", task: "Redline clause 9.2", progress: 60, status: "active" },
  { name: "Review", task: "Check the redline against the playbook", progress: 0, status: "pending" },
  { name: "Citations", task: "Verify every authority cited", progress: 20, status: "active" },
]

/** A coordinator's subagents at work. Drafting stops to ask you something. */
export function DelegationBoardAgents() {
  const [agents, setAgents] = React.useState(start)

  React.useEffect(() => {
    const timer = setInterval(() => {
      setAgents((list) =>
        list.map((a) => {
          if (a.status !== "active") return a
          const progress = Math.min(100, a.progress + 8 + Math.round(Math.random() * 8))
          if (a.name === "Drafting" && progress >= 80) return { ...a, progress: 80, status: "awaiting" }
          return { ...a, progress, status: progress >= 100 ? "complete" : "active" }
        })
      )
    }, 900)
    return () => clearInterval(timer)
  }, [])

  const answer = () =>
    setAgents((list) =>
      list.map((a) =>
        a.name === "Drafting"
          ? { ...a, status: "active" }
          : a.name === "Review" && a.status === "pending"
            ? { ...a, status: "active" }
            : a
      )
    )

  return (
    <div className="flex w-full max-w-2xl flex-col items-center gap-4">
      <DelegationBoard aria-label="Subagents">
        {agents.map((a) => (
          <DelegationSlot key={a.name} status={a.status}>
            <DelegationAgent>
              <NameTag variant="plain">
                <NameTagName>{a.name}</NameTagName>
              </NameTag>
            </DelegationAgent>
            <DelegationTask>
              {a.status === "awaiting" ? "Should email count as written notice?" : a.task}
            </DelegationTask>
            <DelegationProgress value={a.progress} aria-label={`${a.name} progress`} />
          </DelegationSlot>
        ))}
      </DelegationBoard>
      <div className="flex gap-2">
        <button
          type="button"
          disabled={!agents.some((a) => a.status === "awaiting")}
          onClick={answer}
          className="h-9 rounded-md border px-3 text-sm font-medium hover:bg-muted focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none disabled:opacity-50"
        >
          Answer: no, written only
        </button>
        <button
          type="button"
          onClick={() => setAgents(start)}
          className="h-9 rounded-md border px-3 text-sm font-medium hover:bg-muted focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none"
        >
          Restart
        </button>
      </div>
    </div>
  )
}
```
