diff --git a/crates/chat_ui/src/lib.rs b/crates/chat_ui/src/lib.rs index 3622e41b..0ad30ce3 100644 --- a/crates/chat_ui/src/lib.rs +++ b/crates/chat_ui/src/lib.rs @@ -3,7 +3,7 @@ use std::path::PathBuf; use std::sync::{Arc, LazyLock, RwLock}; pub use actions::*; -use anyhow::{Context as AnyhowContext, Error}; +use anyhow::Error; use chat::{ChatRegistry, Message, Room, RoomEvent, SendReport, SendStatus}; use common::{TimestampExt, coop_cache}; use futures::lock::Mutex; @@ -709,13 +709,15 @@ impl ChatPanel { }); self.tasks.push(cx.spawn_in(window, async move |this, cx| { + // Selecting no file means the prompt was cancelled + let Some(path) = path.await??.and_then(|mut paths| paths.pop()) else { + return Ok(()); + }; + this.update(cx, |this, cx| { this.set_uploading(true, cx); })?; - let mut paths = path.await??.context("Not found")?; - let path = paths.pop().context("No path")?; - // Upload the file, encrypted when it is the whole message let result = if encrypted { upload_encrypted(server, path.clone(), cx) diff --git a/crates/workspace/src/panels/profile.rs b/crates/workspace/src/panels/profile.rs index a944c9cf..c9e46d93 100644 --- a/crates/workspace/src/panels/profile.rs +++ b/crates/workspace/src/panels/profile.rs @@ -1,6 +1,6 @@ use std::str::FromStr; -use anyhow::{Context as AnyhowContext, Error}; +use anyhow::Error; use gpui::{ AnyElement, App, AppContext, ClipboardItem, Context, Entity, EventEmitter, FocusHandle, Focusable, IntoElement, ParentElement, PathPromptOptions, Render, SharedString, Styled, Task, @@ -167,13 +167,15 @@ impl ProfilePanel { }); self.tasks.push(cx.spawn_in(window, async move |this, cx| { + // Selecting no file means the prompt was cancelled + let Some(path) = path.await??.and_then(|mut paths| paths.pop()) else { + return Ok(()); + }; + this.update(cx, |this, cx| { this.set_uploading(true, cx); })?; - let mut paths = path.await??.context("Not found")?; - let path = paths.pop().context("No path")?; - // Upload via blossom client match upload(server, path, cx).await { Ok(url) => {