diff --git a/docs/docs/config.mdx b/docs/docs/config.mdx index b1c7b89c5..8cadea106 100644 --- a/docs/docs/config.mdx +++ b/docs/docs/config.mdx @@ -76,9 +76,11 @@ wsh editconfig | window:showmenubar | bool | set to use the OS-native menu bar (Windows and Linux only, requires app restart) | | window:nativetitlebar | bool | set to use the OS-native title bar, rather than the overlay (Windows and Linux only, requires app restart) | | window:disablehardwareacceleration | bool | set to disable Chromium hardware acceleration to resolve graphical bugs (requires app restart) | +| window:savelastwindow | bool | when `true`, the last window that is closed is preserved and is reopened the next time the app is launched (defaults to `true`) | +| window:confirmonclose | bool | when `true`, a prompt will ask a user to confirm that they want to close a window if it has an unsaved workspace with more than one tab (defaults to `true`) | | telemetry:enabled | bool | set to enable/disable telemetry | -For reference this is the current default configuration (v0.9.3): +For reference, this is the current default configuration (v0.10.4): ```json { @@ -90,6 +92,7 @@ For reference this is the current default configuration (v0.9.3): "autoupdate:installonquit": true, "autoupdate:intervalms": 3600000, "conn:askbeforewshinstall": true, + "conn:wshenabled": true, "editor:minimapenabled": true, "web:defaulturl": "https://github.com/wavetermdev/waveterm", "web:defaultsearch": "https://www.google.com/search?q={query}", @@ -100,6 +103,8 @@ For reference this is the current default configuration (v0.9.3): "window:magnifiedblocksize": 0.9, "window:magnifiedblockblurprimarypx": 10, "window:magnifiedblockblursecondarypx": 2, + "window:confirmclose": true, + "window:savelastwindow": true, "telemetry:enabled": true, "term:copyonselect": true } diff --git a/emain/emain-window.ts b/emain/emain-window.ts index 7cc076ad5..068703a70 100644 --- a/emain/emain-window.ts +++ b/emain/emain-window.ts @@ -229,21 +229,26 @@ export class WaveBrowserWindow extends BaseWindow { e.preventDefault(); fireAndForget(async () => { const numWindows = waveWindowMap.size; - if (numWindows > 1) { - console.log("numWindows > 1", numWindows); - const workspace = await WorkspaceService.GetWorkspace(this.workspaceId); - console.log("workspace", workspace); - if (isNonEmptyUnsavedWorkspace(workspace)) { - console.log("workspace has no name, icon, and multiple tabs", 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) { - console.log("user cancelled close window", this.waveWindowId); - return; + const fullConfig = await FileService.GetFullConfig(); + if (numWindows > 1 || !fullConfig.settings["window:savelastwindow"]) { + console.log("numWindows > 1 or user does not want last window saved", numWindows); + if (fullConfig.settings["window:confirmclose"]) { + console.log("confirmclose", this.waveWindowId); + const workspace = await WorkspaceService.GetWorkspace(this.workspaceId); + console.log("workspace", workspace); + if (isNonEmptyUnsavedWorkspace(workspace)) { + console.log("workspace has no name, icon, and multiple tabs", 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) { + console.log("user cancelled close window", this.waveWindowId); + return; + } } } console.log("deleteAllowed = true", this.waveWindowId); @@ -270,11 +275,6 @@ export class WaveBrowserWindow extends BaseWindow { this.destroy(); return; } - const numWindows = waveWindowMap.size; - if (numWindows == 0) { - console.log("win no windows left", this.waveWindowId); - return; - } if (this.deleteAllowed) { console.log("win removing window from backend DB", this.waveWindowId); fireAndForget(() => WindowService.CloseWindow(this.waveWindowId, true)); diff --git a/frontend/types/gotypes.d.ts b/frontend/types/gotypes.d.ts index 15838e1ab..22f582776 100644 --- a/frontend/types/gotypes.d.ts +++ b/frontend/types/gotypes.d.ts @@ -679,6 +679,8 @@ declare global { "window:magnifiedblocksize"?: number; "window:magnifiedblockblurprimarypx"?: number; "window:magnifiedblockblursecondarypx"?: number; + "window:confirmclose"?: boolean; + "window:savelastwindow"?: boolean; "telemetry:*"?: boolean; "telemetry:enabled"?: boolean; "conn:*"?: boolean; diff --git a/pkg/wconfig/defaultconfig/settings.json b/pkg/wconfig/defaultconfig/settings.json index fa8d98f88..3da7e6fd2 100644 --- a/pkg/wconfig/defaultconfig/settings.json +++ b/pkg/wconfig/defaultconfig/settings.json @@ -7,7 +7,7 @@ "autoupdate:installonquit": true, "autoupdate:intervalms": 3600000, "conn:askbeforewshinstall": true, - "conn:wshenabled": true, + "conn:wshenabled": true, "editor:minimapenabled": true, "web:defaulturl": "https://github.com/wavetermdev/waveterm", "web:defaultsearch": "https://www.google.com/search?q={query}", @@ -18,6 +18,8 @@ "window:magnifiedblocksize": 0.9, "window:magnifiedblockblurprimarypx": 10, "window:magnifiedblockblursecondarypx": 2, + "window:confirmclose": true, + "window:savelastwindow": true, "telemetry:enabled": true, "term:copyonselect": true } diff --git a/pkg/wconfig/metaconsts.go b/pkg/wconfig/metaconsts.go index 3197b9ad0..e7cf00c0a 100644 --- a/pkg/wconfig/metaconsts.go +++ b/pkg/wconfig/metaconsts.go @@ -79,6 +79,8 @@ const ( ConfigKey_WindowMagnifiedBlockSize = "window:magnifiedblocksize" ConfigKey_WindowMagnifiedBlockBlurPrimaryPx = "window:magnifiedblockblurprimarypx" ConfigKey_WindowMagnifiedBlockBlurSecondaryPx = "window:magnifiedblockblursecondarypx" + ConfigKey_WindowConfirmClose = "window:confirmclose" + ConfigKey_WindowSaveLastWindow = "window:savelastwindow" ConfigKey_TelemetryClear = "telemetry:*" ConfigKey_TelemetryEnabled = "telemetry:enabled" diff --git a/pkg/wconfig/settingsconfig.go b/pkg/wconfig/settingsconfig.go index b65a73a05..e4325fb66 100644 --- a/pkg/wconfig/settingsconfig.go +++ b/pkg/wconfig/settingsconfig.go @@ -106,6 +106,8 @@ type SettingsType struct { WindowMagnifiedBlockSize *float64 `json:"window:magnifiedblocksize,omitempty"` WindowMagnifiedBlockBlurPrimaryPx *int64 `json:"window:magnifiedblockblurprimarypx,omitempty"` WindowMagnifiedBlockBlurSecondaryPx *int64 `json:"window:magnifiedblockblursecondarypx,omitempty"` + WindowConfirmClose bool `json:"window:confirmclose,omitempty"` + WindowSaveLastWindow bool `json:"window:savelastwindow,omitempty"` TelemetryClear bool `json:"telemetry:*,omitempty"` TelemetryEnabled bool `json:"telemetry:enabled,omitempty"`