diff --git a/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/workflow-block/components/sub-block/components/document-selector/document-selector.tsx b/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/workflow-block/components/sub-block/components/document-selector/document-selector.tsx index 6ef02537c0..751d6d3e01 100644 --- a/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/workflow-block/components/sub-block/components/document-selector/document-selector.tsx +++ b/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/workflow-block/components/sub-block/components/document-selector/document-selector.tsx @@ -1,7 +1,7 @@ 'use client' import { useCallback, useEffect, useState } from 'react' -import { Check, ChevronDown, FileText } from 'lucide-react' +import { Check, ChevronDown, FileText, RefreshCw } from 'lucide-react' import { Button } from '@/components/ui/button' import { Command, @@ -54,6 +54,7 @@ export function DocumentSelector({ const [error, setError] = useState(null) const [open, setOpen] = useState(false) const [selectedDocument, setSelectedDocument] = useState(null) + const [loading, setLoading] = useState(false) // Use the proper hook to get the current value and setter const [storeValue, setStoreValue] = useSubBlockValue(blockId, subBlock.id) @@ -72,6 +73,7 @@ export function DocumentSelector({ return } + setLoading(true) setError(null) try { @@ -93,6 +95,8 @@ export function DocumentSelector({ if ((err as Error).name === 'AbortError') return setError((err as Error).message) setDocuments([]) + } finally { + setLoading(false) } }, [knowledgeBaseId]) @@ -192,7 +196,12 @@ export function DocumentSelector({ - {error ? ( + {loading ? ( +
+ + Loading documents... +
+ ) : error ? (

{error}