diff --git a/frontend/src/lib/components/copilot/chat/AiChatLayout.svelte b/frontend/src/lib/components/copilot/chat/AiChatLayout.svelte
index edcf9808cd..c85ef4189f 100644
--- a/frontend/src/lib/components/copilot/chat/AiChatLayout.svelte
+++ b/frontend/src/lib/components/copilot/chat/AiChatLayout.svelte
@@ -11,6 +11,7 @@
import { onDestroy } from 'svelte'
import Button from '$lib/components/common/button/Button.svelte'
import { Menu } from 'lucide-svelte'
+ import { whenPageIdle } from '$lib/utils/paint'
interface Props {
noPadding?: boolean
@@ -102,7 +103,7 @@
{#if !disableAi}
- {#await import('./CreatedResourceActionDrawers.svelte') then CreatedResourceActionDrawers}
+ {#await whenPageIdle().then(() => import('./CreatedResourceActionDrawers.svelte')) then CreatedResourceActionDrawers}
{/await}
diff --git a/frontend/src/lib/components/home/ItemsList.svelte b/frontend/src/lib/components/home/ItemsList.svelte
index 45c30005a2..dc7d406349 100644
--- a/frontend/src/lib/components/home/ItemsList.svelte
+++ b/frontend/src/lib/components/home/ItemsList.svelte
@@ -1009,6 +1009,12 @@
// would put two of them on the page at once while the workspace is still empty.
let hubPick = $state(undefined)
let hubPickerOpen = $state(false)
+ // Mounted on the first pick and kept, so its dismissal and in-flight run outlive `hubPick`.
+ let importModalMounted = $state(false)
+ function pickHubProject(project: HubProjectPick) {
+ importModalMounted = true
+ hubPick = project
+ }
/**
* Whether a workspace the default listing found empty is empty at all, or just has nothing
@@ -1941,7 +1947,7 @@
(hubPick = project)}
+ onPick={pickHubProject}
onShowArchived={() => (filterValues.val = { ...filterValues.val, archived: true })}
/>
{:else}
@@ -2073,13 +2079,16 @@
onClose={() => (hubPickerOpen = false)}
onPick={(project) => {
hubPickerOpen = false
- hubPick = project
+ pickHubProject(project)
}}
/>
-
-{#await import('./ImportProjectModal.svelte') then ImportProjectModal}
- (hubPick = undefined)} {onImported} />
-{/await}
+
+{#if importModalMounted}
+ {#await import('./ImportProjectModal.svelte') then ImportProjectModal}
+ (hubPick = undefined)} {onImported} />
+ {/await}
+{/if}