Save prompt on quit: "Save changes to <name>?" for every unsaved design

The title bar's ×, File ▸ Quit, the OS closing the window (Alt+F4, Cmd+Q, the window manager:
close_requested is cancelled until the designs are answered) and app.quit / ui.window close all
go through documents::request_quit, which asks Save / Don't Save / Cancel once per design with
unsaved changes. Save saves (Save As for a never-saved design) and quits only if it saved; Don't
Save discards (no recovery copy is kept); Cancel or Esc stays open. Closing a tab asks the same
question (now titled "Save changes to <name>?"); New and Open never replace an unsaved design
(they open a tab). The web app asks through beforeunload while a design is unsaved. Control:
ui.documents {action: quit, answer: save|dont_save|cancel}, app.quit {force}. Tests: quit with
Save then Don't Save across two tabs, Cancel, a Save that saves nothing, Save As; scenario
s43_quit_asks_to_save.

Fixes #33

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
bherbruckandClaude Opus 5.5 committed 2026-10-09 16:03:32 +00:00
1 parent d2bc8e9847
commit 4562c8e5ba
10 files changed
+240 -30

No files matched your search

+5 -2
View File
@@ -57,8 +57,11 @@ pub fn window_action(app: &mut SolveApp, ctx: &egui::Context, action: &str) -> R
"restore" => ctx.send_viewport_cmd(ViewportCommand::Maximized(false)),
"toggle" => toggle_maximize(ctx),
"close" => {
app.quit_requested = true;
ctx.send_viewport_cmd(ViewportCommand::Close);
// Unsaved designs are asked about first; the window closes once they are answered.
crate::documents::request_quit(app);
if app.quit_requested {
ctx.send_viewport_cmd(ViewportCommand::Close);
}
}
other => return Err(format!("unknown window action `{other}` (minimize, maximize, restore, toggle, close)")),
}