Skip to content

Commit 66eca90

Browse files
authored
fix: Better loading state for Client Sessions page (#783)
Address this issue: > when I visit sessions page and select the source, the instruction shows up and I can see sessions once they are loaded. Improves loading state handling and checks for source type.
1 parent 94aa5f8 commit 66eca90

File tree

1 file changed

+35
-24
lines changed

1 file changed

+35
-24
lines changed

packages/app/src/SessionsPage.tsx

Lines changed: 35 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ export default function SessionsPage() {
250250
const where = watch('where');
251251
const whereLanguage = watch('whereLanguage');
252252
const sourceId = watch('source');
253-
const { data: sessionSource } = useSource({
253+
const { data: sessionSource, isPending: isSessionSourceLoading } = useSource({
254254
id: watch('source'),
255255
});
256256

@@ -480,31 +480,42 @@ export default function SessionsPage() {
480480
</Group>
481481
</Group>
482482
</form>
483-
{isSessionsLoading === false &&
484-
(sessionSource?.kind !== SourceKind.Session || traceTrace == null) ? (
485-
<>
486-
<Alert
487-
icon={<i className="bi bi-info-circle-fill text-slate-400" />}
488-
color="gray"
489-
py="xs"
490-
mt="md"
491-
>
492-
Please select a valid session source
493-
</Alert>
494-
<SessionSetupInstructions />
495-
</>
496-
) : sessions.length === 0 && isSessionsLoading === false ? (
497-
<SessionSetupInstructions />
498-
) : (
499-
<div style={{ minHeight: 0 }} className="mt-4">
500-
<SessionCardList
501-
onClick={session => {
502-
setSelectedSession(session);
503-
}}
504-
sessions={sessions}
505-
isSessionLoading={isSessionsLoading}
483+
484+
{isSessionsLoading || isSessionSourceLoading ? (
485+
<div className="text-center mt-8">
486+
<div
487+
className="spinner-border me-2"
488+
role="status"
489+
style={{ width: 14, height: 14 }}
506490
/>
491+
{isSessionSourceLoading ? 'Loading...' : 'Searching sessions...'}
507492
</div>
493+
) : (
494+
<>
495+
{sessionSource && sessionSource.kind !== SourceKind.Session && (
496+
<Alert
497+
icon={<i className="bi bi-info-circle-fill text-slate-400" />}
498+
color="gray"
499+
py="xs"
500+
mt="md"
501+
>
502+
Please select a valid session source
503+
</Alert>
504+
)}
505+
{!sessions.length ? (
506+
<SessionSetupInstructions />
507+
) : (
508+
<div style={{ minHeight: 0 }} className="mt-4">
509+
<SessionCardList
510+
onClick={session => {
511+
setSelectedSession(session);
512+
}}
513+
sessions={sessions}
514+
isSessionLoading={isSessionsLoading}
515+
/>
516+
</div>
517+
)}
518+
</>
508519
)}
509520
</Box>
510521
</div>

0 commit comments

Comments
 (0)