Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.
Python agent-orchestrationai-agentai-coding-assistantclaude-codecoding-agentcomputer-usedesktop-applocal-firstmcppersonal-jarvisvoice-assistantvoice-coding
feat(threads): list a thread's sub-agents under it in the sidebar (#1100)
Ruben Lütked1859bc3166e
diff --git a/dodaios/ui/web/frontend/src/components/agentic/threads/ThreadTree.tsx b/dodaios/ui/web/frontend/src/components/agentic/threads/ThreadTree.tsxindex b1dc2ded09..ccb946bb47 100644--- a/dodaios/ui/web/frontend/src/components/agentic/threads/ThreadTree.tsx+++ b/dodaios/ui/web/frontend/src/components/agentic/threads/ThreadTree.tsx@@ -1,4 +1,4 @@-import { useEffect, useMemo, useRef, useState } from "react";+import { Fragment, useEffect, useMemo, useRef, useState } from "react";import { Archive, ArchiveRestore, Check, ChevronDown, ChevronRight, Folder, FolderOpen, Loader2, Mic, MoreHorizontal, Pencil, Plus, SquarePlus, Trash2, Users, X } from "lucide-react";import { AgentMark } from "@/components/agentic/AgentMark";import { patchAgentChatSession, type AgentChatSession } from "@/lib/agentChatApi";@@ -10,7 +10,9 @@ import { useEventStore } from "@/store/events";import { useIdeProjectsStore } from "@/store/ideProjects";import { TEAM_DRAFT, useIdeThreadsStore } from "@/store/ideThreads";import { useTeamThreads, type TeamThreadRow } from "@/lib/teamThreadsApi";+import { openSubagentOf, useThreadSubagentsStore } from "@/store/threadSubagents";import { ThreadMenuItem, ThreadMenuSeparator, ThreadPopover } from "./ThreadPopover";+import { SubagentFoldToggle, ThreadTreeSubagents } from "./ThreadTreeSubagents";import { arrangeThreads, moveThreadId, projectIdFor, shortAge, threadStatus, threadTitle, threadsByProject, useThreadChatStore, type ThreadStatus } from "./threadModel";const EXPANSION_KEY = "jarvis.ide.threadExpansion.v1";@@ -91,6 +93,11 @@ export function ThreadTree() {const [dropTarget, setDropTarget] = useState<{ sessionId: string; before: boolean } | null>(null);const [confirmDelete, setConfirmDelete] = useState<string | null>(null);const [busy, setBusy] = useState<string | null>(null);+ // Threads whose sub-agent rows the person folded away; open by default.+ const [subagentsFolded, setSubagentsFolded] = useState<Record<string, boolean>>({});+ const subagentsOwner = useThreadSubagentsStore((state) => state.sessionId);+ const subagentRows = useThreadSubagentsStore((state) => state.rows);+ const openSubagent = useThreadSubagentsStore((state) => openSubagentOf(state.open, selection.sessionId));const menuAnchor = useRef<HTMLElement | null>(null);useEffect(() => {@@ -250,7 +257,11 @@ export function ThreadTree() {</form>;}const dropHere = dropTarget?.sessionId === session.session_id ? dropTarget : null;- return <div key={session.session_id} data-testid={`thread-row-${session.session_id}`}+ // The open thread lists the sub-agents its coding agent spawned under it.+ const subRows = selected && subagentsOwner === session.session_id ? subagentRows : [];+ const subOpen = subRows.length > 0 && !subagentsFolded[session.session_id];+ const onSubagent = selected && openSubagent !== null && subRows.some((row) => row.id === openSubagent);+ return <Fragment key={session.session_id}><div data-testid={`thread-row-${session.session_id}`}draggableonDragStart={(event) => {event.dataTransfer.setData(THREAD_DRAG_MIME, session.session_id);@@ -284,7 +295,7 @@ export function ThreadTree() {}}className={cn("group/thread relative flex min-h-8 items-center rounded-md transition-colors hover:bg-muted",- (selected || menuOpen) && "bg-muted",+ ((selected && !onSubagent) || menuOpen) && "bg-muted",dragged?.sessionId === session.session_id && "opacity-40",dropHere?.before && "before:absolute before:-top-0.5 before:left-2 before:right-2 before:h-0.5 before:rounded-full before:bg-primary",dropHere && !dropHere.before && "after:absolute after:-bottom-0.5 after:left-2 after:right-2 after:h-0.5 after:rounded-full after:bg-primary",@@ -296,8 +307,14 @@ export function ThreadTree() {menuAnchor.current = event.currentTarget;setMenu({ sessionId: session.session_id, projectId: project.id });}}>- <button type="button" aria-current={selected ? "page" : undefined}- onClick={() => openThread(session.session_id, project.id)}+ {subRows.length > 0 && <SubagentFoldToggle open={subOpen} count={subRows.length} title={threadTitle(session)}+ onToggle={() => setSubagentsFolded((current) => ({ ...current, [session.session_id]: subOpen }))} />}+ <button type="button" aria-current={selected ? (onSubagent ? "true" : "page") : undefined}+ onClick={() => {+ // The thread's own row leads back from a sub-agent to the main conversation.+ useThreadSubagentsStore.getState().openAgent(session.session_id, null);+ openThread(session.session_id, project.id);+ }}onDoubleClick={() => setRenaming({ sessionId: session.session_id, title: threadTitle(session) })}onKeyDown={(event) => {if (!event.altKey || (event.key !== "ArrowUp" && event.key !== "ArrowDown")) return;@@ -335,7 +352,10 @@ export function ThreadTree() {<MoreHorizontal className="h-3.5 w-3.5" /></button></div>- </div>;+ </div>+ {subOpen && <ThreadTreeSubagents rows={subRows} openId={onSubagent ? openSubagent : null} threadTitle={threadTitle(session)}+ onOpen={(id) => useThreadSubagentsStore.getState().openAgent(session.session_id, id)} />}+ </Fragment>;})}{threads.length > FOLDED_COUNT && <button type="button"onClick={() => setShowAll((current) => ({ ...current, [project.id]: !current[project.id] }))}diff --git a/dodaios/ui/web/frontend/src/components/agentic/threads/ThreadTreeSubagents.test.tsx b/dodaios/ui/web/frontend/src/components/agentic/threads/ThreadTreeSubagents.test.tsxnew file mode 100644index 0000000000..939d866756--- /dev/null+++ b/dodaios/ui/web/frontend/src/components/agentic/threads/ThreadTreeSubagents.test.tsx@@ -0,0 +1,36 @@+import { cleanup, fireEvent, render, screen } from "@testing-library/react";+import { afterEach, describe, expect, it, vi } from "vitest";+import type { SubagentRow } from "@/store/threadSubagents";+import { ThreadTreeSubagents, visibleSubagentRows } from "./ThreadTreeSubagents";++const row = (id: string, over: Partial<SubagentRow> = {}): SubagentRow => ({+ id, parentId: null, depth: 0, title: `Agent ${id}`, agentType: "", status: "done", waiting: false, ...over,+});++afterEach(cleanup);++describe("sidebar sub-agent rows", () => {+ it("shows a short list whole", () => {+ const rows = Array.from({ length: 7 }, (_, index) => row(`a${index}`));+ expect(visibleSubagentRows(rows, null, false)).toHaveLength(7);+ });++ it("folds a long list but keeps working, waiting and open sub-agents in view", () => {+ const rows = Array.from({ length: 12 }, (_, index) => row(`a${index}`));+ rows[9] = row("a9", { status: "running" });+ rows[10] = row("a10", { status: "running", waiting: true });+ const shown = visibleSubagentRows(rows, "a11", false).map((entry) => entry.id);+ expect(shown).toEqual(["a0", "a1", "a2", "a3", "a4", "a5", "a9", "a10", "a11"]);+ });++ it("opens a sub-agent on click and unfolds a long list on request", () => {+ const rows = Array.from({ length: 10 }, (_, index) => row(`a${index}`));+ const onOpen = vi.fn();+ render(<ThreadTreeSubagents rows={rows} openId={null} threadTitle="Fix login" onOpen={onOpen} />);+ expect(screen.getAllByTestId("thread-tree-subagent")).toHaveLength(6);+ fireEvent.click(screen.getByRole("button", { name: /4 more/ }));+ expect(screen.getAllByTestId("thread-tree-subagent")).toHaveLength(10);+ fireEvent.click(screen.getByText("Agent a7"));+ expect(onOpen).toHaveBeenCalledWith("a7");+ });+});diff --git a/dodaios/ui/web/frontend/src/components/agentic/threads/ThreadTreeSubagents.tsx b/dodaios/ui/web/frontend/src/components/agentic/threads/ThreadTreeSubagents.tsxnew file mode 100644index 0000000000..1669d0329b--- /dev/null+++ b/dodaios/ui/web/frontend/src/components/agentic/threads/ThreadTreeSubagents.tsx@@ -0,0 +1,77 @@+import { useState } from "react";+import { ChevronDown, ChevronRight } from "lucide-react";+import { cn } from "@/lib/utils";+import { fill, useT } from "@/i18n";+import type { SubagentRow } from "@/store/threadSubagents";+import { SubagentMark } from "./ThreadSubagents";++/**+ * The open thread's sub-agents in the sidebar, listed under the thread as+ * threads of their own: each one's state at a glance, nested ones indented+ * under the sub-agent that spawned them, and a click opens its conversation.+ */++/** Rows a long list shows before "Show more"; working and waiting ones always show. */+const FOLDED_ROWS = 6;+/** How far each level of nesting moves in, in pixels. */+const INDENT = 14;+/** Deepest level drawn further in; deeper ones line up with it. */+const MAX_DEPTH = 3;++/** The few rows a long list shows: the first ones, plus every one still working, waiting or open. */+export function visibleSubagentRows(rows: readonly SubagentRow[], openId: string | null, all: boolean): SubagentRow[] {+ if (all || rows.length <= FOLDED_ROWS + 1) return [...rows];+ return rows.filter((row, index) => index < FOLDED_ROWS || row.status === "running" || row.waiting || row.id === openId);+}++/** The twisty at the start of a thread row that has sub-agents: folds them away or back. */+export function SubagentFoldToggle({ open, count, title, onToggle }: { open: boolean; count: number; title: string; onToggle: () => void }) {+ const t = useT();+ const label = fill(t(open ? "ide_threads.hide_subagents" : "ide_threads.show_subagents"), { count, title });+ return <button type="button" aria-expanded={open} aria-label={label} title={label} onClick={onToggle}+ data-testid="thread-subagents-fold"+ className="absolute left-2 top-1/2 z-10 flex h-5 w-5 -translate-y-1/2 items-center justify-center rounded text-muted-foreground/80 transition-colors hover:bg-background/70 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring">+ {open ? <ChevronDown aria-hidden className="h-3.5 w-3.5" /> : <ChevronRight aria-hidden className="h-3.5 w-3.5" />}+ </button>;+}++export function ThreadTreeSubagents({ rows, openId, threadTitle, onOpen }: {+ rows: readonly SubagentRow[];+ openId: string | null;+ threadTitle: string;+ onOpen: (id: string) => void;+}) {+ const t = useT();+ const [all, setAll] = useState(false);+ if (rows.length === 0) return null;+ const shown = visibleSubagentRows(rows, openId, all);+ const hidden = rows.length - shown.length;+ return <div role="group" aria-label={fill(t("ide_threads.subagents_of"), { title: threadTitle })} data-testid="thread-tree-subagents"+ className="relative mb-0.5 flex flex-col gap-px before:absolute before:bottom-1.5 before:left-[19px] before:top-0.5 before:w-px before:rounded-full before:bg-border">+ {shown.map((row) => {+ const selected = row.id === openId;+ const depth = Math.min(row.depth, MAX_DEPTH);+ const running = row.status === "running";+ return <button key={row.id} type="button" aria-current={selected ? "page" : undefined}+ onClick={() => onOpen(row.id)} title={row.agentType ? `${row.title} · ${row.agentType}` : row.title}+ data-testid="thread-tree-subagent" data-status={row.status}+ style={{ paddingLeft: 32 + depth * INDENT }}+ className={cn(+ "group/sub relative flex min-h-7 min-w-0 items-center gap-2 rounded-md py-0.5 pr-2 text-left text-[13px] transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",+ selected ? "bg-muted text-foreground-strong" : "text-foreground-secondary",+ )}>+ {depth > 0 && <span aria-hidden style={{ left: 32 + (depth - 1) * INDENT + 6 }}+ className="pointer-events-none absolute top-0 h-1/2 w-2 rounded-bl-md border-b border-l border-border" />}+ <SubagentMark status={row.status} waiting={row.waiting} />+ {/* The sidebar is narrow: the name gets the room, the agent type is in the tooltip. */}+ <span className={cn("min-w-0 flex-1 truncate", running && !row.waiting && !selected && "live-tool-shine")}>{row.title}</span>+ </button>;+ })}+ {hidden > 0 || (all && rows.length > FOLDED_ROWS + 1)+ ?<button type="button" onClick={() => setAll(!all)}+ className="flex min-h-6 items-center rounded-md pl-8 text-left text-[12px] text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring">+ {all ? t("ide_threads.show_less") : fill(t("ide_threads.show_more"), { count: hidden })}+ </button>+ : null}+ </div>;+}diff --git a/dodaios/ui/web/frontend/src/components/agentic/threads/ThreadView.test.tsx b/dodaios/ui/web/frontend/src/components/agentic/threads/ThreadView.test.tsxindex 8e4b09c9a3..0ebf4588ad 100644--- a/dodaios/ui/web/frontend/src/components/agentic/threads/ThreadView.test.tsx+++ b/dodaios/ui/web/frontend/src/components/agentic/threads/ThreadView.test.tsx@@ -5,6 +5,7 @@ import type { AgentChatCatalog, AgentChatSession } from "@/lib/agentChatApi";import type { IdeProject } from "@/lib/agenticIdeApi";import { useIdeProjectsStore } from "@/store/ideProjects";import { useIdeThreadsStore } from "@/store/ideThreads";+import { useThreadSubagentsStore } from "@/store/threadSubagents";const api = vi.hoisted(() => ({fetchAgentChatCatalog: vi.fn(),@@ -80,6 +81,7 @@ beforeEach(() => {useIdeProjectsStore.setState({ projects: [project], activeWorkspaceId: null });useIdeThreadsStore.setState({ layout: "threads", selection: { projectId: "p1", sessionId: null }, projectOf: {}, seen: {}, archived: {}, order: {}, focusNonce: 0 });useThreadChatStore.getState().newChat();+ useThreadSubagentsStore.setState({ sessionId: null, rows: [], open: null });});afterEach(() => {@@ -229,6 +231,48 @@ describe("ThreadTree", () => {}});+ it("lists the open thread's sub-agents under it as threads that open, nest and fold", async () => {+ api.fetchAgentChatSessions.mockResolvedValue([sessionRow({ cli_title: "Fix login test" })]);+ useIdeThreadsStore.setState({ selection: { projectId: "p1", sessionId: "s1" } });+ useThreadSubagentsStore.setState({ open: null });+ useThreadSubagentsStore.getState().publish("s1", [+ { id: "a1", parentId: null, depth: 0, title: "Explore the auth code", agentType: "Explore", status: "running", waiting: false },+ { id: "a2", parentId: "a1", depth: 1, title: "Read the tests", agentType: "", status: "done", waiting: false },+ ]);+ render(<ThreadTree />);+ await waitFor(() => expect(screen.getByText("Fix login test")).toBeTruthy());+ const rows = screen.getAllByTestId("thread-tree-subagent");+ expect(rows.map((row) => row.textContent)).toEqual(["Explore the auth code", "Read the tests"]);+ expect(rows.map((row) => row.getAttribute("data-status"))).toEqual(["running", "done"]);+ expect(rows[1].style.paddingLeft).toBe("46px");++ fireEvent.click(rows[1]);+ expect(useThreadSubagentsStore.getState().open).toEqual({ sessionId: "s1", id: "a2" });+ expect(screen.getAllByTestId("thread-tree-subagent")[1].getAttribute("aria-current")).toBe("page");+ expect(screen.getByText("Fix login test").closest("button")?.getAttribute("aria-current")).toBe("true");++ // The thread's own row leads back to the main conversation.+ fireEvent.click(screen.getByText("Fix login test"));+ expect(useThreadSubagentsStore.getState().open).toBeNull();++ fireEvent.click(screen.getByTestId("thread-subagents-fold"));+ expect(screen.queryAllByTestId("thread-tree-subagent")).toHaveLength(0);+ fireEvent.click(screen.getByTestId("thread-subagents-fold"));+ expect(screen.getAllByTestId("thread-tree-subagent")).toHaveLength(2);+ });++ it("shows no sub-agent rows for a thread that is not the one on screen", async () => {+ api.fetchAgentChatSessions.mockResolvedValue([sessionRow({ cli_title: "Fix login test" })]);+ useIdeThreadsStore.setState({ selection: { projectId: "p1", sessionId: null } });+ useThreadSubagentsStore.getState().publish("s1", [+ { id: "a1", parentId: null, depth: 0, title: "Explore", agentType: "", status: "running", waiting: false },+ ]);+ render(<ThreadTree />);+ await waitFor(() => expect(screen.getByText("Fix login test")).toBeTruthy());+ expect(screen.queryByTestId("thread-tree-subagents")).toBeNull();+ expect(screen.queryByTestId("thread-subagents-fold")).toBeNull();+ });+it("moves a thread with Alt and the arrow keys and keeps that order", async () => {api.fetchAgentChatSessions.mockResolvedValue([sessionRow({ session_id: "s1", cli_title: "Older", updated_ms: 1 }),diff --git a/dodaios/ui/web/frontend/src/components/agentic/threads/ThreadView.tsx b/dodaios/ui/web/frontend/src/components/agentic/threads/ThreadView.tsxindex cafb402cbd..1dc9426a72 100644--- a/dodaios/ui/web/frontend/src/components/agentic/threads/ThreadView.tsx+++ b/dodaios/ui/web/frontend/src/components/agentic/threads/ThreadView.tsx@@ -8,6 +8,7 @@ import { fill, translate, useT } from "@/i18n";import { useIdeProjectsStore } from "@/store/ideProjects";import { useIdeThreadsStore } from "@/store/ideThreads";import { useThreadTerminalsStore } from "@/store/threadTerminals";+import { openSubagentOf, useThreadSubagentsStore, type SubagentRow } from "@/store/threadSubagents";import { ThreadBranchBar, type ThreadCheckout } from "./ThreadBranchBar";import { ThreadComposer } from "./ThreadComposer";import { ThreadMenuItem, ThreadPopover } from "./ThreadPopover";@@ -47,8 +48,13 @@ export function ThreadView({ onScreen }: { onScreen: boolean }) {const [base, setBase] = useState("");const [projectMenu, setProjectMenu] = useState(false);const [composerHeight, setComposerHeight] = useState(160);- // The sub-agent whose conversation shows instead of the main thread's, by its spawn call.- const [openAgent, setOpenAgent] = useState<string | null>(null);+ // The sub-agent whose conversation shows instead of the main thread's, by its spawn+ // call. It lives in a store so the sidebar's sub-agent rows open it too.+ const openAgent = useThreadSubagentsStore((state) => openSubagentOf(state.open, selection.sessionId));+ const setOpenAgent = useCallback((id: string | null) => {+ const sessionId = useIdeThreadsStore.getState().selection.sessionId;+ if (sessionId) useThreadSubagentsStore.getState().openAgent(sessionId, id);+ }, []);// Sub-agents the CLI filed on its own (Codex), read for the open thread.const [discovered, setDiscovered] = useState<{ sessionId: string; agents: DiscoveredAgent[] } | null>(null);const projectAnchor = useRef<HTMLButtonElement | null>(null);@@ -207,8 +213,21 @@ export function ThreadView({ onScreen }: { onScreen: boolean }) {const agentItems = useMemo(() => (agent ? [subagentTurn(agent)] : []), [agent]);const userCount = timeline.items.filter((item) => item.type === "user").length;+ // The sidebar lists the open thread's sub-agents under it.+ useEffect(() => {+ const rows: SubagentRow[] = agents.map((entry) => ({+ id: entry.id, parentId: entry.parentId, depth: entry.depth, title: entry.title,+ agentType: entry.agentType, status: entry.status, waiting: entry.waiting,+ }));+ useThreadSubagentsStore.getState().publish(selection.team ? null : selection.sessionId, rows);+ }, [agents, selection.sessionId, selection.team]);+ useEffect(() => () => useThreadSubagentsStore.getState().publish(null, []), []);+// Another thread, or a new message to the main agent, brings the main conversation back.- useEffect(() => { setOpenAgent(null); }, [selection.sessionId]);+ useEffect(() => {+ const open = useThreadSubagentsStore.getState().open;+ if (open && open.sessionId !== selection.sessionId) useThreadSubagentsStore.getState().openAgent(open.sessionId, null);+ }, [selection.sessionId]);const sentCount = useRef(userCount);useEffect(() => {if (userCount > sentCount.current) setOpenAgent(null);diff --git a/dodaios/ui/web/frontend/src/components/agentic/threads/subagents.test.ts b/dodaios/ui/web/frontend/src/components/agentic/threads/subagents.test.tsindex 4f1ebcec6c..170c798f86 100644--- a/dodaios/ui/web/frontend/src/components/agentic/threads/subagents.test.ts+++ b/dodaios/ui/web/frontend/src/components/agentic/threads/subagents.test.ts@@ -115,6 +115,28 @@ describe("sub-agents in the timeline", () => {expect(subagentTurn(entry).blocks).toEqual([{ kind: "text", id: "answer:c1", text: "Two issues." }]);});+ it("closes a streamed conversation with the report it handed back when its steps end in a tool", () => {+ const turn = turnOf([+ ev("turn_started", { turn_id: "t1", provider: "claude-cli" }),+ ev("tool_call", { turn_id: "t1", call_id: "spawn", name: "Agent", input: { description: "Review", prompt: "Review it" } }),+ ev("subagent_started", { turn_id: "t1", agent_id: "spawn", description: "Review", prompt: "Review it" }),+ ev("tool_call", { turn_id: "t1", agent_id: "spawn", call_id: "read", name: "Read", input: { file_path: "a.py" } }),+ ev("tool_result", { turn_id: "t1", agent_id: "spawn", call_id: "read", output: "x", is_error: false }),+ ev("subagent_finished", { turn_id: "t1", agent_id: "spawn", status: "done" }),+ ev("subagent_finished", { turn_id: "t1", agent_id: "spawn", status: "done", summary: "## Review\nNo issues." }),+ ]);+ const [entry] = listSubagents([turn]);+ expect(entry.streamed).toBe(true);+ const blocks = subagentTurn(entry).blocks;+ expect(blocks[blocks.length - 1]).toEqual({ kind: "text", id: "answer:spawn", text: "## Review\nNo issues." });+ });++ it("does not repeat an answer the streamed conversation already ends in", () => {+ const [entry] = listSubagents([turnOf([...claudeRun(), ...finished()])]);+ const texts = subagentTurn(entry).blocks.filter((block) => block.kind === "text");+ expect(texts).toHaveLength(1);+ });+it("reads a Codex agent's answer from its finished report", () => {const turn = turnOf([ev("turn_started", { turn_id: "t1", provider: "codex-cli" }),diff --git a/dodaios/ui/web/frontend/src/components/agentic/threads/subagents.ts b/dodaios/ui/web/frontend/src/components/agentic/threads/subagents.tsindex b77ab9eef2..569ae3451e 100644--- a/dodaios/ui/web/frontend/src/components/agentic/threads/subagents.ts+++ b/dodaios/ui/web/frontend/src/components/agentic/threads/subagents.ts@@ -186,14 +186,17 @@ const TURN_STATUS: Record<SubagentStatus, TurnStatus> = { running: "running", do/*** A sub-agent's conversation as a turn, so the thread draws it exactly like- * the main agent's work: its steps, thoughts and answer. A CLI that only- * reported the answer shows that answer as the text.+ * the main agent's work: its steps, thoughts and answer. Where the steps do+ * not end in the answer (a CLI that only reported the answer, or one that+ * streamed the steps and handed the final report back separately), the+ * reported answer closes the turn.*/export function subagentTurn(entry: SubagentEntry): TurnItem {- const answer: TextBlock[] = !entry.streamed && entry.summary.trim()+ const running = entry.status === "running";+ const endsInText = entry.blocks.length > 0 && entry.blocks[entry.blocks.length - 1].kind === "text";+ const answer: TextBlock[] = !running && !endsInText && entry.summary.trim()? [{ kind: "text", id: `answer:${entry.id}`, text: entry.summary }]: [];- const running = entry.status === "running";return {type: "turn",id: `agent:${entry.id}`,diff --git a/dodaios/ui/web/frontend/src/i18n/locales/de.json b/dodaios/ui/web/frontend/src/i18n/locales/de.jsonindex 82f8b3507f..ee2435947d 100644--- a/dodaios/ui/web/frontend/src/i18n/locales/de.json+++ b/dodaios/ui/web/frontend/src/i18n/locales/de.json@@ -10280,6 +10280,9 @@"count_failed": "{count} fehlgeschlagen","subagents_aria": "Sub-Agents","main_thread": "Haupt-Thread",+ "show_subagents": "{count} Sub-Agents von „{title}“ zeigen",+ "hide_subagents": "Sub-Agents von „{title}“ ausblenden",+ "subagents_of": "Sub-Agents von {title}","in_background": "Im Hintergrund","task": "Aufgabe","task_from": "Aufgabe von {parent}",diff --git a/dodaios/ui/web/frontend/src/i18n/locales/en.json b/dodaios/ui/web/frontend/src/i18n/locales/en.jsonindex 0ee7f74fd4..bf6d0f80fb 100644--- a/dodaios/ui/web/frontend/src/i18n/locales/en.json+++ b/dodaios/ui/web/frontend/src/i18n/locales/en.json@@ -10280,6 +10280,9 @@"count_failed": "{count} failed","subagents_aria": "Sub-agents","main_thread": "Main thread",+ "show_subagents": "Show {count} sub-agents of “{title}”",+ "hide_subagents": "Hide the sub-agents of “{title}”",+ "subagents_of": "Sub-agents of {title}","in_background": "In the background","task": "Task","task_from": "Task from {parent}",diff --git a/dodaios/ui/web/frontend/src/i18n/locales/es.json b/dodaios/ui/web/frontend/src/i18n/locales/es.jsonindex 4eba4c32f9..fff0e160c8 100644--- a/dodaios/ui/web/frontend/src/i18n/locales/es.json+++ b/dodaios/ui/web/frontend/src/i18n/locales/es.json@@ -10280,6 +10280,9 @@"count_failed": "{count} fallidos","subagents_aria": "Subagentes","main_thread": "Hilo principal",+ "show_subagents": "Mostrar {count} subagentes de «{title}»",+ "hide_subagents": "Ocultar los subagentes de «{title}»",+ "subagents_of": "Subagentes de {title}","in_background": "En segundo plano","task": "Tarea","task_from": "Tarea de {parent}",diff --git a/dodaios/ui/web/frontend/src/i18n/locales/pt.json b/dodaios/ui/web/frontend/src/i18n/locales/pt.jsonindex 5a34af4003..9646b6cf04 100644--- a/dodaios/ui/web/frontend/src/i18n/locales/pt.json+++ b/dodaios/ui/web/frontend/src/i18n/locales/pt.json@@ -10280,6 +10280,9 @@"count_failed": "{count} falharam","subagents_aria": "Subagentes","main_thread": "Thread principal",+ "show_subagents": "Mostrar {count} subagentes de “{title}”",+ "hide_subagents": "Ocultar os subagentes de “{title}”",+ "subagents_of": "Subagentes de {title}","in_background": "Em segundo plano","task": "Tarefa","task_from": "Tarefa de {parent}",diff --git a/dodaios/ui/web/frontend/src/i18n/locales/zh.json b/dodaios/ui/web/frontend/src/i18n/locales/zh.jsonindex d78d1f9c05..256b9e04c8 100644--- a/dodaios/ui/web/frontend/src/i18n/locales/zh.json+++ b/dodaios/ui/web/frontend/src/i18n/locales/zh.json@@ -10280,6 +10280,9 @@"count_failed": "{count} 个失败","subagents_aria": "子智能体","main_thread": "主线程",+ "show_subagents": "显示“{title}”的 {count} 个子智能体",+ "hide_subagents": "隐藏“{title}”的子智能体",+ "subagents_of": "{title} 的子智能体","in_background": "在后台","task": "任务","task_from": "来自 {parent} 的任务",diff --git a/dodaios/ui/web/frontend/src/store/threadSubagents.ts b/dodaios/ui/web/frontend/src/store/threadSubagents.tsnew file mode 100644index 0000000000..9a55637f96--- /dev/null+++ b/dodaios/ui/web/frontend/src/store/threadSubagents.ts@@ -0,0 +1,71 @@+import { create } from "zustand";+import type { SubagentStatus } from "@/components/agentchat/reduce";++/**+ * The open thread's sub-agents, shared between the thread view and the+ * sidebar.+ *+ * Only the thread view reads a thread's conversation, so only it knows which+ * sub-agents the coding agent spawned. It publishes them here; the sidebar+ * lists them under the thread as threads of their own, and opening one from+ * either place shows its conversation. Nothing here is persisted: the list is+ * rebuilt from the conversation every time a thread opens.+ */++/** One sub-agent as the sidebar lists it. */+export interface SubagentRow {+ /** The spawning call's id: what opens it. */+ id: string;+ parentId: string | null;+ depth: number;+ title: string;+ agentType: string;+ status: SubagentStatus;+ waiting: boolean;+}++interface ThreadSubagentsState {+ /** The thread the rows belong to; null while no thread is open. */+ sessionId: string | null;+ rows: SubagentRow[];+ /** The sub-agent whose conversation shows instead of its thread's. */+ open: { sessionId: string; id: string } | null;+ publish: (sessionId: string | null, rows: SubagentRow[]) => void;+ /** Shows sub-agent `id` of thread `sessionId`; null shows the thread itself. */+ openAgent: (sessionId: string, id: string | null) => void;+}++function sameRows(a: readonly SubagentRow[], b: readonly SubagentRow[]): boolean {+ return a.length === b.length && a.every((row, index) => {+ const other = b[index];+ return row.id === other.id && row.parentId === other.parentId && row.depth === other.depth+ && row.title === other.title && row.agentType === other.agentType+ && row.status === other.status && row.waiting === other.waiting;+ });+}++export const useThreadSubagentsStore = create<ThreadSubagentsState>((set, get) => ({+ sessionId: null,+ rows: [],+ open: null,+ publish: (sessionId, rows) => {+ const state = get();+ // A streaming thread republishes on every event; only a real change re-renders the sidebar.+ if (state.sessionId === sessionId && sameRows(state.rows, rows)) return;+ set({ sessionId, rows });+ },+ openAgent: (sessionId, id) => {+ const current = get().open;+ if (id === null) {+ if (current) set({ open: null });+ return;+ }+ if (current?.sessionId === sessionId && current.id === id) return;+ set({ open: { sessionId, id } });+ },+}));++/** The sub-agent open in thread `sessionId`, else null. */+export function openSubagentOf(open: ThreadSubagentsState["open"], sessionId: string | null): string | null {+ return open && sessionId && open.sessionId === sessionId ? open.id : null;+}