prevent accidental quit (#2688)

This commit is contained in:
Max Novich
2025-05-27 17:22:44 -07:00
committed by GitHub
parent 3d0c6e4c00
commit 54a0255f7b
+26
View File
@@ -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) {