From b8d80fdab794a9580d846f1b140754239c4edb9c Mon Sep 17 00:00:00 2001 From: simosmik Date: Thu, 12 Feb 2026 12:25:26 +0000 Subject: [PATCH] refactor(tools): add agent category for Task tool Add visual distinction for the Task tool (subagent invocation) by introducing a new 'agent' category with purple border styling. This separates subagent tasks from regular task management tools (TaskCreate, TaskUpdate, etc.) for clearer user feedback. Also refactor terminal command layout in OneLineDisplay to properly nest flex containers, fixing copy button alignment issues. --- src/components/chat/tools/ToolRenderer.tsx | 1 + .../tools/components/CollapsibleDisplay.tsx | 1 + .../chat/tools/components/OneLineDisplay.tsx | 36 ++++++----- .../chat/tools/configs/toolConfigs.ts | 60 ++++++++++++++++++- 4 files changed, 81 insertions(+), 17 deletions(-) diff --git a/src/components/chat/tools/ToolRenderer.tsx b/src/components/chat/tools/ToolRenderer.tsx index 33fbc2b..2839622 100644 --- a/src/components/chat/tools/ToolRenderer.tsx +++ b/src/components/chat/tools/ToolRenderer.tsx @@ -29,6 +29,7 @@ function getToolCategory(toolName: string): string { if (toolName === 'Bash') return 'bash'; if (['TodoWrite', 'TodoRead'].includes(toolName)) return 'todo'; if (['TaskCreate', 'TaskUpdate', 'TaskList', 'TaskGet'].includes(toolName)) return 'task'; + if (toolName === 'Task') return 'agent'; // Subagent task if (toolName === 'exit_plan_mode' || toolName === 'ExitPlanMode') return 'plan'; return 'default'; } diff --git a/src/components/chat/tools/components/CollapsibleDisplay.tsx b/src/components/chat/tools/components/CollapsibleDisplay.tsx index 41556c3..9d833df 100644 --- a/src/components/chat/tools/components/CollapsibleDisplay.tsx +++ b/src/components/chat/tools/components/CollapsibleDisplay.tsx @@ -21,6 +21,7 @@ const borderColorMap: Record = { bash: 'border-l-green-500 dark:border-l-green-400', todo: 'border-l-violet-500 dark:border-l-violet-400', task: 'border-l-violet-500 dark:border-l-violet-400', + agent: 'border-l-purple-500 dark:border-l-purple-400', plan: 'border-l-indigo-500 dark:border-l-indigo-400', default: 'border-l-gray-300 dark:border-l-gray-600', }; diff --git a/src/components/chat/tools/components/OneLineDisplay.tsx b/src/components/chat/tools/components/OneLineDisplay.tsx index a0707ac..c9e3355 100644 --- a/src/components/chat/tools/components/OneLineDisplay.tsx +++ b/src/components/chat/tools/components/OneLineDisplay.tsx @@ -85,24 +85,28 @@ export const OneLineDisplay: React.FC = ({ // Terminal style: dark pill only around the command if (isTerminal) { return ( -
-
- - - -
-
-
- - $ {value} - +
+
+
+ + + +
+
+
+ + $ {value} + +
+ {action === 'copy' && renderCopyButton()}
- {action === 'copy' && renderCopyButton()}
{secondary && ( - - {secondary} - +
+ + {secondary} + +
)}
); @@ -177,4 +181,4 @@ export const OneLineDisplay: React.FC = ({ {action === 'copy' && renderCopyButton()}
); -}; +}; \ No newline at end of file diff --git a/src/components/chat/tools/configs/toolConfigs.ts b/src/components/chat/tools/configs/toolConfigs.ts index 799e027..49b623e 100644 --- a/src/components/chat/tools/configs/toolConfigs.ts +++ b/src/components/chat/tools/configs/toolConfigs.ts @@ -1,6 +1,6 @@ /** * Centralized tool configuration registry - * Defines display behavior for all tool types using config-driven architecture + * Defines display behavior for all tool types */ export interface ToolDisplayConfig { @@ -371,6 +371,64 @@ export const TOOL_CONFIGS: Record = { } }, + // ============================================================================ + // SUBAGENT TASK TOOL + // ============================================================================ + + Task: { + input: { + type: 'collapsible', + title: (input) => { + const subagentType = input.subagent_type || 'Agent'; + const description = input.description || 'Running task'; + return `${subagentType}: ${description}`; + }, + defaultOpen: true, + contentType: 'markdown', + getContentProps: (input) => { + // Format the subagent task details in a readable way + const parts = []; + + if (input.subagent_type) { + parts.push(`**Agent Type:** ${input.subagent_type}`); + } + + if (input.description) { + parts.push(`**Description:** ${input.description}`); + } + + if (input.model) { + parts.push(`**Model:** ${input.model}`); + } + + if (input.prompt) { + parts.push(`**Prompt:**\n\`\`\`\n${input.prompt}\n\`\`\``); + } + + if (input.resume) { + parts.push(`**Resuming from:** ${input.resume}`); + } + + return { + content: parts.join('\n\n') + }; + }, + colorScheme: { + border: 'border-purple-500 dark:border-purple-400', + icon: 'text-purple-500 dark:text-purple-400' + } + }, + result: { + type: 'collapsible', + title: 'Agent Response', + defaultOpen: true, + contentType: 'markdown', + getContentProps: (result) => ({ + content: String(result.content || result || '') + }) + } + }, + // ============================================================================ // PLAN TOOLS // ============================================================================