(props: { toolName: string; args?: any })
| 12 | * @returns A React node with bolded tool name like "<b>ToolName</b>(arg)" or just "<b>ToolName</b>" if no args |
| 13 | */ |
| 14 | export function ToolCallTitle(props: { toolName: string; args?: any }) { |
| 15 | const { toolName, args } = props; |
| 16 | |
| 17 | const displayName = getToolDisplayName(toolName); |
| 18 | |
| 19 | if (!args || Object.keys(args).length === 0) { |
| 20 | return <Text bold>{displayName}</Text>; |
| 21 | } |
| 22 | |
| 23 | // Get the first argument value if it's a simple one |
| 24 | let formattedValue = ""; |
| 25 | const [key, value] = Object.entries(args)[0]; |
| 26 | if ( |
| 27 | key.toLowerCase().includes("path") || |
| 28 | typeof value === "number" || |
| 29 | typeof value === "boolean" |
| 30 | ) { |
| 31 | formattedValue = formatToolArgument(value); |
| 32 | } else if (typeof value === "string") { |
| 33 | const valueLines = value.split("\n"); |
| 34 | if (valueLines.length === 1) { |
| 35 | formattedValue = formatToolArgument(value); |
| 36 | } else { |
| 37 | // For multi-line strings, show first line with ellipsis |
| 38 | const firstLine = valueLines[0].trim(); |
| 39 | formattedValue = firstLine |
| 40 | ? `${formatToolArgument(firstLine)}...` |
| 41 | : "..."; |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | return ( |
| 46 | <Text wrap="truncate"> |
| 47 | <Text bold>{displayName}</Text>({formattedValue}) |
| 48 | </Text> |
| 49 | ); |
| 50 | } |
nothing calls this directly
no test coverage detected