From a4634f3e701eabc8fb4e581088934882502ffae1 Mon Sep 17 00:00:00 2001 From: Diego Imbert Date: Tue, 2 Jun 2026 13:58:12 +0200 Subject: [PATCH] fix(frontend): don't re-adopt workspace param in agnostic sync (race) syncWorkspaceToUrl re-adopted ?workspace= into the store on agnostic routes, duplicating onQueryChange. If a user switched workspace between navigation and the post-navigation afterNavigate sync, that re-adoption set the store back to the URL's (now stale) value, silently undoing the switch. Adoption is already onQueryChange's job (URL -> store); the agnostic branch now only strips the param. Verified the deep-link adoption still works via onQueryChange (storage adopts the linked workspace before the strip). Co-Authored-By: Claude Opus 4.8 (1M context) --- frontend/src/routes/(root)/(logged)/+layout.svelte | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/frontend/src/routes/(root)/(logged)/+layout.svelte b/frontend/src/routes/(root)/(logged)/+layout.svelte index d9d77b075b..ce9a81e5ab 100644 --- a/frontend/src/routes/(root)/(logged)/+layout.svelte +++ b/frontend/src/routes/(root)/(logged)/+layout.svelte @@ -143,11 +143,11 @@ const param = page.url.searchParams.get('workspace') try { if (workspaceAgnosticRoute(path)) { - // Workspace-agnostic page: adopt an explicit ?workspace= into the store - // (so it propagates to later scoped pages), then strip it for a clean - // URL. The store/storage keep the workspace; the URL need not. + // Workspace-agnostic page: strip ?workspace= for a clean URL. Adoption + // of an explicit param into the store is handled by onQueryChange + // (URL → store); doing it here too could clobber a workspace switch + // that happened between navigation and this post-navigation sync. if (!param) return - if (param !== $workspaceStore) $workspaceStore = param const url = new URL(page.url) url.searchParams.delete('workspace') replaceState(url, page.state)