From 43d47ac537eeb1964ff1bcb134649f1b1f185fc1 Mon Sep 17 00:00:00 2001 From: "mr. m" <91018726+mr-cheffy@users.noreply.github.com> Date: Thu, 3 Sep 2026 11:17:28 +0200 Subject: [PATCH] gh-14470: Make sure sidebar is initialized before syncing (gh-15219) --- src/zen/sync/ZenSpacesSyncModel.sys.mjs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/zen/sync/ZenSpacesSyncModel.sys.mjs b/src/zen/sync/ZenSpacesSyncModel.sys.mjs index b180f9f12..2f100a3f8 100644 --- a/src/zen/sync/ZenSpacesSyncModel.sys.mjs +++ b/src/zen/sync/ZenSpacesSyncModel.sys.mjs @@ -653,12 +653,24 @@ class nsZenSpacesSyncModel { return this.projections().get(id) ?? null; } + /** + * Before the session file is read the sidebar reads as empty. Diffing that + * against the uploaded snapshot would tombstone every synced item. An + * initialized sidebar always holds at least one space. + */ + #sidebarReady() { + return !!lazy.ZenSessionStore.getSidebarData()?.spaces?.length; + } + /** * Changes = diff between the current projections and the last state the * server acknowledged. Ids present locally with different content are * modified; ids only present in the uploaded snapshot are deletions. */ computeChangedIDs() { + if (!this.#sidebarReady()) { + return {}; + } const uploaded = this.#data().uploaded; const current = this.#digestAll(); const pending = this.#pendingIds(); @@ -687,6 +699,9 @@ class nsZenSpacesSyncModel { } hasPendingChanges() { + if (!this.#sidebarReady()) { + return false; + } const uploaded = this.#data().uploaded; const current = this.#digestAll(); const pending = this.#pendingIds();