App: a lost graphics device tells the user why the window closes and where the recovery copy is (#591)

Ported from #673: a native error dialog names the auto-saved recovery copy before the window
closes; agent runs through the control channel skip it. The UI calls Hooks::device_lost once.

Co-Authored-By: Dennis M. Francis <44986763+didpublishing@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QiAJeFttZp83Fh7YuzAR5f
This commit is contained in:
Claude
2026-10-10 23:36:52 +00:00
co-authored by Dennis M. Francis
parent 7fd1d09088
commit cb37c2511c
3 changed files with 35 additions and 5 deletions
+4
View File
@@ -98,6 +98,9 @@ fn a_lost_device_draws_nothing_autosaves_and_closes() {
s.execute("comp.new", json!({"name": "Unsaved", "width": 64, "height": 64, "duration": 1})).unwrap();
assert!(s.is_dirty());
let mut h = Harness::builder().with_size(egui::vec2(1200.0, 800.0)).build_eframe(|_| EffectcraftApp::new(s));
let told = std::rc::Rc::new(std::cell::RefCell::new(Vec::new()));
let log = told.clone();
h.state_mut().hooks.device_lost = Some(Box::new(move |saved| log.borrow_mut().push(saved)));
h.run_steps(3);
assert!(!h.output().shapes.is_empty(), "the UI draws before the loss");
let bridge = effectcraft_ui_egui::gpu_failure::GpuFailureBridge::new(&h.ctx);
@@ -111,5 +114,6 @@ fn a_lost_device_draws_nothing_autosaves_and_closes() {
assert!(h.output().shapes.is_empty());
let saved = h.state().session.autosave.last_path.clone().expect("unsaved changes auto-saved");
assert!(std::path::Path::new(&saved).is_file(), "{saved}");
assert_eq!(*told.borrow(), vec![Some(Ok(saved))], "the user is told once, with the recovery copy");
let _ = std::fs::remove_dir_all(&dir);
}