<!-- Generated by scripts/gen-docs.mts from the JSDoc in registry/. Do not edit; run `pnpm run docs`. -->

# SubagentThread

A piece of work your agent handed to a helper agent, as a row in the conversation: who, what for, and where it stands, with what they are doing now while they run and what came of it once they finish, how many steps they took and for how long. Open thread opens everything they did in your `ThreadRail`, inside `ThreadLayout`, which gives focus back to the button when the thread closes. A helper waiting for the person says "Waiting for you"; put the `PermissionPrompt` or `PlanApproval` they wait on in their thread. Status is said in words, not only by colour, and a screen reader hears it with the row's name.

## Install

Once per app, with Tailwind CSS v4 and an `@/*` path alias (skip `init` in an existing shadcn app), then the component:

```sh
npx shadcn@latest init --base base --preset nova --yes --no-monorepo
npx shadcn@latest add ourostack/ouro-ui/ouro-base#v1.3.823
npx shadcn@latest add ourostack/ouro-ui/subagent-thread#v1.3.823
```

More: [Installing](https://ui.ouroboros.bot/docs/installing.md).

```tsx
import { SubagentThread } from "@/components/ouro/subagent-thread/subagent-thread";
```

## Example

```tsx
<ThreadLayout
  conversation={<SubagentThread name="Research helper" task="Find three weeknight dinners" status="running" latest="Reading recipes/roast.md" steps={4} duration={38} onOpen={() => setOpen(true)} open={open} />}
  thread={open ? <ThreadRail label="Research helper's thread" title="Research helper" onClose={() => setOpen(false)}>{calls}</ThreadRail> : null}
/>
```

## Use instead when

- Use `ToolCall` instead for one call to a tool, and `ToolCallGroup` for several in a row.
- Use `AgentPresence` instead for agents listening on the person's behalf outside a conversation.

## Props

Type: `SubagentThreadProps`.

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `className` | `string` |  | Layout only: margins, width (`mt-1`). Appearance classes warn in development. |
| `duration` | `number` |  | How long they have worked, in seconds, shown short: "1m 4s". |
| `latest` | `ReactNode` |  | What they are doing right now, shown while they run or wait: "Reading recipes/roast.md". |
| `name` (required) | `ReactNode` |  | Who the agent handed the work to, as the person knows them: "Research helper". |
| `onOpen` | `(() => void)` |  | Called when the person presses Open thread: open the helper's thread in your `ThreadRail` beside the conversation. The button shows only when you pass it. |
| `open` | `boolean` |  | Whether their thread is open now: the button is filled, and says so to a screen reader (`aria-expanded`). |
| `openLabel` | `string` | `"Open thread"` | The button's label. A screen reader hears it with the helper's name: "Open thread for Research helper". |
| `ref` | `Ref<HTMLElement>` |  | Reaches the rendered element. |
| `status` (required) | `"failed" \| "running" \| "done" \| "waiting"` |  | Where their work stands, as a ToolCall's does. `running` shows a spinner; `done` a tick; `failed` a cross and "Failed"; `waiting` (for the person, such as for their permission) a clock and "Waiting for you". |
| `steps` | `number` |  | How many steps they have taken so far, such as tool calls: "12 steps". |
| `summary` | `ReactNode` |  | What came of it, shown once they are done or have failed: "Found three weeknight dinners." |
| `task` (required) | `ReactNode` |  | What they were asked to do, in a few words: "Find three weeknight dinners". |

## Don't use

These are not props. Passing one fails the type check with the fix in the error, and in development a console message names the fix.

- `agent`: Not a prop. Who did the work is `name`: `<SubagentThread name="Research helper">`.
- `description`: Not a prop. What they were asked is `task`: `<SubagentThread task="Find three dinners">`.
- `onClick`: Not a prop. The button calls `onOpen`: `<SubagentThread onOpen={openThread}>`.
- `result`: Not a prop. What came of it is `summary`: `<SubagentThread summary="Found three">`.
- `state`: Not a prop. Where the work stands is `status`: `<SubagentThread status="running">`.
- `title`: Not a prop. What they were asked is `task`: `<SubagentThread task="Find three dinners">`.

## `className` is for layout only

Pass margins, width and grid placement (`mt-4`, `w-full`, `col-span-2`).

Appearance comes from props, not classes. In development, a class that sets appearance logs one warning per component instance, naming the prop to use instead. A class sets appearance when, after its variants (`hover:`, `sm:`) and any `!` are removed, it starts with `bg-`, `text-`, `border-`, `rounded-`, `shadow-`, `font-`, `ring-`, `from-`, `via-`, `to-`, `fill-` or `stroke-`, or is `border`, `rounded`, `shadow` or `ring`, or has a `dark:` variant. Text wrapping, overflow and table layout classes (`text-wrap`, `text-ellipsis`, `border-collapse`) are layout and do not warn.

Alignment classes (`text-center`) warn too: set alignment on a parent element.
