From d74660d1d1fac9c16de951cf5de641f4c864f144 Mon Sep 17 00:00:00 2001 From: Hare Date: Fri, 16 Oct 2026 11:08:27 +0900 Subject: [PATCH] fix: retain workspace creation state across session rechecks --- .../src/routes/dashboard/+page.svelte | 19 +- .../routes/dashboard/WorkspaceCatalog.svelte | 78 ++----- .../dashboard/workspace-creation.svelte.ts | 63 ++++++ .../src/routes/entry.browser.spec.ts | 151 ++++++++++++- .../routes/workspace-catalog.browser.spec.ts | 5 +- .../auth-browser/entry-shell.browser.test.ts | 213 ++++++++++++++++++ 6 files changed, 470 insertions(+), 59 deletions(-) create mode 100644 web/workspace/src/routes/dashboard/workspace-creation.svelte.ts diff --git a/web/workspace/src/routes/dashboard/+page.svelte b/web/workspace/src/routes/dashboard/+page.svelte index 5c0917c53..c131f33c1 100644 --- a/web/workspace/src/routes/dashboard/+page.svelte +++ b/web/workspace/src/routes/dashboard/+page.svelte @@ -5,15 +5,30 @@ import { loginUrl } from '#lib/workspace/auth/routes.ts'; import AccountNavigation from '#lib/workspace/auth/AccountNavigation.svelte'; import WorkspaceCatalog from './WorkspaceCatalog.svelte'; + import { WorkspaceCreation } from './workspace-creation.svelte.ts'; import '#lib/workspace/auth/auth-page.css'; const auth = new BrowserAuth(); + let creation = $state(null); + let mounted = false; + $effect(() => { + if (auth.session.kind !== 'ready') return; + const actor = auth.session.actor; + if (!actor) { creation = null; return; } + if (creation?.accountId !== actor.account_id) { + const draft: WorkspaceCreation = new WorkspaceCreation(actor.account_id, () => + mounted && creation === draft && auth.actor?.account_id === draft.accountId); + creation = draft; + } + }); onMount(() => { + mounted = true; const refresh = () => { void auth.refresh(); }; refresh(); window.addEventListener('focus', refresh); window.addEventListener(SESSION_CHANGED_EVENT, refresh); return () => { + mounted = false; auth.dispose(); window.removeEventListener('focus', refresh); window.removeEventListener(SESSION_CHANGED_EVENT, refresh); @@ -33,7 +48,9 @@ {:else if auth.actor} {#key auth.actor.account_id} - + {#if creation?.accountId === auth.actor.account_id} + + {/if} {/key} {:else}

Log in to select or create a Workspace.

diff --git a/web/workspace/src/routes/dashboard/WorkspaceCatalog.svelte b/web/workspace/src/routes/dashboard/WorkspaceCatalog.svelte index b996bc2d9..d44e6a6ac 100644 --- a/web/workspace/src/routes/dashboard/WorkspaceCatalog.svelte +++ b/web/workspace/src/routes/dashboard/WorkspaceCatalog.svelte @@ -1,36 +1,21 @@