feat: subagent runtime & CLI display - wip

This commit is contained in:
tanzhenxin
2025-09-08 20:01:49 +08:00
parent 1f8ea7ab7a
commit 4985bfc000
31 changed files with 2664 additions and 390 deletions

View File

@@ -39,6 +39,19 @@ vi.mock('../../utils/MarkdownDisplay.js', () => ({
return <Text>MockMarkdown:{text}</Text>;
},
}));
vi.mock('../subagents/index.js', () => ({
SubagentExecutionDisplay: function MockSubagentExecutionDisplay({
data,
}: {
data: { subagentName: string; taskDescription: string };
}) {
return (
<Text>
🤖 {data.subagentName} Task: {data.taskDescription}
</Text>
);
},
}));
// Helper to render with context
const renderWithContext = (
@@ -180,4 +193,33 @@ describe('<ToolMessage />', () => {
// We can at least ensure it doesn't have the high emphasis indicator.
expect(lowEmphasisFrame()).not.toContain('←');
});
it('shows subagent execution display for task tool with proper result display', () => {
const subagentResultDisplay = {
type: 'subagent_execution' as const,
subagentName: 'file-search',
taskDescription: 'Search for files matching pattern',
status: 'running' as const,
};
const props: ToolMessageProps = {
name: 'task',
description: 'Delegate task to subagent',
resultDisplay: subagentResultDisplay,
status: ToolCallStatus.Executing,
terminalWidth: 80,
callId: 'test-call-id-2',
confirmationDetails: undefined,
};
const { lastFrame } = renderWithContext(
<ToolMessage {...props} />,
StreamingState.Responding,
);
const output = lastFrame();
expect(output).toContain('🤖'); // Subagent execution display should show
expect(output).toContain('file-search'); // Actual subagent name
expect(output).toContain('Search for files matching pattern'); // Actual task description
});
});