diff --git a/frontend/src/lib/components/home/ImportProjectModal.svelte b/frontend/src/lib/components/home/ImportProjectModal.svelte index f7ae84aa11..d5f3cde7a4 100644 --- a/frontend/src/lib/components/home/ImportProjectModal.svelte +++ b/frontend/src/lib/components/home/ImportProjectModal.svelte @@ -79,6 +79,11 @@ sendUserToast('Import stopped. What it already added stays; reopen the project to finish.') } } + // A run that started wrote items, whether it finished, was abandoned midway or failed + // partway — so the list behind this dialog is stale either way, and only `finish()` + // was reloading it. Closing a landed import with the X left an emptied-out home + // showing its placeholder rows over a workspace that now holds a project. + if (!finishing && execution) onImported?.() finishing = false onClose() } diff --git a/frontend/src/lib/components/workspaceSettings/SimpleCreateWorkspace.svelte b/frontend/src/lib/components/workspaceSettings/SimpleCreateWorkspace.svelte index de75852a38..9fa93ec3b7 100644 --- a/frontend/src/lib/components/workspaceSettings/SimpleCreateWorkspace.svelte +++ b/frontend/src/lib/components/workspaceSettings/SimpleCreateWorkspace.svelte @@ -118,8 +118,10 @@ creating = true const workspaceName = name.trim() const started = Date.now() + + let id: string | undefined try { - const id = await freeWorkspaceId(idSeed(workspaceName)) + id = await freeWorkspaceId(idSeed(workspaceName)) if (!id) { sendUserToast( 'No workspace ID could be derived from that name. Pick one in advanced settings.', @@ -136,19 +138,29 @@ username: automateUsername ? undefined : suggestedUsername } }) - usersWorkspaceStore.set(await WorkspaceService.listUserWorkspaces()) - switchWorkspace(id) - const left = WORKSPACE_HANDOVER_MS - (Date.now() - started) - if (left > 0) await new Promise((resolve) => setTimeout(resolve, left)) - // Left up rather than cleared: the navigation it hands over to loads the workspace - // layout for the first time, and dropping back to the form under it would show the - // button again for as long as that takes. - onCreated() } catch (error) { console.error('Could not create the workspace:', error) sendUserToast('Could not create the workspace: ' + (error?.body || error?.message), true) creating = false + return } + + // The workspace exists from here on, so nothing below may report failure or hand the + // form back: a retry would pick the next free id and create a second one. A refresh + // that fails is worth a log and nothing more — the list reloads on the next page load, + // and the workspace this hands over to is real either way. + try { + usersWorkspaceStore.set(await WorkspaceService.listUserWorkspaces()) + } catch (error) { + console.error('Created the workspace but could not refresh the list:', error) + } + switchWorkspace(id) + const left = WORKSPACE_HANDOVER_MS - (Date.now() - started) + if (left > 0) await new Promise((resolve) => setTimeout(resolve, left)) + // Left up rather than cleared: the navigation it hands over to loads the workspace + // layout for the first time, and dropping back to the form under it would show the + // button again for as long as that takes. + onCreated() } @@ -197,7 +209,7 @@