Skip to content

Commit 2f58e8a

Browse files
committed
Show loading indicator before listing sessions
1 parent d0cab51 commit 2f58e8a

File tree

1 file changed

+33
-19
lines changed

1 file changed

+33
-19
lines changed

packages/ui/src/components/instance-welcome-view.tsx

Lines changed: 33 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Component, createSignal, Show, For, createEffect, onMount, onCleanup, createMemo } from "solid-js"
2-
import { Trash2 } from "lucide-solid"
2+
import { Loader2, Trash2 } from "lucide-solid"
33

44
import type { Instance } from "../types/instance"
55
import { getParentSessions, createSession, setActiveParentSession, deleteSession, loading } from "../stores/sessions"
@@ -26,6 +26,7 @@ const InstanceWelcomeView: Component<InstanceWelcomeViewProps> = (props) => {
2626
)
2727

2828
const parentSessions = () => getParentSessions(props.instance.id)
29+
const isFetchingSessions = createMemo(() => Boolean(loading().fetchingSessions.get(props.instance.id)))
2930
const isSessionDeleting = (sessionId: string) => {
3031
const deleting = loading().deletingSession.get(props.instance.id)
3132
return deleting ? deleting.has(sessionId) : false
@@ -255,25 +256,38 @@ const InstanceWelcomeView: Component<InstanceWelcomeViewProps> = (props) => {
255256
<Show
256257
when={parentSessions().length > 0}
257258
fallback={
258-
<div class="panel panel-empty-state flex-1 flex flex-col justify-center">
259-
<div class="panel-empty-state-icon">
260-
<svg class="w-12 h-12 mx-auto" fill="none" stroke="currentColor" viewBox="0 0 24 24">
261-
<path
262-
stroke-linecap="round"
263-
stroke-linejoin="round"
264-
stroke-width="2"
265-
d="M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"
266-
/>
267-
</svg>
259+
<Show
260+
when={isFetchingSessions()}
261+
fallback={
262+
<div class="panel panel-empty-state flex-1 flex flex-col justify-center">
263+
<div class="panel-empty-state-icon">
264+
<svg class="w-12 h-12 mx-auto" fill="none" stroke="currentColor" viewBox="0 0 24 24">
265+
<path
266+
stroke-linecap="round"
267+
stroke-linejoin="round"
268+
stroke-width="2"
269+
d="M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"
270+
/>
271+
</svg>
272+
</div>
273+
<p class="panel-empty-state-title">No Previous Sessions</p>
274+
<p class="panel-empty-state-description">Create a new session below to get started</p>
275+
<Show when={!isDesktopLayout() && !showInstanceInfoOverlay()}>
276+
<button type="button" class="button-tertiary mt-4 lg:hidden" onClick={openInstanceInfoOverlay}>
277+
View Instance Info
278+
</button>
279+
</Show>
280+
</div>
281+
}
282+
>
283+
<div class="panel panel-empty-state flex-1 flex flex-col justify-center">
284+
<div class="panel-empty-state-icon">
285+
<Loader2 class="w-12 h-12 mx-auto animate-spin text-muted" />
286+
</div>
287+
<p class="panel-empty-state-title">Loading Sessions</p>
288+
<p class="panel-empty-state-description">Fetching your previous sessions...</p>
268289
</div>
269-
<p class="panel-empty-state-title">No Previous Sessions</p>
270-
<p class="panel-empty-state-description">Create a new session below to get started</p>
271-
<Show when={!isDesktopLayout() && !showInstanceInfoOverlay()}>
272-
<button type="button" class="button-tertiary mt-4 lg:hidden" onClick={openInstanceInfoOverlay}>
273-
View Instance Info
274-
</button>
275-
</Show>
276-
</div>
290+
</Show>
277291
}
278292
>
279293
<div class="panel flex flex-col flex-1 min-h-0">

0 commit comments

Comments
 (0)