The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
feat(tui): dock live subagent roster above composer
Teknium2a908d762b24
diff --git a/ui-tui/src/__tests__/agentRoster.test.ts b/ui-tui/src/__tests__/agentRoster.test.tsnew file mode 100644index 00000000000..7e2e4170fb5--- /dev/null+++ b/ui-tui/src/__tests__/agentRoster.test.ts@@ -0,0 +1,25 @@+import { expect, it } from 'vitest'++import { $agentSnapshot, applyAgentSnapshot, mergeAgentRoster } from '../app/agentRoster.js'+import { shouldPassThroughToGlobalHandler } from '../components/textInput.js'++it('lets the agents shortcut leave the composer without stealing redo', () => {+ const key = { ctrl: true, shift: false, meta: false } as Parameters<typeof shouldPassThroughToGlobalHandler>[1]+ expect(shouldPassThroughToGlobalHandler('t', key)).toBe(true)+ expect(shouldPassThroughToGlobalHandler('y', key)).toBe(false)+})++it('merges one row per actual child and does not notify unchanged snapshots', () => {+ const data = {+ subagents: [{ subagent_id: 'child', delegation_id: 'batch', goal: 'inspect', started_at: 1 }],+ delegations: [{ delegation_id: 'batch', status: 'running', subagent_ids: ['child'] }]+ }++ applyAgentSnapshot('session', data)+ const previous = $agentSnapshot.get()+ applyAgentSnapshot('session', structuredClone(data))+ expect($agentSnapshot.get()).toBe(previous)+ expect(mergeAgentRoster([], data).map(s => s.id)).toEqual(['child'])+ applyAgentSnapshot('next')+ expect($agentSnapshot.get().data.subagents).toEqual([])+})diff --git a/ui-tui/src/__tests__/agentsDock.test.tsx b/ui-tui/src/__tests__/agentsDock.test.tsxnew file mode 100644index 00000000000..24208783a82--- /dev/null+++ b/ui-tui/src/__tests__/agentsDock.test.tsx@@ -0,0 +1,72 @@+import { PassThrough } from 'node:stream'++import { renderSync } from '@hermes/ink'+import React from 'react'+import stripAnsi from 'strip-ansi'+import { expect, it } from 'vitest'++import { AgentsPanelView } from '../components/agentsPanel.js'+import { buildAgentRows, dockRowLimit } from '../lib/agentRows.js'+import { DEFAULT_THEME } from '../theme.js'+import type { SubagentProgress } from '../types.js'++const agent = (id: string): SubagentProgress => ({+ id,+ goal: 'Investigate authentication handshake '.repeat(8),+ depth: 0,+ index: 0,+ parentId: null,+ notes: [],+ tools: ['read_file auth.ts'],+ thinking: [],+ toolCount: 1,+ taskCount: 1,+ startedAt: 1000,+ status: 'running'+})++it('bounds painted chrome by viewport while retaining true live count and activity', () => {+ const agents = Array.from({ length: 12 }, (_, i) => agent(`child-${i}`))++ for (const height of [14, 24, 40]) {+ const rows = buildAgentRows(agents, [], 45000, dockRowLimit(height))+ expect(rows.running).toBe(agents.length)+ expect(rows.hidden + rows.rows.length).toBe(agents.length)+ const stdout = Object.assign(new PassThrough(), { columns: 72, rows: height })+ const frames: string[] = []+ stdout.on('data', chunk => {+ frames.push(chunk.toString())+ })++ const view = renderSync(<AgentsPanelView cols={72} {...rows} t={DEFAULT_THEME} />, {+ stdout: stdout as unknown as NodeJS.WriteStream,+ stdin: new PassThrough() as NodeJS.ReadStream+ })++ view.unmount()+ view.cleanup()++ const lines = stripAnsi(frames.filter(frame => stripAnsi(frame).trim()).at(-1) ?? '')+ .trim()+ .split('\n')++ expect(lines.length).toBeLessThanOrEqual(dockRowLimit(height) * 2 + 1)+ expect(lines.join('\n')).toContain('12 live')+ expect(lines.join('\n')).toContain('read_file')+ }++ expect(dockRowLimit(14)).toBeLessThan(dockRowLimit(40))+})++it('deduplicates async batches and hides settled history without dropping live work', () => {+ const a = agent('child-1')++ const rows = buildAgentRows(+ [a, { ...agent('done'), status: 'completed' }],+ [{ delegation_id: 'batch', status: 'running', subagent_ids: [a.id] }],+ 50000+ )++ expect(rows.running).toBe(1)+ expect(rows.rows.map(row => row.key)).toEqual(['live:child-1'])+})diff --git a/ui-tui/src/app/agentRoster.ts b/ui-tui/src/app/agentRoster.tsnew file mode 100644index 00000000000..bbae805bb1a--- /dev/null+++ b/ui-tui/src/app/agentRoster.ts@@ -0,0 +1,73 @@+import { useStore } from '@nanostores/react'+import { atom } from 'nanostores'+import { useMemo } from 'react'++import type { SubagentListResponse } from '../gatewayTypes.js'+import type { SubagentProgress } from '../types.js'++import { useTurnSelector } from './turnStore.js'+import { $uiState } from './uiStore.js'++const EMPTY: SubagentListResponse = { subagents: [], delegations: [] }+export const $agentSnapshot = atom<{ sid: string | null; data: SubagentListResponse }>({ sid: null, data: EMPTY })++export function applyAgentSnapshot(sid: string | null, data: SubagentListResponse = EMPTY) {+ const previous = $agentSnapshot.get()++ if (previous.sid !== sid || JSON.stringify(previous.data) !== JSON.stringify(data)) {$agentSnapshot.set({ sid, data })}+}++export function mergeAgentRoster(events: SubagentProgress[], data: SubagentListResponse): SubagentProgress[] {+ const merged = new Map(events.map(s => [s.id, s]))++ for (const [index, s] of data.subagents.entries()) {+ const previous = merged.get(s.subagent_id)+ merged.set(s.subagent_id, {+ depth: s.depth ?? 0,+ index,+ parentId: s.parent_id ?? null,+ notes: [],+ thinking: [],+ taskCount: 1,+ ...previous,+ id: s.subagent_id,+ goal: s.goal || previous?.goal || 'Starting agent',+ delegationId: s.delegation_id ?? previous?.delegationId,+ model: s.model ?? previous?.model,+ startedAt: s.started_at != null ? s.started_at * 1000 : previous?.startedAt,+ status: s.status === 'queued' ? 'queued' : 'running',+ toolCount: s.tool_count ?? previous?.toolCount ?? 0,+ tools: previous?.tools.length ? previous.tools : s.current_tool ? [s.current_tool] : []+ })+ }++ for (const d of data.delegations) {+ if (!['running', 'finalizing', 'dispatched', 'queued'].includes(d.status ?? '')) {continue}++ if ([...merged.values()].some(s => s.delegationId === d.delegation_id || d.subagent_ids?.includes(s.id))) {continue}+ merged.set(d.delegation_id, {+ id: d.delegation_id,+ goal: d.goal || 'Starting delegation',+ depth: 0,+ index: merged.size,+ parentId: null,+ notes: [],+ thinking: [],+ tools: [],+ taskCount: 1,+ toolCount: 0,+ status: 'queued',+ startedAt: d.dispatched_at == null ? undefined : d.dispatched_at * 1000+ })+ }++ return [...merged.values()]+}++export function useAgentRoster() {+ const events = useTurnSelector(s => s.subagents)+ const snapshot = useStore($agentSnapshot)+ const { sid } = useStore($uiState)++ return useMemo(() => mergeAgentRoster(events, snapshot.sid === sid ? snapshot.data : EMPTY), [events, snapshot, sid])+}diff --git a/ui-tui/src/app/useInputHandlers.ts b/ui-tui/src/app/useInputHandlers.tsindex 222d50cdafe..0239befdb6a 100644--- a/ui-tui/src/app/useInputHandlers.ts+++ b/ui-tui/src/app/useInputHandlers.ts@@ -631,6 +631,10 @@ export function useInputHandlers(ctx: InputHandlerContext): InputHandlerResult {// typed to run the command. Works mid-stream: picking a model writes the// session model (config.set), which the next turn reads while the in-flight// turn keeps streaming.+ if (isCtrl(key, ch, 't')) {+ return patchOverlayState({ agents: true, agentsInitialHistoryIndex: 0 })+ }+if (isCtrl(key, ch, 'o')) {return patchOverlayState({ modelPicker: true })}diff --git a/ui-tui/src/app/useMainApp.ts b/ui-tui/src/app/useMainApp.tsindex 7d573826443..23aabe97626 100644--- a/ui-tui/src/app/useMainApp.ts+++ b/ui-tui/src/app/useMainApp.ts@@ -19,6 +19,7 @@ import { SECTION_NAMES, sectionMode } from '../domain/details.js'import { composeTabTitle, fmtProjectCwdBranch, shortCwd } from '../domain/paths.js'import { sessionScopedModelArg } from '../domain/slash.js'import { type GatewayClient } from '../gatewayClient.js'+import type { SubagentListResponse } from '../gatewayTypes.js'import type {ClarifyRespondResponse,ConfigSetResponse,@@ -46,6 +47,7 @@ import { estimatedMsgHeight, messageHeightKey } from '../lib/virtualHeights.js'import { onUserWidgets } from '../sdk/userWidgets.js'import type { Msg, PanelSection, SlashCatalog } from '../types.js'+import { applyAgentSnapshot } from './agentRoster.js'import { createGatewayEventHandler } from './createGatewayEventHandler.js'import { createSlashHandler } from './createSlashHandler.js'import { planGatewayRecovery } from './gatewayRecovery.js'@@ -590,8 +592,15 @@ export function useMainApp(gw: GatewayClient) {}let stopped = false+ applyAgentSnapshot(ui.sid)const refresh = () => {+ const sid = ui.sid+ gw.request<SubagentListResponse>('subagent.list', { session_id: sid }).then(raw => {+ const result = asRpcResult<SubagentListResponse>(raw)++ if (!stopped && result && getUiState().sid === sid) {applyAgentSnapshot(sid, result)}+ }).catch(() => {})gw.request<SessionActiveListResponse>('session.active_list', { current_session_id: getUiState().sid }).then(raw => {const result = asRpcResult<SessionActiveListResponse>(raw)diff --git a/ui-tui/src/components/agentsOverlay.tsx b/ui-tui/src/components/agentsOverlay.tsxindex cecfa0ef6ba..f35856d5578 100644--- a/ui-tui/src/components/agentsOverlay.tsx+++ b/ui-tui/src/components/agentsOverlay.tsx@@ -2,6 +2,7 @@ import { Box, NoSelect, ScrollBox, type ScrollBoxHandle, Text, useInput, useStdoimport { useStore } from '@nanostores/react'import { type ReactNode, useEffect, useMemo, useRef, useState } from 'react'+import { useAgentRoster } from '../app/agentRoster.js'import {$delegationState,$overlaySectionsOpen,@@ -10,7 +11,6 @@ import {} from '../app/delegationStore.js'import { patchOverlayState } from '../app/overlayStore.js'import { $spawnDiff, $spawnHistory, clearDiffPair, type SpawnSnapshot } from '../app/spawnHistoryStore.js'-import { useTurnSelector } from '../app/turnStore.js'import type { GatewayClient } from '../gatewayClient.js'import type { DelegationPauseResponse, DelegationStatusResponse, SubagentInterruptResponse } from '../gatewayTypes.js'import { asRpcResult } from '../lib/rpc.js'@@ -595,7 +595,7 @@ function DiffView({// ── Main overlay ─────────────────────────────────────────────────────export function AgentsOverlay({ gw, initialHistoryIndex = 0, onClose, t }: AgentsOverlayProps) {- const liveSubagents = useTurnSelector(state => state.subagents)+ const liveSubagents = useAgentRoster()const delegation = useStore($delegationState)const history = useStore($spawnHistory)const diffPair = useStore($spawnDiff)diff --git a/ui-tui/src/components/agentsPanel.tsx b/ui-tui/src/components/agentsPanel.tsxnew file mode 100644index 00000000000..a338925d19c--- /dev/null+++ b/ui-tui/src/components/agentsPanel.tsx@@ -0,0 +1,52 @@+import { Box, Text, useStdout } from '@hermes/ink'+import { useStore } from '@nanostores/react'+import { useEffect, useState } from 'react'++import { useAgentRoster } from '../app/agentRoster.js'+import { patchOverlayState } from '../app/overlayStore.js'+import { $uiState } from '../app/uiStore.js'+import { type AgentRows, buildAgentRows, dockRowLimit } from '../lib/agentRows.js'+import { statusGlyph } from '../lib/subagentGlyph.js'+import { fmtDuration } from '../lib/subagentTree.js'+import { compactPreview } from '../lib/text.js'+import type { Theme } from '../theme.js'++export function AgentsPanelView({ cols, hidden, rows, running, t }: AgentRows & { cols: number; t: Theme }) {+ if (!running) {return null}++ return (+ <Box flexDirection="column" flexShrink={0} width={cols}>+ <Text bold color={t.color.accent} onClick={() => patchOverlayState({ agents: true })} wrap="truncate-end">+ {`▾ ${running} live agents${hidden ? ` · +${hidden} more` : ''} · Ctrl+T expand`}+ </Text>+ {rows.map(row => (+ <Box flexDirection="column" key={row.key} onClick={() => patchOverlayState({ agents: true })}>+ <Text wrap="truncate-end">+ <Text color={statusGlyph(row.status, t).color}>{statusGlyph(row.status, t).glyph} </Text>+ <Text color={t.color.text}>{compactPreview(row.goal, Math.max(8, cols - 18))}</Text>+ <Text color={t.color.muted}> {row.elapsedSeconds == null ? '' : fmtDuration(row.elapsedSeconds)}</Text>+ </Text>+ <Text color={t.color.muted} wrap="truncate-end">{` ↳ ${compactPreview(row.detail, cols - 4)}`}</Text>+ </Box>+ ))}+ </Box>+ )+}++export function LiveAgentsPanel({ cols }: { cols: number }) {+ const { theme } = useStore($uiState)+ const { stdout } = useStdout()+ const subagents = useAgentRoster()+ const live = subagents.some(s => s.status === 'running' || s.status === 'queued')+ const [now, setNow] = useState(Date.now)+ useEffect(() => {+ if (!live) {return}+ const timer = setInterval(() => setNow(Date.now()), 1000)++ return () => clearInterval(timer)+ }, [live])++ return (+ <AgentsPanelView cols={cols} {...buildAgentRows(subagents, [], now, dockRowLimit(stdout?.rows ?? 24))} t={theme} />+ )+}diff --git a/ui-tui/src/components/appLayout.tsx b/ui-tui/src/components/appLayout.tsxindex 67e8ede2bf1..0bbe6c92bf9 100644--- a/ui-tui/src/components/appLayout.tsx+++ b/ui-tui/src/components/appLayout.tsx@@ -25,6 +25,7 @@ import { composerPromptText } from '../lib/prompt.js'import { ActiveWidgetSlot, AmbientDock, AmbientRail, useAmbientRailWidth } from '../sdk/host.js'import { AgentsOverlay } from './agentsOverlay.js'+import { LiveAgentsPanel } from './agentsPanel.js'import { GoodVibesHeart, StatusRule, StickyPromptTracker, TranscriptScrollbar } from './appChrome.js'import { FloatingOverlays, PromptZone } from './appOverlays.js'import { Banner, Panel, SessionPanel } from './branding.js'@@ -363,6 +364,7 @@ const ComposerPane = memo(function ComposerPane({<Box height={1} onMouseDown={captureInputDrag} onMouseDrag={dragFromSpacer} onMouseUp={endInputDrag} />)}+ <LiveAgentsPanel cols={Math.max(1, composer.cols - 2)} /><StatusRulePane at="top" composer={composer} status={status} /><AmbientDock placement="dock-top" />diff --git a/ui-tui/src/components/textInput.tsx b/ui-tui/src/components/textInput.tsxindex eb6e93ad952..65b9a45c8d6 100644--- a/ui-tui/src/components/textInput.tsx+++ b/ui-tui/src/components/textInput.tsx@@ -1834,6 +1834,7 @@ export const shouldPassThroughToGlobalHandler = ((key.ctrl && input === 'c') ||(key.ctrl && input === 'x') ||(key.ctrl && input === 'o') ||+ (key.ctrl && input === 't') ||key.tab ||(key.shift && key.tab) ||key.pageUp ||diff --git a/ui-tui/src/content/hotkeys.ts b/ui-tui/src/content/hotkeys.tsindex 37f21f6c134..13cc2628f14 100644--- a/ui-tui/src/content/hotkeys.ts+++ b/ui-tui/src/content/hotkeys.ts@@ -25,6 +25,7 @@ export const HOTKEYS: [string, string][] = [['Tab', 'apply completion'],['↑/↓', 'completions / queue edit / history'],['Ctrl+X', 'open live session switcher (deletes queued message while editing)'],+ ['Ctrl+T', 'expand live agents (keeps your draft)'],['Ctrl+O', 'open model picker (keeps your draft; applies to next turn mid-stream)'],[action + '+A/E', 'home / end of line'],[action + '+Z / ' + action + '+Y', 'undo / redo input edits'],diff --git a/ui-tui/src/gatewayTypes.ts b/ui-tui/src/gatewayTypes.tsindex 212bfbf8f11..7de5b462a47 100644--- a/ui-tui/src/gatewayTypes.ts+++ b/ui-tui/src/gatewayTypes.ts@@ -595,6 +595,33 @@ export interface DelegationPauseResponse {paused?: boolean}+export interface AsyncDelegationRecord {+ delegation_id: string+ goal?: string | null+ role?: string | null+ model?: string | null+ status?: string | null+ dispatched_at?: number | null+ completed_at?: number | null+ subagent_ids?: string[]+}++export interface SubagentListResponse {+ subagents: {+ subagent_id: string+ parent_id?: string | null+ delegation_id?: string | null+ depth?: number | null+ goal?: string | null+ model?: string | null+ started_at?: number | null+ status?: string | null+ tool_count?: number | null+ current_tool?: string | null+ }[]+ delegations: AsyncDelegationRecord[]+}+export interface SubagentInterruptResponse {found?: booleansubagent_id?: stringdiff --git a/ui-tui/src/lib/agentRows.ts b/ui-tui/src/lib/agentRows.tsnew file mode 100644index 00000000000..718769fb813--- /dev/null+++ b/ui-tui/src/lib/agentRows.ts@@ -0,0 +1,174 @@+import type { AsyncDelegationRecord } from '../gatewayTypes.js'+import type { SubagentProgress } from '../types.js'++// Pure merge + layout logic for the docked agents panel. Kept ink-free so it is+// unit testable on its own; agentsPanel.tsx owns only the presentation.++// One merged panel row — either a live in-turn subagent or a background+// async delegation, normalised to the same shape so the view stays dumb.+export interface AgentRow {+ detail: string+ elapsedSeconds: null | number+ goal: string+ /** Shortest unambiguous prefix of the agent id — the token the user types+ * back as `@<id> steer text`. Empty when the row carries no id. */+ id: string+ key: string+ name: string+ resultReady: boolean+ status: string+}++export interface AgentRows {+ done: number+ /** Rows that exist but were cut by the height bound, so the panel can say so+ * instead of silently lying about how many agents are in flight. */+ hidden: number+ rows: AgentRow[]+ running: number+}++/** Hard height bound for the docked panel. It sits between the transcript and+ * the composer as fixed chrome, so every row it paints is a row the transcript+ * loses forever — it is never allowed to grow with history. The full list+ * lives in the `/agents` overlay. */+export const PANEL_MAX_ROWS = 5++export const dockRowLimit = (height: number): number =>+ Math.max(1, Math.min(PANEL_MAX_ROWS, Math.floor((height - 10) / 6)))++/** Statuses that mean "this agent is still going" — the union of the live+ * subagent vocabulary and the async delegation one. */+const IN_FLIGHT = new Set(['dispatched', 'finalizing', 'queued', 'running'])++const RESULT_READY = new Set(['completed', 'done'])++/** Never abbreviate an id below this many characters — shorter prefixes are+ * too easy to typo into a different agent. */+const MIN_ID = 4++/** Shortest prefix of `id` that no other live id shares, floored at MIN_ID.+ * The panel prints this and `resolveSteerTargetId` accepts it, so what the user+ * reads is exactly what they can type back. */+export const shortAgentId = (id: string, all: readonly string[]): string => {+ for (let n = MIN_ID; n < id.length; n += 1) {+ const p = id.slice(0, n)++ if (!all.some(other => other !== id && other.startsWith(p))) {+ return p+ }+ }++ return id+}++// Live subagent elapsed: prefer a settled duration, else clock from startedAt+// while still running. Mirrors the overlay's displayElapsedSeconds.+const liveElapsed = (item: SubagentProgress, nowMs: number): null | number => {+ if (item.durationSeconds != null) {+ return item.durationSeconds+ }++ if (item.startedAt != null && IN_FLIGHT.has(item.status)) {+ return Math.max(0, (nowMs - item.startedAt) / 1000)+ }++ return null+}++/** Drop the batch rows whose own children are already on screen as live rows.+ *+ * A background fan-out is ONE registry record covering N children, but those+ * children also stream live subagent events, so the naive merge paints N+1+ * rows and counts N+1 agents for N agents. While the children are reporting+ * they are the better row (per-child goal, tool and elapsed, and each is+ * individually steerable by its own `@id`), so the batch row is suppressed.+ * Once they clear at the turn boundary — or when the batch finishes and the+ * `result ready ⏎` cue is the whole point — the batch row comes back. */+const dropCoveredBatches = (+ subagents: readonly SubagentProgress[],+ asyncDelegations: readonly AsyncDelegationRecord[]+): readonly AsyncDelegationRecord[] => {+ const live = new Set(subagents.filter(s => IN_FLIGHT.has(s.status)).map(s => s.id))++ if (live.size === 0) {+ return asyncDelegations+ }++ return asyncDelegations.filter(d => {+ const covered = IN_FLIGHT.has(d.status ?? 'running') && (d.subagent_ids ?? []).some(id => live.has(id))++ return !covered+ })+}++/** Merge live in-turn subagents with background async delegations into one+ * ordered, height-bounded row list. In-flight rows first (they carry the+ * freshest tool/elapsed signal), then recently finished rows newest-first. */+export const buildAgentRows = (+ subagents: SubagentProgress[],+ asyncDelegations: readonly AsyncDelegationRecord[],+ nowMs: number,+ maxRows: number = PANEL_MAX_ROWS+): AgentRows => {+ const delegations = dropCoveredBatches(subagents, asyncDelegations)+ const ids = [...subagents.map(s => s.id), ...delegations.map(d => d.delegation_id)]+ const active: AgentRow[] = []+ let running = 0+ let done = 0++ for (const s of subagents) {+ const row: AgentRow = {+ detail: s.notes.at(-1) || s.outputTail?.at(-1)?.preview || s.tools.at(-1) || 'Starting…',+ elapsedSeconds: liveElapsed(s, nowMs),+ goal: s.goal || 'agent',+ id: shortAgentId(s.id, ids),+ key: `live:${s.id}`,+ name: '',+ resultReady: false,+ status: s.status+ }++ if (IN_FLIGHT.has(s.status)) {+ running += 1+ active.push(row)+ } else {+ if (RESULT_READY.has(s.status)) {done += 1}+ }+ }++ for (const d of delegations) {+ const status = d.status ?? 'running'+ const inFlight = IN_FLIGHT.has(status)+ const resultReady = RESULT_READY.has(status)+ const endMs = !inFlight && d.completed_at != null ? d.completed_at * 1000 : nowMs+ const elapsedSeconds = d.dispatched_at != null ? Math.max(0, (endMs - d.dispatched_at * 1000) / 1000) : null++ const row: AgentRow = {+ detail: resultReady ? 'result ready' : status,+ elapsedSeconds,+ goal: d.goal ?? '',+ id: shortAgentId(d.delegation_id, ids),+ key: `async:${d.delegation_id}`,+ name: d.role ?? 'agent',+ resultReady,+ status+ }++ if (inFlight) {+ running += 1+ active.push(row)++ continue+ }++ if (resultReady) {+ done += 1+ }+ }++ const candidates = active+ const rows = maxRows > 0 ? candidates.slice(0, maxRows) : candidates++ return { done, hidden: candidates.length - rows.length, rows, running }+}diff --git a/ui-tui/src/lib/subagentGlyph.ts b/ui-tui/src/lib/subagentGlyph.tsnew file mode 100644index 00000000000..e9c0478346c--- /dev/null+++ b/ui-tui/src/lib/subagentGlyph.ts@@ -0,0 +1,42 @@+import type { Theme } from '../theme.js'+import type { SubagentProgress } from '../types.js'++// Shared status→glyph lookup for the subagent surfaces. Extracted so the+// docked agents panel and the full /agents overlay render identical glyphs+// and colours — a single source of truth prevents visual drift between them.++export type SubagentStatus = SubagentProgress['status']++/** Background async delegations carry their own lifecycle vocabulary+ * (`dispatched → running → finalizing → completed|error`, plus `rejected`+ * when the capacity gate refuses one). They render through the same table so+ * a background row never falls through to the unknown-status glyph. */+export type AgentStatus = 'cancelled' | 'dispatched' | 'finalizing' | 'rejected' | SubagentStatus++export const STATUS_GLYPH: Record<AgentStatus, { color: (t: Theme) => string; glyph: string }> = {+ running: { color: t => t.color.accent, glyph: '●' },+ queued: { color: t => t.color.muted, glyph: '○' },+ dispatched: { color: t => t.color.muted, glyph: '○' },+ finalizing: { color: t => t.color.accent, glyph: '◐' },+ completed: { color: t => t.color.statusGood, glyph: '✓' },+ interrupted: { color: t => t.color.warn, glyph: '■' },+ cancelled: { color: t => t.color.warn, glyph: '■' },+ rejected: { color: t => t.color.warn, glyph: '⊘' },+ failed: { color: t => t.color.error, glyph: '✗' },+ timeout: { color: t => t.color.warn, glyph: '⌛' },+ error: { color: t => t.color.error, glyph: '⚠' }+}++/** Neutral fallback for a status this build has never heard of (an older or+ * newer daemon on the other end of the socket). Deliberately not the `error`+ * glyph: an unknown status is not a failure, and painting it red made healthy+ * rows look broken. */+const UNKNOWN_GLYPH = { color: (t: Theme) => t.color.muted, glyph: '·' }++/** Resolve a status to its glyph + theme colour, with a defensive fallback for+ * cross-version snapshots carrying an unknown status. */+export const statusGlyph = (status: string, t: Theme): { color: string; glyph: string } => {+ const g = STATUS_GLYPH[status as AgentStatus] ?? UNKNOWN_GLYPH++ return { color: g.color(t), glyph: g.glyph }+}