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

@ -14,7 +14,7 @@ use gpui::{
use project::ProjectPath;
use thread_context_picker::{render_thread_context_entry, ThreadContextEntry};
use ui::{prelude::*, ContextMenu, ContextMenuEntry, ContextMenuItem};
use workspace::Workspace;
use workspace::{notifications::NotifyResultExt, Workspace};
use crate::context::ContextKind;
use crate::context_picker::directory_context_picker::DirectoryContextPicker;
@ -227,25 +227,8 @@ impl ContextPicker {
context_store.add_file_from_path(project_path.clone(), cx)
});
let workspace = self.workspace.clone();
cx.spawn(|_, mut cx| async move {
match task.await {
Ok(_) => {
return anyhow::Ok(());
}
Err(err) => {
let Some(workspace) = workspace.upgrade() else {
return anyhow::Ok(());
};
workspace.update(&mut cx, |workspace, cx| {
workspace.show_error(&err, cx);
})
}
}
})
.detach_and_log_err(cx);
cx.spawn(|_, mut cx| async move { task.await.notify_async_err(&mut cx) })
.detach();
cx.notify();
}