From d6b2db70314b9e5ee99ad49f03335c3847f663d5 Mon Sep 17 00:00:00 2001 From: ".CooCoo" Date: Mon, 16 Nov 2026 18:36:51 -0800 Subject: [PATCH] update: Later on a ready update no longer closes the app after a save (#1262) --- crates/update/src/updater.rs | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/crates/update/src/updater.rs b/crates/update/src/updater.rs index 86ef6d996..253781690 100644 --- a/crates/update/src/updater.rs +++ b/crates/update/src/updater.rs @@ -162,7 +162,8 @@ pub struct Updater { /// An update is ready and waits for the app to exit; nothing starts a second one. installed: bool, /// [`Self::show_if`] returns [`Action::Close`] at its next frame that may close: once when an - /// installation finishes, and again for each [`Self::restart_to_update`]. + /// installation finishes, and again for each [`Self::restart_to_update`]. Later on the prompt + /// clears it. close_wanted: bool, /// The folders that hold the outcome records ([`self_update::take_outcome`]) in place of the /// app's own (tests). @@ -620,8 +621,10 @@ impl Updater { action } StartupPromptResponse::Later => { - // An installation carries on and reports through `tick`. + // An installation carries on and reports through `tick`. A ready update drops the + // close it asked for: it installs at the exit, or Restart to Update asks again. self.prompt = None; + self.close_wanted = false; Action::None } } @@ -1455,6 +1458,22 @@ mod tests { assert!(u.install.is_none()); } + /// Later on a finished install drops the close it asked for: saving the work afterwards does + /// not close the app. The update stays ready, and Restart to Update asks for the close again. + #[test] + fn later_on_a_finished_install_does_not_close_the_app_after_a_save() { + let ctx = egui::Context::default(); + let mut u = installed(&ctx); + assert_eq!(frame(&mut u, &ctx, false), Action::None, "unsaved work holds the close back"); + let escape = egui::Event::Key { key: egui::Key::Escape, physical_key: None, pressed: true, repeat: false, modifiers: egui::Modifiers::NONE }; + assert_eq!(frame_saving(&mut u, &ctx, false, false, vec![escape]).0, Action::None); + assert!(!u.prompt_open()); + assert_eq!(frame(&mut u, &ctx, true), Action::None, "the work is saved, and the user chose Later"); + assert!(u.restart.is_some(), "the update still waits for the exit"); + u.restart_to_update(); + assert_eq!(frame(&mut u, &ctx, true), Action::Close); + } + /// A stopped save on a finished install keeps saying the update is ready. #[test] fn a_stopped_save_on_a_finished_install_keeps_its_note() {