From 92be0c8fc298c3c8c3aab35afa63839f976e7381 Mon Sep 17 00:00:00 2001 From: Jordy Perez Date: Thu, 2 Jul 2026 17:58:58 -0400 Subject: [PATCH] Preserve all windows/workspaces on close, not just the last one Closing a window when other windows are still open (or when window:savelastwindow is off) always deleted its workspace, tabs, and blocks from the DB, discarding each terminal's persisted cwd along with them. Only a single-window full app quit survived a restart. Add window:restoreallwindows (default true) so every window is kept on close, matching the existing per-block cmd:cwd persistence that already restores a shell's working directory when its block relaunches. --- docs/docs/config.mdx | 1 + emain/emain-window.ts | 5 ++++- frontend/types/gotypes.d.ts | 1 + pkg/wconfig/defaultconfig/settings.json | 1 + pkg/wconfig/metaconsts.go | 1 + pkg/wconfig/settingsconfig.go | 1 + schema/settings.json | 3 +++ 7 files changed, 12 insertions(+), 1 deletion(-) diff --git a/docs/docs/config.mdx b/docs/docs/config.mdx index 05389e99ef..37e838127a 100644 --- a/docs/docs/config.mdx +++ b/docs/docs/config.mdx @@ -113,6 +113,7 @@ wsh editconfig | window:disablehardwareacceleration | bool | set to disable Chromium hardware acceleration to resolve graphical bugs (requires app restart) | | window:fullscreenonlaunch | bool | set to true to launch the foreground window in fullscreen mode (defaults to false) | | 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:restoreallwindows | bool | when `true`, all open windows (not just the last one) are preserved when closed and reopened the next time the app is launched, keeping their workspaces, tabs, and terminal working directories (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`) | | window:dimensions | string | set the default dimensions for new windows using the format "WIDTHxHEIGHT" (e.g. "1920x1080"). when a new window is created, these dimensions will be automatically applied. The width and height values should be specified in pixels. | | telemetry:enabled | bool | set to enable/disable telemetry | diff --git a/emain/emain-window.ts b/emain/emain-window.ts index e3bfa87751..a572f19148 100644 --- a/emain/emain-window.ts +++ b/emain/emain-window.ts @@ -308,7 +308,10 @@ export class WaveBrowserWindow extends BaseWindow { fireAndForget(async () => { const numWindows = waveWindowMap.size; const fullConfig = await RpcApi.GetFullConfigCommand(ElectronWshClient); - if (numWindows > 1 || !fullConfig.settings["window:savelastwindow"]) { + const preserveThisWindow = + fullConfig.settings["window:restoreallwindows"] || + (numWindows === 1 && fullConfig.settings["window:savelastwindow"]); + if (!preserveThisWindow) { if (fullConfig.settings["window:confirmclose"]) { const workspace = await WorkspaceService.GetWorkspace(this.workspaceId); if (isNonEmptyUnsavedWorkspace(workspace)) { diff --git a/frontend/types/gotypes.d.ts b/frontend/types/gotypes.d.ts index c5b870d7ed..235b90d951 100644 --- a/frontend/types/gotypes.d.ts +++ b/frontend/types/gotypes.d.ts @@ -1467,6 +1467,7 @@ declare global { "window:magnifiedblockblursecondarypx"?: number; "window:confirmclose"?: boolean; "window:savelastwindow"?: boolean; + "window:restoreallwindows"?: boolean; "window:dimensions"?: string; "window:zoom"?: number; "telemetry:*"?: boolean; diff --git a/pkg/wconfig/defaultconfig/settings.json b/pkg/wconfig/defaultconfig/settings.json index d8847cabf2..76e69b1a8d 100644 --- a/pkg/wconfig/defaultconfig/settings.json +++ b/pkg/wconfig/defaultconfig/settings.json @@ -29,6 +29,7 @@ "window:magnifiedblockblursecondarypx": 2, "window:confirmclose": true, "window:savelastwindow": true, + "window:restoreallwindows": true, "telemetry:enabled": true, "term:bellsound": false, "term:bellindicator": true, diff --git a/pkg/wconfig/metaconsts.go b/pkg/wconfig/metaconsts.go index 7d5bba5d9d..ad4d404ae2 100644 --- a/pkg/wconfig/metaconsts.go +++ b/pkg/wconfig/metaconsts.go @@ -110,6 +110,7 @@ const ( ConfigKey_WindowMagnifiedBlockBlurSecondaryPx = "window:magnifiedblockblursecondarypx" ConfigKey_WindowConfirmClose = "window:confirmclose" ConfigKey_WindowSaveLastWindow = "window:savelastwindow" + ConfigKey_WindowRestoreAllWindows = "window:restoreallwindows" ConfigKey_WindowDimensions = "window:dimensions" ConfigKey_WindowZoom = "window:zoom" diff --git a/pkg/wconfig/settingsconfig.go b/pkg/wconfig/settingsconfig.go index 67118b1670..0ce81b6caa 100644 --- a/pkg/wconfig/settingsconfig.go +++ b/pkg/wconfig/settingsconfig.go @@ -161,6 +161,7 @@ type SettingsType struct { WindowMagnifiedBlockBlurSecondaryPx *int64 `json:"window:magnifiedblockblursecondarypx,omitempty"` WindowConfirmClose bool `json:"window:confirmclose,omitempty"` WindowSaveLastWindow bool `json:"window:savelastwindow,omitempty"` + WindowRestoreAllWindows bool `json:"window:restoreallwindows,omitempty"` WindowDimensions string `json:"window:dimensions,omitempty"` WindowZoom *float64 `json:"window:zoom,omitempty"` diff --git a/schema/settings.json b/schema/settings.json index f341a0f365..360dd65871 100644 --- a/schema/settings.json +++ b/schema/settings.json @@ -301,6 +301,9 @@ "window:savelastwindow": { "type": "boolean" }, + "window:restoreallwindows": { + "type": "boolean" + }, "window:dimensions": { "type": "string" },