feat: add silent flag to SubagentState for display filtering (#1220)

This commit is contained in:
Devansh Jain
2026-02-27 19:08:51 -08:00
committed by GitHub
parent e4c2893f60
commit ba6df7a9ed
3 changed files with 27 additions and 7 deletions

View File

@@ -340,8 +340,12 @@ export const SubagentGroupDisplay = memo(() => {
} }
}); });
// Hide silent subagents (e.g. init) — they handle user notifications
// via their own mechanisms (e.g. EventMessage).
const visible = agents.filter((a) => !a.silent);
// Don't render if no agents // Don't render if no agents
if (agents.length === 0) { if (visible.length === 0) {
return null; return null;
} }
@@ -349,24 +353,24 @@ export const SubagentGroupDisplay = memo(() => {
// This ensures consistent behavior - when we disable animation, we also simplify the view // This ensures consistent behavior - when we disable animation, we also simplify the view
const condensed = !shouldAnimate; const condensed = !shouldAnimate;
const allCompleted = agents.every( const allCompleted = visible.every(
(a) => a.status === "completed" || a.status === "error", (a) => a.status === "completed" || a.status === "error",
); );
const hasErrors = agents.some((a) => a.status === "error"); const hasErrors = visible.some((a) => a.status === "error");
return ( return (
<Box flexDirection="column" marginTop={1}> <Box flexDirection="column" marginTop={1}>
<GroupHeader <GroupHeader
count={agents.length} count={visible.length}
allCompleted={allCompleted} allCompleted={allCompleted}
hasErrors={hasErrors} hasErrors={hasErrors}
expanded={expanded} expanded={expanded}
/> />
{agents.map((agent, index) => ( {visible.map((agent, index) => (
<AgentRow <AgentRow
key={agent.id} key={agent.id}
agent={agent} agent={agent}
isLast={index === agents.length - 1} isLast={index === visible.length - 1}
expanded={expanded} expanded={expanded}
condensed={condensed} condensed={condensed}
/> />

View File

@@ -30,6 +30,7 @@ export interface SubagentState {
startTime: number; startTime: number;
toolCallId?: string; // Links this subagent to its parent Task tool call toolCallId?: string; // Links this subagent to its parent Task tool call
isBackground?: boolean; // True if running in background (fire-and-forget) isBackground?: boolean; // True if running in background (fire-and-forget)
silent?: boolean; // True if this subagent should be hidden from SubagentGroupDisplay
} }
interface SubagentStore { interface SubagentStore {
@@ -108,6 +109,7 @@ export function registerSubagent(
description: string, description: string,
toolCallId?: string, toolCallId?: string,
isBackground?: boolean, isBackground?: boolean,
silent?: boolean,
): void { ): void {
// Capitalize type for display (explore -> Explore) // Capitalize type for display (explore -> Explore)
const displayType = type.charAt(0).toUpperCase() + type.slice(1); const displayType = type.charAt(0).toUpperCase() + type.slice(1);
@@ -124,6 +126,7 @@ export function registerSubagent(
startTime: Date.now(), startTime: Date.now(),
toolCallId, toolCallId,
isBackground, isBackground,
silent,
}; };
store.agents.set(id, agent); store.agents.set(id, agent);

View File

@@ -66,6 +66,11 @@ export interface SpawnBackgroundSubagentTaskArgs {
existingAgentId?: string; existingAgentId?: string;
existingConversationId?: string; existingConversationId?: string;
maxTurns?: number; maxTurns?: number;
/**
* When true, skip injecting the completion notification into the primary
* agent's message queue and hide from SubagentGroupDisplay.
*/
silentCompletion?: boolean;
/** /**
* Optional dependency overrides for tests. * Optional dependency overrides for tests.
* Production callers should not provide this. * Production callers should not provide this.
@@ -191,6 +196,7 @@ export function spawnBackgroundSubagentTask(
existingAgentId, existingAgentId,
existingConversationId, existingConversationId,
maxTurns, maxTurns,
silentCompletion,
deps, deps,
} = args; } = args;
@@ -208,7 +214,14 @@ export function spawnBackgroundSubagentTask(
deps?.getSubagentSnapshotImpl ?? getSubagentSnapshot; deps?.getSubagentSnapshotImpl ?? getSubagentSnapshot;
const subagentId = generateSubagentIdFn(); const subagentId = generateSubagentIdFn();
registerSubagentFn(subagentId, subagentType, description, toolCallId, true); registerSubagentFn(
subagentId,
subagentType,
description,
toolCallId,
true,
silentCompletion,
);
const taskId = getNextTaskId(); const taskId = getNextTaskId();
const outputFile = createBackgroundOutputFile(taskId); const outputFile = createBackgroundOutputFile(taskId);