gh-15088: Fixed syncing essentials with different containers (gh-15105)

This commit is contained in:
mr. m
2026-08-25 22:05:54 +02:00
committed by GitHub
parent b9c4000fe2
commit b93d19b873
3 changed files with 11 additions and 5 deletions

View File

@@ -606,7 +606,9 @@ class nsZenWindowSync {
if (isTab) {
if (originalIsEssential !== targetIsEssential) {
if (originalIsEssential) {
gZenPinnedTabManager.addToEssentials(aTargetItem);
gZenPinnedTabManager.addToEssentials(aTargetItem, {
replicating: true,
});
} else {
gZenPinnedTabManager.removeEssentials(
aTargetItem,

View File

@@ -498,7 +498,7 @@ class nsZenSpacesSyncApplier {
tab._zenContentsVisible = true;
this.#updateTabIdentity(win, tab, data);
if (data.essential) {
win.gZenPinnedTabManager.addToEssentials(tab);
win.gZenPinnedTabManager.addToEssentials(tab, { replicating: true });
} else {
if (data.workspaceUuid) {
tab.setAttribute("zen-workspace-id", data.workspaceUuid);
@@ -658,7 +658,7 @@ class nsZenSpacesSyncApplier {
const isEssential = tab.hasAttribute("zen-essential");
if (data.essential && !isEssential) {
win.gZenPinnedTabManager.addToEssentials(tab);
win.gZenPinnedTabManager.addToEssentials(tab, { replicating: true });
return;
}
if (!data.essential && isEssential) {

View File

@@ -503,7 +503,7 @@ class nsZenPinnedTabManager extends nsZenDOMOperatedFeature {
}
}
addToEssentials(tab) {
addToEssentials(tab, { replicating = false } = {}) {
// eslint-disable-next-line no-nested-ternary
const tabs = tab
? // if it's already an array, dont make it [tab]
@@ -518,7 +518,11 @@ class nsZenPinnedTabManager extends nsZenDOMOperatedFeature {
// eslint-disable-next-line no-shadow
let tab = tabs[i];
const section = gZenWorkspaces.getEssentialsSection(tab);
if (!this.canEssentialBeAdded(tab)) {
// canEssentialBeAdded gates user-initiated adds on the *active* space's
// container. A replicated add mirrors a decision already made in another
// window or on another device, always into the tab's own container
// section.
if (!replicating && !this.canEssentialBeAdded(tab)) {
movedAll = false;
continue;
}