Skip to content

gh-12140: Avoid reopening individually closed fully synced windows - #15904

Closed
briankeefe wants to merge 4 commits into
zen-browser:devfrom
briankeefe:fix/12140-closed-synced-windows
Closed

briankeefe wants to merge 4 commits into
zen-browser:devfrom
briankeefe:fix/12140-closed-synced-windows

Conversation

@briankeefe

@briankeefe briankeefe commented Oct 11, 2026 •

Copy link
Copy Markdown

Refs #12140

Firefox marks windows closed in succession with _shouldRestore, and SessionSaver puts them back into the saved open-window list unless a tab action clears the flag. With full Zen window sync, closing two windows individually and reopening Zen brings back two copies of the same tabs.

The existing maybeSaveClosedWindow hook now clears that flag for non-last normal windows only when all tabs are synced. The window stays in undo history, and the last normal window is still saved. Pinned-only and disabled sync keep their existing behavior. This targets the close-in-succession case, not launcher double-invocation or the other causes discussed in the issue.

Added browser_closed_window_restore.js to check the persisted open-window list and closed-window history. In an isolated copy of Zen 1.22.3b with temporary profiles, the persisted-state assertions fail without the change and pass with it; closing both windows and restarting goes from two restored windows to one, with tabs preserved. Explicit two-window quit, crash recovery, undo-close-window, and pinned-only/disabled-sync checks also passed.

I haven't run a full build of current dev or the new browser-chrome test. Runtime verification used the same close-hook change overlaid into the isolated installed-version copy; the installed browser and user's profile were untouched. Keeping this as a draft pending that validation.

@briankeefe
briankeefe marked this pull request as ready for review October 11, 2026 19:23
@briankeefe
briankeefe requested a review from mr-cheffy as a code owner October 11, 2026 19:23
Comment thread docs/contribute.md Outdated

Before you set up your local development environment, **read our [Building Guidelines](https://docs.zen-browser.app/guides/building)**. Skipping them can lead to avoidable build errors.

For changes to window session restoration, cover both full window sync and

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for this

return;
}
if (!isLastWindow) {
if (lazy.gWindowSyncEnabled && !lazy.gSyncOnlyPinnedTabs) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why ignore !gSyncOnlyPinnedTabs?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@briankeefe just making sure you've read this :)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kept the pinned-only check because those windows can still have their own unpinned tabs. Without it, those tabs wouldn’t come back on restart unless you used undo-close-window. Added a comment explaining that and removed the docs change.

@mr-cheffy mr-cheffy Oct 20, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you reproduce the issue tho? Why do we need to do this and firefox doesnt have the same issue? Pretty sure the issue also happens when syncing normal tabs as well

@mr-cheffy mr-cheffy linked an issue Oct 14, 2026 that may be closed by this pull request
5 tasks done
@mr-cheffy

Copy link
Copy Markdown
Member

I dont think this quite handles the issue nicely unfortunately, I did my own solution here that I think works best: #16047

Because this would only fix the issue if "restore pinned tabs" is false. Thanks tho!

@mr-cheffy mr-cheffy closed this Oct 20, 2026
@mr-cheffy mr-cheffy self-assigned this Oct 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Multiple Windows On Launch In Wayland and Windows

2 participants