Skip to content

Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins

feat(work-panel): show subagents as closable transcript tabs (#1027)

TioitWang62afc7444b74
diff --git a/apps/desktop/src/components/ChatTranscript.tsx b/apps/desktop/src/components/ChatTranscript.tsx
index c08351345..c66e73bbf 100644
--- a/apps/desktop/src/components/ChatTranscript.tsx
+++ b/apps/desktop/src/components/ChatTranscript.tsx
@@ -1,2 +1 @@
-export { ChatTranscript } from "../features/chat/transcript/ChatTranscript";
-export { SubagentDetail } from "../features/chat/transcript/SubagentDetail";
+export { ChatTranscript } from "../features/chat/transcript/ChatTranscript";
diff --git a/apps/desktop/src/components/workpanel/SubagentPanel.tsx b/apps/desktop/src/components/workpanel/SubagentPanel.tsx
deleted file mode 100644
index bf259702f..000000000
--- a/apps/desktop/src/components/workpanel/SubagentPanel.tsx
+++ /dev/null
@@ -1,181 +0,0 @@
-import { useLayoutEffect, useMemo } from "react";
-import { useTranslation } from "react-i18next";
-import type { UiMessage } from "@pi-desktop/shared";
-import {
- buildTranscriptEntries,
- type AssistantActivityItem,
-} from "../../lib/assistant-turns";
-import {
- collectDelegationFailures,
- collectDelegationStatuses,
- collectDelegationTimings,
- isDelegationActivityItem,
- type DelegationActivityItem,
- type DelegationFailure,
- type SubagentOutcome,
- type SubagentTiming,
-} from "../../lib/subagent-topology";
-import { delegationIdForMessage, type SubagentPanelSelection } from "../../lib/subagent-panel";
-import { useAppStore } from "../../stores/app-store";
-import { useFollowScroll } from "../../hooks/use-follow-scroll";
-import { useTranscriptView } from "../../hooks/use-transcript-view";
-import { useTranscriptSearchFocus } from "../../hooks/use-transcript-search-focus";
-import { IconArrowDown } from "../icons";
-import { DisclosureAnchorContext } from "../../lib/disclosure-anchor-context";
-import { TranscriptDisclosureProvider } from "../../features/chat/transcript/disclosure";
-import { TooltipButton } from "../ui";
-import { SubagentDetail } from "../ChatTranscript";
-
-type SelectedSubagent = {
- item: DelegationActivityItem;
- turnActivityItems: AssistantActivityItem[];
-};
-
-function findSelectedSubagent(
- messages: UiMessage[],
- delegationId: string,
-): SelectedSubagent | null {
- const { entries } = buildTranscriptEntries(messages);
- for (const entry of entries) {
- if (entry.kind !== "assistant-turn") continue;
- const turnActivityItems = entry.parts.flatMap((part) =>
- part.kind === "activity" ? part.items : [],
- );
- const item = turnActivityItems.find(
- (candidate): candidate is DelegationActivityItem =>
- isDelegationActivityItem(candidate) &&
- delegationIdForMessage(candidate.message) === delegationId,
- );
- if (item) return { item, turnActivityItems };
- }
- return null;
-}
-
-export function SubagentPanel({ selection }: { selection: SubagentPanelSelection }) {
- return (
- <TranscriptDisclosureProvider key={`${selection.sessionId}:${selection.delegationId}`}>
- <SubagentPanelSurface selection={selection} />
- </TranscriptDisclosureProvider>
- );
-}
-
-function SubagentPanelSurface({ selection }: { selection: SubagentPanelSelection }) {
- const { t } = useTranslation();
- const activeSessionId = useAppStore((state) => state.activeSessionId);
- const transcript = useTranscriptView(selection.sessionId);
- const { messages } = transcript;
- const searchTarget = selection.searchRequestId === transcript.focus?.requestId ? transcript.focus : null;
- const isRunning = useAppStore(
- (state) => state.runningSessions[selection.sessionId] ?? false,
- );
- const selected = useMemo(
- () => findSelectedSubagent(messages, selection.delegationId),
- [messages, selection.delegationId],
- );
- const delegationStatuses = useMemo<ReadonlyMap<string, SubagentOutcome>>(
- () =>
- selected
- ? collectDelegationStatuses(selected.turnActivityItems, {
- turnLive: isRunning,
- })
- : new Map(),
- [isRunning, selected],
- );
- const delegationFailures = useMemo<ReadonlyMap<string, DelegationFailure>>(
- () =>
- selected
- ? collectDelegationFailures(selected.turnActivityItems)
- : new Map(),
- [selected],
- );
- const delegationTimings = useMemo<ReadonlyMap<string, SubagentTiming>>(
- () =>
- selected
- ? collectDelegationTimings(selected.turnActivityItems)
- : new Map(),
- [selected],
- );
- const {
- scrollRef,
- contentRef,
- showJump,
- handleScroll,
- jumpToLatest,
- scheduleFollowScroll,
- releaseFollow,
- disclosureAnchorNotifier,
- } = useFollowScroll();
-
- useLayoutEffect(() => {
- if (!searchTarget) jumpToLatest();
- }, [jumpToLatest, selection.delegationId, searchTarget]);
-
- useLayoutEffect(() => {
- scheduleFollowScroll();
- }, [messages, scheduleFollowScroll]);
-
- useTranscriptSearchFocus({
- target: searchTarget,
- source: messages.find((message) => message.id === searchTarget?.messageId)?.content ?? "",
- scrollRef,
- contentRef,
- contentVersion: messages,
- onNavigate: releaseFollow,
- });
-
- return (
- <DisclosureAnchorContext.Provider value={disclosureAnchorNotifier}>
- <section
- id="subagent-panel"
- className="subagent-panel"
- role="complementary"
- aria-labelledby="subagent-panel-title"
- data-testid="subagent-panel"
- >
- <div
- ref={scrollRef}
- data-scroll-owner="follow"
- className="subagent-panel-scroll"
- onScroll={handleScroll}
- role="log"
- aria-live="polite"
- tabIndex={0}
- >
- <div ref={contentRef}>
- {selected ? (
- <SubagentDetail
- message={selected.item.message}
- {...(selected.item.delegate
- ? { delegate: selected.item.delegate }
- : {})}
- delegationStatuses={delegationStatuses}
- delegationFailures={delegationFailures}
- delegationTimings={delegationTimings}
- />
- ) : (
- <div className="subagent-panel-empty" role="status">
- {t("panel.subagentEmpty")}
- </div>
- )}
- </div>
- </div>
- {showJump ? (
- <TooltipButton
- type="button"
- className="jump-latest-btn subagent-panel-jump"
- tooltip={t("chat.scrollToBottom")}
- ariaLabel={t("chat.scrollToBottom")}
- onClick={jumpToLatest}
- >
- <IconArrowDown size={14} />
- </TooltipButton>
- ) : null}
- <span id="subagent-panel-title" className="sr-only">
- {activeSessionId === selection.sessionId
- ? t("panel.subagent")
- : t("panel.subagentEmpty")}
- </span>
- </section>
- </DisclosureAnchorContext.Provider>
- );
-}
diff --git a/apps/desktop/src/components/workpanel/SubagentTranscriptTab.tsx b/apps/desktop/src/components/workpanel/SubagentTranscriptTab.tsx
new file mode 100644
index 000000000..8df9a8e06
--- /dev/null
+++ b/apps/desktop/src/components/workpanel/SubagentTranscriptTab.tsx
@@ -0,0 +1,189 @@
+import { Fragment, useLayoutEffect, useMemo } from "react";
+import { useTranslation } from "react-i18next";
+import { useAppStore } from "../../stores/app-store";
+import { useFollowScroll } from "../../hooks/use-follow-scroll";
+import { useTranscriptView } from "../../hooks/use-transcript-view";
+import { useTranscriptSearchFocus } from "../../hooks/use-transcript-search-focus";
+import { IconArrowDown } from "../icons";
+import { Textarea, TooltipButton } from "../ui";
+import { DisclosureAnchorContext } from "../../lib/disclosure-anchor-context";
+import { TranscriptDisclosureProvider } from "../../features/chat/transcript/disclosure";
+import { buildSubagentTranscript } from "../../lib/subagent-transcript";
+import {
+ AssistantErrorMessage,
+ ThinkingRow,
+} from "../../features/chat/transcript/shared";
+import {
+ ReviewChangeCard,
+} from "../ReviewChangeCard";
+import { ToolRow } from "../../features/chat/transcript/ToolRow";
+import { Markdown } from "../Markdown";
+
+/**
+ * The work-panel tab showing one delegation as a conversation (issue #917).
+ *
+ * Every `Task` call of the delegation chain opens a turn: the prompt the
+ * parent sent renders as a user row, and the rows the delegate produced under
+ * that call render with the main transcript's own message-list language —
+ * tool rows, thinking rows, and answer bubbles alike. Follow-up `Task` calls
+ * on the same delegation append further turns, so a resumed delegate reads as
+ * one continuing user/assistant exchange.
+ *
+ * The tab is display-only: the composer at the foot is a disabled textarea
+ * whose placeholder says the delegate is driven by the main agent. There is
+ * deliberately no send path.
+ */
+export function SubagentTranscriptTab({ delegationId }: { delegationId: string }) {
+ return (
+ <TranscriptDisclosureProvider key={delegationId}>
+ <SubagentTranscriptSurface delegationId={delegationId} />
+ </TranscriptDisclosureProvider>
+ );
+}
+
+function SubagentTranscriptSurface({ delegationId }: { delegationId: string }) {
+ const { t } = useTranslation();
+ const activeSessionId = useAppStore((state) => state.activeSessionId);
+ // A tab only renders inside a presented panel, which always has a session;
+ // the empty key keeps the hook's contract while nothing is active.
+ const transcript = useTranscriptView(activeSessionId ?? "");
+ const { messages } = transcript;
+ const isRunning = useAppStore(
+ (state) => (activeSessionId ? state.runningSessions[activeSessionId] ?? false : false),
+ );
+ const transcriptResult = useMemo(
+ () => buildSubagentTranscript(messages, delegationId),
+ [messages, delegationId],
+ );
+ const {
+ scrollRef,
+ contentRef,
+ showJump,
+ handleScroll,
+ jumpToLatest,
+ scheduleFollowScroll,
+ releaseFollow,
+ disclosureAnchorNotifier,
+ } = useFollowScroll();
+
+ // Several delegation tabs can be open at once, so an explicit search hit
+ // is claimed only by the tab whose own conversation contains the message;
+ // the other tabs stay where the reader left them.
+ const searchTarget = useMemo(() => {
+ const focus = transcript.focus;
+ if (!focus) return null;
+ const claimed = transcriptResult?.turns.some((turn) =>
+ turn.rows.some((row) => row.message.id === focus.messageId),
+ );
+ return claimed ? focus : null;
+ }, [transcript.focus, transcriptResult]);
+
+ useTranscriptSearchFocus({
+ target: searchTarget,
+ source:
+ messages.find((message) => message.id === searchTarget?.messageId)?.content ?? "",
+ scrollRef,
+ contentRef,
+ contentVersion: messages,
+ onNavigate: releaseFollow,
+ });
+
+ useLayoutEffect(() => {
+ if (!searchTarget) jumpToLatest();
+ }, [jumpToLatest, searchTarget]);
+
+ useLayoutEffect(() => {
+ scheduleFollowScroll();
+ }, [messages, scheduleFollowScroll]);
+
+ return (
+ <DisclosureAnchorContext.Provider value={disclosureAnchorNotifier}>
+ <div className="subagent-transcript-tab" data-testid="subagent-transcript-tab">
+ <div
+ ref={scrollRef}
+ data-scroll-owner="follow"
+ className="subagent-transcript-scroll"
+ onScroll={handleScroll}
+ role="log"
+ aria-live="polite"
+ aria-label={t("panel.subagent")}
+ tabIndex={0}
+ >
+ <div ref={contentRef} className="subagent-transcript-list">
+ {transcriptResult ? (
+ transcriptResult.turns.map((turn, turnIndex) => (
+ <Fragment key={`turn-${turnIndex}`}>
+ <div className="message-row user">
+ <div className="message-col">
+ <div className="message-bubble">
+ <div className="message-user-text selectable">
+ {turn.task || t("panel.subagentTaskEmpty")}
+ </div>
+ </div>
+ </div>
+ </div>
+ {turn.rows.map((row) =>
+ row.kind === "tool" ? (
+ <Fragment key={row.message.id}>
+ <ToolRow message={row.message} />
+ <ReviewChangeCard message={row.message} />
+ </Fragment>
+ ) : row.kind === "thinking" ? (
+ <ThinkingRow
+ key={`thinking-${row.message.id}`}
+ message={row.message}
+ streaming={isRunning && row.message.status === "streaming"}
+ />
+ ) : (
+ <div
+ className="message-row assistant"
+ data-message-id={row.message.id}
+ key={`answer-${row.message.id}`}
+ >
+ <div className="message-col">
+ <div className="message-bubble">
+ {row.message.content ? (
+ <div className="prose-chat selectable">
+ <Markdown source={row.message.content} />
+ </div>
+ ) : null}
+ {row.message.error ? (
+ <AssistantErrorMessage message={row.message} />
+ ) : null}
+ </div>
+ </div>
+ </div>
+ ),
+ )}
+ </Fragment>
+ ))
+ ) : (
+ <div className="subagent-transcript-empty" role="status">
+ {t("panel.subagentEmpty")}
+ </div>
+ )}
+ </div>
+ </div>
+ {showJump ? (
+ <TooltipButton
+ type="button"
+ className="jump-latest-btn subagent-transcript-jump"
+ tooltip={t("chat.scrollToBottom")}
+ ariaLabel={t("chat.scrollToBottom")}
+ onClick={jumpToLatest}
+ >
+ <IconArrowDown size={14} />
+ </TooltipButton>
+ ) : null}
+ <footer className="subagent-transcript-composer">
+ <Textarea
+ disabled
+ rows={2}
+ aria-label={t("panel.subagentReadOnly")}
+ placeholder={t("panel.subagentReadOnly")}
+ />
+ </footer>
+ </div>
+ </DisclosureAnchorContext.Provider>
+ );
+}
diff --git a/apps/desktop/src/components/workpanel/WorkPanel.tsx b/apps/desktop/src/components/workpanel/WorkPanel.tsx
index f3ee8c647..f12ca92bb 100644
--- a/apps/desktop/src/components/workpanel/WorkPanel.tsx
+++ b/apps/desktop/src/components/workpanel/WorkPanel.tsx
@@ -15,13 +15,14 @@ import {
workPanelTabReorderInsertAfter,
workPanelTabReorderShouldArm,
} from "../../lib/work-panel-tab-reorder";
-import type { PluginViewMeta } from "@pi-desktop/shared";
import {
isKnownWorkPanelTab,
parsePluginViewRef,
pluginWorkPanelTab,
+ subagentTabDisplayLabels,
toolWorkPanelTab,
} from "../../lib/work-panel-tabs";
+import type { PluginViewMeta } from "@pi-desktop/shared";
import { pluginViewIcon, pluginViewInitial } from "../../lib/plugin-view-icons";
import { useAppStore } from "../../stores/app-store";
import type { WorkPanelTab } from "../../stores/app-store";
@@ -30,7 +31,6 @@ import { TooltipButton } from "../ui";
import type { IconProps } from "../icons";
import {
IconBot,
- IconChevronLeft,
IconClose,
IconDiff,
IconFileText,
@@ -42,8 +42,7 @@ import {
import { ReviewTab } from "./ReviewTab";
import { FilesTab } from "./FilesTab";
import { PluginViewTab } from "./PluginViewTab";
-import { SubagentPanel } from "./SubagentPanel";
-import type { SubagentPanelSelection } from "../../lib/subagent-panel";
+import { SubagentTranscriptTab } from "./SubagentTranscriptTab";
import {
MAIN_PANE_MIN_WIDTH,
WORK_PANEL_COMPACT_MIN_WIDTH,
@@ -59,6 +58,7 @@ const TAB_ICONS = {
review: IconDiff,
file: IconFileText,
plugin: IconPlug,
+ subagent: IconBot,
} as const;
type WorkPanelResizeState = {
@@ -111,6 +111,7 @@ function tabLabel(
return view?.title ?? tab.resource ?? t("panel.tabs.plugin");
}
if (tab.kind === "new") return t("panel.new.title");
+ if (tab.kind === "subagent") return tab.label ?? t("panel.tabs.subagent");
if (tab.kind !== "file") return t(`panel.tabs.${tab.kind}`);
const path = tab.resource ?? "";
return path.split("/").filter(Boolean).pop() || t("panel.tabs.file");
@@ -156,8 +157,6 @@ export function WorkPanel({
panelBlocked = false,
exiting = false,
onExitAnimationEnd,
- subagentPanel = null,
- onCloseSubagentPanel,
containerWidth = 0,
sidebarCollapsed = false,
sidebarExiting = false,
@@ -175,9 +174,6 @@ export function WorkPanel({
/** Plays work-panel-out; parent unmounts after animationend. */
exiting?: boolean;
onExitAnimationEnd?: () => void;
- /** Temporarily replaces the resource body with the selected subagent detail. */
- subagentPanel?: SubagentPanelSelection | null;
- onCloseSubagentPanel?: () => void;
/** Current renderer shell width used for the three-column budget. */
containerWidth?: number;
/** Sidebar state is part of the shared shell budget. */
@@ -212,6 +208,18 @@ export function WorkPanel({
const tabSignature = JSON.stringify(
tabs.map(({ id, kind, resource, location }) => [id, kind, resource, location]),
);
+ // Subagent tabs may share an agent name; repeats gain a 1-based `#n`
+ // suffix in strip order so the row stays unambiguous. The base label
+ // already falls back to panel.tabs.subagent when no name was captured.
+ const subagentTabsInOrder = tabs.filter((tab) => tab.kind === "subagent");
+ const subagentDisplayLabels = subagentTabDisplayLabels(
+ subagentTabsInOrder.map((tab) => tabLabel(tab, t, pluginViews)),
+ );
+ const subagentLabelById = new Map(
+ subagentTabsInOrder.map(
+ (tab, index) => [tab.id, subagentDisplayLabels[index]] as const,
+ ),
+ );
const [panelDragWidth, setPanelDragWidth] = useState<number | null>(null);
const panelResizeState = useRef<WorkPanelResizeState | null>(null);
@@ -567,18 +575,6 @@ export function WorkPanel({
},
[closeTab, tabs],
);
- const closeSubagentPanelAndFocus = useCallback(() => {
- const delegationId = subagentPanel?.delegationId;
- onCloseSubagentPanel?.();
- if (!delegationId) return;
- requestAnimationFrame(() => {
- const trigger = [...document.querySelectorAll<HTMLElement>("[data-subagent-trigger]")].find(
- (candidate) => candidate.dataset.subagentTrigger === delegationId,
- );
- trigger?.focus({ preventScroll: true });
- });
- }, [onCloseSubagentPanel, subagentPanel?.delegationId]);
-
const onTabKeyDown = useCallback(
(event: ReactKeyboardEvent<HTMLButtonElement>, tabId: string) => {
const index = tabs.findIndex((tab) => tab.id === tabId);
@@ -805,12 +801,6 @@ export function WorkPanel({
<div className="work-panel-main">
<header className="work-panel-header">
<div className="work-panel-tab-strip-wrap no-drag">
- {subagentPanel ? (
- <div className="work-panel-subagent-heading" aria-label={t("panel.subagent")}>
- <IconBot size={15} />
- <span>{t("panel.subagent")}</span>
- </div>
- ) : (
<div
ref={tabStripRef}
className="work-panel-tab-strip"
@@ -819,7 +809,10 @@ export function WorkPanel({
onWheel={onTabStripWheel}
>
{tabs.map((tab) => {
- const label = tabLabel(tab, t, pluginViews);
+ const label =
+ tab.kind === "subagent"
+ ? (subagentLabelById.get(tab.id) ?? t("panel.tabs.subagent"))
+ : tabLabel(tab, t, pluginViews);
const selected = tab.id === activeTabId;
const Icon =
tab.kind === "plugin"
@@ -852,7 +845,7 @@ export function WorkPanel({
aria-grabbed={draggingTabId === tab.id}
aria-keyshortcuts="Alt+ArrowLeft Alt+ArrowRight"
className="work-panel-tab-button"
- title={tab.resource ?? label}
+ title={tab.kind === "subagent" ? label : tab.resource ?? label}
onPointerDown={(event) => beginTabReorder(event, tab.id)}
onDragStart={(event) => event.preventDefault()}
onClick={() => activateTab(tab.id)}
@@ -880,20 +873,8 @@ export function WorkPanel({
);
})}
</div>
- )}
</div>
<div className="work-panel-actions no-drag">
- {subagentPanel && onCloseSubagentPanel ? (
- <TooltipButton
- type="button"
- className="work-panel-subagent-back"
- tooltip={t("panel.subagentClose")}
- ariaLabel={t("panel.subagentClose")}
- onClick={closeSubagentPanelAndFocus}
- >
- <IconChevronLeft size={15} />
- </TooltipButton>
- ) : (
<TooltipButton
ref={newTabButtonRef}
type="button"
@@ -904,7 +885,6 @@ export function WorkPanel({
>
<IconPlus size={16} />
</TooltipButton>
- )}
<TooltipButton
type="button"
className="work-panel-maximize"
@@ -922,8 +902,18 @@ export function WorkPanel({
</div>
</header>
<div className="work-panel-body">
- {subagentPanel ? <SubagentPanel selection={subagentPanel} /> : null}
- {!subagentPanel && activeTab?.kind === "review" && (
+ {activeTab?.kind === "subagent" && (
+ <div
+ key={activeTab.id}
+ id={`work-panel-surface-${activeTab.id}`}
+ className="work-panel-tabpane"
+ role="tabpanel"
+ aria-labelledby={`work-panel-tab-${activeTab.id}`}
+ >
+ <SubagentTranscriptTab delegationId={activeTab.resource ?? ""} />
+ </div>
+ )}
+ {activeTab?.kind === "review" && (
<div
id={`work-panel-surface-${activeTab.id}`}
className="work-panel-tabpane"
@@ -933,7 +923,7 @@ export function WorkPanel({
<ReviewTab />
</div>
)}
- {!subagentPanel && activeTab?.kind === "file" && (
+ {activeTab?.kind === "file" && (
<div
key={activeTab.id}
id={`work-panel-surface-${activeTab.id}`}
@@ -944,8 +934,7 @@ export function WorkPanel({
<FilesTab />
</div>
)}
- {!subagentPanel &&
- activeTab?.kind === "plugin" &&
+ {activeTab?.kind === "plugin" &&
(() => {
const ref = parsePluginViewRef(activeTab.resource);
if (!ref) return null;
@@ -970,7 +959,7 @@ export function WorkPanel({
</div>
);
})()}
- {!subagentPanel && (!activeTab || activeTab.kind === "new") && (
+ {(!activeTab || activeTab.kind === "new") && (
<div
className="work-panel-tabpane"
data-testid="work-panel-empty"
diff --git a/apps/desktop/src/features/app/AppShell.tsx b/apps/desktop/src/features/app/AppShell.tsx
index 496243b93..20ec725df 100644
--- a/apps/desktop/src/features/app/AppShell.tsx
+++ b/apps/desktop/src/features/app/AppShell.tsx
@@ -49,9 +49,6 @@ export function AppShell() {
ready,
page,
activeSessionId,
- subagentPanel,
- subagentPanelOpen,
- closeSubagentPanel,
workPanelOpen,
searchOpen,
setSearchOpen,
@@ -274,8 +271,6 @@ export function AppShell() {
onExitAnimationEnd={() =>
finishWorkPanelExit(workPanelExitGeneration.current)
}
- subagentPanel={subagentPanelOpen ? subagentPanel : null}
- onCloseSubagentPanel={closeSubagentPanel}
containerWidth={shellWidth}
sidebarWidth={sidebarWidth}
sidebarCollapsed={sidebarCollapsed}
diff --git a/apps/desktop/src/features/app/useAppShellRuntime.tsx b/apps/desktop/src/features/app/useAppShellRuntime.tsx
index 54ccb5f3d..08d0f0869 100644
--- a/apps/desktop/src/features/app/useAppShellRuntime.tsx
+++ b/apps/desktop/src/features/app/useAppShellRuntime.tsx
@@ -54,20 +54,13 @@ export function useAppShellRuntime() {
const handlePlansChanged = useAppStore((s) => s.handlePlansChanged);
const abort = useAppStore((s) => s.abort);
const settings = useAppStore((s) => s.settings);
- const subagentPanel = useAppStore((s) => s.subagentPanel);
- const closeSubagentPanel = useAppStore((s) => s.closeSubagentPanel);
const workPanelOpen = useAppStore((s) => s.workPanelOpen);
const workPanelWidth = useAppStore((s) => s.workPanelWidth);
- const subagentPanelOpen = Boolean(
- page === "chat" &&
- subagentPanel &&
- subagentPanel.sessionId === activeSessionId,
- );
const pluginThemes = useAppStore((s) => s.pluginThemes);
const refreshPluginThemes = useAppStore((s) => s.refreshPluginThemes);
const plugins = useAppStore((s) => s.plugins);
const projectPath = useAppStore((s) => s.workspace?.path ?? null);
- const workPanelVisible = workPanelOpen || subagentPanelOpen;
+ const workPanelVisible = workPanelOpen;
const [searchOpen, setSearchOpen] = useState(false);
const [sidebarCollapsed, setSidebarCollapsed] = useState(false);
@@ -213,15 +206,6 @@ export function useAppShellRuntime() {
presentedWorkPanelRef.current = presentedWorkPanelOpen;
}, [presentedWorkPanelOpen]);
- useEffect(() => {
- if (
- subagentPanel &&
- (page !== "chat" || subagentPanel.sessionId !== activeSessionId)
- ) {
- closeSubagentPanel();
- }
- }, [activeSessionId, closeSubagentPanel, page, subagentPanel]);
-
// Destination pages own the center pane. Leaving Chat while previewing must
// restore that pane before the destination is presented; otherwise the
// sidebar can change `page` successfully while the route stays unmounted.
@@ -248,11 +232,6 @@ export function useAppShellRuntime() {
store.openWorkPanel();
return;
}
- // Close a visible subagent dock through the same path as Cmd/Ctrl+J.
- if (store.subagentPanel) {
- store.toggleWorkPanel();
- return;
- }
// Prefer the visible presentation over a briefly stale session projection:
// a second click on the same button must always collapse a panel the user
// can currently see instead of routing through openWorkPanel again.
@@ -300,7 +279,7 @@ export function useAppShellRuntime() {
const pageHidesWorkPanel =
page === "settings" || page === "plugins" || page === "scheduled";
const shouldPresent =
- ready && !pageHidesWorkPanel && (workPanelOpen || subagentPanelOpen);
+ ready && !pageHidesWorkPanel && workPanelOpen;
const request = ++workPanelReservationRequest.current;
if (shouldPresent) {
@@ -336,7 +315,7 @@ export function useAppShellRuntime() {
isCurrent: () => request === workPanelReservationRequest.current,
commit: () => setPresentedWorkPanelOpen(shouldPresent),
});
- }, [page, ready, subagentPanelOpen, workPanelOpen]);
+ }, [page, ready, workPanelOpen]);
// Fallback if animationend is skipped (display:none mid-flight, etc.).
useEffect(() => {
@@ -919,9 +898,6 @@ export function useAppShellRuntime() {
ready,
page,
activeSessionId,
- subagentPanel,
- subagentPanelOpen,
- closeSubagentPanel,
workPanelOpen,
searchOpen,
setSearchOpen,
diff --git a/apps/desktop/src/features/chat/transcript/SubagentDetail.tsx b/apps/desktop/src/features/chat/transcript/SubagentDetail.tsx
index 70f298b82..f003518f1 100644
--- a/apps/desktop/src/features/chat/transcript/SubagentDetail.tsx
+++ b/apps/desktop/src/features/chat/transcript/SubagentDetail.tsx
@@ -1,328 +1,13 @@
-import {
- useEffect,
- useId,
- useLayoutEffect,
- useRef,
- useState,
-} from "react";
+import { useId } from "react";
import { useTranslation } from "react-i18next";
-import type { UiMessage } from "@pi-desktop/shared";
-import { formatToolDuration } from "../../../lib/tool-display";
-import { toolResultPayload } from "../../../lib/tool-presentation";
+import { IconTarget } from "../../../components/icons";
import {
- delegationIsCreating,
- subagentOutcome,
summarizeSubagentActivity,
type DelegationActivityItem,
- type DelegationFailure,
type SubagentOutcome,
type SubagentTiming,
} from "../../../lib/subagent-topology";
-import type { SubagentRun } from "../../../lib/assistant-turns";
-import { useAppStore } from "../../../stores/app-store";
-import {
- IconBot,
- IconCheck,
- IconChevronDown,
- IconChevronRight,
- IconCircleAlert,
- IconStop,
- IconTarget,
-} from "../../../components/icons";
-import { useDisclosureAnchorNotifier } from "../../../lib/disclosure-anchor-context";
-import { CopyButton } from "./shared";
-import {
- delegateAgentName,
- delegateModelId,
- delegateThinkingLevel,
-} from "./model";
-import {
- SubagentRunRows,
- ToolRow,
-} from "./ToolRow";
-
-function delegateTaskDescription(message: UiMessage): string {
- const args = message.toolArgs;
- if (!args || typeof args !== "object" || Array.isArray(args)) return "";
- const task = (args as { task?: unknown }).task;
- return typeof task === "string" ? task.trim() : "";
-}
-
-/**
- * Why a settled delegate failed, at the foot of its detail panel (issue #161).
- *
- * The step stream ends on `Failed` / `Timed out` / `Aborted` without saying
- * why: a delegate that dies before emitting a message row has no other carrier
- * for its reason, and the badge plus a duration is all a reader gets. The
- * runtime already reports `error: { code, message }` on the delegation roster
- * entry, so it is rendered here with the same visual language as the parent
- * reply's error card instead of being reachable only by reading the raw tool
- * result.
- */
-function SubagentFailureCard({
- outcome,
- failure,
-}: {
- outcome: SubagentOutcome;
- failure: DelegationFailure;
-}) {
- const { t } = useTranslation();
- const [open, setOpen] = useState(true);
- const detailsId = useId();
- const headingId = useId();
- // A known runtime code already has a localized sentence; otherwise the
- // outcome's own label is the summary, which stays truthful and localized.
- const localizedKey = `errors.${failure.code}`;
- const localized = failure.code ? t(localizedKey) : localizedKey;
- const summary =
- failure.code && localized !== localizedKey
- ? localized
- : t(`chat.subagentStatus.${outcome}`);
- // A code-only error carries no detail to disclose, so it stays a one-line
- // card rather than opening onto an empty box.
- const hasMessage = failure.message.length > 0;
-
- return (
- <section
- className="message-error subagent-failure"
- aria-labelledby={headingId}
- data-testid="subagent-failure"
- >
- <div className="message-error-heading">
- <span className="message-error-icon" aria-hidden>
- <IconCircleAlert size={16} />
- </span>
- <div className="message-error-copy">
- <strong id={headingId}>{summary}</strong>
- {failure.code ? <code>{failure.code}</code> : null}
- </div>
- <div className="message-error-actions">
- {/* The toggle stays outside the collapsed region, otherwise hiding
- * the details would take away the control that brings them back. */}
- {hasMessage ? (
- <button
- type="button"
- className="message-error-toggle"
- aria-expanded={open}
- aria-controls={detailsId}
- onClick={() => setOpen((value) => !value)}
- >
- <IconChevronRight size={12} aria-hidden />
- {open ? t("chat.hideErrorDetails") : t("chat.showErrorDetails")}
- </button>
- ) : null}
- </div>
- </div>
- {hasMessage ? (
- <div
- id={detailsId}
- className={`message-error-details ${open ? "open" : ""}`}
- hidden={!open}
- >
- <div className="message-error-raw">
- <pre className="selectable">{failure.message}</pre>
- <CopyButton text={failure.message} label={t("chat.copyErrorDetails")} />
- </div>
- </div>
- ) : null}
- </section>
- );
-}
-
-/**
- * The side-sheet view for a selected delegate. It shows a sticky identity
- * header, the task as an inset grouped card, and the live process timeline.
- * Reports and counters remain omitted from this compact surface.
- */
-export function SubagentDetail({
- message,
- delegate,
- delegationStatuses,
- delegationFailures,
- delegationTimings,
-}: {
- message: UiMessage;
- delegate?: SubagentRun;
- delegationStatuses?: ReadonlyMap<string, SubagentOutcome>;
- delegationFailures?: ReadonlyMap<string, DelegationFailure>;
- delegationTimings?: ReadonlyMap<string, SubagentTiming>;
-}) {
- const { t } = useTranslation();
- const agentName = delegateAgentName(message, delegate);
- const modelId = delegateModelId(message);
- const thinkingLevel = delegateThinkingLevel(message);
- const thinkingLabel = thinkingLevel ?? "";
- const modelLabel = [modelId, thinkingLabel].filter(Boolean).join(" ");
- const outcome = subagentOutcome(message, delegationStatuses);
- // A bare `running` Task row (no delegation handle yet) is still being
- // created: the delegate runtime is spawning. Name that phase explicitly
- // instead of a generic running state, and keep the badge class distinct.
- const creating = outcome === "running" && delegationIsCreating(message);
- const statusKey = creating
- ? "chat.subagentCreating"
- : `chat.subagentStatus.${outcome}`;
- const payload = toolResultPayload(message);
- const payloadRecord =
- payload && typeof payload === "object" && !Array.isArray(payload)
- ? (payload as { delegationId?: unknown; startedAt?: unknown; completedAt?: unknown })
- : undefined;
- const delegationId =
- typeof payloadRecord?.delegationId === "string"
- ? payloadRecord.delegationId
- : message.toolCallId || message.id;
- const timing = delegationTimings?.get(delegationId);
- const failure = delegationFailures?.get(delegationId);
- const startedAt =
- timing?.startedAt ??
- (typeof payloadRecord?.startedAt === "number"
- ? payloadRecord.startedAt
- : creating && message.createdAt
- ? Date.parse(message.createdAt) || undefined
- : undefined);
- const completedAt =
- timing?.completedAt ??
- (typeof payloadRecord?.completedAt === "number" ? payloadRecord.completedAt : undefined);
- const [now, setNow] = useState(Date.now);
- const durationMs =
- startedAt !== undefined
- ? Math.max(0, (completedAt ?? (outcome === "running" ? now : startedAt)) - startedAt)
- : message.toolDurationMs;
- const duration =
- typeof durationMs === "number" && durationMs > 0
- ? formatToolDuration(durationMs / 1000)
- : "";
- const statusClass = creating
- ? "outcome-creating"
- : outcome.replaceAll("_", "-");
- const taskDescription = delegateTaskDescription(message);
- const taskBodyId = useId();
- const taskLabelId = useId();
- const taskBodyRef = useRef<HTMLDivElement>(null);
- const [taskExpanded, setTaskExpanded] = useState(false);
- const taskToggleRef = useRef<HTMLButtonElement | null>(null);
- const notifyDisclosureAnchor = useDisclosureAnchorNotifier();
- const [taskOverflow, setTaskOverflow] = useState(false);
-
- useLayoutEffect(() => {
- setTaskExpanded(false);
- }, [taskDescription]);
-
- useLayoutEffect(() => {
- const element = taskBodyRef.current;
- if (!element) return;
- const measure = () => {
- const overflowing = element.scrollHeight > element.clientHeight + 1;
- setTaskOverflow((current) => (taskExpanded ? current : overflowing));
- };
- measure();
- const observer = new ResizeObserver(measure);
- observer.observe(element);
- return () => observer.disconnect();
- }, [taskDescription, taskExpanded]);
-
- useEffect(() => {
- if (outcome !== "running") return;
- setNow(Date.now());
- const id = window.setInterval(() => setNow(Date.now()), 1000);
- return () => window.clearInterval(id);
- }, [outcome]);
-
- return (
- <div className="subagent-detail" data-testid="subagent-detail">
- <header className="subagent-detail-hero">
- <div className="subagent-detail-heading">
- <span className="subagent-detail-avatar" aria-hidden>
- <IconBot size={18} />
- <span className={`subagent-detail-status outcome-${statusClass}`} />
- </span>
- <div className="subagent-detail-heading-copy">
- <strong className="subagent-detail-name">
- {agentName || t("chat.subagentUnnamed")}
- </strong>
- {modelLabel ? (
- <span
- className="subagent-detail-model"
- title={modelLabel}
- aria-label={modelLabel}
- >
- {modelLabel}
- </span>
- ) : null}
- </div>
- </div>
- <div
- className="subagent-detail-summary"
- role="list"
- aria-label={t("panel.subagent")}
- >
- <span
- className={`subagent-detail-badge outcome-${statusClass}`}
- role="listitem"
- >
- {t(statusKey)}
- </span>
- {duration ? (
- <span className="subagent-detail-meta" role="listitem">
- {duration}
- </span>
- ) : null}
- </div>
- </header>
- <section className="subagent-detail-task" aria-labelledby={taskLabelId}>
- <div className="subagent-detail-section-label" id={taskLabelId}>
- {t("panel.subagentTask")}
- </div>
- <div className="subagent-detail-task-card">
- <div
- id={taskBodyId}
- ref={taskBodyRef}
- className={`subagent-task-message-body selectable${
- taskExpanded ? " is-expanded" : " is-collapsed"
- }`}
- >
- {taskDescription || t("panel.subagentTaskEmpty")}
- </div>
- {taskOverflow ? (
- <button
- type="button"
- ref={taskToggleRef}
- className="subagent-task-toggle"
- aria-expanded={taskExpanded}
- aria-controls={taskBodyId}
- onClick={() => {
- // Expanding the brief changes the height of whichever scroller
- // this card sits in (#324), so it holds the same reading
- // position the tool and activity titles do.
- notifyDisclosureAnchor?.(taskToggleRef.current);
- setTaskExpanded((expanded) => !expanded);
- }}
- >
- <span>
- {taskExpanded
- ? t("chat.subagentTaskCollapse")
- : t("chat.subagentTaskExpand")}
- </span>
- <IconChevronDown size={12} aria-hidden />
- </button>
- ) : null}
- </div>
- </section>
- {delegate ? (
- <SubagentRunRows
- run={delegate}
- agentName={agentName}
- scrollable={false}
- variant="dock"
- />
- ) : null}
- {/* A completed delegate has nothing to explain, so the card is tied to a
- * non-success terminal outcome rather than to the error field alone. */}
- {failure && outcome !== "completed" && outcome !== "running" ? (
- <SubagentFailureCard outcome={outcome} failure={failure} />
- ) : null}
- </div>
- );
-}
+import { ToolRow } from "./ToolRow";
/**
* A truthful one-level graph of one parent fan-out (ADR 0062).
@@ -379,10 +64,3 @@ export function SubagentTopology({
</section>
);
}
-
-/**
- * One item on the activity timeline between two answers: either a thinking
- * segment (an assistant message's reasoning) or a tool call. Grouping both
- * into a single disclosure keeps long agent loops from stacking alternating
- * "Thinking" / "Processed" rows down the transcript.
- */
diff --git a/apps/desktop/src/features/chat/transcript/ToolRow.tsx b/apps/desktop/src/features/chat/transcript/ToolRow.tsx
index 94350b875..b234973ae 100644
--- a/apps/desktop/src/features/chat/transcript/ToolRow.tsx
+++ b/apps/desktop/src/features/chat/transcript/ToolRow.tsx
@@ -154,8 +154,8 @@ export const ToolRow = memo(function ToolRow({
const detailsId = useId();
const root = useAppStore((s) => s.workspace?.path);
const openTarget = useOpenPreviewTarget();
- const toggleSubagentPanel = useAppStore((s) => s.toggleSubagentPanel);
- const subagentPanel = useAppStore((s) => s.subagentPanel);
+ const openSubagentTab = useAppStore((s) => s.openSubagentTab);
+ const activeWorkPanelTabId = useAppStore((s) => s.activeWorkPanelTabId);
const status = message.toolStatus;
const action = getToolAction(message.toolName);
// A run row states what the command did, not what the call around it did: an
@@ -289,7 +289,7 @@ export const ToolRow = memo(function ToolRow({
: message.toolCallId || message.id;
const panelOpen =
variant === "topology" &&
- subagentPanel?.delegationId === panelSelectionId;
+ activeWorkPanelTabId === `subagent:${panelSelectionId}`;
const renderedOpen = variant === "topology" ? panelOpen : open;
const inlineOpen = variant !== "topology" && open;
const delegationTiming =
@@ -370,15 +370,14 @@ export const ToolRow = memo(function ToolRow({
{variant === "topology" ? (
<button
className="subagent-topology-node-header"
- data-subagent-trigger={panelSelectionId}
aria-expanded={panelOpen}
- aria-controls={panelOpen ? "subagent-panel" : undefined}
+ aria-controls={panelOpen ? `work-panel-surface-subagent:${panelSelectionId}` : undefined}
disabled={!hasDetails}
title={[agentName || rawName, modelLabel, summary].filter(Boolean).join(" · ")}
onClick={() => {
if (!hasDetails) return;
onUserInteraction?.();
- toggleSubagentPanel(panelSelectionId);
+ openSubagentTab(panelSelectionId, agentName || undefined);
}}
>
<span className="subagent-topology-avatar" aria-hidden>
diff --git a/apps/desktop/src/lib/assistant-turns.ts b/apps/desktop/src/lib/assistant-turns.ts
index 60cd55374..848566be3 100644
--- a/apps/desktop/src/lib/assistant-turns.ts
+++ b/apps/desktop/src/lib/assistant-turns.ts
@@ -114,13 +114,18 @@ function collectSubagentRuns(
return runs;
}
-// Map each Task call to the last call of its chain (ADR 0279): a resumed
-// delegation is one delegate session continued by a later Task call, so the
-// chain's rows all belong on the latest card, where they read as one
-// continuing conversation rather than a card per call.
-function chainLatestCalls(
- messages: readonly UiMessage[],
-): (toolCallId: string) => string {
+/**
+ * The delegation-chain structure of one transcript (ADR 0279).
+ *
+ * `callByDelegationId` maps each Task result's `delegationId` to the call that
+ * returned it; `childOf` links a resumed call to the call it resumed. Shared
+ * by the delegation card grouping and the subagent transcript tab so both read
+ * the same chain semantics from one place.
+ */
+export function delegationChainMaps(messages: readonly UiMessage[]): {
+ callByDelegationId: Map<string, string>;
+ childOf: Map<string, string>;
+} {
const callByDelegationId = new Map<string, string>();
const childOf = new Map<string, string>();
for (const message of messages) {
@@ -152,6 +157,17 @@ function chainLatestCalls(
: undefined;
if (prior) childOf.set(prior, toolCallId);
}
+ return { callByDelegationId, childOf };
+}
+
+// Map each Task call to the last call of its chain (ADR 0279): a resumed
+// delegation is one delegate session continued by a later Task call, so the
+// chain's rows all belong on the latest card, where they read as one
+// continuing conversation rather than a card per call.
+function chainLatestCalls(
+ messages: readonly UiMessage[],
+): (toolCallId: string) => string {
+ const { childOf } = delegationChainMaps(messages);
const latest = new Map<string, string>();
return (toolCallId: string): string => {
const cached = latest.get(toolCallId);
diff --git a/apps/desktop/src/lib/subagent-panel.ts b/apps/desktop/src/lib/subagent-panel.ts
index bf35b1e9b..0d7cd01f0 100644
--- a/apps/desktop/src/lib/subagent-panel.ts
+++ b/apps/desktop/src/lib/subagent-panel.ts
@@ -1,15 +1,11 @@
import type { UiMessage } from "@pi-desktop/shared";
import { toolResultPayload } from "./tool-presentation";
-/** The renderer-local subagent detail currently shown in the work-panel dock. */
-export type SubagentPanelSelection = {
- sessionId: string;
- /** Stable delegation id from the Task result, used to re-find live rows. */
- delegationId: string;
- /** Connect an explicit search to the shared transcript reading view. */
- searchRequestId?: number;
-};
-
+/**
+ * The stable delegation id a transcript row is keyed by: the Task result's
+ * `delegationId` when the runtime recorded one, else the call's own identity.
+ * Shared by the delegation topology and the subagent transcript tab.
+ */
export function delegationIdForMessage(message: UiMessage): string {
const payload = toolResultPayload(message);
if (payload && typeof payload === "object" && !Array.isArray(payload)) {
diff --git a/apps/desktop/src/lib/subagent-transcript.ts b/apps/desktop/src/lib/subagent-transcript.ts
new file mode 100644
index 000000000..ca0877848
--- /dev/null
+++ b/apps/desktop/src/lib/subagent-transcript.ts
@@ -0,0 +1,170 @@
+import type { UiMessage } from "@pi-desktop/shared";
+import {
+ delegationChainMaps,
+ messageThinking,
+ type SubagentRunItem,
+} from "./assistant-turns";
+import { isDelegationStartTool } from "./tool-display";
+import { delegationIdForMessage } from "./subagent-panel";
+
+/** One user/assistant exchange of a delegate session. */
+export type SubagentTranscriptTurn = { task: string; rows: SubagentRunItem[] };
+
+/**
+ * A delegate's conversation as alternating turns: each Task call of the
+ * delegation chain opens a turn with its `task` argument, followed by the
+ * rows the delegate produced under that call.
+ */
+export type SubagentTranscript = {
+ agentName?: string;
+ turns: SubagentTranscriptTurn[];
+};
+
+function delegateTaskDescription(call: UiMessage): string {
+ const args = call.toolArgs;
+ if (!args || typeof args !== "object" || Array.isArray(args)) return "";
+ const task = (args as { task?: unknown }).task;
+ return typeof task === "string" ? task.trim() : "";
+}
+
+function requestedAgentName(call: UiMessage): string {
+ const args = call.toolArgs;
+ if (!args || typeof args !== "object" || Array.isArray(args)) return "";
+ const agent = (args as { agent?: unknown }).agent;
+ return typeof agent === "string" ? agent : "";
+}
+
+/** Task calls whose `resume` argument resolves to one of `priorCallIds`. */
+function resumedCalls(
+ messages: readonly UiMessage[],
+ priorCallIds: ReadonlySet<string>,
+ callByDelegationId: ReadonlyMap<string, string>,
+): Set<string> {
+ const next = new Set<string>();
+ for (const message of messages) {
+ if (message.role !== "tool" || !isDelegationStartTool(message.toolName)) {
+ continue;
+ }
+ const args = message.toolArgs;
+ const resume =
+ args && typeof args === "object" && !Array.isArray(args)
+ ? (args as { resume?: unknown }).resume
+ : undefined;
+ if (typeof resume !== "string" || !resume.trim()) continue;
+ // The runtime records `resume` as a prior delegation id; a bare call id
+ // is accepted too, so the chain stays legible before any result lands.
+ const target = callByDelegationId.get(resume.trim()) ?? resume.trim();
+ if (priorCallIds.has(target) && message.toolCallId) next.add(message.toolCallId);
+ }
+ return next;
+}
+
+/**
+ * Build the delegate's transcript from the session messages.
+ *
+ * A Task call belongs to the delegation of `delegationId` when the call
+ * identifies itself by that id — via its result payload, or via its own call
+ * id when the runtime recorded none — or when it resumed another call of that
+ * chain. Turns appear in session order; each turn's rows are the messages
+ * whose `parentToolCallId` names that call, mapped exactly like the
+ * delegation card's run grouping. Returns null when no Task call matches, so
+ * the tab can show its unavailable state instead of an empty conversation.
+ */
+export function buildSubagentTranscript(
+ messages: readonly UiMessage[],
+ delegationId: string,
+): SubagentTranscript | null {
+ const target = delegationId.trim();
+ const { childOf, callByDelegationId } = delegationChainMaps(messages);
+ // A resumed call may cite the prior delegation id (the runtime's shape) or
+ // a bare prior call id. `childOf` covers the delegation-id form; the bare
+ // form is resolved here so the chain still closes before results land.
+ const resumeLink = new Map(childOf);
+ for (const message of messages) {
+ if (message.role !== "tool" || !isDelegationStartTool(message.toolName)) {
+ continue;
+ }
+ const args = message.toolArgs;
+ const resume =
+ args && typeof args === "object" && !Array.isArray(args)
+ ? (args as { resume?: unknown }).resume
+ : undefined;
+ if (typeof resume !== "string" || !resume.trim()) continue;
+ const priorId = callByDelegationId.get(resume.trim()) ?? resume.trim();
+ if (message.toolCallId && !resumeLink.has(priorId)) {
+ resumeLink.set(priorId, message.toolCallId);
+ }
+ }
+ const calls = messages.filter(
+ (message) =>
+ message.role === "tool" &&
+ isDelegationStartTool(message.toolName) &&
+ Boolean(message.toolCallId),
+ );
+ // The chain is the connected component of resumed calls around the call
+ // this delegation id names; forward and backward walks share that set.
+ let chain = new Set(
+ calls
+ .filter((call) => delegationIdForMessage(call) === target)
+ .map((call) => call.toolCallId as string),
+ );
+ if (chain.size === 0) return null;
+ for (;;) {
+ const forward = resumedCalls(messages, chain, callByDelegationId);
+ const backward = new Set(
+ [...chain].flatMap((callId) => {
+ const prior = [...resumeLink.entries()]
+ .filter(([, next]) => next === callId)
+ .map(([priorId]) => priorId);
+ return prior;
+ }),
+ );
+ const grown = new Set([
+ ...chain,
+ ...[...forward, ...backward].filter((id) => !chain.has(id)),
+ ]);
+ if (grown.size === chain.size) break;
+ chain = grown;
+ }
+
+ // Attribution prefers what the delegate's own rows carried; a chain whose
+ // delegate has not produced a row yet falls back to the requested agent.
+ const runAgentName = messages.find(
+ (message) =>
+ message.parentToolCallId &&
+ chain.has(message.parentToolCallId) &&
+ message.agentName,
+ )?.agentName;
+ const requestedName = calls
+ .filter((call) => chain.has(call.toolCallId as string))
+ .map(requestedAgentName)
+ .find(Boolean);
+ const agentName = runAgentName || requestedName;
+
+ const turns: SubagentTranscriptTurn[] = [];
+ for (const call of calls) {
+ const callId = call.toolCallId as string;
+ if (!chain.has(callId)) continue;
+ const rows: SubagentRunItem[] = [];
+ for (const message of messages) {
+ if (message.parentToolCallId !== callId) continue;
+ if (message.role === "tool") {
+ rows.push({ kind: "tool", message });
+ continue;
+ }
+ // A delegate turn can carry reasoning and text at once, and both are
+ // worth showing: the text is the only place its narration and report
+ // exist.
+ if (messageThinking(message)) rows.push({ kind: "thinking", message });
+ if ((message.content || "").trim() || message.error) {
+ rows.push({ kind: "answer", message });
+ }
+ }
+ turns.push({ task: delegateTaskDescription(call), rows });
+ }
+
+ return {
+ ...(agentName ? { agentName } : {}),
+ turns,
+ };
+}
diff --git a/apps/desktop/src/lib/work-panel-tabs.ts b/apps/desktop/src/lib/work-panel-tabs.ts
index 5ae9c299d..b9a2f6c14 100644
--- a/apps/desktop/src/lib/work-panel-tabs.ts
+++ b/apps/desktop/src/lib/work-panel-tabs.ts
@@ -2,10 +2,13 @@ export type WorkPanelTabKind =
| "new"
| "review"
| "file"
- | "plugin";
+ | "plugin"
+ | "subagent";
export type WorkPanelTab = {
id: string;
+ /** Display name captured at open time, used by labels that have no resource. */
+ label?: string;
kind: WorkPanelTabKind;
resource?: string;
/** Guest URL or workspace path for the Browser plugin view (D333). */
@@ -61,7 +64,7 @@ export function switchWorkPanelContextState(
}
export function toolWorkPanelTab(
- kind: Exclude<WorkPanelTabKind, "new" | "file" | "plugin">,
+ kind: Exclude<WorkPanelTabKind, "new" | "file" | "plugin" | "subagent">,
): WorkPanelTab {
return { id: kind, kind };
}
@@ -92,6 +95,26 @@ export function pluginWorkPanelTab(pluginId: string, viewId: string): WorkPanelT
return { id: `plugin:${resource}`, kind: "plugin", resource };
}
+/**
+ * A subagent transcript tab (ADR 0062 delegations).
+ *
+ * Keyed by the delegation id, so re-opening the same delegate reuses its tab
+ * and parallel delegates coexist as independent tabs. The agent name is
+ * captured at open time so the strip can label the tab even before the
+ * delegate produced any row.
+ */
+export function subagentWorkPanelTab(
+ delegationId: string,
+ agentName?: string,
+): WorkPanelTab {
+ return {
+ id: `subagent:${delegationId}`,
+ kind: "subagent",
+ resource: delegationId,
+ ...(agentName ? { label: agentName } : {}),
+ };
+}
+
export const BROWSER_PLUGIN_TAB = {
pluginId: "pi.browser",
viewId: "browser",
@@ -181,7 +204,8 @@ export function isKnownWorkPanelTab(tab: WorkPanelTab): boolean {
return (
Boolean(tab) &&
(tab.kind === "new" || tab.kind === "review" ||
- tab.kind === "file" || tab.kind === "plugin")
+ tab.kind === "file" || tab.kind === "plugin" ||
+ tab.kind === "subagent")
);
}
@@ -335,3 +359,27 @@ export function closeWorkPanelTabState(
activeTabId: tabs[Math.min(index, tabs.length - 1)]?.id ?? null,
};
}
+
+/**
+ * Display labels for the subagent tabs in strip order.
+ *
+ * Delegates with the same agent name would otherwise render identical tab
+ * labels, so a repeated base label gains a 1-based `#n` suffix within its
+ * label group; a label that occurs once stays unnumbered. Other tab kinds are
+ * unique by construction and are not passed here.
+ */
+export function subagentTabDisplayLabels(
+ baseLabels: readonly string[],
+): string[] {
+ const counts = new Map<string, number>();
+ for (const label of baseLabels) {
+ counts.set(label, (counts.get(label) ?? 0) + 1);
+ }
+ const seen = new Map<string, number>();
+ return baseLabels.map((label) => {
+ if ((counts.get(label) ?? 0) <= 1) return label;
+ const index = (seen.get(label) ?? 0) + 1;
+ seen.set(label, index);
+ return `${label}#${index}`;
+ });
+}
diff --git a/apps/desktop/src/stores/app-state.ts b/apps/desktop/src/stores/app-state.ts
index aeecff157..33807d7a9 100644
--- a/apps/desktop/src/stores/app-state.ts
+++ b/apps/desktop/src/stores/app-state.ts
@@ -40,7 +40,6 @@ import type {
QueuedPromptDirection,
QueuedPrompts,
} from "../lib/queued-prompts";
-import type { SubagentPanelSelection } from "../lib/subagent-panel";
import type {
ComposerDraftSnapshot,
ComposerPrefill,
@@ -350,8 +349,6 @@ export type AppState = {
dismissToast: (id: number) => void;
composerPrefill: ComposerPrefill | null;
clearComposerPrefill: () => void;
- /** Renderer-only subagent details selected from the transcript. */
- subagentPanel: SubagentPanelSelection | null;
workPanelOpen: boolean;
workPanelTabs: WorkPanelTab[];
activeWorkPanelTabId: string | null;
@@ -360,9 +357,8 @@ export type AppState = {
workPanelWidth: number;
/** Chat-initiated "preview this file" request consumed by the files viewer. */
workPanelFileRequest: { path: string; seq: number; mimeType?: string } | null;
- /** Toggle the selected subagent detail. */
- toggleSubagentPanel: (delegationId: string) => void;
- closeSubagentPanel: () => void;
+ /** Open (or activate) the transcript tab of one delegated subagent. */
+ openSubagentTab: (delegationId: string, agentName?: string) => void;
/** Abort one session's running turn, visible or not. */
abortSession: (sessionId: string) => Promise<void>;
openWorkPanel: () => void;
diff --git a/apps/desktop/src/stores/app-store.ts b/apps/desktop/src/stores/app-store.ts
index ee8efa7f6..d27cbe8cf 100644
--- a/apps/desktop/src/stores/app-store.ts
+++ b/apps/desktop/src/stores/app-store.ts
@@ -145,7 +145,6 @@ import {
} from "../lib/queued-prompts";
import type { AgentQueueChangedEvent, QueuedTurnSummary } from "@pi-desktop/shared";
import { settleBootstrapRequests } from "../lib/bootstrap-result";
-import type { SubagentPanelSelection } from "../lib/subagent-panel";
import {
createSessionRuntime,
type SessionRuntime,
diff --git a/apps/desktop/src/stores/runtime/transcript-reading-runtime.ts b/apps/desktop/src/stores/runtime/transcript-reading-runtime.ts
index d3452a15c..ad8d6d80d 100644
--- a/apps/desktop/src/stores/runtime/transcript-reading-runtime.ts
+++ b/apps/desktop/src/stores/runtime/transcript-reading-runtime.ts
@@ -1,6 +1,5 @@
import type { SessionDetail } from "@pi-desktop/shared";
import type { SessionHistoryReadOptions } from "../../lib/api";
-import { delegationIdForMessage } from "../../lib/subagent-panel";
import {
EMPTY_TRANSCRIPT,
extendTranscriptView,
@@ -53,12 +52,7 @@ export function createTranscriptReadingRuntime({ get, set }: StoreAccess, read:
set((state) => {
if (!state.transcriptViews[sessionId]) return {};
const { [sessionId]: _released, ...transcriptViews } = state.transcriptViews;
- return {
- transcriptViews,
- ...(state.subagentPanel?.sessionId === sessionId && state.subagentPanel.searchRequestId
- ? { subagentPanel: null }
- : {}),
- };
+ return { transcriptViews };
});
}
@@ -93,23 +87,11 @@ export function createTranscriptReadingRuntime({ get, set }: StoreAccess, read:
if (!session || !message) throw new Error("Message no longer exists in this conversation.");
if (message.parentToolCallId && !session.navigationParent)
throw new Error("The task for this message no longer exists in this conversation.");
- const parent = session.navigationParent;
set((state) => ({
transcriptViews: {
...state.transcriptViews,
[sessionId]: transcriptViewFromSession(session, focus),
},
- ...(parent
- ? {
- subagentPanel: {
- sessionId,
- delegationId: delegationIdForMessage(parent),
- searchRequestId: focus.requestId,
- },
- }
- : state.subagentPanel?.searchRequestId
- ? { subagentPanel: null }
- : {}),
}));
} catch (error) {
if (get().transcriptViews[sessionId] !== pending) return;
diff --git a/apps/desktop/src/stores/slices/initial-state.ts b/apps/desktop/src/stores/slices/initial-state.ts
index 742bb6b2f..95518c86f 100644
--- a/apps/desktop/src/stores/slices/initial-state.ts
+++ b/apps/desktop/src/stores/slices/initial-state.ts
@@ -41,7 +41,6 @@ export function createInitialState(): AppStateData {
.filter(([, meta]) => meta.collapsed === true)
.map(([path]) => [path, true]),
),
- subagentPanel: null,
workPanelOpen: false,
workPanelTabs: [],
activeWorkPanelTabId: null,
diff --git a/apps/desktop/src/stores/slices/work-panel-slice.ts b/apps/desktop/src/stores/slices/work-panel-slice.ts
index 2b3b607b9..1e2df303a 100644
--- a/apps/desktop/src/stores/slices/work-panel-slice.ts
+++ b/apps/desktop/src/stores/slices/work-panel-slice.ts
@@ -10,6 +10,7 @@ import {
reorderWorkPanelTabsState,
replaceWorkPanelTabState,
sanitizeWorkPanelTabsState,
+ subagentWorkPanelTab,
switchWorkPanelContextState,
type WorkPanelContext,
type WorkPanelTab,
@@ -97,8 +98,7 @@ export function createWorkPanelSlice({
isSessionSelectionPending,
}: WorkPanelSliceDependencies): Pick<
AppState,
- "toggleSubagentPanel"
- | "closeSubagentPanel"
+ "openSubagentTab"
| "openWorkPanel"
| "toggleWorkPanel"
| "openWorkPanelTab"
@@ -117,21 +117,11 @@ export function createWorkPanelSlice({
let workPanelFileRequestSeq = 0;
return {
- toggleSubagentPanel: (delegationId) => {
- const state = get();
- const sessionId = state.activeSessionId;
+ openSubagentTab: (delegationId, agentName) => {
const id = delegationId.trim();
- if (!sessionId || !id) return;
- if (
- state.subagentPanel?.sessionId === sessionId &&
- state.subagentPanel.delegationId === id
- ) {
- set({ subagentPanel: null });
- return;
- }
- set({ subagentPanel: { sessionId, delegationId: id } });
+ if (!id) return;
+ get().openWorkPanelTab(subagentWorkPanelTab(id, agentName || undefined));
},
- closeSubagentPanel: () => set({ subagentPanel: null }),
openWorkPanel: () => {
const state = get();
@@ -149,11 +139,6 @@ export function createWorkPanelSlice({
toggleWorkPanel: () => {
const state = get();
- if (state.subagentPanel) {
- state.closeSubagentPanel();
- if (get().workPanelOpen) get().collapseWorkPanel();
- return;
- }
if (state.workPanelOpen) {
state.collapseWorkPanel();
return;
diff --git a/apps/desktop/src/styles/work-panel.css b/apps/desktop/src/styles/work-panel.css
index 085268cd9..5e145e17e 100644
--- a/apps/desktop/src/styles/work-panel.css
+++ b/apps/desktop/src/styles/work-panel.css
@@ -318,8 +318,8 @@
/* One button group with the viewport-fixed collapse toggle: the same control
gap the header reserves for it, and no divider, inset, or margin of its own.
The rule owns spacing only — `+` and maximize take the shared chrome-control
- geometry and transparent seat from chrome.css, beside the subagent back
- control's own matching rule, so the group reads as quiet icon controls. */
+ geometry and transparent seat from chrome.css, so the group reads as quiet
+ icon controls. */
.work-panel-actions {
display: flex;
flex: 0 0 auto;
@@ -327,24 +327,6 @@
gap: var(--ds-work-panel-control-gap);
}
-.work-panel-subagent-back {
- display: inline-flex;
- width: 28px;
- height: 28px;
- flex: 0 0 auto;
- align-items: center;
- justify-content: center;
- border-radius: var(--radius-md);
- color: var(--ds-text-secondary);
- transition:
- background var(--motion-duration-fast) var(--motion-ease-out),
- color var(--motion-duration-fast) var(--motion-ease-out);
-}
-
-.work-panel-subagent-back:hover {
- background: var(--ds-bg-hover);
- color: var(--ds-text-primary);
-}
/* Preview mode: the panel takes MainChat's width as well, so the divider has no
second column to trade width with and the dock fills its flex row. */
@@ -358,23 +340,6 @@
cursor: default;
}
-.work-panel-subagent-heading {
- display: inline-flex;
- min-width: 0;
- align-items: center;
- gap: 7px;
- padding: 0 8px;
- color: var(--ds-text-secondary);
-}
-
-.work-panel-subagent-heading span {
- min-width: 0;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- font-size: var(--text-md);
- font-weight: var(--font-weight-medium);
-}
.work-panel-body {
position: relative;
@@ -395,34 +360,44 @@
display: none;
}
-/* ---------- Subagent detail dock --------------------------------------- */
+/* ---------- Subagent transcript tab ------------------------------------- */
-.subagent-panel {
- position: relative;
+/*
+ * A delegation renders as a conversation: the tab reuses the main transcript's
+ * message-list classes for its rows, so the only tab-specific layout is the
+ * column (scroll area above a read-only composer) and the composer itself.
+ * The scroll area owns the only scrollbar; the composer never scrolls.
+ */
+.subagent-transcript-tab {
display: flex;
min-width: 0;
min-height: 0;
flex: 1;
flex-direction: column;
- background: transparent;
}
-.subagent-panel-scroll {
+.subagent-transcript-scroll {
min-width: 0;
min-height: 0;
flex: 1;
overflow-x: hidden;
overflow-y: auto;
padding: 0 0 32px;
- background: transparent;
}
-.subagent-panel-jump {
- bottom: 12px;
- z-index: 6;
+.subagent-transcript-list {
+ display: flex;
+ min-width: 0;
+ flex-direction: column;
}
-.subagent-panel-empty {
+/* A tab pane is narrower than the chat column, so the user plate's percentage
+ cap needs a definite floor of its own; the bubble still shrink-wraps. */
+.subagent-transcript-list .message-row.user .message-col {
+ max-width: min(100%, 520px);
+}
+
+.subagent-transcript-empty {
display: grid;
min-height: 160px;
place-items: center;
@@ -432,372 +407,23 @@
text-align: center;
}
-.subagent-panel-switcher:hover {
- background: transparent;
-}
-
-.subagent-detail {
- display: flex;
- min-width: 0;
- flex-direction: column;
- gap: 16px;
-}
-
-/* Sticky identity so the sheet keeps the agent in view while the process scrolls. */
-.subagent-detail-hero {
- position: sticky;
- top: 0;
- z-index: 2;
- display: flex;
- flex-direction: row;
- align-items: center;
- gap: 10px;
- padding: 16px 16px 12px;
- background: var(--ds-bg-dock);
-}
-
-.subagent-detail-heading {
- display: flex;
- min-width: 0;
- flex: 1;
- align-items: center;
- gap: 12px;
-}
-
-.subagent-detail-avatar {
- position: relative;
- display: inline-flex;
- width: 36px;
- height: 36px;
- flex: 0 0 auto;
- align-items: center;
- justify-content: center;
- border-radius: var(--radius-round);
- background: var(--ds-tile-deep);
- color: var(--ds-text-secondary);
-}
-
-.subagent-detail-status {
- position: absolute;
- right: -1px;
- bottom: -1px;
- width: 10px;
- height: 10px;
- border: 2px solid var(--ds-bg-dock);
- border-radius: var(--radius-round);
- background: var(--ds-text-muted);
-}
-
-.subagent-detail-status.outcome-completed {
- background: var(--ds-success);
-}
-
-.subagent-detail-status.outcome-running {
- background: var(--ds-accent);
- animation: subagent-status-pulse 1.6s var(--motion-ease-standard) infinite;
-}
-
-.subagent-detail-status.outcome-failed,
-.subagent-detail-status.outcome-denied {
- background: var(--ds-error);
-}
-
-.subagent-detail-status.outcome-truncated,
-.subagent-detail-status.outcome-timed-out {
- background: var(--ds-warning);
-}
-
-@keyframes subagent-status-pulse {
- 50% {
- opacity: 0.45;
- }
-}
-
-@media (prefers-reduced-motion: reduce) {
- .subagent-detail-status.outcome-running,
- .subagent-detail-status.outcome-creating {
- animation: none;
- }
-}
-
-.subagent-detail-heading-copy {
- display: flex;
- min-width: 0;
- flex: 1;
- flex-direction: column;
- justify-content: center;
- gap: 2px;
-}
-
-.subagent-detail-name {
- min-width: 0;
- overflow: hidden;
- color: var(--ds-text-primary);
- font-size: var(--text-base);
- font-weight: var(--font-weight-semibold);
- line-height: var(--leading-tight);
- text-overflow: ellipsis;
- white-space: nowrap;
-}
-
-.subagent-detail-model {
- min-width: 0;
- overflow: hidden;
- color: var(--ds-text-muted);
- font-family: var(--font-mono);
- font-size: var(--text-xs);
- line-height: var(--leading-tight);
- text-overflow: ellipsis;
- white-space: nowrap;
-}
-
-.subagent-detail-summary {
- display: flex;
- flex: 0 0 auto;
- flex-wrap: nowrap;
- align-items: center;
- gap: 6px;
- color: var(--ds-text-muted);
-}
-
-.subagent-detail-badge {
- display: inline-flex;
- flex: none;
- align-items: center;
- height: 20px;
- padding: 0 8px;
- border-radius: var(--radius-full);
- background: var(--ds-tile-deep);
- color: var(--ds-text-secondary);
- font-size: var(--text-xs);
- font-weight: var(--font-weight-medium);
- line-height: var(--leading-none);
- white-space: nowrap;
-}
-
-.subagent-detail-badge.outcome-completed {
- background: color-mix(in oklab, var(--ds-success) 16%, transparent);
- color: var(--ds-success);
-}
-
-.subagent-detail-badge.outcome-running {
- background: var(--ds-tile-deep);
- color: var(--ds-text-primary);
-}
-
-.subagent-detail-badge.outcome-creating {
- background: color-mix(in oklab, var(--ds-purple) 16%, transparent);
- color: var(--ds-purple);
-}
-
-.subagent-detail-status.outcome-creating {
- background: var(--ds-purple);
- animation: subagent-status-pulse 1.6s var(--motion-ease-standard) infinite;
-}
-
-.subagent-detail-badge.outcome-failed,
-.subagent-detail-badge.outcome-denied {
- background: color-mix(in oklab, var(--ds-error) 16%, transparent);
- color: var(--ds-error);
-}
-
-.subagent-detail-badge.outcome-truncated,
-.subagent-detail-badge.outcome-timed-out,
-.subagent-detail-badge.outcome-aborted,
-.subagent-detail-badge.outcome-stopped {
- background: color-mix(in oklab, var(--ds-warning) 16%, transparent);
- color: var(--ds-warning);
-}
-
-.subagent-detail-meta {
- flex: none;
- color: var(--ds-text-muted);
- font-size: var(--text-xs);
- font-variant-numeric: tabular-nums;
- line-height: var(--leading-row);
- white-space: nowrap;
-}
-
-.subagent-detail-task,
-.subagent-detail > .subagent-run {
- padding: 0 16px;
-}
-
-/* Issue #161: the failure card closes out a settled delegate, so it lines up
- with the task card and the run rows instead of the panel's own edges. The
- card carries its own padding, so it is inset with margins. */
-.subagent-detail > .subagent-failure {
- width: auto;
- margin: 0 16px;
-}
-
-.subagent-detail-section-label,
-.subagent-detail > .subagent-run .subagent-run-heading.is-dock {
- min-height: 20px;
- margin: 0;
- color: var(--ds-text-secondary);
- font-size: var(--text-sm);
- font-weight: var(--font-weight-semibold);
- letter-spacing: var(--tracking-wide);
- line-height: var(--leading-row);
- text-transform: uppercase;
-}
-
-:lang(zh-CN) .subagent-detail-section-label,
-:lang(zh-CN) .subagent-detail > .subagent-run .subagent-run-heading.is-dock,
-:lang(zh-TW) .subagent-detail-section-label,
-:lang(zh-TW) .subagent-detail > .subagent-run .subagent-run-heading.is-dock,
-:lang(ko) .subagent-detail-section-label,
-:lang(ko) .subagent-detail > .subagent-run .subagent-run-heading.is-dock {
- letter-spacing: var(--tracking-normal);
- text-transform: none;
-}
-
-.subagent-detail-task {
- display: flex;
- min-width: 0;
- flex-direction: column;
- gap: 8px;
-}
-
-.subagent-detail-task-card {
- min-width: 0;
- border-radius: var(--radius-md);
- background: var(--ds-tile);
- padding: 12px 14px;
-}
-
-.subagent-task-message-body {
- color: var(--ds-text-primary);
- font-size: var(--text-md);
- line-height: var(--leading-body);
- white-space: pre-wrap;
- overflow-wrap: anywhere;
-}
-
-.subagent-task-message-body.is-collapsed {
- display: -webkit-box;
- overflow: hidden;
- -webkit-box-orient: vertical;
- -webkit-line-clamp: 4;
-}
-
-.subagent-task-toggle {
- display: inline-flex;
- align-items: center;
- gap: 2px;
- margin-top: 8px;
- padding: 0;
- color: var(--ds-text-muted);
- font-size: var(--text-sm);
- line-height: var(--leading-row);
+.subagent-transcript-jump {
+ bottom: 76px;
+ z-index: 6;
}
-.subagent-task-toggle svg {
+.subagent-transcript-composer {
flex: none;
- transition: transform var(--motion-duration-fast) var(--motion-ease-out);
-}
-
-.subagent-task-toggle[aria-expanded="true"] svg {
- transform: rotate(180deg);
-}
-
-.subagent-task-toggle:hover {
- color: var(--ds-text-primary);
-}
-
-.subagent-detail > .subagent-run {
- /* This is a flex child of the detail column. Without an explicit zero
- minimum, a long command/path can win the min-content calculation and push
- the whole side sheet past the work-panel edge. */
- min-width: 0;
- margin: 0;
- border-radius: 0;
- background: transparent;
- padding: 0 16px;
-}
-
-.subagent-detail > .subagent-run .subagent-run-heading.is-dock {
- gap: 8px;
-}
-
-.subagent-detail > .subagent-run .subagent-run-heading.is-dock .subagent-run-count {
- color: var(--ds-text-muted);
- font-family: var(--font-sans);
- font-size: var(--text-xs);
- font-weight: var(--font-weight-medium);
- letter-spacing: var(--tracking-normal);
- text-transform: none;
-}
-
-.subagent-detail > .subagent-run .subagent-run-rows {
- position: relative;
- margin-top: 6px;
- padding: 2px 0 8px 16px;
- border-left: 1px solid var(--ds-border-subtle);
- border-radius: 0;
- background: transparent;
-}
-
-.subagent-detail > .subagent-run .subagent-run-rows.is-panel-flow > div {
- display: grid;
- gap: 4px;
- min-width: 0;
-}
-
-.subagent-detail > .subagent-run .subagent-run-rows.is-panel-flow > div > .tool-row,
-.subagent-detail > .subagent-run .subagent-run-rows.is-panel-flow > div > .subagent-answer {
- position: relative;
- min-width: 0;
-}
-
-/* Dock rows share the main transcript's content model: labels may stay
- compact, but the actual path, command, and summary must use the committed
- panel width instead of becoming a one-line ellipsis. */
-.subagent-detail > .subagent-run .subagent-run-rows.is-panel-flow .tool-row-header {
- align-items: flex-start;
- min-height: 28px;
- padding-block: 4px;
-}
-
-.subagent-detail > .subagent-run .subagent-run-rows.is-panel-flow .tool-row-summary {
- overflow: visible;
- overflow-wrap: anywhere;
- text-overflow: clip;
- white-space: normal;
- word-break: break-word;
+ border-top: 1px solid var(--ds-border-subtle);
+ padding: 10px 14px;
}
-.subagent-detail > .subagent-run .subagent-run-rows.is-panel-flow .tool-row-agent {
- max-width: 100%;
- overflow: hidden;
- text-overflow: ellipsis;
-}
-
-.subagent-detail > .subagent-run .subagent-run-rows.is-panel-flow > div > .subagent-answer {
+.subagent-transcript-composer textarea {
+ display: block;
width: 100%;
- overflow-wrap: anywhere;
- word-break: break-word;
+ min-height: calc(var(--leading-chat) * 2em);
+ resize: none;
}
-
-.subagent-detail > .subagent-run .subagent-run-rows.is-panel-flow > div > .tool-row::before,
-.subagent-detail > .subagent-run .subagent-run-rows.is-panel-flow > div > .subagent-answer::before {
- position: absolute;
- top: 12px;
- left: -20px;
- width: 7px;
- height: 7px;
- border: 2px solid var(--ds-bg-dock);
- border-radius: var(--radius-round);
- background: var(--ds-text-muted);
- content: "";
-}
-
-.subagent-detail > .subagent-run .subagent-run-rows.is-panel-flow > div > .tool-row:last-child::before,
-.subagent-detail > .subagent-run .subagent-run-rows.is-panel-flow > div > .subagent-answer:last-child::before {
- background: var(--ds-accent);
-}
-
/* Shared per-tool empty state used by Files and plugin fallback surfaces. */
.work-tab-empty {
display: flex;
diff --git a/apps/desktop/test/interaction-polish.test.mjs b/apps/desktop/test/interaction-polish.test.mjs
index 038276c08..4377e0d87 100644
--- a/apps/desktop/test/interaction-polish.test.mjs
+++ b/apps/desktop/test/interaction-polish.test.mjs
@@ -13,7 +13,7 @@ test("high-traffic chrome uses shared motion tokens on hover fills", () => {
".search-item",
".footer-action",
".notification-item",
- ".work-panel-subagent-back",
+ ".work-panel-tab-close",
]) {
// Match the selector anywhere in a rule's selector list, and require the
// transition inside that rule's own body — a shared list is as valid as a
diff --git a/apps/desktop/test/subagent-panel.test.mjs b/apps/desktop/test/subagent-panel.test.mjs
index 61f6a6170..b04164f6b 100644
--- a/apps/desktop/test/subagent-panel.test.mjs
+++ b/apps/desktop/test/subagent-panel.test.mjs
@@ -3,201 +3,123 @@ import assert from "node:assert/strict";
import { readFile } from "node:fs/promises";
import test from "node:test";
-const panelSource = await readFile(
- new URL("../src/components/workpanel/SubagentPanel.tsx", import.meta.url),
+const tabSource = await readFile(
+ new URL("../src/components/workpanel/SubagentTranscriptTab.tsx", import.meta.url),
"utf8",
);
const workPanelSource = await readFile(
new URL("../src/components/workpanel/WorkPanel.tsx", import.meta.url),
"utf8",
);
+const tabsSource = await readFile(
+ new URL("../src/lib/work-panel-tabs.ts", import.meta.url),
+ "utf8",
+);
const appSource = await readAppSource();
const transcriptSource = await readTranscriptSource();
-const detailSource = transcriptSource.slice(
- transcriptSource.indexOf("export function SubagentDetail"),
- transcriptSource.indexOf("/**\n * A truthful one-level graph", transcriptSource.indexOf("export function SubagentDetail")),
-);
-const failureCardSource = transcriptSource.slice(
- transcriptSource.indexOf("function SubagentFailureCard("),
- transcriptSource.indexOf("export function SubagentDetail"),
-);
const storeSource = await readStoreSource();
const workPanelCss = await readFile(
new URL("../src/styles/work-panel.css", import.meta.url),
"utf8",
);
-const messagesCss = await readFile(
- new URL("../src/styles/messages.css", import.meta.url),
+const englishCatalogSource = await readFile(
+ new URL("../../../packages/i18n/src/locales/en/index.ts", import.meta.url),
+ "utf8",
+);
+const chineseCatalogSource = await readFile(
+ new URL("../../../packages/i18n/src/locales/zh-CN/index.ts", import.meta.url),
"utf8",
);
-test("a topology node toggles a session-scoped side-panel selection", () => {
- assert.match(transcriptSource, /const toggleSubagentPanel = useAppStore\(\(s\) => s\.toggleSubagentPanel\)/);
+test("a topology node opens a real subagent tab in the work panel", () => {
+ assert.match(transcriptSource, /const openSubagentTab = useAppStore\(\(s\) => s\.openSubagentTab\)/);
assert.match(transcriptSource, /const panelSelectionId =/);
- assert.match(transcriptSource, /toggleSubagentPanel\(panelSelectionId\)/);
- assert.match(transcriptSource, /aria-controls=\{panelOpen \? "subagent-panel" : undefined\}/);
- assert.match(transcriptSource, /variant !== "topology" && open/);
- assert.match(transcriptSource, /variant !== "topology" && open && hasDetails/);
- assert.match(storeSource, /subagentPanel: SubagentPanelSelection \| null/);
- assert.match(storeSource, /toggleSubagentPanel:\s*\(delegationId\) => \{/);
+ assert.match(transcriptSource, /openSubagentTab\(panelSelectionId, agentName \|\| undefined\)/);
assert.match(
- storeSource,
- /state\.subagentPanel\?\.sessionId === sessionId[\s\S]*?state\.subagentPanel\.delegationId === id[\s\S]*?set\(\{ subagentPanel: null \}\)/,
+ transcriptSource,
+ /activeWorkPanelTabId === `subagent:\$\{panelSelectionId\}`/,
);
- assert.match(storeSource, /set\(\{ subagentPanel: \{ sessionId, delegationId: id \} \}\)/);
- assert.match(storeSource, /closeSubagentPanel: \(\) => set\(\{ subagentPanel: null \}\)/);
- assert.match(storeSource, /if \(state\.subagentPanel\) \{/);
- assert.match(storeSource, /state\.closeSubagentPanel\(\)/);
- assert.match(storeSource, /if \(get\(\)\.workPanelOpen\) get\(\)\.collapseWorkPanel\(\)/);
-});
-
-test("the side panel renders the live conversation process", () => {
- assert.match(panelSource, /<SubagentDetail/);
- assert.match(panelSource, /data-testid="subagent-panel"/);
- assert.match(panelSource, /selected\.item\.delegate/);
- assert.doesNotMatch(panelSource, /role="tablist"|aria-selected|subagent-panel-tabs/);
- assert.match(transcriptSource, /function delegateTaskDescription\(message: UiMessage\)/);
- assert.match(detailSource, /className="subagent-detail-hero"/);
- assert.match(detailSource, /className="subagent-detail-task-card"/);
- assert.match(detailSource, /panel.subagentTask/);
- assert.match(detailSource, /subagentTaskExpand/);
- assert.match(detailSource, /subagentTaskCollapse/);
- assert.match(detailSource, /aria-controls={taskBodyId}/);
- assert.match(workPanelCss, /-webkit-line-clamp: 4/);
- assert.match(detailSource, /<SubagentRunRows/);
- assert.match(detailSource, /scrollable=\{false\}/);
- assert.match(detailSource, /variant="dock"/);
-});
-
-test("the side panel re-finds live rows instead of storing a stale render snapshot", () => {
- assert.match(panelSource, /buildTranscriptEntries\(messages\)/);
- assert.match(panelSource, /selection\.delegationId/);
- assert.match(panelSource, /useTranscriptView\(selection\.sessionId\)/);
- assert.match(panelSource, /collectDelegationStatuses\(selected\.turnActivityItems/);
- assert.match(panelSource, /collectDelegationTimings\(selected\.turnActivityItems\)/);
- assert.match(panelSource, /<SubagentDetail/);
- assert.match(panelSource, /data-testid="subagent-panel"/);
- assert.match(panelSource, /selected\.item\.message/);
+ assert.match(
+ transcriptSource,
+ /aria-controls=\{panelOpen \? `work-panel-surface-subagent:\$\{panelSelectionId\}` : undefined\}/,
+ );
+ assert.match(storeSource, /openSubagentTab: \(delegationId, agentName\) => \{/);
+ assert.match(
+ storeSource,
+ /openWorkPanelTab\(subagentWorkPanelTab\(id, agentName \|\| undefined\)\)/,
+ );
+ // The overlay state and its actions are gone: closing happens per tab.
+ assert.doesNotMatch(storeSource, /subagentPanel/);
+ assert.doesNotMatch(storeSource, /toggleSubagentPanel|closeSubagentPanel/);
+ assert.match(tabsSource, /\| "plugin"\s*\|\s*"subagent";/);
+ assert.match(
+ tabsSource,
+ /export function subagentWorkPanelTab\(\s*delegationId: string,\s*agentName\?: string,\s*\): WorkPanelTab \{/,
+ );
+ assert.match(tabsSource, /id: `subagent:\$\{delegationId\}`/);
+ assert.match(tabsSource, /tab\.kind === "subagent"\)/);
+ // Retained runtime state must survive the session-switch sanitizer.
+ assert.match(tabsSource, /export function subagentTabDisplayLabels\(/);
+ assert.match(tabsSource, /tab\.kind === "subagent"\)/);
+ // Retained runtime state must survive the session-switch sanitizer.
+ assert.match(tabsSource, /export function subagentTabDisplayLabels\(/);
});
-test("the work-panel dock hosts subagent details without creating a resource tab", () => {
- assert.match(workPanelSource, /subagentPanel\?: SubagentPanelSelection \| null/);
- assert.match(workPanelSource, /onCloseSubagentPanel\?: \(\) => void/);
- assert.match(workPanelSource, /\{subagentPanel \? \(/);
- assert.match(workPanelSource, /<SubagentPanel selection=\{subagentPanel\} \/>/);
- assert.match(workPanelSource, /!subagentPanel && activeTab\?\.kind === "review"/);
- assert.match(workPanelSource, /subagentPanel && onCloseSubagentPanel/);
- assert.match(appSource, /const subagentPanelOpen = Boolean\(/);
- assert.match(appSource, /page === "chat"/);
- assert.match(appSource, /page !== "chat" \|\| subagentPanel\.sessionId !== activeSessionId/);
- assert.match(appSource, /workPanelOpen \|\| subagentPanelOpen/);
- assert.match(appSource, /subagentPanel=\{subagentPanelOpen \? subagentPanel : null\}/);
- assert.doesNotMatch(workPanelSource, /setContextOpen/);
+test("the work panel renders the delegation tab like every other resource", () => {
+ assert.match(workPanelSource, /subagent: IconBot/);
+ assert.match(workPanelSource, /if \(tab\.kind === "subagent"\) return tab\.label \?\? t\("panel\.tabs\.subagent"\);/);
+ assert.match(workPanelSource, /const subagentTabsInOrder = tabs\.filter\(\(tab\) => tab\.kind === "subagent"\)/);
+ assert.match(workPanelSource, /subagentTabDisplayLabels\(/);
+ assert.match(workPanelSource, /\{activeTab\?\.kind === "subagent" && \(/);
+ assert.match(
+ workPanelSource,
+ /<SubagentTranscriptTab delegationId=\{activeTab\.resource \?\? ""\} \/>/,
+ );
+ // The tab strip is never replaced by a dock heading or a back control.
+ assert.doesNotMatch(workPanelSource, /work-panel-subagent-heading|work-panel-subagent-back/);
+ assert.doesNotMatch(workPanelSource, /subagentPanel\?: SubagentPanelSelection/);
+ assert.doesNotMatch(workPanelSource, /!subagentPanel &&/);
+ // The shell no longer overrides visibility for a dock-only surface.
+ assert.match(appSource, /const workPanelVisible = workPanelOpen;/);
+ assert.doesNotMatch(appSource, /subagentPanelOpen/);
});
-test("the task dock keeps one body scroll owner while the process streams", () => {
- assert.match(workPanelCss, /\.subagent-panel \{[^}]*flex: 1/);
- assert.match(workPanelCss, /\.subagent-panel-scroll \{[^}]*overflow-y: auto/);
- assert.match(messagesCss, /\.subagent-run-rows\.is-panel-flow \{[\s\S]*?overflow: visible/);
- assert.match(panelSource, /useFollowScroll\(\)/);
- assert.match(panelSource, /ref=\{scrollRef\}/);
- assert.match(panelSource, /onScroll=\{handleScroll\}/);
- assert.match(panelSource, /onClick=\{jumpToLatest\}/);
- assert.match(panelSource, /role="log"/);
- assert.match(panelSource, /aria-live="polite"/);
- assert.match(panelSource, /tabIndex=\{0\}/);
- assert.match(panelSource, /\[jumpToLatest, selection\.delegationId, searchTarget\]/);
+test("the delegation tab renders a message list with a read-only composer", () => {
+ assert.match(tabSource, /data-testid="subagent-transcript-tab"/);
+ assert.match(tabSource, /buildSubagentTranscript\(messages, delegationId\)/);
+ assert.match(tabSource, /className="message-row user"/);
+ assert.match(tabSource, /className="message-user-text selectable"/);
+ assert.match(tabSource, /className="message-row assistant"/);
+ assert.match(tabSource, /data-message-id=\{row\.message\.id\}/);
+ assert.match(tabSource, /<Textarea/);
+ assert.match(tabSource, /disabled/);
+ assert.match(tabSource, /rows=\{2\}/);
+ assert.match(tabSource, /placeholder=\{t\("panel\.subagentReadOnly"\)\}/);
+ // Display-only: no send path may exist in the composer.
+ assert.doesNotMatch(tabSource, /onSubmit|onSend|api\.send/);
});
-test("subagent process rows wrap long content inside the dock", () => {
- assert.match(
- workPanelCss,
- /\.subagent-detail > \.subagent-run \.subagent-run-rows\.is-panel-flow \.tool-row-header\s*\{[\s\S]*?align-items:\s*flex-start;/,
- );
- assert.match(
- workPanelCss,
- /\.subagent-detail > \.subagent-run \.subagent-run-rows\.is-panel-flow \.tool-row-summary\s*\{[\s\S]*?overflow-wrap:\s*anywhere;[\s\S]*?white-space:\s*normal;/,
- );
- assert.match(
- workPanelCss,
- /\.subagent-detail > \.subagent-run \.subagent-run-rows\.is-panel-flow > div > \.subagent-answer\s*\{[\s\S]*?width:\s*100%;[\s\S]*?overflow-wrap:\s*anywhere;/,
- );
- assert.match(
- messagesCss,
- /\.subagent-run-rows\.is-panel-flow\s*\{[\s\S]*?overflow:\s*visible;/,
- );
+test("the tab owns one scroll surface and pins to the latest output", () => {
+ assert.match(workPanelCss, /\.subagent-transcript-tab \{[^}]*flex-direction: column/);
+ assert.match(workPanelCss, /\.subagent-transcript-scroll \{[^}]*overflow-y: auto/);
+ assert.match(tabSource, /useFollowScroll\(\)/);
+ assert.match(tabSource, /ref=\{scrollRef\}/);
+ assert.match(tabSource, /onScroll=\{handleScroll\}/);
+ assert.match(tabSource, /onClick=\{jumpToLatest\}/);
+ assert.match(tabSource, /role="log"/);
+ assert.match(tabSource, /aria-live="polite"/);
+ assert.match(tabSource, /tabIndex=\{0\}/);
+ assert.match(tabSource, /useTranscriptSearchFocus\(\{/);
});
-test("the subagent dock uses a grouped identity, task card, and process timeline", () => {
- assert.match(
- detailSource,
- /className="subagent-detail-hero"[\s\S]*?subagent-detail-badge[\s\S]*?subagent-detail-meta/,
- );
- assert.match(
- workPanelCss,
- /\.subagent-detail-hero\s*\{[\s\S]*?position:\s*sticky;[\s\S]*?top:\s*0;[\s\S]*?flex-direction:\s*row;/,
- );
- assert.match(
- workPanelCss,
- /\.subagent-detail-summary\s*\{[\s\S]*?flex-wrap:\s*nowrap;/,
- );
- assert.match(
- detailSource,
- /className="subagent-detail-task"[\s\S]*?className="subagent-detail-task-card"/,
- );
- assert.match(
- workPanelCss,
- /\.subagent-detail-task-card\s*\{[\s\S]*?border-radius:\s*var\(--radius-md\);[\s\S]*?background:\s*var\(--ds-tile\);/,
- );
- assert.match(
- workPanelCss,
- /\.subagent-detail-badge\s*\{[\s\S]*?border-radius:\s*var\(--radius-full\);/,
- );
- assert.match(
- workPanelCss,
- /\.subagent-detail > \.subagent-run\s*\{[\s\S]*?min-width:\s*0;[\s\S]*?background:\s*transparent;[\s\S]*?padding:\s*0 16px;/,
- );
- assert.match(messagesCss, /\.subagent-run\s*\{[\s\S]*?min-width:\s*0;/);
- assert.match(messagesCss, /\.subagent-run-follow\s*\{[\s\S]*?min-width:\s*0;/);
- assert.match(
- workPanelCss,
- /\.subagent-detail > \.subagent-run \.subagent-run-rows\s*\{[\s\S]*?border-left:\s*1px solid var\(--ds-border-subtle\);[\s\S]*?background:\s*transparent;/,
- );
- assert.match(transcriptSource, /t\("chat.subagentProcess"\)/);
- assert.match(detailSource, /variant="dock"/);
-});
-
-test("a settled delegate that failed explains itself at the foot of the dock", () => {
- // The status says *that* a delegate failed; only the lifecycle rows can say
- // why (ADR 0089), and the dock is the surface that renders the outcome.
- assert.match(panelSource, /collectDelegationFailures\(selected\.turnActivityItems\)/);
- assert.match(panelSource, /delegationFailures=\{delegationFailures\}/);
- assert.match(
- detailSource,
- /delegationFailures\?: ReadonlyMap<string, DelegationFailure>/,
- );
- assert.match(detailSource, /delegationFailures\?\.get\(delegationId\)/);
- // Tied to a non-success terminal outcome, not to the error field alone, so a
- // completed or still-running delegate never shows an error card.
- assert.match(
- detailSource,
- /failure && outcome !== "completed" && outcome !== "running"/,
- );
- assert.match(failureCardSource, /function SubagentFailureCard\(/);
- assert.match(failureCardSource, /data-testid="subagent-failure"/);
- assert.match(failureCardSource, /className="message-error subagent-failure"/);
- assert.match(failureCardSource, /t\(`chat\.subagentStatus\.\$\{outcome\}`\)/);
- assert.match(failureCardSource, /t\(localizedKey\)/);
- assert.match(failureCardSource, /<CopyButton /);
- // The disclosure control must precede the region it collapses, otherwise
- // hiding the details would take away the control that brings them back.
- assert.match(
- failureCardSource,
- /className="message-error-toggle"[\s\S]*?className=\{`message-error-details/,
- );
- assert.match(
- workPanelCss,
- /\.subagent-detail > \.subagent-failure\s*\{[\s\S]*?margin:\s*0 16px;/,
- );
+test("composer copy names the driver and lives in the field, per locale", () => {
+ for (const [locale, source] of [
+ ["en", englishCatalogSource],
+ ["zh-CN", chineseCatalogSource],
+ ]) {
+ assert.match(source, /subagentReadOnly: "/);
+ assert.match(source, /tabs: \{[^}]*subagent: "/s);
+ assert.doesNotMatch(source, /subagentClose/);
+ }
});
diff --git a/apps/desktop/test/subagent-transcript-turns.test.mjs b/apps/desktop/test/subagent-transcript-turns.test.mjs
new file mode 100644
index 000000000..66cbdfb0f
--- /dev/null
+++ b/apps/desktop/test/subagent-transcript-turns.test.mjs
@@ -0,0 +1,159 @@
+import assert from "node:assert/strict";
+import { register } from "node:module";
+import { dirname, join } from "node:path";
+import test from "node:test";
+import { fileURLToPath, pathToFileURL } from "node:url";
+
+const here = dirname(fileURLToPath(import.meta.url));
+register(pathToFileURL(join(here, "helpers/ts-import-hooks.mjs")));
+const { buildSubagentTranscript } = await import(
+ "../src/lib/subagent-transcript.ts"
+);
+
+function message(id, content, extra = {}) {
+ return { id, content, ...extra };
+}
+
+function taskCall(id, task, extra = {}) {
+ return message(id, "", {
+ role: "tool",
+ toolName: "Task",
+ toolCallId: id,
+ toolArgs: { task },
+ ...extra,
+ });
+}
+
+test("one Task call becomes one user turn followed by the delegate's rows", () => {
+ const messages = [
+ taskCall("call-1", "Find all call sites of resize()", {
+ toolResult: { delegationId: "del-1" },
+ }),
+ message("step-1", "grep resize(", {
+ role: "tool",
+ parentToolCallId: "call-1",
+ agentName: "explorer",
+ }),
+ message("note-1", "Found three call sites.", {
+ role: "assistant",
+ parentToolCallId: "call-1",
+ thinking: "Check the header first.",
+ agentName: "explorer",
+ }),
+ ];
+ const transcript = buildSubagentTranscript(messages, "del-1");
+ assert.ok(transcript);
+ assert.equal(transcript.agentName, "explorer");
+ assert.equal(transcript.turns.length, 1);
+ assert.equal(transcript.turns[0].task, "Find all call sites of resize()");
+ assert.deepEqual(
+ transcript.turns[0].rows.map((row) => row.kind),
+ ["tool", "thinking", "answer"],
+ );
+});
+
+test("a resumed delegation renders follow-up prompts as further user turns", () => {
+ const messages = [
+ taskCall("call-1", "First prompt", {
+ toolResult: { delegationId: "del-1" },
+ }),
+ message("answer-1", "First answer.", {
+ role: "assistant",
+ parentToolCallId: "call-1",
+ }),
+ taskCall("call-2", "Follow-up prompt", {
+ toolArgs: { task: "Follow-up prompt", resume: "call-1" },
+ toolResult: { delegationId: "del-1" },
+ }),
+ message("answer-2", "Second answer.", {
+ role: "assistant",
+ parentToolCallId: "call-2",
+ }),
+ ];
+ const transcript = buildSubagentTranscript(messages, "del-1");
+ assert.equal(transcript.turns.length, 2);
+ assert.equal(transcript.turns[0].task, "First prompt");
+ assert.deepEqual(
+ transcript.turns[0].rows.map((row) => row.message.id),
+ ["answer-1"],
+ );
+ assert.equal(transcript.turns[1].task, "Follow-up prompt");
+ assert.deepEqual(
+ transcript.turns[1].rows.map((row) => row.message.id),
+ ["answer-2"],
+ );
+});
+
+test("a chain is recognized from either end of the resume links", () => {
+ // Only the resumed call carries the result payload; the original call is
+ // linked backward through the runtime's resume record.
+ const messages = [
+ taskCall("call-1", "Original prompt"),
+ taskCall("call-2", "Follow-up prompt", {
+ toolArgs: { task: "Follow-up prompt", resume: "call-1" },
+ toolResult: { delegationId: "del-1" },
+ }),
+ message("answer-1", "Original answer.", {
+ role: "assistant",
+ parentToolCallId: "call-1",
+ }),
+ ];
+ const transcript = buildSubagentTranscript(messages, "del-1");
+ assert.equal(transcript.turns.length, 2);
+ assert.equal(transcript.turns[0].task, "Original prompt");
+});
+
+test("parallel delegates never mix into each other's turns", () => {
+ const messages = [
+ taskCall("call-a", "Task A", {
+ toolResult: { delegationId: "del-a" },
+ }),
+ taskCall("call-b", "Task B", {
+ toolResult: { delegationId: "del-b" },
+ }),
+ message("answer-a", "Answer A.", {
+ role: "assistant",
+ parentToolCallId: "call-a",
+ agentName: "explorer",
+ }),
+ message("answer-b", "Answer B.", {
+ role: "assistant",
+ parentToolCallId: "call-b",
+ agentName: "reviewer",
+ }),
+ ];
+ const a = buildSubagentTranscript(messages, "del-a");
+ const b = buildSubagentTranscript(messages, "del-b");
+ assert.equal(a.agentName, "explorer");
+ assert.deepEqual(
+ a.turns.flatMap((turn) => turn.rows.map((row) => row.message.id)),
+ ["answer-a"],
+ );
+ assert.equal(b.agentName, "reviewer");
+ assert.deepEqual(
+ b.turns.flatMap((turn) => turn.rows.map((row) => row.message.id)),
+ ["answer-b"],
+ );
+});
+
+test("an unknown delegation id yields no transcript", () => {
+ const messages = [taskCall("call-1", "Task", {
+ toolResult: { delegationId: "del-1" },
+ })];
+ assert.equal(buildSubagentTranscript(messages, "missing"), null);
+ assert.equal(buildSubagentTranscript(messages, ""), null);
+});
+
+test("a call with no task argument degrades to an empty prompt", () => {
+ const messages = [
+ message("call-1", "", {
+ role: "tool",
+ toolName: "Task",
+ toolCallId: "call-1",
+ toolArgs: {},
+ toolResult: { delegationId: "del-1" },
+ }),
+ ];
+ const transcript = buildSubagentTranscript(messages, "del-1");
+ assert.equal(transcript.turns[0].task, "");
+});
diff --git a/apps/desktop/test/subagent-transcript.test.mjs b/apps/desktop/test/subagent-transcript.test.mjs
index fdb08a085..e7834a67d 100644
--- a/apps/desktop/test/subagent-transcript.test.mjs
+++ b/apps/desktop/test/subagent-transcript.test.mjs
@@ -8,10 +8,6 @@ import { readFile } from "node:fs/promises";
import test from "node:test";
const transcriptSource = await readTranscriptSource();
-const detailSource = transcriptSource.slice(
- transcriptSource.indexOf("function delegateTaskDescription"),
- transcriptSource.indexOf("/**\n * A truthful one-level graph", transcriptSource.indexOf("function delegateTaskDescription")),
-);
const runtimeSource = await readFile(
new URL("../../../packages/agent-runtime/src/runtime.ts", import.meta.url),
"utf8",
@@ -129,21 +125,13 @@ test("a terminal tool event repairs a row lost during renderer reload", () => {
assert.match(eventsSource, /toolName: message\.toolName \?\? completed\.toolName/);
});
-test("the shared side-panel detail keeps the live conversation process", () => {
+test("inline delegate runs keep the live conversation process", () => {
assert.match(transcriptSource, /delegate\?: SubagentRun/);
- assert.match(detailSource, /function delegateTaskDescription\(message: UiMessage\)/);
- assert.match(detailSource, /className="subagent-detail-hero"/);
- assert.match(detailSource, /className="subagent-detail-task-card"/);
- assert.match(detailSource, /taskOverflow/);
- assert.match(detailSource, /setTaskOverflow\(\(current\) => \(taskExpanded \? current : overflowing\)\)/);
- assert.match(detailSource, /aria-expanded=\{taskExpanded\}/);
- assert.match(detailSource, /aria-controls=\{taskBodyId\}/);
- assert.match(detailSource, /<SubagentRunRows/);
- assert.match(detailSource, /scrollable=\{false\}/);
+ assert.match(transcriptSource, /<SubagentRunRows/);
+ assert.match(transcriptSource, /variant !== "topology" && open && hasDetails/);
assert.match(transcriptSource, /className=\{`subagent-run-rows\$\{scrollable \? "" : " is-panel-flow"\}`\}/);
assert.match(transcriptSource, /onScroll=\{scrollable \? handleScroll : undefined\}/);
assert.match(transcriptSource, /\{scrollable && showJump \?/);
- assert.doesNotMatch(detailSource, /<ToolDetailBlocks blocks=\{blocks\}/);
});
test("a Task row is expandable and names the delegate it used", () => {
@@ -201,10 +189,6 @@ test("a Task node and detail header show the effective thinking level", () => {
transcriptSource,
/className="subagent-topology-node-model"[\s\S]*?title=\{modelLabel\}[\s\S]*?aria-label=\{modelLabel\}/,
);
- assert.match(
- transcriptSource,
- /className="subagent-detail-model"[\s\S]*?title=\{modelLabel\}[\s\S]*?aria-label=\{modelLabel\}/,
- );
});
test("the report is printed once: in the body, or as the nested answer", () => {
@@ -258,9 +242,11 @@ test("every Task row renders as one accessible delegation topology", () => {
assert.match(transcriptSource, /role="list"/);
assert.match(transcriptSource, /variant="topology"/);
assert.match(transcriptSource, /className="subagent-topology-node-header"/);
- assert.match(transcriptSource, /data-subagent-trigger=\{panelSelectionId\}/);
- assert.match(transcriptSource, /aria-controls=\{panelOpen \? "subagent-panel" : undefined\}/);
assert.match(transcriptSource, /aria-expanded=\{panelOpen\}/);
+ assert.match(
+ transcriptSource,
+ /aria-controls=\{panelOpen \? `work-panel-surface-subagent:\$\{panelSelectionId\}` : undefined\}/,
+ );
const topologyNode = transcriptSource.slice(
transcriptSource.indexOf('className="subagent-topology-node-header"'),
transcriptSource.indexOf(
@@ -271,17 +257,17 @@ test("every Task row renders as one accessible delegation topology", () => {
assert.doesNotMatch(topologyNode, /tool-row-caret/);
assert.match(
topologyNode,
- /onClick=\{\(\) => \{\s*if \(!hasDetails\) return;\s*onUserInteraction\?\.\(\);\s*toggleSubagentPanel\(panelSelectionId\);\s*\}\}/,
+ /onClick=\{\(\) => \{\s*if \(!hasDetails\) return;\s*onUserInteraction\?\.\(\);\s*openSubagentTab\(panelSelectionId, agentName \|\| undefined\);\s*\}\}/,
);
assert.match(
transcriptSource,
- /const toggleSubagentPanel = useAppStore\(\(s\) => s\.toggleSubagentPanel\)/,
+ /const openSubagentTab = useAppStore\(\(s\) => s\.openSubagentTab\)/,
);
- assert.match(storeSource, /toggleSubagentPanel:\s*\(delegationId\) => \{/);
assert.match(
- storeSource,
- /state\.subagentPanel\?\.sessionId === sessionId[\s\S]*?state\.subagentPanel\.delegationId === id[\s\S]*?set\(\{ subagentPanel: null \}\)/,
+ transcriptSource,
+ /activeWorkPanelTabId === `subagent:\$\{panelSelectionId\}`/,
);
+ assert.match(storeSource, /openWorkPanelTab\(subagentWorkPanelTab\(id, agentName \|\| undefined\)\)/);
assert.match(transcriptSource, /const inlineOpen = variant !== "topology" && open;/);
});
diff --git a/apps/desktop/test/transcript-reading.test.mjs b/apps/desktop/test/transcript-reading.test.mjs
index 4c0eeba61..8cee8d1ac 100644
--- a/apps/desktop/test/transcript-reading.test.mjs
+++ b/apps/desktop/test/transcript-reading.test.mjs
@@ -50,7 +50,6 @@ function reader(read, overrides = {}) {
retainedSessionIds: ["s"],
retainedTranscripts: {},
runningSessions: {},
- subagentPanel: null,
showToast: (error) => errors.push(error),
...overrides,
};
@@ -221,15 +220,13 @@ test("a nested result opens its real Task and exposes its answer even outside th
});
const r = reader(async () => page([child], { navigationParent: parent }));
await r.navigateTranscript(target("child"));
- assert.equal(r.get().subagentPanel.delegationId, "task-call");
- assert.equal(r.get().subagentPanel.searchRequestId, r.view().focus.requestId);
+ assert.equal(r.view().focus.messageId, "child");
const { entries } = buildTranscriptEntries(r.visible());
const task = entries[0].parts[0].items[0];
assert.equal(task.message.id, parent.id);
assert.equal(task.delegate.items[0].message.id, child.id);
assert.equal(r.view().messageStart, 20, "parent context does not move physical cursors");
r.returnToLatestTranscript("s");
- assert.equal(r.get().subagentPanel, null);
});
test("a failed search cannot restore a cancelled page's loading state or ownership", async () => {
@@ -296,7 +293,6 @@ test("a session switch cannot let an old nested search open the new session's pa
}),
);
await navigation;
- assert.equal(r.get().subagentPanel, null);
assert.equal(r.view(), undefined);
});
diff --git a/apps/desktop/test/transcript-search-rendering.test.mjs b/apps/desktop/test/transcript-search-rendering.test.mjs
index 7e4f68a71..14272aae0 100644
--- a/apps/desktop/test/transcript-search-rendering.test.mjs
+++ b/apps/desktop/test/transcript-search-rendering.test.mjs
@@ -24,8 +24,8 @@ test("rendered Markdown and file chips map source-only hits to their visible own
const { LinkifiedText } = await server.ssrLoadModule(
"/src/features/chat/transcript/shared.tsx",
);
- const { SubagentPanel } = await server.ssrLoadModule(
- "/src/components/workpanel/SubagentPanel.tsx",
+ const { SubagentTranscriptTab } = await server.ssrLoadModule(
+ "/src/components/workpanel/SubagentTranscriptTab.tsx",
);
const { useAppStore } = await server.ssrLoadModule("/src/stores/app-store.ts");
const { ActivityGroup } = await server.ssrLoadModule(
@@ -182,8 +182,8 @@ test("rendered Markdown and file chips map source-only hits to their visible own
},
},
});
- const panel = render(SubagentPanel, {
- selection: { sessionId: "s", delegationId: "task", searchRequestId: 1 },
+ const panel = render(SubagentTranscriptTab, {
+ delegationId: "task",
});
assert.match(panel, /data-message-id="child"/);
const groupProps = { items: [{ kind: "tool", message: parent }], isActive: false };
@@ -206,13 +206,13 @@ test("rendered Markdown and file chips map source-only hits to their visible own
);
assert.match(panel, /<strong data-source-start="5" data-source-end="15">needle<\/strong>/);
- assert.doesNotMatch(panel, /subagent-panel-empty/);
+ assert.doesNotMatch(panel, /subagent-transcript-empty/);
Object.assign(useAppStore.getInitialState(), {
transcriptViews: {},
messages: [parent, { ...child, content: "Updated live answer." }],
});
- const livePanel = render(SubagentPanel, {
- selection: { sessionId: "s", delegationId: "task" },
+ const livePanel = render(SubagentTranscriptTab, {
+ delegationId: "task",
});
assert.match(livePanel, /Updated live answer/);
assert.doesNotMatch(livePanel, /Read <strong/);
diff --git a/apps/desktop/test/work-panel-tabs.test.mjs b/apps/desktop/test/work-panel-tabs.test.mjs
index 1b0b9de63..1c6bbe56e 100644
--- a/apps/desktop/test/work-panel-tabs.test.mjs
+++ b/apps/desktop/test/work-panel-tabs.test.mjs
@@ -19,6 +19,8 @@ const {
replaceWorkPanelTabState,
reorderWorkPanelTabsState,
sanitizeWorkPanelTabsState,
+ subagentTabDisplayLabels,
+ subagentWorkPanelTab,
switchWorkPanelContextState,
toolWorkPanelTab,
} = await import("../src/lib/work-panel-tabs.ts");
@@ -282,3 +284,58 @@ test("a newer retained artifact is not overwritten by a stale visible projection
assert.deepEqual(switched.contexts["session-a"], retained);
assert.deepEqual(switched.visible, emptyWorkPanelContext());
});
+
+test("subagent tabs key by delegation and carry the captured agent name", () => {
+ const tab = subagentWorkPanelTab("del-1", "explorer");
+ assert.equal(tab.id, "subagent:del-1");
+ assert.equal(tab.kind, "subagent");
+ assert.equal(tab.resource, "del-1");
+ assert.equal(tab.label, "explorer");
+ const unnamed = subagentWorkPanelTab("del-2");
+ assert.equal(unnamed.label, undefined);
+});
+
+test("subagent tabs reopen in place and close like any resource tab", () => {
+ const empty = { tabs: [], activeTabId: null };
+ const first = openWorkPanelTabState(empty, subagentWorkPanelTab("del-1", "explorer"));
+ const second = openWorkPanelTabState(
+ first,
+ subagentWorkPanelTab("del-2", "explorer"),
+ );
+ assert.equal(second.tabs.length, 2);
+ assert.equal(second.activeTabId, "subagent:del-2");
+ // Re-opening the same delegation reuses its tab instead of stacking one.
+ const reopened = openWorkPanelTabState(second, subagentWorkPanelTab("del-1"));
+ assert.equal(reopened.tabs.length, 2);
+ assert.equal(reopened.activeTabId, "subagent:del-1");
+ const closed = closeWorkPanelTabState(reopened, "subagent:del-1");
+ assert.deepEqual(
+ closed.tabs.map((tab) => tab.id),
+ ["subagent:del-2"],
+ );
+ assert.equal(closed.activeTabId, "subagent:del-2");
+});
+
+test("the sanitizer keeps subagent tabs across session switches", () => {
+ const state = {
+ tabs: [subagentWorkPanelTab("del-1", "explorer"), toolWorkPanelTab("review")],
+ activeTabId: "subagent:del-1",
+ };
+ assert.equal(isKnownWorkPanelTab({ id: "x", kind: "subagent" }), true);
+ assert.deepEqual(sanitizeWorkPanelTabsState(state), state);
+ const switched = switchWorkPanelContextState(
+ {},
+ undefined,
+ { ...state, open: true, fileRequest: null },
+ "session-b",
+ );
+ assert.deepEqual(switched.visible.tabs, []);
+});
+
+test("repeated subagent labels gain a strip-order suffix, singletons stay bare", () => {
+ assert.deepEqual(
+ subagentTabDisplayLabels(["explorer", "reviewer", "explorer", "explorer"]),
+ ["explorer#1", "reviewer", "explorer#2", "explorer#3"],
+ );
+ assert.deepEqual(subagentTabDisplayLabels(["explorer"]), ["explorer"]);
+});
diff --git a/apps/desktop/test/work-panel.test.mjs b/apps/desktop/test/work-panel.test.mjs
index d6e2c571b..08ef9e209 100644
--- a/apps/desktop/test/work-panel.test.mjs
+++ b/apps/desktop/test/work-panel.test.mjs
@@ -28,12 +28,10 @@ const panelSource = await readFile(
const transcriptSource = await readTranscriptSource();
const storeSource = await readStoreSource();
const globalStyles = await loadStyles();
-test("closing a subagent panel restores focus to its transcript trigger", () => {
- assert.match(panelSource, /const closeSubagentPanelAndFocus = useCallback/);
- assert.match(panelSource, /data-subagent-trigger/);
- assert.match(panelSource, /candidate\.dataset\.subagentTrigger === delegationId/);
- assert.match(panelSource, /trigger\?\.focus\(\{ preventScroll: true \}\)/);
- assert.match(panelSource, /onClick=\{closeSubagentPanelAndFocus\}/);
+test("closing a tab restores focus to its neighbor or the new-tab action", () => {
+ assert.match(panelSource, /const closeTabAndFocus = useCallback/);
+ assert.match(panelSource, /tabButtonRefs\.current\[nextTab\.id\]\?\.focus/);
+ assert.match(panelSource, /else newTabButtonRef\.current\?\.focus\(\)/);
});
test("work panel replaces the context panel overlay", async () => {
@@ -58,9 +56,10 @@ test("a viewport-fixed toggle is the sole pointer collapse control", () => {
assert.match(appSource, /className="app-work-panel-toggle no-drag"/);
assert.match(appSource, /aria-pressed=\{workPanelOpen \|\| presentedWorkPanelOpen\}/);
assert.match(appSource, /togglePresentedWorkPanel/);
- assert.match(appSource, /if \(store\.subagentPanel\) \{\s*store\.toggleWorkPanel\(\);/s);
assert.doesNotMatch(appSource, /onCollapse=/);
- assert.doesNotMatch(panelSource, /onCollapse/);
+ // The dock-only subagent branch is gone; the toggle routes through the
+ // panel's own open/collapse path.
+ assert.doesNotMatch(appSource, /store\.subagentPanel/);
assert.doesNotMatch(panelSource, /work-panel-toolbar-collapse/);
assert.match(
globalStyles,
@@ -156,7 +155,7 @@ test("the work panel shortcut closes the panel it opened", () => {
storeSource.indexOf("toggleWorkPanel: () => {"),
storeSource.indexOf("openWorkPanelTabForSession: (sessionId, tab) => {"),
);
- assert.match(toggleBody, /get\(\)\.workPanelOpen/);
+ assert.match(toggleBody, /state\.workPanelOpen/);
assert.match(toggleBody, /collapseWorkPanel\(\)/);
assert.match(toggleBody, /openWorkPanel\(\)/);
});
@@ -244,8 +243,10 @@ test("work panel header exposes a scrollable tab strip and direct new-page actio
assert.match(panelSource, /data-work-panel-launcher-item=\{item\.id\}/);
assert.doesNotMatch(panelSource, /aria-haspopup|work-panel-new-menu|role="menuitemradio"/);
assert.match(panelSource, /role="tabpanel"/);
- assert.match(panelSource, /className="work-panel-subagent-back"/);
- assert.match(panelSource, /IconChevronLeft/);
+ // Subagent details are tabs, not a dock takeover: the bot icon labels the
+ // tab kind and no separate back control exists.
+ assert.match(panelSource, /subagent: IconBot/);
+ assert.doesNotMatch(panelSource, /work-panel-subagent-back|IconChevronLeft/);
// Reopening an already-open plugin view must reuse its tab so the browser
// keeps its location instead of being replaced by a blank singleton.
assert.match(
@@ -556,7 +557,7 @@ test("the panel and a new tab share the same launcher rows", async () => {
);
// `Cmd/Ctrl+J` reveals the panel without creating a tab, while `+` creates
// an explicit launcher tab. Both states offer the same tool rows.
- assert.match(panelSource, /!subagentPanel && \(!activeTab \|\| activeTab\.kind === "new"\)/);
+ assert.match(panelSource, /\(\!activeTab \|\| activeTab\.kind === "new"\)/);
assert.match(panelSource, /data-testid="work-panel-empty"/);
assert.match(panelSource, /panel\.new\.title/);
assert.match(panelSource, /panel\.toolsAndPanels/);
diff --git a/docs/spec/04-ux/08-component-spec.md b/docs/spec/04-ux/08-component-spec.md
index 6d4a2cf74..db32a9169 100644
--- a/docs/spec/04-ux/08-component-spec.md
+++ b/docs/spec/04-ux/08-component-spec.md
@@ -2331,40 +2331,51 @@ never summarizes from its own arguments:
└────────────────┘ └───────────────────────────────────────────┘
```
-Clicking a topology node toggles an inset grouped side sheet in the right-side
-work-panel dock rather than expanding the transcript. Clicking the selected node
-again closes the side sheet; selecting another node replaces the current detail
-in place:
+Clicking a topology node opens a dedicated `subagent` tab in the work panel —
+the same tab strip that hosts Review, files, and plugin views — instead of
+expanding the transcript. Re-opening the same delegation activates its tab;
+parallel delegates coexist as independent tabs. The tab renders the delegation
+as a conversation:
```text
┌──────────────────────────────────────────────┐
-│ [bot] code-reviewer [Completed] 32s │
-│ claude-sonnet-4-5 │
-│ │
-│ TASK │
-│ ┌──────────────────────────────────────────┐ │
-│ │ Review the changes in src/stores for … │ │
-│ │ Show more │ │
-│ └──────────────────────────────────────────┘ │
-│ │
-│ ACTIVITY 3 steps │
-│ ● Thinking … │
-│ ● Read store.ts │
+│ [bot] [code-reviewer] [✕] [bot] [explorer#2] [✕] [+] ⤢ │
+├──────────────────────────────────────────────┤
+│ ┌──────────────────────┐ │
+│ │ Review the changes │ │
+│ │ in src/stores. │ │
+│ └──────────────────────┘ │
+│ ● Thinking … │
+│ ● Read store.ts │
+│ The store diff looks consistent. … │
+│ ┌──────────────────────┐ │
+│ │ Now check the tests. │ │
+│ └──────────────────────┘ │
+│ ● Edit composer.tsx │
+├──────────────────────────────────────────────┤
+│ [ Subagents are driven by the main agent… ] │
└──────────────────────────────────────────────┘
```
-- The dock renders a sticky identity header with the delegate name and model
- on the left and the status capsule plus elapsed time trailing on the same
- row, followed by the Task call's `task` argument as a selectable inset
- grouped card and the live process timeline.
-- Reports and counters remain omitted from this surface. The live thinking,
- tool, and answer process is shown on the dock timeline. The topology card
- remains a compact summary in the transcript and does not gain height when
- the dock opens.
-- The selected task is re-found from the session's live/retained messages, so
- the header status and elapsed time stay current while the delegate runs.
-- A missing or deleted task renders a localized unavailable state. Delegation
- rows remain excluded from the parent turn stream and minimap.
+- The tab is a message list, not a card: every `Task` call of the resume
+ chain renders its `task` argument as a user row (the main transcript's user
+ bubble), and the delegate's thinking, tool, and answer rows under that call
+ render with the same message-list language, so a follow-up prompt reads as
+ the next user turn.
+- The composer at the foot is a disabled two-row textarea whose placeholder
+ says subagents are driven by the main agent and cannot take input; the tab
+ is display-only and has no send path.
+- Tab labels carry the agent name captured when the tab opened, with a
+ strip-order `#n` suffix when the same name occurs more than once; a
+ localization fallback covers a delegate with no name.
+- Tabs are never opened automatically when a delegate starts. They persist
+ after the delegate settles until the user closes them and are scoped to
+ their session like every other tab.
+- The conversation is re-found from the session's live/retained messages, so
+ streaming rows keep arriving in the open tab while the delegate runs.
+- A delegation whose Task calls are missing renders a localized unavailable
+ state. Delegation rows remain excluded from the parent turn stream and
+ minimap.
- Runs are rebuilt from the message list on every render, so group memoization
compares them by row identity and length rather than by object identity —
diff --git a/docs/spec/04-ux/09-interaction-patterns.md b/docs/spec/04-ux/09-interaction-patterns.md
index a46ad44f4..6a48c4577 100644
--- a/docs/spec/04-ux/09-interaction-patterns.md
+++ b/docs/spec/04-ux/09-interaction-patterns.md
@@ -1362,28 +1362,33 @@ Project drag/drop follows these patterns:
- Button appears as soon as upward scrolling releases follow mode
- Click button: scrolls to bottom, resumes auto-scroll
- Button disappears when at bottom
-- The subagent task dock uses the same single-body scroll owner as the work
- panel. It renders the task description followed by the delegate's live
- thinking, tool, and answer rows in normal content flow; it does not mount a
- nested `.subagent-run-rows` workflow scrollbar. While the panel is pinned,
- new process rows stay in view; a real upward gesture pauses follow and shows
- the standard jump-to-latest control. This keeps the process readable without
- a second scrollbar or an empty tail.
-- Clicking a delegation topology node toggles an inset grouped side sheet in the
- right-side work-panel dock instead of expanding the transcript. Clicking the
- selected node again closes the side sheet; selecting another node replaces
- the current detail in place. The dock has
- a sticky identity header (avatar, name, and model caption on the left; status
- capsule and elapsed time trailing on the same row), the Task call's selectable description as a full-width grouped
- card under a Task section label, capped at four lines with an inline Show
- more / Show less control for longer tasks, and its live process under an
- Activity section on one subtle vertical timeline; it does not render separate
- details, output, or workflow tabs. At the minimum panel width, long commands,
- paths, and tool summaries remain contained by the dock instead of expanding
- the side sheet past the client area.
- Selecting another node replaces the task in place, closing it restores the
- prior resource view when present, and switching sessions or routes hides the
- selection. `Cmd/Ctrl + J` hides the whole dock.
+- A delegation tab uses the same single-body scroll owner as the work panel.
+ It renders the delegate's conversation — each `Task` call's prompt as a user
+ row followed by the delegate's live thinking, tool, and answer rows — in
+ normal content flow; it does not mount a nested `.subagent-run-rows`
+ workflow scrollbar. While the panel is pinned, new rows stay in view; a real
+ upward gesture pauses follow and shows the standard jump-to-latest control.
+ This keeps the conversation readable without a second scrollbar or an empty
+ tail.
+- Clicking a delegation topology node opens (or activates) a dedicated
+ `subagent` tab in the work panel instead of expanding the transcript or
+ replacing the tab strip. Multiple delegations coexist as independent tabs —
+ ten subagents yield ten tabs — with the standard tab affordances (activate,
+ drag-reorder, close via ×, middle-click, or Delete, and wheel overflow).
+ A tab shows the delegation as a message list: every `Task` call of the
+ resume chain renders its prompt as a user row, and the rows the delegate
+ produced under that call render with the main transcript's message-list
+ language, so a follow-up prompt reads as the next user turn. The tab is
+ display-only: a disabled two-row composer sits at the foot with an in-field
+ hint that subagents are driven by the main agent and cannot take input; no
+ send path exists. At the minimum panel width, long commands, paths, and
+ tool summaries wrap inside the committed width instead of expanding the
+ panel past the client area.
+ A tab is never opened automatically when a delegate starts; only a node
+ click opens one. Tabs persist after the delegate settles until the user
+ closes them, and they are scoped to their session like every other tab.
+ Switching sessions or routes hides the panel; `Cmd/Ctrl + J` toggles the
+ whole work panel.
### 9.1a Sidebar project path and open folder
diff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.md
index fd50459a5..99df71764 100644
--- a/docs/spec/06-delivery/04-e2e-test-plan.md
+++ b/docs/spec/06-delivery/04-e2e-test-plan.md
@@ -6552,6 +6552,41 @@ must keep splitting are covered by `markdown-blocks.test.mjs`.
`apps/desktop/test/rpc-lifecycle-contract.test.mjs` (client precheck),
`packages/shared/src/rpc-limits.test.ts`. Desktop journey remains Draft.
+#### E2E-248: Subagent details open as closable work-panel tabs with a read-only composer
+
+- **Preconditions**: A project-bound Agent session whose assistant emits at
+ least two `Task` calls — one named `explorer` and one resumed `explorer`
+ follow-up — plus one `Task` that ends in failure; the work panel closed.
+- **Steps**:
+ 1. Run the turn. Without clicking anything, verify the panel stays closed
+ while the delegates run (no tab is opened automatically).
+ 2. Click the `explorer` topology node. Verify a `subagent` tab opens in the
+ work panel's normal tab strip (labeled `explorer`, bot icon) and the
+ tab strip keeps its other tabs.
+ 3. Click the second (resumed) `explorer` node. Verify a second tab opens
+ labeled `explorer#2`, both tabs coexist, and each can be activated,
+ drag-reordered, and closed via ×, middle-click, or Delete.
+ 4. In the resumed tab, verify the conversation reads `user: first prompt`,
+ delegate rows, `user: follow-up prompt`, delegate rows — the same
+ message-list language as the main transcript (user bubbles, tool rows,
+ thinking rows, markdown answers).
+ 5. Verify the composer at the foot is a disabled two-row textarea whose
+ placeholder reads the read-only hint, in every supported locale.
+ 6. Wait for the failed delegate to settle, open its tab, and verify the
+ ended tab persists until manually closed.
+ 7. Switch to another session and back. Verify the tabs are restored per
+ session and closed tabs stay closed.
+- **Expected**: No auto-open on delegate start; N subagents = N coexisting
+ closable tabs with deduplicated `name#n` labels; the tab body is the
+ delegation's user/assistant message stream with follow-up prompts as user
+ turns; the composer is disabled with the in-field hint and has no send
+ path; ended delegates' tabs persist until closed; tabs are session-scoped.
+- **Specs linked**: `04-ux/08-component-spec.md` (delegation tab),
+ `04-ux/09-interaction-patterns.md` (work panel tabs)
+- **Acceptance**: Quality
+- **Milestone**: M6
+- **Status**: Draft
+
#### E2E-119: Parallel subagents report back without entering the parent's context
- **Preconditions**: A project-bound Agent session with the user home containing
@@ -6578,10 +6613,10 @@ must keep splitting are covered by `markdown-blocks.test.mjs`.
7. Switch the session to Plan, then to Goal, and inspect the tool catalog.
8. Reload the session and re-expand the delegation card and every `Task`
node.
- 9. Open a node with a long description and long tool paths, then resize the
- work-panel dock to its minimum, default, and a wider width. Inspect the
- topology card and live process at each width without repeatedly dragging
- the divider to read a complete line.
+ 9. Open a node with a long description and long tool paths. Resize the work
+ panel to its minimum, default, and a wider width and inspect the topology
+ card and the delegation tab at each width. Long content wraps inside the
+ committed width without dragging the divider to read a complete line.
- **Expected**:
- Both delegates in step 1 run concurrently, and `pinned` streams on its own
provider/model while the parent keeps the session's.
@@ -6599,11 +6634,11 @@ must keep splitting are covered by `markdown-blocks.test.mjs`.
count. Expanding a node shows the brief, report exactly once, and
`status`/`turns`/`toolCalls`. Delegate rows appear only inside that node,
never in the turn stream or the minimap.
- - At narrow, default, and wide dock widths, topology titles, descriptions,
+ - At narrow, default, and wide panel widths, topology titles, descriptions,
and step summaries reflow within the card instead of using a fixed
one-line ellipsis. Long tool paths, commands, and answer fragments in the
- dock wrap inside the committed width, produce no horizontal overflow, and
- retain the panel body as the only scroll owner.
+ delegation tab wrap inside the committed width, produce no horizontal
+ overflow, and retain the tab as the only scroll owner.
- If the parent keeps working after those `Task` calls — thinking, `Read`,
`Grep`, or a lifecycle row — that work is a separate processing group, not
rows inside the delegation card (D319). The card's tile, “Subagent working”
diff --git a/packages/i18n/src/locales/de/index.ts b/packages/i18n/src/locales/de/index.ts
index 8fbea7eb2..f9fed0ed5 100644
--- a/packages/i18n/src/locales/de/index.ts
+++ b/packages/i18n/src/locales/de/index.ts
@@ -1725,7 +1725,7 @@ sklm: {
"subagent": "Unteragent",
"subagentTask": "Aufgabe",
"subagentTaskEmpty": "Keine Aufgabenbeschreibung.",
- "subagentClose": "Unteragent-Details schließen",
+ "subagentReadOnly": "Unteragenten werden vom Haupt-Agenten gesteuert — eine Eingabe ist nicht möglich.",
"subagentEmpty": "Die Unteragent-Details sind nicht mehr verfügbar.",
"resize": "Größe des Arbeitsfensters ändern",
"maximize": "Expand work panel",
@@ -1741,7 +1741,8 @@ sklm: {
"review": "Überprüfen",
"browser": "Browser",
"file": "Dateien",
- "plugin": "Plugin-Ansicht"
+ "plugin": "Plugin-Ansicht",
+ "subagent": "Subagent"
},
"pluginView": {
"failed": "Diese Ansicht konnte nicht geladen werden. Laden Sie das Plugin neu und versuchen Sie es erneut."
diff --git a/packages/i18n/src/locales/en/index.ts b/packages/i18n/src/locales/en/index.ts
index 177d31eba..249749a58 100644
--- a/packages/i18n/src/locales/en/index.ts
+++ b/packages/i18n/src/locales/en/index.ts
@@ -1744,7 +1744,7 @@ sklm: {
subagent: "Subagent",
subagentTask: "Task",
subagentTaskEmpty: "No task description.",
- subagentClose: "Close subagent details",
+ subagentReadOnly: "Subagents are driven by the main agent — input is unavailable.",
subagentEmpty: "Subagent details are no longer available.",
resize: "Resize work panel",
maximize: "Expand work panel",
@@ -1761,6 +1761,7 @@ sklm: {
browser: "Browser",
file: "Files",
plugin: "Plugin view",
+ subagent: "Subagent",
},
pluginView: {
failed: "This view could not be loaded. Reload the plugin and try again.",
diff --git a/packages/i18n/src/locales/es/index.ts b/packages/i18n/src/locales/es/index.ts
index 72845cab5..ed3657f14 100644
--- a/packages/i18n/src/locales/es/index.ts
+++ b/packages/i18n/src/locales/es/index.ts
@@ -1725,7 +1725,7 @@ sklm: {
"subagent": "Subagente",
"subagentTask": "Tarea",
"subagentTaskEmpty": "No hay descripción de la tarea.",
- "subagentClose": "Cerrar detalles del subagente",
+ "subagentReadOnly": "Los subagentes son dirigidos por el agente principal; no se puede escribir aquí.",
"subagentEmpty": "Los detalles del subagente ya no están disponibles.",
"resize": "Cambiar tamaño del panel de trabajo",
"maximize": "Expand work panel",
@@ -1741,7 +1741,8 @@ sklm: {
"review": "Revisar",
"browser": "Navegador",
"file": "Archivos",
- "plugin": "Vista de complemento"
+ "plugin": "Vista de complemento",
+ "subagent": "Subagente"
},
"pluginView": {
"failed": "Esta vista no se pudo cargar. Vuelva a cargar el complemento e inténtelo de nuevo."
diff --git a/packages/i18n/src/locales/fr/index.ts b/packages/i18n/src/locales/fr/index.ts
index bb507fb1d..d02da9d12 100644
--- a/packages/i18n/src/locales/fr/index.ts
+++ b/packages/i18n/src/locales/fr/index.ts
@@ -1725,7 +1725,7 @@ sklm: {
"subagent": "Sous-agent",
"subagentTask": "Tâche",
"subagentTaskEmpty": "Aucune description de tâche.",
- "subagentClose": "Fermer les détails du sous-agent",
+ "subagentReadOnly": "Les sous-agents sont pilotés par l'agent principal — la saisie est indisponible.",
"subagentEmpty": "Les détails du sous-agent ne sont plus disponibles.",
"resize": "Redimensionner le panneau de travail",
"maximize": "Expand work panel",
@@ -1741,7 +1741,8 @@ sklm: {
"review": "Réviser",
"browser": "Navigateur",
"file": "Fichiers",
- "plugin": "Vue du plugin"
+ "plugin": "Vue du plugin",
+ "subagent": "Sous-agent"
},
"pluginView": {
"failed": "Cette vue n'a pas pu être chargée. Rechargez le plugin et réessayez."
diff --git a/packages/i18n/src/locales/ko/index.ts b/packages/i18n/src/locales/ko/index.ts
index 07b065e68..c3c165e53 100644
--- a/packages/i18n/src/locales/ko/index.ts
+++ b/packages/i18n/src/locales/ko/index.ts
@@ -1741,7 +1741,7 @@ sklm: {
subagent: "서브에이전트",
subagentTask: "작업",
subagentTaskEmpty: "작업 설명이 없습니다.",
- subagentClose: "서브에이전트 세부 정보 닫기",
+ subagentReadOnly: "서브에이전트는 메인 에이전트가 구동하므로 입력할 수 없습니다.",
subagentEmpty: "서브에이전트 세부 정보를 더 이상 사용할 수 없습니다.",
resize: "작업 패널 크기 조절",
maximize: "Expand work panel",
@@ -1758,6 +1758,7 @@ sklm: {
browser: "브라우저",
file: "파일",
plugin: "플러그인 화면",
+ subagent: "서브에이전트",
},
pluginView: {
failed: "이 화면을 불러올 수 없습니다. 플러그인을 새로 고친 후 다시 시도하세요.",
diff --git a/packages/i18n/src/locales/pt-BR/index.ts b/packages/i18n/src/locales/pt-BR/index.ts
index 396872934..a62abcd8d 100644
--- a/packages/i18n/src/locales/pt-BR/index.ts
+++ b/packages/i18n/src/locales/pt-BR/index.ts
@@ -1676,7 +1676,7 @@ export const ptBR = {
subagent: "Subagente",
subagentTask: "Tarefa",
subagentTaskEmpty: "Nenhuma descrição de tarefa.",
- subagentClose: "Fechar detalhes do subagente",
+ subagentReadOnly: "Subagentes são orientados pelo agente principal — a entrada não está disponível.",
subagentEmpty: "Os detalhes do subagente não estão mais disponíveis.",
resize: "Redimensionar painel de trabalho",
maximize: "Expandir painel de trabalho",
@@ -1693,6 +1693,7 @@ export const ptBR = {
browser: "Navegador",
file: "Arquivos",
plugin: "Visualização de plugin",
+ subagent: "Subagente",
},
pluginView: {
failed: "Não foi possível carregar esta visualização. Recarregue o plugin e tente novamente."
diff --git a/packages/i18n/src/locales/tr/index.ts b/packages/i18n/src/locales/tr/index.ts
index d3e38d1b9..b8c903643 100644
--- a/packages/i18n/src/locales/tr/index.ts
+++ b/packages/i18n/src/locales/tr/index.ts
@@ -1731,7 +1731,7 @@ sklm: {
subagent: "Alt ajan",
subagentTask: "Görev",
subagentTaskEmpty: "Görev açıklaması yok.",
- subagentClose: "Alt ajan ayrıntılarını kapat",
+ subagentReadOnly: "Alt ajanlar ana ajan tarafından yönetilir — girdi kullanılamaz.",
subagentEmpty: "Alt ajan ayrıntıları artık kullanılamıyor.",
resize: "Çalışma paneli genişliğini ayarla",
maximize: "Expand work panel",
@@ -1748,6 +1748,7 @@ sklm: {
browser: "Tarayıcı",
file: "Dosyalar",
plugin: "Eklenti görünümü",
+ subagent: "Alt ajan",
},
pluginView: {
failed: "Bu görünüm yüklenemedi. Eklentiyi yeniden yükleyip deneyin.",
diff --git a/packages/i18n/src/locales/zh-CN/index.ts b/packages/i18n/src/locales/zh-CN/index.ts
index d5dff6148..49494d567 100644
--- a/packages/i18n/src/locales/zh-CN/index.ts
+++ b/packages/i18n/src/locales/zh-CN/index.ts
@@ -1711,7 +1711,7 @@ sklm: {
subagent: "子智能体",
subagentTask: "任务",
subagentTaskEmpty: "暂无任务描述。",
- subagentClose: "关闭子智能体详情",
+ subagentReadOnly: "子智能体由主智能体驱动,无法在此输入。",
subagentEmpty: "子智能体详情已不可用。",
resize: "调整工作面板宽度",
maximize: "放大",
@@ -1728,6 +1728,7 @@ sklm: {
browser: "浏览器",
file: "文件",
plugin: "插件视图",
+ subagent: "子智能体",
},
pluginView: {
failed: "无法加载该视图。请重新加载插件后重试。",
diff --git a/packages/i18n/src/locales/zh-TW/index.ts b/packages/i18n/src/locales/zh-TW/index.ts
index 6641b1ee1..493c113a7 100644
--- a/packages/i18n/src/locales/zh-TW/index.ts
+++ b/packages/i18n/src/locales/zh-TW/index.ts
@@ -1711,7 +1711,7 @@ sklm: {
subagent: "子智慧體",
subagentTask: "任務",
subagentTaskEmpty: "暫無任務描述。",
- subagentClose: "關閉子智慧體詳情",
+ subagentReadOnly: "子智慧體由主智慧體驅動,無法在此輸入。",
subagentEmpty: "子智慧體詳情已不可用。",
resize: "調整工作面板寬度",
maximize: "放大",
@@ -1728,6 +1728,7 @@ sklm: {
browser: "瀏覽器",
file: "檔案",
plugin: "外掛檢視",
+ subagent: "子智慧體",
},
pluginView: {
failed: "無法載入該檢視。請重新載入外掛後重試。",