workspace: Pop a toast if manually spawning a task fails (#38405)

Release Notes:

- N/A *or* Added/Fixed/Improved ...
This commit is contained in:
Lukas Wirth
2025-09-18 12:03:35 +02:00
committed by GitHub
parent 32c868ff7d
commit 9f9e8063fc
+13 -5
View File
@@ -8,7 +8,7 @@ use remote::ConnectionState;
use task::{DebugScenario, ResolvedTask, SpawnInTerminal, TaskContext, TaskTemplate};
use ui::Window;
use crate::Workspace;
use crate::{Toast, Workspace, notifications::NotificationId};
impl Workspace {
pub fn schedule_task(
@@ -73,8 +73,10 @@ impl Workspace {
if let Some(terminal_provider) = self.terminal_provider.as_ref() {
let task_status = terminal_provider.spawn(spawn_in_terminal, window, cx);
let task = cx.background_spawn(async move {
match task_status.await {
let task = cx.spawn(async |w, cx| {
let res = cx.background_spawn(task_status).await;
match res {
Some(Ok(status)) => {
if status.success() {
log::debug!("Task spawn succeeded");
@@ -82,9 +84,15 @@ impl Workspace {
log::debug!("Task spawn failed, code: {:?}", status.code());
}
}
Some(Err(e)) => log::error!("Task spawn failed: {e:#}"),
Some(Err(e)) => {
log::error!("Task spawn failed: {e:#}");
_ = w.update(cx, |w, cx| {
let id = NotificationId::unique::<ResolvedTask>();
w.show_toast(Toast::new(id, format!("Task spawn failed: {e}")), cx);
})
}
None => log::debug!("Task spawn got cancelled"),
}
};
});
self.scheduled_tasks.push(task);
}