/** * @license * Copyright 2025 Qwen Team * SPDX-License-Identifier: Apache-2.0 * * Execute tool call component - specialized for command execution operations */ import type React from 'react'; import type { BaseToolCallProps } from '../shared/types.js'; import { ToolCallContainer } from '../shared/LayoutComponents.js'; import { safeTitle, groupContent } from '../shared/utils.js'; import { useVSCode } from '../../../../hooks/useVSCode.js'; import { createAndOpenTempFile } from '../../../../utils/tempFileManager.js'; import './Bash.css'; /** * Specialized component for Execute/Bash tool calls * Shows: Bash bullet + description + IN/OUT card */ export const ExecuteToolCall: React.FC = ({ toolCall }) => { const { title, content, rawInput, toolCallId } = toolCall; const commandText = safeTitle(title); const vscode = useVSCode(); // Group content by type const { textOutputs, errors } = groupContent(content); // Extract command from rawInput if available let inputCommand = commandText; if (rawInput && typeof rawInput === 'object') { const inputObj = rawInput as { command?: string }; inputCommand = inputObj.command || commandText; } else if (typeof rawInput === 'string') { inputCommand = rawInput; } // Handle click on IN section const handleInClick = () => { createAndOpenTempFile( vscode.postMessage, inputCommand, 'bash-input', '.sh', ); }; // Handle click on OUT section const handleOutClick = () => { if (textOutputs.length > 0) { const output = textOutputs.join('\n'); createAndOpenTempFile(vscode.postMessage, output, 'bash-output', '.txt'); } }; // Map tool status to container status for proper bullet coloring const containerStatus: | 'success' | 'error' | 'warning' | 'loading' | 'default' = errors.length > 0 ? 'error' : toolCall.status === 'in_progress' || toolCall.status === 'pending' ? 'loading' : 'success'; // Error case if (errors.length > 0) { return ( {/* Branch connector summary */}
{commandText}
{/* Error card - semantic DOM + Tailwind styles */}
{/* IN row */}
IN
{inputCommand}
{/* ERROR row */}
Error
                  {errors.join('\n')}
                
); } // Success with output if (textOutputs.length > 0) { const output = textOutputs.join('\n'); const truncatedOutput = output.length > 500 ? output.substring(0, 500) + '...' : output; return ( {/* Branch connector summary */}
{commandText}
{/* Output card - semantic DOM + Tailwind styles */}
{/* IN row */}
IN
{inputCommand}
{/* OUT row */}
OUT
{truncatedOutput}
); } // Success without output: show command with branch connector return (
{commandText}
); };