recent_projects: Improve user facing error messages on connection failure (#42083)

Lukas Wirth created

cc https://github.com/zed-industries/zed/issues/42004

Release Notes:

- N/A *or* Added/Fixed/Improved ...

Change summary

crates/auto_update/src/auto_update.rs            |  3 +++
crates/markdown/src/markdown.rs                  |  2 +-
crates/recent_projects/src/remote_connections.rs | 10 ++++++----
crates/remote/src/transport/wsl.rs               |  4 +---
4 files changed, 11 insertions(+), 8 deletions(-)

Detailed changes

crates/auto_update/src/auto_update.rs 🔗

@@ -406,6 +406,7 @@ impl AutoUpdater {
         arch: &str,
         release_channel: ReleaseChannel,
         version: Option<SemanticVersion>,
+        set_status: impl Fn(&str, &mut AsyncApp) + Send + 'static,
         cx: &mut AsyncApp,
     ) -> Result<PathBuf> {
         let this = cx.update(|cx| {
@@ -415,6 +416,7 @@ impl AutoUpdater {
                 .context("auto-update not initialized")
         })??;
 
+        set_status("Fetching remote server release", cx);
         let release = Self::get_release(
             &this,
             "zed-remote-server",
@@ -439,6 +441,7 @@ impl AutoUpdater {
                 "downloading zed-remote-server {os} {arch} version {}",
                 release.version
             );
+            set_status("Downloading remote server", cx);
             download_remote_server_binary(&version_path, release, client, cx).await?;
         }
 

crates/markdown/src/markdown.rs 🔗

@@ -1215,7 +1215,7 @@ impl Element for MarkdownElement {
                 }
                 MarkdownEvent::SoftBreak => builder.push_text(" ", range.clone()),
                 MarkdownEvent::HardBreak => builder.push_text("\n", range.clone()),
-                _ => log::error!("unsupported markdown event {:?}", event),
+                _ => log::debug!("unsupported markdown event {:?}", event),
             }
         }
         let mut rendered_markdown = builder.build();

crates/recent_projects/src/remote_connections.rs 🔗

@@ -482,12 +482,14 @@ impl remote::RemoteClientDelegate for RemoteClientDelegate {
         version: Option<SemanticVersion>,
         cx: &mut AsyncApp,
     ) -> Task<anyhow::Result<PathBuf>> {
+        let this = self.clone();
         cx.spawn(async move |cx| {
             AutoUpdater::download_remote_server_release(
                 platform.os,
                 platform.arch,
                 release_channel,
                 version,
+                move |status, cx| this.set_status(Some(status), cx),
                 cx,
             )
             .await
@@ -659,7 +661,7 @@ pub async fn open_remote_project(
                             }
                         })
                         .ok();
-                    log::error!("Failed to open project: {e:?}");
+                    log::error!("Failed to open project: {e:#}");
                     let response = window
                         .update(cx, |_, window, cx| {
                             window.prompt(
@@ -668,7 +670,7 @@ pub async fn open_remote_project(
                                     RemoteConnectionOptions::Ssh(_) => "Failed to connect over SSH",
                                     RemoteConnectionOptions::Wsl(_) => "Failed to connect to WSL",
                                 },
-                                Some(&e.to_string()),
+                                Some(&format!("{e:#}")),
                                 &["Retry", "Cancel"],
                                 cx,
                             )
@@ -715,7 +717,7 @@ pub async fn open_remote_project(
 
         match opened_items {
             Err(e) => {
-                log::error!("Failed to open project: {e:?}");
+                log::error!("Failed to open project: {e:#}");
                 let response = window
                     .update(cx, |_, window, cx| {
                         window.prompt(
@@ -724,7 +726,7 @@ pub async fn open_remote_project(
                                 RemoteConnectionOptions::Ssh(_) => "Failed to connect over SSH",
                                 RemoteConnectionOptions::Wsl(_) => "Failed to connect to WSL",
                             },
-                            Some(&e.to_string()),
+                            Some(&format!("{e:#}")),
                             &["Retry", "Cancel"],
                             cx,
                         )

crates/remote/src/transport/wsl.rs 🔗

@@ -210,8 +210,6 @@ impl WslRemoteConnection {
             return Ok(dst_path);
         }
 
-        delegate.set_status(Some("Installing remote server"), cx);
-
         let wanted_version = match release_channel {
             ReleaseChannel::Nightly | ReleaseChannel::Dev => None,
             _ => Some(cx.update(|cx| AppVersion::global(cx))?),
@@ -242,7 +240,7 @@ impl WslRemoteConnection {
         delegate: &Arc<dyn RemoteClientDelegate>,
         cx: &mut AsyncApp,
     ) -> Result<()> {
-        delegate.set_status(Some("Uploading remote server to WSL"), cx);
+        delegate.set_status(Some("Uploading remote server"), cx);
 
         if let Some(parent) = dst_path.parent() {
             let parent = parent.display(PathStyle::Posix);