Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
fix(desktop-gpui): let a manual check or channel change replace a held update prompt
Richie McIlroyce71f7ad6e0d
diff --git a/apps/desktop-gpui/src/updates.rs b/apps/desktop-gpui/src/updates.rsindex 85324423d..ae48b344e 100644--- a/apps/desktop-gpui/src/updates.rs+++ b/apps/desktop-gpui/src/updates.rs@@ -97,6 +97,12 @@ fn holds_scheduled_prompt(manual: bool, busy: bool) -> bool {!manual && busy}+/// A manual check or a channel change queued while an automatic prompt waits+/// replaces it, so neither has to wait for the work in flight to finish.+fn supersedes_held_prompt(pending: &PendingUpdateRequests) -> bool {+ pending.manual || pending.channel.is_some()+}+fn current_version() -> Result<Version, String> {Version::parse(env!("CARGO_PKG_VERSION")).map_err(|error| error.to_string())}@@ -382,16 +388,24 @@ pub(crate) fn schedule_startup_check(cx: &mut App) {// The prompt is modal and brings Cap forward, so an automatic// check holds it until a recording, export, import or// transcription has finished rather than interrupting it.- let mut channel_changed = false;+ let mut superseded = false;while holds_scheduled_prompt(manual, cx.update(work_in_flight)) {- cx.background_executor().timer(BUSY_RETRY_DELAY).await;- channel_changed =- cx.update(|cx| cx.global::<UpdateScheduler>().pending.channel.is_some());- if channel_changed {+ let timer = cx.background_executor().timer(BUSY_RETRY_DELAY);+ let request = requests.recv_async();+ futures_util::pin_mut!(timer, request);+ if let Either::Right((Err(_), _)) = select(timer, request).await {+ return;+ }+ superseded = cx.update(|cx| {+ supersedes_held_prompt(&cx.global::<UpdateScheduler>().pending)+ });+ if superseded {break;}}- if channel_changed {+ if superseded {+ // Run the queued manual check or channel change straight away.+ delay = Some(Duration::ZERO);continue;}@@ -730,6 +744,19 @@ mod tests {assert!(!holds_scheduled_prompt(true, false));}+ #[test]+ fn queued_manual_checks_and_channel_changes_replace_a_held_prompt() {+ assert!(!supersedes_held_prompt(&PendingUpdateRequests::default()));+ assert!(supersedes_held_prompt(&PendingUpdateRequests {+ manual: true,+ ..PendingUpdateRequests::default()+ }));+ assert!(supersedes_held_prompt(&PendingUpdateRequests {+ channel: Some(UpdateChannel::Nightly),+ ..PendingUpdateRequests::default()+ }));+ }+#[test]fn stable_channel_accepts_newer_versions_and_explicit_prerelease_downgrades() {assert!(qualifies(