fix: even nicer tool UI
This commit is contained in:
parent
fa4b98f455
commit
3716ebcdd7
1 changed files with 19 additions and 15 deletions
|
|
@ -128,15 +128,21 @@ const TUIChat: React.FC<TUIChatProps> = ({
|
||||||
]);
|
]);
|
||||||
},
|
},
|
||||||
onToolResult: (result: string, toolName: string) => {
|
onToolResult: (result: string, toolName: string) => {
|
||||||
setMessages((prev) => [
|
setMessages((prev) => {
|
||||||
...prev,
|
const newMessages = [...prev];
|
||||||
{
|
// Find the last tool-start message for this tool and replace it
|
||||||
role: "system",
|
for (let i = newMessages.length - 1; i >= 0; i--) {
|
||||||
content: result,
|
if (newMessages[i].messageType === "tool-start" && newMessages[i].toolName === toolName) {
|
||||||
messageType: "tool-result",
|
newMessages[i] = {
|
||||||
toolName,
|
...newMessages[i],
|
||||||
},
|
content: result,
|
||||||
]);
|
messageType: "tool-result",
|
||||||
|
};
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return newMessages;
|
||||||
|
});
|
||||||
},
|
},
|
||||||
onToolError: (error: string, toolName?: string) => {
|
onToolError: (error: string, toolName?: string) => {
|
||||||
setMessages((prev) => [
|
setMessages((prev) => [
|
||||||
|
|
@ -212,10 +218,9 @@ const TUIChat: React.FC<TUIChatProps> = ({
|
||||||
case "tool-start":
|
case "tool-start":
|
||||||
return (
|
return (
|
||||||
<Box key={index} marginBottom={1} paddingLeft={2}>
|
<Box key={index} marginBottom={1} paddingLeft={2}>
|
||||||
<Text color="yellow" bold>
|
<Text color="white">
|
||||||
🔧{" "}
|
○ {message.content}
|
||||||
</Text>
|
</Text>
|
||||||
<Text color="yellow">{message.content}</Text>
|
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -228,10 +233,9 @@ const TUIChat: React.FC<TUIChatProps> = ({
|
||||||
flexDirection="column"
|
flexDirection="column"
|
||||||
>
|
>
|
||||||
<Box>
|
<Box>
|
||||||
<Text color="green" bold>
|
<Text color="white">
|
||||||
✓{" "}
|
✓ Completed {message.toolName}
|
||||||
</Text>
|
</Text>
|
||||||
<Text color="green">Tool completed</Text>
|
|
||||||
</Box>
|
</Box>
|
||||||
<Box marginLeft={2} paddingTop={1}>
|
<Box marginLeft={2} paddingTop={1}>
|
||||||
<ToolResultSummary
|
<ToolResultSummary
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue