assistant2: Use notify_async_err for error notifications (#23330)

Release Notes:

- N/A
This commit is contained in:
Michael Sloan 2025-01-18 14:10:22 -07:00 committed by GitHub
parent 0199eca289
commit 8c09a3d5db
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 21 additions and 74 deletions

View file

@ -10,7 +10,7 @@ use gpui::{
use itertools::Itertools;
use language::Buffer;
use ui::{prelude::*, KeyBinding, PopoverMenu, PopoverMenuHandle, Tooltip};
use workspace::Workspace;
use workspace::{notifications::NotifyResultExt, Workspace};
use crate::context::ContextKind;
use crate::context_picker::{ConfirmBehavior, ContextPicker};
@ -311,24 +311,14 @@ impl ContextStrip {
context_store.accept_suggested_context(&suggested, cx)
});
let workspace = self.workspace.clone();
cx.spawn(|this, mut cx| async move {
match task.await {
Ok(()) => {
match task.await.notify_async_err(&mut cx) {
None => {}
Some(()) => {
if let Some(this) = this.upgrade() {
this.update(&mut cx, |_, cx| cx.notify())?;
}
}
Err(err) => {
let Some(workspace) = workspace.upgrade() else {
return anyhow::Ok(());
};
workspace.update(&mut cx, |workspace, cx| {
workspace.show_error(&err, cx);
})?;
}
}
anyhow::Ok(())
})