From f830070cf64e663b0a02db5b70e05649ed89e98d Mon Sep 17 00:00:00 2001 From: Guilhem Lemouel Date: Wed, 23 Sep 2026 18:57:48 +0200 Subject: [PATCH] fix: recheck for a newer workspace switch after navigating home Co-Authored-By: Claude Opus 5.5 (1M context) --- frontend/src/lib/components/sidebar/workspaceSwitchUrl.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/frontend/src/lib/components/sidebar/workspaceSwitchUrl.ts b/frontend/src/lib/components/sidebar/workspaceSwitchUrl.ts index ed4d2f3243..36e1e8330e 100644 --- a/frontend/src/lib/components/sidebar/workspaceSwitchUrl.ts +++ b/frontend/src/lib/components/sidebar/workspaceSwitchUrl.ts @@ -153,7 +153,7 @@ export async function switchWorkspaceAndPage( ): Promise { const request = ++latestSwitch const missing = !opts?.landOnHome && (await itemPageMissingIn(id)) - // A switch picked while this lookup was in flight wins. + // A switch picked while this lookup (or the navigation home below) was in flight wins. if (request !== latestSwitch) return // Read after the lookup: the user can edit while it is in flight. const unsavedEdits = editorHasUnsavedEdits() @@ -165,6 +165,7 @@ export async function switchWorkspaceAndPage( // applies. On cancel nothing is switched. const from = page.route.id await goto(`/?workspace=${encodeURIComponent(id)}`) + if (request !== latestSwitch) return if (unsavedEdits && page.route.id === from) return switchTo(id) return