From 54a0255f7b0682d1150625aaa73ccd3a33518a9b Mon Sep 17 00:00:00 2001 From: Max Novich Date: Tue, 27 May 2025 17:22:44 -0700 Subject: [PATCH] prevent accidental quit (#2688) --- ui/desktop/src/main.ts | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/ui/desktop/src/main.ts b/ui/desktop/src/main.ts index ed54a7da43..1a3b7b4413 100644 --- a/ui/desktop/src/main.ts +++ b/ui/desktop/src/main.ts @@ -1290,6 +1290,32 @@ app.on('will-quit', () => { }); // Quit when all windows are closed, except on macOS or if we have a tray icon. +// Add confirmation dialog when quitting with Cmd+Q +app.on('before-quit', (event) => { + // Prevent the default quit behavior + event.preventDefault(); + + // Show confirmation dialog + dialog + .showMessageBox({ + type: 'question', + buttons: ['Quit', 'Cancel'], + defaultId: 1, // Default to Cancel + title: 'Confirm Quit', + message: 'Are you sure you want to quit Goose?', + detail: 'Any unsaved changes may be lost.', + }) + .then(({ response }) => { + if (response === 0) { + // User clicked "Quit" + // Set a flag to avoid showing the dialog again + app.removeAllListeners('before-quit'); + // Actually quit the app + app.quit(); + } + }); +}); + app.on('window-all-closed', () => { // Only quit if we're not on macOS or don't have a tray icon if (process.platform !== 'darwin' || !tray) {