From ccc1e998dab8b73318f2fcaf2e7223ae26a456b6 Mon Sep 17 00:00:00 2001 From: "mr. m" Date: Mon, 26 Jan 2026 09:43:31 +0100 Subject: [PATCH] fix: Fixed 'Restore previous session' not working winth wsync disabled, b=closes #12034, c=common --- src/zen/common/modules/ZenMenubar.mjs | 3 +++ .../sessionstore/ZenSessionManager.sys.mjs | 19 +++++++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/zen/common/modules/ZenMenubar.mjs b/src/zen/common/modules/ZenMenubar.mjs index 2c5773905..81a9ce9c9 100644 --- a/src/zen/common/modules/ZenMenubar.mjs +++ b/src/zen/common/modules/ZenMenubar.mjs @@ -124,6 +124,9 @@ export class nsZenMenuBar { } #hideWindowRestoreMenus() { + if (!Services.prefs.getBoolPref("zen.window-sync.enabled", true)) { + return; + } const itemsToHide = ["appMenuRecentlyClosedWindows", "historyUndoWindowMenu"]; for (const id of itemsToHide) { const element = PanelMultiView.getViewNode(document, id); diff --git a/src/zen/sessionstore/ZenSessionManager.sys.mjs b/src/zen/sessionstore/ZenSessionManager.sys.mjs index d3b5ff863..60af2824b 100644 --- a/src/zen/sessionstore/ZenSessionManager.sys.mjs +++ b/src/zen/sessionstore/ZenSessionManager.sys.mjs @@ -191,6 +191,13 @@ export class nsZenSessionManager { } } + get #shouldRestoreOnlyPinned() { + return ( + Services.prefs.getIntPref("browser.startup.page", 1) !== BROWSER_STARTUP_RESUME_SESSION || + lazy.PrivateBrowsingUtils.permanentPrivateBrowsing + ); + } + /** * Called when the session file is read. Restores the sidebar data * into all windows. @@ -200,6 +207,13 @@ export class nsZenSessionManager { */ onFileRead(initialState) { if (!lazy.gWindowSyncEnabled) { + if (initialState?.windows?.length && this.#shouldRestoreOnlyPinned) { + this.log("Window sync disabled, restoring only pinned tabs"); + for (let i = 0; i < initialState.windows.length; i++) { + let winData = initialState.windows[i]; + winData.tabs = (winData.tabs || []).filter((tab) => tab.pinned); + } + } return initialState; } // For the first time after migration, we restore the tabs @@ -225,10 +239,7 @@ export class nsZenSessionManager { } // When we don't have browser.startup.page set to resume session, // we only want to restore the pinned tabs into the new windows. - const shouldRestoreOnlyPinned = - Services.prefs.getIntPref("browser.startup.page", 1) !== BROWSER_STARTUP_RESUME_SESSION || - lazy.PrivateBrowsingUtils.permanentPrivateBrowsing; - if (shouldRestoreOnlyPinned && this.#sidebar?.tabs) { + if (this.#shouldRestoreOnlyPinned && this.#sidebar?.tabs) { this.log("Restoring only pinned tabs into windows"); const sidebar = this.#sidebar; sidebar.tabs = (sidebar.tabs || []).filter((tab) => tab.pinned);