fix: tool UI again
This commit is contained in:
parent
8f6ec398ff
commit
9d4ea20deb
2 changed files with 19 additions and 16 deletions
|
|
@ -294,7 +294,7 @@ const TUIChat: React.FC<TUIChatProps> = ({
|
||||||
<Text color="green">●</Text>
|
<Text color="green">●</Text>
|
||||||
<Text> {message.content}</Text>
|
<Text> {message.content}</Text>
|
||||||
</Box>
|
</Box>
|
||||||
<Box marginLeft={2} paddingTop={1}>
|
<Box marginLeft={2}>
|
||||||
<ToolResultSummary
|
<ToolResultSummary
|
||||||
toolName={message.toolName}
|
toolName={message.toolName}
|
||||||
content={message.toolResult || ""}
|
content={message.toolResult || ""}
|
||||||
|
|
@ -327,9 +327,7 @@ const TUIChat: React.FC<TUIChatProps> = ({
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box key={index} marginBottom={1}>
|
<Box key={index} marginBottom={1}>
|
||||||
<Text color={isUser ? "green" : "blue"}>
|
<Text color={isUser ? "green" : "blue"}>●</Text>
|
||||||
●
|
|
||||||
</Text>
|
|
||||||
<Text> {message.content}</Text>
|
<Text> {message.content}</Text>
|
||||||
{message.isStreaming && <Text color="gray">▋</Text>}
|
{message.isStreaming && <Text color="gray">▋</Text>}
|
||||||
</Box>
|
</Box>
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { Text, Box } from "ink";
|
import { Box, Text } from "ink";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
interface ToolResultSummaryProps {
|
interface ToolResultSummaryProps {
|
||||||
|
|
@ -13,7 +13,7 @@ const ToolResultSummary: React.FC<ToolResultSummaryProps> = ({
|
||||||
const getSummary = () => {
|
const getSummary = () => {
|
||||||
if (!content) return "No output";
|
if (!content) return "No output";
|
||||||
|
|
||||||
const lines = content.split('\n').length;
|
const lines = content.split("\n").length;
|
||||||
const chars = content.length;
|
const chars = content.length;
|
||||||
|
|
||||||
// Use exact tool name matching
|
// Use exact tool name matching
|
||||||
|
|
@ -32,10 +32,10 @@ const ToolResultSummary: React.FC<ToolResultSummaryProps> = ({
|
||||||
return "File written successfully";
|
return "File written successfully";
|
||||||
|
|
||||||
case "list_files":
|
case "list_files":
|
||||||
return `Listed ${lines} ${lines === 1 ? 'item' : 'items'}`;
|
return `Listed ${lines} ${lines === 1 ? "item" : "items"}`;
|
||||||
|
|
||||||
case "search_code":
|
case "search_code":
|
||||||
return `Found ${lines} ${lines === 1 ? 'match' : 'matches'}`;
|
return `Found ${lines} ${lines === 1 ? "match" : "matches"}`;
|
||||||
|
|
||||||
case "run_terminal_command":
|
case "run_terminal_command":
|
||||||
return `Command output (${lines} lines)`;
|
return `Command output (${lines} lines)`;
|
||||||
|
|
@ -58,13 +58,13 @@ const ToolResultSummary: React.FC<ToolResultSummaryProps> = ({
|
||||||
|
|
||||||
case "Glob":
|
case "Glob":
|
||||||
const fileCount = lines;
|
const fileCount = lines;
|
||||||
return `Found ${fileCount} ${fileCount === 1 ? 'file' : 'files'}`;
|
return `Found ${fileCount} ${fileCount === 1 ? "file" : "files"}`;
|
||||||
|
|
||||||
case "Grep":
|
case "Grep":
|
||||||
return `Found ${lines} ${lines === 1 ? 'match' : 'matches'}`;
|
return `Found ${lines} ${lines === 1 ? "match" : "matches"}`;
|
||||||
|
|
||||||
case "LS":
|
case "LS":
|
||||||
return `Listed ${lines} ${lines === 1 ? 'item' : 'items'}`;
|
return `Listed ${lines} ${lines === 1 ? "item" : "items"}`;
|
||||||
|
|
||||||
case "Write":
|
case "Write":
|
||||||
return "File written successfully";
|
return "File written successfully";
|
||||||
|
|
@ -94,15 +94,19 @@ const ToolResultSummary: React.FC<ToolResultSummaryProps> = ({
|
||||||
default:
|
default:
|
||||||
// Handle MCP tools or unknown tools
|
// Handle MCP tools or unknown tools
|
||||||
if (toolName?.startsWith("mcp__")) {
|
if (toolName?.startsWith("mcp__")) {
|
||||||
const mcpToolName = toolName.replace("mcp__", "").replace("ide__", "");
|
const mcpToolName = toolName
|
||||||
|
.replace("mcp__", "")
|
||||||
|
.replace("ide__", "");
|
||||||
return `${mcpToolName} tool output (${lines} lines)`;
|
return `${mcpToolName} tool output (${lines} lines)`;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fallback for unknown tools
|
// Fallback for unknown tools
|
||||||
if (chars > 1000) {
|
if (chars > 1000) {
|
||||||
return `${toolName || 'Tool'} output: ${lines} lines, ${chars} characters`;
|
return `${
|
||||||
|
toolName || "Tool"
|
||||||
|
} output: ${lines} lines, ${chars} characters`;
|
||||||
} else if (lines > 10) {
|
} else if (lines > 10) {
|
||||||
return `${toolName || 'Tool'} output: ${lines} lines`;
|
return `${toolName || "Tool"} output: ${lines} lines`;
|
||||||
} else {
|
} else {
|
||||||
return content.slice(0, 100) + (content.length > 100 ? "..." : "");
|
return content.slice(0, 100) + (content.length > 100 ? "..." : "");
|
||||||
}
|
}
|
||||||
|
|
@ -111,9 +115,10 @@ const ToolResultSummary: React.FC<ToolResultSummaryProps> = ({
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box>
|
<Box>
|
||||||
<Text color="gray">{getSummary()}</Text>
|
<Text color="gray">⎿ </Text>
|
||||||
|
<Text color="gray"> {getSummary()}</Text>
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default ToolResultSummary;
|
export default ToolResultSummary;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue