mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-18 23:02:14 +00:00
Mark pending tool components as aborted when streaming is interrupted
When user presses Esc during tool argument streaming, the assistant message ends with stopReason="aborted" but tool execution never starts. Now we check for aborted/error stopReasons in message_end and update all pending tool execution components to show red error state with "Operation aborted" message. This fixes the issue where tool components stayed stuck in blue/pending state after aborting during JSON streaming.
This commit is contained in:
parent
594edec31b
commit
2fdd304fbf
1 changed files with 15 additions and 0 deletions
|
|
@ -213,6 +213,21 @@ export class TuiRenderer {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (this.streamingComponent && event.message.role === "assistant") {
|
if (this.streamingComponent && event.message.role === "assistant") {
|
||||||
|
const assistantMsg = event.message as AssistantMessage;
|
||||||
|
|
||||||
|
// If message was aborted or errored, mark all pending tool components as failed
|
||||||
|
if (assistantMsg.stopReason === "aborted" || assistantMsg.stopReason === "error") {
|
||||||
|
const errorMessage =
|
||||||
|
assistantMsg.stopReason === "aborted" ? "Operation aborted" : assistantMsg.errorMessage || "Error";
|
||||||
|
for (const [toolCallId, component] of this.pendingTools.entries()) {
|
||||||
|
component.updateResult({
|
||||||
|
output: errorMessage,
|
||||||
|
isError: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
this.pendingTools.clear();
|
||||||
|
}
|
||||||
|
|
||||||
// Keep the streaming component - it's now the final assistant message
|
// Keep the streaming component - it's now the final assistant message
|
||||||
this.streamingComponent = null;
|
this.streamingComponent = null;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue