Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Show version info when downloading and installing updates (#31568)
Joseph T. Lyons7443fde4e9d3
diff --git a/crates/activity_indicator/src/activity_indicator.rs b/crates/activity_indicator/src/activity_indicator.rsindex cde7929557e..3a98830d447 100644--- a/crates/activity_indicator/src/activity_indicator.rs+++ b/crates/activity_indicator/src/activity_indicator.rs@@ -472,7 +472,7 @@ impl ActivityIndicator {})),tooltip_message: None,}),- AutoUpdateStatus::Downloading => Some(Content {+ AutoUpdateStatus::Downloading { version } => Some(Content {icon: Some(Icon::new(IconName::Download).size(IconSize::Small)@@ -482,9 +482,9 @@ impl ActivityIndicator {on_click: Some(Arc::new(|this, window, cx| {this.dismiss_error_message(&DismissErrorMessage, window, cx)})),- tooltip_message: None,+ tooltip_message: Some(Self::version_tooltip_message(&version)),}),- AutoUpdateStatus::Installing => Some(Content {+ AutoUpdateStatus::Installing { version } => Some(Content {icon: Some(Icon::new(IconName::Download).size(IconSize::Small)@@ -494,7 +494,7 @@ impl ActivityIndicator {on_click: Some(Arc::new(|this, window, cx| {this.dismiss_error_message(&DismissErrorMessage, window, cx)})),- tooltip_message: None,+ tooltip_message: Some(Self::version_tooltip_message(&version)),}),AutoUpdateStatus::Updated {binary_path,@@ -508,7 +508,7 @@ impl ActivityIndicator {};move |_, _, cx| workspace::reload(&reload, cx)})),- tooltip_message: Some(Self::install_version_tooltip_message(&version)),+ tooltip_message: Some(Self::version_tooltip_message(&version)),}),AutoUpdateStatus::Errored => Some(Content {icon: Some(@@ -548,8 +548,8 @@ impl ActivityIndicator {None}- fn install_version_tooltip_message(version: &VersionCheckType) -> String {- format!("Install version: {}", {+ fn version_tooltip_message(version: &VersionCheckType) -> String {+ format!("Version: {}", {match version {auto_update::VersionCheckType::Sha(sha) => format!("{}…", sha.short()),auto_update::VersionCheckType::Semantic(semantic_version) => {@@ -699,17 +699,17 @@ mod tests {use super::*;#[test]- fn test_install_version_tooltip_message() {- let message = ActivityIndicator::install_version_tooltip_message(- &VersionCheckType::Semantic(SemanticVersion::new(1, 0, 0)),- );+ fn test_version_tooltip_message() {+ let message = ActivityIndicator::version_tooltip_message(&VersionCheckType::Semantic(+ SemanticVersion::new(1, 0, 0),+ ));- assert_eq!(message, "Install version: 1.0.0");+ assert_eq!(message, "Version: 1.0.0");- let message = ActivityIndicator::install_version_tooltip_message(&VersionCheckType::Sha(+ let message = ActivityIndicator::version_tooltip_message(&VersionCheckType::Sha(AppCommitSha::new("14d9a4189f058d8736339b06ff2340101eaea5af".to_string()),));- assert_eq!(message, "Install version: 14d9a41…");+ assert_eq!(message, "Version: 14d9a41…");}}diff --git a/crates/auto_update/src/auto_update.rs b/crates/auto_update/src/auto_update.rsindex e8e2afa99c0..8342136312c 100644--- a/crates/auto_update/src/auto_update.rs+++ b/crates/auto_update/src/auto_update.rs@@ -49,8 +49,12 @@ pub enum VersionCheckType {pub enum AutoUpdateStatus {Idle,Checking,- Downloading,- Installing,+ Downloading {+ version: VersionCheckType,+ },+ Installing {+ version: VersionCheckType,+ },Updated {binary_path: PathBuf,version: VersionCheckType,@@ -531,7 +535,9 @@ impl AutoUpdater {};this.update(&mut cx, |this, cx| {- this.status = AutoUpdateStatus::Downloading;+ this.status = AutoUpdateStatus::Downloading {+ version: newer_version.clone(),+ };cx.notify();})?;@@ -540,7 +546,9 @@ impl AutoUpdater {download_release(&target_path, fetched_release_data, client, &cx).await?;this.update(&mut cx, |this, cx| {- this.status = AutoUpdateStatus::Installing;+ this.status = AutoUpdateStatus::Installing {+ version: newer_version.clone(),+ };cx.notify();})?;diff --git a/crates/title_bar/src/title_bar.rs b/crates/title_bar/src/title_bar.rsindex 4bd21c4d5fe..d2c9131a140 100644--- a/crates/title_bar/src/title_bar.rs+++ b/crates/title_bar/src/title_bar.rs@@ -647,8 +647,8 @@ impl TitleBar {let auto_updater = auto_update::AutoUpdater::get(cx);let label = match auto_updater.map(|auto_update| auto_update.read(cx).status()) {Some(AutoUpdateStatus::Updated { .. }) => "Please restart Zed to Collaborate",- Some(AutoUpdateStatus::Installing)- | Some(AutoUpdateStatus::Downloading)+ Some(AutoUpdateStatus::Installing { .. })+ | Some(AutoUpdateStatus::Downloading { .. })| Some(AutoUpdateStatus::Checking) => "Updating...",Some(AutoUpdateStatus::Idle) | Some(AutoUpdateStatus::Errored) | None => {"Please update Zed to Collaborate"