feat: Start checking for spaces mroe robustly when restoring, b=no-bug, c=common, workspaces

This commit is contained in:
mr. m
2026-03-01 13:50:28 +01:00
parent 9bc0a4ca92
commit 657d03821f
5 changed files with 28 additions and 15 deletions

View File

@@ -30,7 +30,7 @@ panel[type="arrow"]:not(#feature-callout) {
}
@media (-moz-platform: macos) {
&:where([followanchor="false"], [nonnativepopover="true"]) {
&:where([nativepopover="true"]) {
appearance: auto !important;
-moz-default-appearance: menupopup;
/* We set the default background here, rather than on ::part(content),

View File

@@ -221,7 +221,7 @@ export class nsZenSessionManager {
try {
await this.#file.load();
this._dataFromFile = this.#file.data;
if (!this._dataFromFile?.spaces) {
if (!this._dataFromFile?.spaces?.length) {
// Go to the catch block to try to recover from backup files
// if the file is empty or has invalid data, as it can happen if the app
// crashes while writing the session file.
@@ -232,6 +232,9 @@ export class nsZenSessionManager {
try {
let data = await IOUtils.readJSON(backupFile, { decompress: true });
this.log(`Recovered data from backup file ${backupFile}`);
if (!data?.spaces?.length) {
continue;
}
this._dataFromFile = data;
break;
} catch (e) {
@@ -710,6 +713,12 @@ export class nsZenSessionManager {
// Folders are always pinned, so we dont need to check for the pinned state here.
aWindowData.folders = sidebar.folders;
aWindowData.spaces = sidebar.spaces;
this.log("Restored sidebar data into window", {
tabs: aWindowData.tabs?.length || 0,
groups: aWindowData.groups?.length || 0,
folders: aWindowData.folders?.length || 0,
spaces: aWindowData.spaces?.length || 0,
});
}
/**

View File

@@ -373,7 +373,7 @@ class nsZenWorkspaces {
const defaultSelectedContainer = this.workspaceElement(this.activeWorkspace)?.querySelector(
".zen-workspace-normal-tabs-section"
);
const pinnedContainer = this.workspaceElement(this.activeWorkspace).querySelector(
const pinnedContainer = this.workspaceElement(this.activeWorkspace)?.querySelector(
".zen-workspace-pinned-tabs-section"
);
// New profile with no workspaces does not have a default selected container
@@ -895,7 +895,9 @@ class nsZenWorkspaces {
// We don't want to depend on this by mistake
delete workspace.hasCollapsedPinnedTabs;
}
this.#hasInitialized = true;
promise.finally(() => {
this.#hasInitialized = true;
});
return promise;
}
@@ -1602,7 +1604,7 @@ class nsZenWorkspaces {
this.#inChangingWorkspace = true;
try {
this.log("Changing workspace to", workspace?.uuid);
await this._performWorkspaceChange(workspace, ...args);
await this.#performWorkspaceChange(workspace, ...args);
} catch (e) {
console.error("gZenWorkspaces: Error changing workspace", e);
}
@@ -1613,7 +1615,7 @@ class nsZenWorkspaces {
this._animateTabs(this.getActiveWorkspaceFromCache(), true);
}
async _performWorkspaceChange(
async #performWorkspaceChange(
workspace,
{ onInit = false, alwaysChange = false, whileScrolling = false } = {}
) {
@@ -1654,7 +1656,7 @@ class nsZenWorkspaces {
// Update UI and state
const previousWorkspaceIndex = workspaces.findIndex((w) => w.uuid === previousWorkspace.uuid);
await this._updateWorkspaceState(workspace, onInit, tabToSelect, {
await this.#updateWorkspaceState(workspace, onInit, tabToSelect, {
previousWorkspaceIndex,
previousWorkspace,
});
@@ -2020,8 +2022,10 @@ class nsZenWorkspaces {
Math.abs(newWorkspaceIndex - (isGoingLeft ? firstWorkspaceIndex : lastWorkspaceIndex)) +
1;
const usingSameContainer =
newWorkspaceEssentialsContainer.workspaces.some((w) => w.uuid === newWorkspace.uuid) &&
newWorkspaceEssentialsContainer.workspaces.some((w) => w.uuid === previousWorkspace.uuid);
newWorkspaceEssentialsContainer?.workspaces.some((w) => w.uuid === newWorkspace.uuid) &&
newWorkspaceEssentialsContainer?.workspaces.some(
(w) => w.uuid === previousWorkspace.uuid
);
let newOffset =
-(
newWorkspaceIndex -
@@ -2259,7 +2263,7 @@ class nsZenWorkspaces {
return tabToSelect;
}
async _updateWorkspaceState(
async #updateWorkspaceState(
workspace,
onInit,
tabToSelect,

View File

@@ -46,10 +46,10 @@
pointer-events: none;
line-height: 0;
position: absolute;
font-size: 14px;
font-size: 12px;
@media (-moz-platform: linux) {
font-size: 12px;
@media (-moz-platform: macos) {
font-size: 14px;
}
&:is(img) {

View File

@@ -20,7 +20,7 @@
"brandShortName": "Zen",
"brandFullName": "Zen Browser",
"release": {
"displayVersion": "1.19b",
"displayVersion": "1.19.1b",
"github": {
"repo": "zen-browser/desktop"
},
@@ -40,7 +40,7 @@
"brandShortName": "Twilight",
"brandFullName": "Zen Twilight",
"release": {
"displayVersion": "1.19t",
"displayVersion": "1.20t",
"github": {
"repo": "zen-browser/desktop"
}