From 78ee43347ee4dd1eed8350ddd2d719fc6debc57a Mon Sep 17 00:00:00 2001 From: "mr. m" Date: Fri, 25 Apr 2025 15:21:27 +0200 Subject: [PATCH] fix: Tab siwtcher crashing zen if no active tabs exist, b=(closes #7865), c=tabs, workspaces --- .../tabbrowser/content/browser-ctrlTab-js.patch | 11 ++++++++++- src/zen/tabs/zen-tabs/vertical-tabs.css | 1 + src/zen/workspaces/ZenWorkspaces.mjs | 12 ++++++++++-- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/browser/components/tabbrowser/content/browser-ctrlTab-js.patch b/src/browser/components/tabbrowser/content/browser-ctrlTab-js.patch index 4ab641d43..f143def6b 100644 --- a/src/browser/components/tabbrowser/content/browser-ctrlTab-js.patch +++ b/src/browser/components/tabbrowser/content/browser-ctrlTab-js.patch @@ -1,5 +1,5 @@ diff --git a/browser/components/tabbrowser/content/browser-ctrlTab.js b/browser/components/tabbrowser/content/browser-ctrlTab.js -index 6753641cb579032306453be3f5054d7bc7661e8c..e0eda8d77637334ca30ee1842057cb43b4af2c21 100644 +index 6753641cb579032306453be3f5054d7bc7661e8c..436ee8940c8a73d238a7aed10768a0a752a3f119 100644 --- a/browser/components/tabbrowser/content/browser-ctrlTab.js +++ b/browser/components/tabbrowser/content/browser-ctrlTab.js @@ -252,7 +252,7 @@ var ctrlTab = { @@ -20,6 +20,15 @@ index 6753641cb579032306453be3f5054d7bc7661e8c..e0eda8d77637334ca30ee1842057cb43 return; } +@@ -483,7 +483,7 @@ var ctrlTab = { + }, + + open: function ctrlTab_open() { +- if (this.isOpen) { ++ if (this.isOpen || !this.tabCount) { + return; + } + @@ -761,7 +761,7 @@ var ctrlTab = { _initRecentlyUsedTabs() { this._recentlyUsedTabs = Array.prototype.filter.call( diff --git a/src/zen/tabs/zen-tabs/vertical-tabs.css b/src/zen/tabs/zen-tabs/vertical-tabs.css index 858b6248c..8e5a3e18d 100644 --- a/src/zen/tabs/zen-tabs/vertical-tabs.css +++ b/src/zen/tabs/zen-tabs/vertical-tabs.css @@ -1274,5 +1274,6 @@ &[hidden='true'] { visibility: hidden; pointer-events: none; + position: fixed; } } diff --git a/src/zen/workspaces/ZenWorkspaces.mjs b/src/zen/workspaces/ZenWorkspaces.mjs index bda99f7ed..fe5a73c5f 100644 --- a/src/zen/workspaces/ZenWorkspaces.mjs +++ b/src/zen/workspaces/ZenWorkspaces.mjs @@ -1809,6 +1809,7 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature { // Second pass: Handle tab selection this.tabContainer._invalidateCachedTabs(); const tabToSelect = await this._handleTabSelection(window, onInit, previousWorkspace.uuid); + gBrowser.warmupTab(tabToSelect); // Update UI and state const previousWorkspaceIndex = workspaces.workspaces.findIndex((w) => w.uuid === previousWorkspace.uuid); @@ -2771,8 +2772,12 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature { } try { + const currentWorkspace = this.getActiveWorkspaceFromCache(); // Check if we need to change workspace - if (!tab.hasAttribute('zen-essential') && tab.getAttribute('zen-workspace-id') !== this.activeWorkspace) { + if ( + tab.getAttribute('zen-workspace-id') !== this.activeWorkspace || + (currentWorkspace.containerTabId !== tab.getAttribute('usercontextid') && this.containerSpecificEssentials) + ) { // Use a mutex-like approach to prevent concurrent workspace changes if (this._workspaceChangeInProgress) { console.warn('Workspace change already in progress, deferring tab switch'); @@ -2781,7 +2786,10 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature { this._workspaceChangeInProgress = true; try { - await this.changeWorkspace({ uuid: tab.getAttribute('zen-workspace-id') }); + await this.changeWorkspace({ + uuid: tab.getAttribute('zen-workspace-id'), + containerTabId: tab.getAttribute('usercontextid'), + }); } finally { this._workspaceChangeInProgress = false; }