Fix aborted tool display when continuing sessions
Two fixes for rendering aborted tools in --continue mode: 1. In renderInitialMessages: Check if assistant message was aborted/errored and immediately mark tool execution components as failed instead of leaving them in pending state. 2. In AssistantMessageComponent: Don't show "Aborted" text when there are tool calls in the message, since the tool execution components will show the error state themselves. This prevents duplicate error messages. Now aborted tools show properly as red with "Operation aborted" message, without the duplicate "Aborted" text above them.
This commit is contained in:
@@ -49,11 +49,15 @@ export class AssistantMessageComponent extends Container {
|
||||
}
|
||||
|
||||
// Check if aborted - show after partial content
|
||||
if (message.stopReason === "aborted") {
|
||||
this.contentContainer.addChild(new Text(chalk.red("Aborted")));
|
||||
} else if (message.stopReason === "error") {
|
||||
const errorMsg = message.errorMessage || "Unknown error";
|
||||
this.contentContainer.addChild(new Text(chalk.red(`Error: ${errorMsg}`)));
|
||||
// But only if there are no tool calls (tool execution components will show the error)
|
||||
const hasToolCalls = message.content.some((c) => c.type === "toolCall");
|
||||
if (!hasToolCalls) {
|
||||
if (message.stopReason === "aborted") {
|
||||
this.contentContainer.addChild(new Text(chalk.red("Aborted")));
|
||||
} else if (message.stopReason === "error") {
|
||||
const errorMsg = message.errorMessage || "Unknown error";
|
||||
this.contentContainer.addChild(new Text(chalk.red(`Error: ${errorMsg}`)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -327,8 +327,21 @@ export class TuiRenderer {
|
||||
if (content.type === "toolCall") {
|
||||
const component = new ToolExecutionComponent(content.name, content.arguments);
|
||||
this.chatContainer.addChild(component);
|
||||
// Store in map so we can update with results later
|
||||
this.pendingTools.set(content.id, component);
|
||||
|
||||
// If message was aborted/errored, immediately mark tool as failed
|
||||
if (assistantMsg.stopReason === "aborted" || assistantMsg.stopReason === "error") {
|
||||
const errorMessage =
|
||||
assistantMsg.stopReason === "aborted"
|
||||
? "Operation aborted"
|
||||
: assistantMsg.errorMessage || "Error";
|
||||
component.updateResult({
|
||||
output: errorMessage,
|
||||
isError: true,
|
||||
});
|
||||
} else {
|
||||
// Store in map so we can update with results later
|
||||
this.pendingTools.set(content.id, component);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (message.role === "toolResult") {
|
||||
|
||||
Reference in New Issue
Block a user