From d6ac283388290c419a779c0cc49fe5b51234ae41 Mon Sep 17 00:00:00 2001
From: atharva kamble <60008419+athkdev@users.noreply.github.com>
Date: Sun, 5 Oct 2025 17:55:29 -0400
Subject: [PATCH] feat: Unload a workspace context menu, p=#10688
Co-authored-by: mr. m <91018726+mr-cheffy@users.noreply.github.com>
---
.../en-US/browser/browser/zen-workspaces.ftl | 3 +++
.../base/content/zen-commands.inc.xhtml | 1 +
.../base/content/zen-panels/popups.inc | 1 +
src/zen/common/zen-sets.js | 4 ++++
src/zen/workspaces/ZenWorkspaces.mjs | 20 +++++++++++++++++++
5 files changed, 29 insertions(+)
diff --git a/locales/en-US/browser/browser/zen-workspaces.ftl b/locales/en-US/browser/browser/zen-workspaces.ftl
index 5b6452475..0933f225c 100644
--- a/locales/en-US/browser/browser/zen-workspaces.ftl
+++ b/locales/en-US/browser/browser/zen-workspaces.ftl
@@ -23,6 +23,9 @@ zen-workspaces-panel-change-icon =
zen-workspaces-panel-context-default-profile =
.label = Set Profile
+zen-workspaces-panel-unload =
+ .label = Unload Space
+
zen-workspaces-how-to-reorder-title = How to reorder spaces
zen-workspaces-how-to-reorder-desc = Drag the space icons at the bottom of the sidebar to reorder them
diff --git a/src/browser/base/content/zen-commands.inc.xhtml b/src/browser/base/content/zen-commands.inc.xhtml
index 25db87158..d1cbacd7a 100644
--- a/src/browser/base/content/zen-commands.inc.xhtml
+++ b/src/browser/base/content/zen-commands.inc.xhtml
@@ -39,6 +39,7 @@
+
diff --git a/src/browser/base/content/zen-panels/popups.inc b/src/browser/base/content/zen-panels/popups.inc
index cdada5655..d94f76ae0 100644
--- a/src/browser/base/content/zen-panels/popups.inc
+++ b/src/browser/base/content/zen-panels/popups.inc
@@ -25,6 +25,7 @@
hide-if-usercontext-disabled="true">
+
diff --git a/src/zen/common/zen-sets.js b/src/zen/common/zen-sets.js
index 4609d2e76..e9ca4b8bc 100644
--- a/src/zen/common/zen-sets.js
+++ b/src/zen/common/zen-sets.js
@@ -122,6 +122,10 @@ document.addEventListener(
}
break;
}
+ case 'cmd_zenUnloadWorkspace': {
+ gZenWorkspaces.unloadWorkspace();
+ break;
+ }
default:
gZenGlanceManager.handleMainCommandSet(event);
if (event.target.id.startsWith('cmd_zenWorkspaceSwitch')) {
diff --git a/src/zen/workspaces/ZenWorkspaces.mjs b/src/zen/workspaces/ZenWorkspaces.mjs
index 708ac626e..41e983f70 100644
--- a/src/zen/workspaces/ZenWorkspaces.mjs
+++ b/src/zen/workspaces/ZenWorkspaces.mjs
@@ -1479,6 +1479,26 @@ var gZenWorkspaces = new (class extends nsZenMultiWindowFeature {
});
}
+ async unloadWorkspace() {
+ const workspaceId = this.#contextMenuData?.workspaceId || this.activeWorkspace;
+
+ const tabsToUnload = this.allStoredTabs.filter(
+ (tab) =>
+ tab.getAttribute('zen-workspace-id') === workspaceId &&
+ !tab.hasAttribute('zen-empty-tab') &&
+ !tab.hasAttribute('zen-essential') &&
+ !tab.hasAttribute('pending')
+ );
+
+ if (tabsToUnload.length === 0) {
+ return;
+ }
+
+ this.log('Unloading workspace', workspaceId);
+
+ await gBrowser.explicitUnloadTabs(tabsToUnload); // TODO: unit test this
+ }
+
moveTabToWorkspace(tab, workspaceID) {
return this.moveTabsToWorkspace([tab], workspaceID);
}