Show version info when downloading and installing updates (#31568)

Follow up to #31179 

In addition to seeing the version when in the `Click to restart and
update Zed` status, this PR allows us to see the version when in
`Downloading Zed update…` or `Installing Zed update…` status, in a
tooltip, when hovering on the activity indicator.

Will merge after tomorrow's release.

Release Notes:

- Added version information, in a tooltip, when hovering on the activity
indicator for both the download and install status.
This commit is contained in:
Joseph T. Lyons 2025-05-28 11:51:21 -04:00 committed by GitHub
parent d5ab42aeb8
commit 7443fde4e9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 28 additions and 20 deletions

View file

@ -472,7 +472,7 @@ impl ActivityIndicator {
})), })),
tooltip_message: None, tooltip_message: None,
}), }),
AutoUpdateStatus::Downloading => Some(Content { AutoUpdateStatus::Downloading { version } => Some(Content {
icon: Some( icon: Some(
Icon::new(IconName::Download) Icon::new(IconName::Download)
.size(IconSize::Small) .size(IconSize::Small)
@ -482,9 +482,9 @@ impl ActivityIndicator {
on_click: Some(Arc::new(|this, window, cx| { on_click: Some(Arc::new(|this, window, cx| {
this.dismiss_error_message(&DismissErrorMessage, 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: Some(
Icon::new(IconName::Download) Icon::new(IconName::Download)
.size(IconSize::Small) .size(IconSize::Small)
@ -494,7 +494,7 @@ impl ActivityIndicator {
on_click: Some(Arc::new(|this, window, cx| { on_click: Some(Arc::new(|this, window, cx| {
this.dismiss_error_message(&DismissErrorMessage, window, cx) this.dismiss_error_message(&DismissErrorMessage, window, cx)
})), })),
tooltip_message: None, tooltip_message: Some(Self::version_tooltip_message(&version)),
}), }),
AutoUpdateStatus::Updated { AutoUpdateStatus::Updated {
binary_path, binary_path,
@ -508,7 +508,7 @@ impl ActivityIndicator {
}; };
move |_, _, cx| workspace::reload(&reload, cx) 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 { AutoUpdateStatus::Errored => Some(Content {
icon: Some( icon: Some(
@ -548,8 +548,8 @@ impl ActivityIndicator {
None None
} }
fn install_version_tooltip_message(version: &VersionCheckType) -> String { fn version_tooltip_message(version: &VersionCheckType) -> String {
format!("Install version: {}", { format!("Version: {}", {
match version { match version {
auto_update::VersionCheckType::Sha(sha) => format!("{}", sha.short()), auto_update::VersionCheckType::Sha(sha) => format!("{}", sha.short()),
auto_update::VersionCheckType::Semantic(semantic_version) => { auto_update::VersionCheckType::Semantic(semantic_version) => {
@ -699,17 +699,17 @@ mod tests {
use super::*; use super::*;
#[test] #[test]
fn test_install_version_tooltip_message() { fn test_version_tooltip_message() {
let message = ActivityIndicator::install_version_tooltip_message( let message = ActivityIndicator::version_tooltip_message(&VersionCheckType::Semantic(
&VersionCheckType::Semantic(SemanticVersion::new(1, 0, 0)), 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()), AppCommitSha::new("14d9a4189f058d8736339b06ff2340101eaea5af".to_string()),
)); ));
assert_eq!(message, "Install version: 14d9a41…"); assert_eq!(message, "Version: 14d9a41…");
} }
} }

View file

@ -49,8 +49,12 @@ pub enum VersionCheckType {
pub enum AutoUpdateStatus { pub enum AutoUpdateStatus {
Idle, Idle,
Checking, Checking,
Downloading, Downloading {
Installing, version: VersionCheckType,
},
Installing {
version: VersionCheckType,
},
Updated { Updated {
binary_path: PathBuf, binary_path: PathBuf,
version: VersionCheckType, version: VersionCheckType,
@ -531,7 +535,9 @@ impl AutoUpdater {
}; };
this.update(&mut cx, |this, cx| { this.update(&mut cx, |this, cx| {
this.status = AutoUpdateStatus::Downloading; this.status = AutoUpdateStatus::Downloading {
version: newer_version.clone(),
};
cx.notify(); cx.notify();
})?; })?;
@ -540,7 +546,9 @@ impl AutoUpdater {
download_release(&target_path, fetched_release_data, client, &cx).await?; download_release(&target_path, fetched_release_data, client, &cx).await?;
this.update(&mut cx, |this, cx| { this.update(&mut cx, |this, cx| {
this.status = AutoUpdateStatus::Installing; this.status = AutoUpdateStatus::Installing {
version: newer_version.clone(),
};
cx.notify(); cx.notify();
})?; })?;

View file

@ -647,8 +647,8 @@ impl TitleBar {
let auto_updater = auto_update::AutoUpdater::get(cx); let auto_updater = auto_update::AutoUpdater::get(cx);
let label = match auto_updater.map(|auto_update| auto_update.read(cx).status()) { let label = match auto_updater.map(|auto_update| auto_update.read(cx).status()) {
Some(AutoUpdateStatus::Updated { .. }) => "Please restart Zed to Collaborate", Some(AutoUpdateStatus::Updated { .. }) => "Please restart Zed to Collaborate",
Some(AutoUpdateStatus::Installing) Some(AutoUpdateStatus::Installing { .. })
| Some(AutoUpdateStatus::Downloading) | Some(AutoUpdateStatus::Downloading { .. })
| Some(AutoUpdateStatus::Checking) => "Updating...", | Some(AutoUpdateStatus::Checking) => "Updating...",
Some(AutoUpdateStatus::Idle) | Some(AutoUpdateStatus::Errored) | None => { Some(AutoUpdateStatus::Idle) | Some(AutoUpdateStatus::Errored) | None => {
"Please update Zed to Collaborate" "Please update Zed to Collaborate"