From 76978b1634e5a8670461e84050a7dfc49c86b2e7 Mon Sep 17 00:00:00 2001 From: Brandon Thomas Date: Wed, 14 Oct 2026 15:50:07 -0400 Subject: [PATCH] Fix up merged PRs: a background open that fails says why on the start screen Main (#346) shows why a file couldn't be opened as a notice over the start screen; #488's background open put the error in the status bar instead, which broke a_file_that_cant_be_opened_says_why. The background open now reports through the same notice, and the test waits for the background read. Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/backstage_tests.rs | 9 +++++++++ crates/ui-egui/src/opening.rs | 13 +++++++------ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/crates/ui-egui/src/backstage_tests.rs b/crates/ui-egui/src/backstage_tests.rs index e0f4e6d2..9b3906a2 100644 --- a/crates/ui-egui/src/backstage_tests.rs +++ b/crates/ui-egui/src/backstage_tests.rs @@ -444,6 +444,15 @@ fn a_file_that_cant_be_opened_says_why() { h.run_steps(2); h.get_by_label("Browse").click(); h.run_steps(3); + // The file is read in the background (#350): wait for it. + for _ in 0..500 { + if h.state().opening.is_none() { + break; + } + std::thread::sleep(std::time::Duration::from_millis(10)); + h.run_steps(1); + } + h.run_steps(2); assert!(h.state().session.documents().is_empty()); assert!(h.query_by_label_contains("not a presentation DeckCraft can read").is_some(), "the error is on screen"); let _ = std::fs::remove_dir_all(&dir); diff --git a/crates/ui-egui/src/opening.rs b/crates/ui-egui/src/opening.rs index debeb03c..37d20a4e 100644 --- a/crates/ui-egui/src/opening.rs +++ b/crates/ui-egui/src/opening.rs @@ -32,7 +32,7 @@ impl SlideApp { #[cfg(target_arch = "wasm32")] { if let Err(e) = self.open_path(path) { - self.set_status(e); + self.notify(e); } } #[cfg(not(target_arch = "wasm32"))] @@ -47,7 +47,7 @@ impl SlideApp { Ok(_) => self.opening = Some(Opening { path: path.to_string(), started_ms: crate::now_ms(), rx }), Err(_) => { if let Err(e) = self.open_path(path) { - self.set_status(e); + self.notify(e); } } } @@ -76,10 +76,11 @@ impl SlideApp { let token = self.session.stage_loaded(f); match self.session.execute("file.adopt", &serde_json::json!({"path": o.path, "token": token})) { Ok(_) => self.note_recent(&o.path), - Err(e) => self.set_status(e.to_string()), + Err(e) => self.notify(e.to_string()), } } - Err(e) => self.set_status(e), + // Over the start screen too, like a failed file.open (#346). + Err(e) => self.notify(e), } } @@ -167,14 +168,14 @@ mod tests { } #[test] - fn errors_show_in_the_status_bar_and_a_second_open_waits() { + fn errors_are_shown_and_a_second_open_waits() { let mut app = SlideApp::new(Session::new(), crate::Services::default()); app.open_path_in_background("/nonexistent/deckcraft/missing.pptx"); app.open_path_in_background("/nonexistent/deckcraft/other.pptx"); assert!(app.status.as_ref().is_some_and(|(m, _)| m.starts_with("Still opening missing.pptx"))); wait(&mut app); assert!(app.session.documents().is_empty()); - assert!(app.status.as_ref().is_some_and(|(m, _)| m.contains("missing.pptx")), "{:?}", app.status); + assert!(app.toast.as_ref().is_some_and(|t| t.text.contains("missing.pptx")), "the reason is shown"); } #[test]