Skip to content

Commit a9fa508

Browse files
committed
fix(ui): prevent flash of empty state while workflows query is pending
Dashboard and EmbeddedWorkflow checked workflow list length before the RQ query resolved, briefly showing "No workflows" or "Workflow not found" on initial load. Now gates on isPending first.
1 parent 51492d8 commit a9fa508

2 files changed

Lines changed: 4 additions & 5 deletions

File tree

apps/sim/app/workspace/[workspaceId]/home/components/mothership-view/components/resource-content/resource-content.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -376,17 +376,16 @@ interface EmbeddedWorkflowProps {
376376
}
377377

378378
function EmbeddedWorkflow({ workspaceId, workflowId }: EmbeddedWorkflowProps) {
379-
const { data: workflowList } = useWorkflows(workspaceId)
379+
const { data: workflowList, isPending: isWorkflowsPending } = useWorkflows(workspaceId)
380380
const workflowExists = useMemo(
381381
() => (workflowList ?? []).some((w) => w.id === workflowId),
382382
[workflowList, workflowId]
383383
)
384-
const isMetadataLoaded = useWorkflowRegistry((state) => state.hydration.phase !== 'idle')
385384
const hasLoadError = useWorkflowRegistry(
386385
(state) => state.hydration.phase === 'error' && state.hydration.workflowId === workflowId
387386
)
388387

389-
if (!isMetadataLoaded) return LOADING_SKELETON
388+
if (isWorkflowsPending) return LOADING_SKELETON
390389

391390
if (!workflowExists || hasLoadError) {
392391
return (

apps/sim/app/workspace/[workspaceId]/logs/components/dashboard/dashboard.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ function DashboardInner({ stats, isLoading, error }: DashboardProps) {
158158
)
159159

160160
const { workspaceId } = useParams<{ workspaceId: string }>()
161-
const { data: allWorkflowList = [] } = useWorkflows(workspaceId)
161+
const { data: allWorkflowList = [], isPending: isWorkflowsPending } = useWorkflows(workspaceId)
162162

163163
const expandedWorkflowId = workflowIds.length === 1 ? workflowIds[0] : null
164164

@@ -461,7 +461,7 @@ function DashboardInner({ stats, isLoading, error }: DashboardProps) {
461461
)
462462
}
463463

464-
if (allWorkflowList.length === 0) {
464+
if (!isWorkflowsPending && allWorkflowList.length === 0) {
465465
return (
466466
<div className='mt-6 flex flex-1 items-center justify-center'>
467467
<div className='text-center text-[var(--text-secondary)]'>

0 commit comments

Comments
 (0)