fix: tool name matching

This commit is contained in:
Nate 2025-07-13 17:24:54 -07:00
parent 9c18d28cbe
commit 9792b1411f
2 changed files with 52 additions and 11 deletions

View file

@ -122,6 +122,21 @@ const TUIChat: React.FC<TUIChatProps> = ({
if (!args) return name;
switch (name) {
// CLI Internal Tools (snake_case)
case "read_file":
return `Read(${args.filepath || ""})`;
case "write_file":
return `Write(${args.filepath || ""})`;
case "list_files":
return `List(${args.dirpath || ""})`;
case "search_code":
return `Search(${args.pattern || ""})`;
case "run_terminal_command":
return `Terminal(${args.command || ""})`;
case "view_diff":
return `Diff(${args.path || "."})`;
// External Claude Code Tools (PascalCase)
case "Read":
return `Read(${args.file_path || args.path || ""})`;
case "Write":
@ -130,29 +145,29 @@ const TUIChat: React.FC<TUIChatProps> = ({
case "MultiEdit":
return `Edit(${args.file_path || ""})`;
case "Bash":
return `Bash(${args.command || ""})`;
return `Terminal(${args.command || ""})`;
case "Glob":
return `Glob(${args.pattern || ""})`;
return `Find(${args.pattern || ""})`;
case "Grep":
return `Grep(${args.pattern || ""})`;
return `Search(${args.pattern || ""})`;
case "LS":
return `LS(${args.path || ""})`;
return `List(${args.path || ""})`;
case "NotebookRead":
return `NotebookRead(${args.notebook_path || ""})`;
return `Notebook(${args.notebook_path || ""})`;
case "NotebookEdit":
return `NotebookEdit(${args.notebook_path || ""})`;
return `Notebook(${args.notebook_path || ""})`;
case "WebFetch":
return `WebFetch(${args.url || ""})`;
return `Web(${args.url || ""})`;
case "WebSearch":
return `WebSearch(${args.query || ""})`;
return `Search(${args.query || ""})`;
case "TodoWrite":
return `TodoWrite(${args.todos?.length || 0} items)`;
return `Todo(${args.todos?.length || 0} items)`;
case "Task":
return `Task(${args.description || ""})`;
default:
// Handle MCP tools or unknown tools
if (name.startsWith("mcp__")) {
const mcpToolName = name.replace("mcp__", "");
const mcpToolName = name.replace("mcp__", "").replace("ide__", "");
const firstParam = Object.values(args)[0];
return `${mcpToolName}(${firstParam || ""})`;
}

View file

@ -18,6 +18,32 @@ const ToolResultSummary: React.FC<ToolResultSummaryProps> = ({
// Use exact tool name matching
switch (toolName) {
// CLI Internal Tools (snake_case)
case "read_file":
// Try to extract file path from content if it contains line numbers
if (content.includes("→")) {
const pathMatch = content.match(/^(.+?):/);
const filePath = pathMatch ? pathMatch[1] : "file";
return `Read ${filePath} (${lines} lines)`;
}
return `Read tool output (${lines} lines)`;
case "write_file":
return "File written successfully";
case "list_files":
return `Listed ${lines} ${lines === 1 ? 'item' : 'items'}`;
case "search_code":
return `Found ${lines} ${lines === 1 ? 'match' : 'matches'}`;
case "run_terminal_command":
return `Command output (${lines} lines)`;
case "view_diff":
return `Diff output (${lines} lines)`;
// External Claude Code Tools (PascalCase)
case "Read":
// Try to extract file path from content if it contains line numbers
if (content.includes("→")) {
@ -68,7 +94,7 @@ const ToolResultSummary: React.FC<ToolResultSummaryProps> = ({
default:
// Handle MCP tools or unknown tools
if (toolName?.startsWith("mcp__")) {
const mcpToolName = toolName.replace("mcp__", "");
const mcpToolName = toolName.replace("mcp__", "").replace("ide__", "");
return `${mcpToolName} tool output (${lines} lines)`;
}