import React from 'react'; import { Box, Text } from 'ink'; import Spinner from 'ink-spinner'; import { ToolCallStatus } from '../../types.js'; import { ToolResultDisplay } from '../../../tools/tools.js'; import DiffRenderer from './DiffRenderer.js'; import { MarkdownRenderer } from '../../utils/MarkdownRenderer.js'; interface ToolMessageProps { name: string; description: string; resultDisplay: ToolResultDisplay | undefined; status: ToolCallStatus; } const ToolMessage: React.FC = ({ name, description, resultDisplay, status, }) => { const statusIndicatorWidth = 3; const hasResult = (status === ToolCallStatus.Invoked || status === ToolCallStatus.Canceled) && resultDisplay && resultDisplay.toString().trim().length > 0; return ( {/* Row for Status Indicator and Tool Info */} {/* Status Indicator */} {status === ToolCallStatus.Pending && } {status === ToolCallStatus.Invoked && } {status === ToolCallStatus.Confirming && ?} {status === ToolCallStatus.Canceled && ( - )} {name} {description} {hasResult && ( {/* Use default text color (white) or gray instead of dimColor */} {typeof resultDisplay === 'string' && ( {MarkdownRenderer.render(resultDisplay)} )} {typeof resultDisplay === 'object' && ( )} )} ); }; export default ToolMessage;