Skip to content

Commit

Permalink
assistant2: Cancel pending completion when an error occurs (#23143)
Browse files Browse the repository at this point in the history
This PR makes it so the pending completion is cleared when an error
occurs.

This makes it so `Thread::is_streaming()` will return `false` in the
error case (and thus hide the streaming indicator in the UI).

Release Notes:

- N/A
  • Loading branch information
maxdeviant authored Jan 14, 2025
1 parent c33eb01 commit 4febc7e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion crates/assistant2/src/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ impl Thread {
let result = stream_completion.await;

thread
.update(&mut cx, |_thread, cx| match result.as_ref() {
.update(&mut cx, |thread, cx| match result.as_ref() {
Ok(stop_reason) => match stop_reason {
StopReason::ToolUse => {
cx.emit(ThreadEvent::UsePendingTools);
Expand All @@ -384,6 +384,8 @@ impl Thread {
SharedString::from(error_message.clone()),
)));
}

thread.cancel_last_completion();
}
})
.ok();
Expand Down

0 comments on commit 4febc7e

Please sign in to comment.