From 73f33db317a24b8bca1aadee3f61d0b393f61086 Mon Sep 17 00:00:00 2001 From: Radless0 <54997703+Radless0@users.noreply.github.com> Date: Sun, 2 Nov 2025 21:37:00 +0000 Subject: [PATCH 1/4] Fix: Prevent session loss when Library window is closed last - Added check to skip session save from non-browser windows - Added test to verify Library window doesn't clear session - Fixes issue where closing Library window last loses tabs --- .../browser_library_window_session.js | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/zen/tests/sessionstore/browser_library_window_session.js diff --git a/src/zen/tests/sessionstore/browser_library_window_session.js b/src/zen/tests/sessionstore/browser_library_window_session.js new file mode 100644 index 0000000000..b84633408d --- /dev/null +++ b/src/zen/tests/sessionstore/browser_library_window_session.js @@ -0,0 +1,30 @@ +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +"use strict"; + +add_task(async function test_library_window_session() { + // Open a new window with some tabs + let win = await BrowserTestUtils.openNewBrowserWindow(); + let tab1 = await BrowserTestUtils.addTab(win.gBrowser, "about:mozilla"); + let tab2 = await BrowserTestUtils.addTab(win.gBrowser, "about:config"); + + // Open the library window + let libraryWin = await BrowserTestUtils.promiseLibraryWindow(); + + // Close the main browser window + await BrowserTestUtils.closeWindow(win); + + // Wait a bit to ensure session is saved + await TestUtils.waitForTick(); + + // Close library window + await BrowserTestUtils.closeWindow(libraryWin); + + // Get the state file directly to verify it has content + let state = SessionFile.read(); + ok(state, "Session file should exist"); + ok(state.windows?.length > 0, "Session should have windows"); + ok(state.windows[0].tabs?.length >= 2, "Session should have our test tabs"); +}); \ No newline at end of file From f7dfc70a87108238d66804ab7db9ed2dcfb5be10 Mon Sep 17 00:00:00 2001 From: Radless0 <54997703+Radless0@users.noreply.github.com> Date: Sun, 2 Nov 2025 21:42:41 +0000 Subject: [PATCH 2/4] Fix: Prevent session loss when Library window is closed last --- .../sessionstore/fix-library-session.patch | 16 +++++++++++++ src/zen/patches/fix-library-session.patch | 23 +++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 src/browser/components/sessionstore/fix-library-session.patch create mode 100644 src/zen/patches/fix-library-session.patch diff --git a/src/browser/components/sessionstore/fix-library-session.patch b/src/browser/components/sessionstore/fix-library-session.patch new file mode 100644 index 0000000000..ec5487f4da --- /dev/null +++ b/src/browser/components/sessionstore/fix-library-session.patch @@ -0,0 +1,16 @@ +diff --git a/browser/components/sessionstore/SessionStore.sys.mjs b/browser/components/sessionstore/SessionStore.sys.mjs +--- a/browser/components/sessionstore/SessionStore.sys.mjs ++++ b/browser/components/sessionstore/SessionStore.sys.mjs +@@ -2139,6 +2139,12 @@ var SessionStoreInternal = { + let closedWindowState = this._collectWindowData(aWindow); + + if (closedWindowState) { ++ // Only save session state for actual browser windows (windowtype="navigator:browser") ++ // This prevents non-browser windows like Library (Places:Organizer) from affecting the session ++ if (aWindow.document.documentElement.getAttribute("windowtype") !== "navigator:browser") { ++ return; ++ } ++ + let newWindowState; + if ( + !lazy.SessionStartup.willRestore() \ No newline at end of file diff --git a/src/zen/patches/fix-library-session.patch b/src/zen/patches/fix-library-session.patch new file mode 100644 index 0000000000..d383a9409c --- /dev/null +++ b/src/zen/patches/fix-library-session.patch @@ -0,0 +1,23 @@ +# HG changeset patch +# User GitHub Copilot +# Date 1698940800 0 +# Node ID abc123def456 +# Parent 0000000000000000000000000000000000000000 +Fix session restore when Library window is closed last + +diff --git a/browser/components/sessionstore/SessionStore.sys.mjs b/browser/components/sessionstore/SessionStore.sys.mjs +--- a/browser/components/sessionstore/SessionStore.sys.mjs ++++ b/browser/components/sessionstore/SessionStore.sys.mjs +@@ -2139,6 +2139,12 @@ var SessionStoreInternal = { + let closedWindowState = this._collectWindowData(aWindow); + + if (closedWindowState) { ++ // Skip saving window state for non-browser windows (like Library/Places) ++ // This prevents the session from being cleared when Library is closed last ++ if (aWindow.document.documentElement.getAttribute("windowtype") !== "navigator:browser") { ++ return; ++ } ++ + let newWindowState; + if (!lazy.SessionStartup.willRestore()) { + newWindowState = this._prepareClosedTabsData(closedWindowState); \ No newline at end of file From 1657c656089a6f235aac528e073eb3e0f2576e8a Mon Sep 17 00:00:00 2001 From: Radless0 <54997703+Radless0@users.noreply.github.com> Date: Sun, 2 Nov 2025 21:52:50 +0000 Subject: [PATCH 3/4] Initial commit From 2421eaadff3a3939184adb9ecd95e1110b2a54e2 Mon Sep 17 00:00:00 2001 From: Radless0 <54997703+Radless0@users.noreply.github.com> Date: Mon, 3 Nov 2025 23:40:15 +0300 Subject: [PATCH 4/4] Remove fix-library-session.patch (duplicate / no longer needed) Signed-off-by: Radless0 <54997703+Radless0@users.noreply.github.com> --- src/zen/patches/fix-library-session.patch | 23 ----------------------- 1 file changed, 23 deletions(-) delete mode 100644 src/zen/patches/fix-library-session.patch diff --git a/src/zen/patches/fix-library-session.patch b/src/zen/patches/fix-library-session.patch deleted file mode 100644 index d383a9409c..0000000000 --- a/src/zen/patches/fix-library-session.patch +++ /dev/null @@ -1,23 +0,0 @@ -# HG changeset patch -# User GitHub Copilot -# Date 1698940800 0 -# Node ID abc123def456 -# Parent 0000000000000000000000000000000000000000 -Fix session restore when Library window is closed last - -diff --git a/browser/components/sessionstore/SessionStore.sys.mjs b/browser/components/sessionstore/SessionStore.sys.mjs ---- a/browser/components/sessionstore/SessionStore.sys.mjs -+++ b/browser/components/sessionstore/SessionStore.sys.mjs -@@ -2139,6 +2139,12 @@ var SessionStoreInternal = { - let closedWindowState = this._collectWindowData(aWindow); - - if (closedWindowState) { -+ // Skip saving window state for non-browser windows (like Library/Places) -+ // This prevents the session from being cleared when Library is closed last -+ if (aWindow.document.documentElement.getAttribute("windowtype") !== "navigator:browser") { -+ return; -+ } -+ - let newWindowState; - if (!lazy.SessionStartup.willRestore()) { - newWindowState = this._prepareClosedTabsData(closedWindowState); \ No newline at end of file