From cbad85f1622a283f323977cd92948fa9a4ea0567 Mon Sep 17 00:00:00 2001 From: Mike Vincent Date: Fri, 23 Jan 2026 18:40:23 -0800 Subject: [PATCH] chore: sync local changes --- emain/emain-window.ts | 32 +++++---- emain/emain.ts | 86 +++++++++++++++++-------- pkg/wconfig/defaultconfig/settings.json | 2 + pkg/wconfig/settingsconfig.go | 4 +- schema/settings.json | 6 ++ 5 files changed, 89 insertions(+), 41 deletions(-) diff --git a/emain/emain-window.ts b/emain/emain-window.ts index 6d30daebe8..5e36d5ac3b 100644 --- a/emain/emain-window.ts +++ b/emain/emain-window.ts @@ -299,18 +299,14 @@ export class WaveBrowserWindow extends BaseWindow { const fullConfig = await RpcApi.GetFullConfigCommand(ElectronWshClient); if (numWindows > 1 || !fullConfig.settings["window:savelastwindow"]) { if (fullConfig.settings["window:confirmclose"]) { - const workspace = await WorkspaceService.GetWorkspace(this.workspaceId); - if (isNonEmptyUnsavedWorkspace(workspace)) { - const choice = dialog.showMessageBoxSync(this, { - type: "question", - buttons: ["Cancel", "Close Window"], - title: "Confirm", - message: - "Window has unsaved tabs, closing window will delete existing tabs.\n\nContinue?", - }); - if (choice === 0) { - return; - } + const choice = dialog.showMessageBoxSync(this, { + type: "question", + buttons: ["Cancel", "Close Window"], + title: "Confirm", + message: "Close this window?", + }); + if (choice === 0) { + return; } } this.deleteAllowed = true; @@ -550,6 +546,18 @@ export class WaveBrowserWindow extends BaseWindow { break; case "closetab": tabId = entry.tabId; + const closeTabConfig = await RpcApi.GetFullConfigCommand(ElectronWshClient); + if (closeTabConfig.settings["tab:confirmclose"]) { + const choice = dialog.showMessageBoxSync(this, { + type: "question", + buttons: ["Cancel", "Close Tab"], + title: "Confirm", + message: "Close this tab?", + }); + if (choice === 0) { + return; + } + } const rtn = await WorkspaceService.CloseTab(this.workspaceId, tabId, true); if (rtn == null) { console.log( diff --git a/emain/emain.ts b/emain/emain.ts index 093a74bd41..f472defcc6 100644 --- a/emain/emain.ts +++ b/emain/emain.ts @@ -14,6 +14,7 @@ import { getActivityState, getAndClearTermCommandsRun, getForceQuit, + getGlobalIsQuitting, getGlobalIsRelaunching, setForceQuit, setGlobalIsQuitting, @@ -242,38 +243,67 @@ electronApp.on("window-all-closed", () => { } }); electronApp.on("before-quit", (e) => { - setGlobalIsQuitting(true); - updater?.stop(); - if (unamePlatform == "win32") { - // win32 doesn't have a SIGINT, so we just let electron die, which - // ends up killing wavesrv via closing it's stdin. - return; - } - getWaveSrvProc()?.kill("SIGINT"); - shutdownWshrpc(); - if (getForceQuit()) { + // If already confirmed and in quit process, run shutdown logic + if (getGlobalIsQuitting()) { + updater?.stop(); + if (unamePlatform == "win32") { + // win32 doesn't have a SIGINT, so we just let electron die, which + // ends up killing wavesrv via closing it's stdin. + return; + } + getWaveSrvProc()?.kill("SIGINT"); + shutdownWshrpc(); + if (getForceQuit()) { + return; + } + e.preventDefault(); + const allWindows = getAllWaveWindows(); + for (const window of allWindows) { + hideWindowWithCatch(window); + } + const allBuilders = getAllBuilderWindows(); + for (const builder of allBuilders) { + builder.hide(); + } + if (getIsWaveSrvDead()) { + console.log("wavesrv is dead, quitting immediately"); + setForceQuit(true); + electronApp.quit(); + return; + } + setTimeout(() => { + console.log("waiting for wavesrv to exit..."); + setForceQuit(true); + electronApp.quit(); + }, 3000); return; } + + // First time through - check if confirmation needed e.preventDefault(); - const allWindows = getAllWaveWindows(); - for (const window of allWindows) { - hideWindowWithCatch(window); - } - const allBuilders = getAllBuilderWindows(); - for (const builder of allBuilders) { - builder.hide(); - } - if (getIsWaveSrvDead()) { - console.log("wavesrv is dead, quitting immediately"); - setForceQuit(true); - electronApp.quit(); - return; - } - setTimeout(() => { - console.log("waiting for wavesrv to exit..."); - setForceQuit(true); + fireAndForget(async () => { + // Skip confirmation if RPC client not ready (early quit before app fully started) + if (ElectronWshClient == null) { + setGlobalIsQuitting(true); + electronApp.quit(); + return; + } + const fullConfig = await RpcApi.GetFullConfigCommand(ElectronWshClient); + if (fullConfig.settings["app:confirmquit"]) { + const choice = electron.dialog.showMessageBoxSync({ + type: "question", + buttons: ["Cancel", "Quit"], + title: "Confirm", + message: "Quit Wave Terminal?", + }); + if (choice === 0) { + return; // User cancelled + } + } + // User confirmed or setting disabled - proceed with quit + setGlobalIsQuitting(true); electronApp.quit(); - }, 3000); + }); }); process.on("SIGINT", () => { console.log("Caught SIGINT, shutting down"); diff --git a/pkg/wconfig/defaultconfig/settings.json b/pkg/wconfig/defaultconfig/settings.json index 2e3d2410d9..74c016b2c8 100644 --- a/pkg/wconfig/defaultconfig/settings.json +++ b/pkg/wconfig/defaultconfig/settings.json @@ -20,6 +20,8 @@ "window:magnifiedblockblurprimarypx": 10, "window:fullscreenonlaunch": false, "window:magnifiedblockblursecondarypx": 2, + "app:confirmquit": false, + "tab:confirmclose": false, "window:confirmclose": true, "window:savelastwindow": true, "telemetry:enabled": true, diff --git a/pkg/wconfig/settingsconfig.go b/pkg/wconfig/settingsconfig.go index 50a1da2474..58affdace0 100644 --- a/pkg/wconfig/settingsconfig.go +++ b/pkg/wconfig/settingsconfig.go @@ -59,6 +59,7 @@ type SettingsType struct { AppDefaultNewBlock string `json:"app:defaultnewblock,omitempty"` AppShowOverlayBlockNums *bool `json:"app:showoverlayblocknums,omitempty"` AppCtrlVPaste *bool `json:"app:ctrlvpaste,omitempty"` + AppConfirmQuit bool `json:"app:confirmquit,omitempty"` FeatureWaveAppBuilder bool `json:"feature:waveappbuilder,omitempty"` @@ -120,7 +121,8 @@ type SettingsType struct { PreviewShowHiddenFiles *bool `json:"preview:showhiddenfiles,omitempty"` - TabPreset string `json:"tab:preset,omitempty"` + TabPreset string `json:"tab:preset,omitempty"` + TabConfirmClose bool `json:"tab:confirmclose,omitempty"` WidgetClear bool `json:"widget:*,omitempty"` WidgetShowHelp *bool `json:"widget:showhelp,omitempty"` diff --git a/schema/settings.json b/schema/settings.json index 9492e7bb8d..5766aa4d89 100644 --- a/schema/settings.json +++ b/schema/settings.json @@ -23,6 +23,9 @@ "app:ctrlvpaste": { "type": "boolean" }, + "app:confirmquit": { + "type": "boolean" + }, "feature:waveappbuilder": { "type": "boolean" }, @@ -179,6 +182,9 @@ "tab:preset": { "type": "string" }, + "tab:confirmclose": { + "type": "boolean" + }, "widget:*": { "type": "boolean" },