ChatSubagentCardComponent
ChatSubagentCardComponent is a composition that renders an expandable card for a subagent stream. It displays the subagent's name (or tool call ID), current status (with a color-coded badge) and message count, and expands to show the subagent's full transcript — every message rendered as streaming markdown, alongside any reasoning and the subagent's own tool-call cards.
The card is built on the <chat-trace> primitive, so it auto-expands while the subagent is running and collapses once it reaches complete (a user toggle always wins).
Selector: chat-subagent-card
Import:
#Basic Usage
#API
#Inputs
| Input | Type | Default | Description |
|---|---|---|---|
subagent | Subagent | Required | The subagent to display |
#Subagent
The Subagent type comes from @threadplane/chat. It provides reactive state for a subagent:
| Property | Type | Description |
|---|---|---|
toolCallId | string | The ID linking this subagent to its parent tool call |
name | string | undefined | Optional human-readable name. The card's "Subagent" label uses it when present |
status() | Signal<'pending' | 'running' | 'complete' | 'error'> | Current execution status |
messages() | Signal<Message[]> | Messages produced by the subagent |
toolCalls() | Signal<ToolCall[]> | undefined | The subagent's own tool calls (name/args/result), referenced by each message's toolCallIds. Optional — adapters that don't surface subagent tool calls omit it, and the card defaults to [] |
state() | Signal<Record<string, unknown>> | Arbitrary subagent state exposed by the runtime |
#Card Behavior
#Header
The card header (the <chat-trace> toggle button) shows:
- A chevron that reflects the expanded state
- The subagent
nameif present, otherwise the literal"Subagent", with thetoolCallIdin monospace - A color-coded status pill
- The message count (e.g., "3 message(s)")
#Auto-expand and collapse
Expansion is driven by <chat-trace>: the card auto-expands while status() is running and collapses when it settles to complete. Clicking the header toggles it manually, and a manual toggle overrides the automatic behavior.
#Transcript
When expanded, the card renders the subagent's entire message list (not just the latest). For each message it shows, in order:
- Any
reasoningtext, as a muted italic line - The message
content, rendered through<chat-streaming-md>(streaming markdown) - A
<chat-tool-call-card>for each tool call referenced by the message'stoolCallIds
#Status Pill Colors
The status pill is styled via a data-status attribute and CSS selectors (the exported statusColor() helper is retained for backward compatibility). Colors map to chat theme variables:
| Status | Background | Text Color |
|---|---|---|
pending | --ngaf-chat-surface-alt | --ngaf-chat-text-muted |
running | --ngaf-chat-warning-bg | --ngaf-chat-warning-text |
complete | (none) | --ngaf-chat-success |
error | --ngaf-chat-error-bg | --ngaf-chat-error-text |
#Using with ChatSubagentsComponent
The ChatSubagentsComponent primitive iterates over active subagent streams from an Agent. Combine it with ChatSubagentCardComponent:
#Full Example
#Styling
The card uses the following CSS custom properties:
| Variable | Applied To |
|---|---|
--ngaf-chat-text | Subagent name, message content |
--ngaf-chat-text-muted | Tool call ID, message count, reasoning line |
--ngaf-chat-font-mono | Tool call ID |
--ngaf-chat-separator | Divider between successive transcript messages |
--ngaf-chat-warning-bg / --ngaf-chat-warning-text | running status pill |
--ngaf-chat-success | complete status pill |
--ngaf-chat-error-bg / --ngaf-chat-error-text | error status pill |
The outer card chrome (background, border, radius) comes from the wrapping <chat-trace>.
#ARIA
- The header button (from
<chat-trace>) exposesaria-expandedreflecting the current state