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
361 let result = stream_completion.await;361 let result = stream_completion.await;
362 362
363 thread363 thread
364 .update(&mut cx, |_thread, cx| match result.as_ref() {364 .update(&mut cx, |thread, cx| match result.as_ref() {
365 Ok(stop_reason) => match stop_reason {365 Ok(stop_reason) => match stop_reason {
366 StopReason::ToolUse => {366 StopReason::ToolUse => {
367 cx.emit(ThreadEvent::UsePendingTools);367 cx.emit(ThreadEvent::UsePendingTools);
@@ -384,6 +384,8 @@ impl Thread { · 16 unmodified lines
384 SharedString::from(error_message.clone()),384 SharedString::from(error_message.clone()),
385 )));385 )));
386 }386 }
387
388 thread.cancel_last_completion();
387 }389 }
388 })390 })
389 .ok();391 .ok();