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) <noreply@anthropic.com>
This commit is contained in:
Diego Imbert
2026-06-02 13:58:12 +02:00
parent a329a5cd61
commit a4634f3e70
@@ -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)