diff --git a/packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx b/packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx index 5288a819b3c9..f6ece3a6caa7 100644 --- a/packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx +++ b/packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx @@ -102,6 +102,35 @@ export function Prompt(props: PromptProps) { const dialog = useDialog() const toast = useToast() const status = createMemo(() => sync.data.session_status?.[props.sessionID ?? ""] ?? { type: "idle" }) + const subagents = createMemo(() => { + if (!props.sessionID) return { total: 0, active: 0 } + const byParent = new Map() + for (const s of sync.data.session) { + if (!s.parentID) continue + const list = byParent.get(s.parentID) ?? [] + list.push(s) + byParent.set(s.parentID, list) + } + const descendants: (typeof sync.data.session)[number][] = [] + const queue = [props.sessionID] + const visited = new Set() + while (queue.length > 0) { + const pid = queue.pop()! + if (visited.has(pid)) continue + visited.add(pid) + const children = byParent.get(pid) + if (!children) continue + for (const c of children) { + descendants.push(c) + queue.push(c.id) + } + } + const active = descendants.filter((d) => { + const st = sync.data.session_status[d.id]?.type + return st === "busy" || st === "retry" + }).length + return { total: descendants.length, active } + }) const history = usePromptHistory() const stash = usePromptStash() const command = useCommandDialog() @@ -1398,6 +1427,12 @@ export function Prompt(props: PromptProps) { {keybind.print("command_list")} commands + 0}> + 0 ? theme.warning : theme.textMuted }}> + {subagents().active > 0 ? " ⚡" : " "} + {subagents().active}/{subagents().total} sub agents + +