History

assistant2: Cancel pending completion when an error occurs (#23143)

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

Marshall Bowers committed 1 year ago

Commit 4febc7e1 parent c33eb011 file · +3 −1Browse files

Unified · Split

crates/assistant2/src/thread.rs+3−1
@@ -361,7 +361,7 @@ impl Thread { · 360 unmodified lines
361361 let result = stream_completion.await;
362362
363363 thread
364− .update(&mut cx, |_thread, cx| match result.as_ref() {
364+ .update(&mut cx, |thread, cx| match result.as_ref() {
365365 Ok(stop_reason) => match stop_reason {
366366 StopReason::ToolUse => {
367367 cx.emit(ThreadEvent::UsePendingTools);
@@ -384,6 +384,8 @@ impl Thread { · 16 unmodified lines
384384 SharedString::from(error_message.clone()),
385385 )));
386386 }
387+
388+ thread.cancel_last_completion();
387389 }
388390 })
389391 .ok();