mirror of
https://github.com/langgenius/dify.git
synced 2026-05-03 17:08:03 +08:00
feat: poll sandbox files every 5s during workflow/chatflow runs
Add conditional refetchInterval to Artifacts components so the file list refreshes automatically while a workflow debug run or chatflow preview is in progress, stopping once the run completes.
This commit is contained in:
@ -7,6 +7,7 @@ import { useCallback, useState } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import FolderSpark from '@/app/components/base/icons/src/vender/workflow/FolderSpark'
|
||||
import { useStore, useWorkflowStore } from '@/app/components/workflow/store'
|
||||
import { WorkflowRunningStatus } from '@/app/components/workflow/types'
|
||||
import { useDownloadSandboxFile, useSandboxFilesTree } from '@/service/use-sandbox-file'
|
||||
import { cn } from '@/utils/classnames'
|
||||
import { downloadUrl } from '@/utils/download'
|
||||
@ -21,8 +22,14 @@ const ArtifactsSection = ({ className }: ArtifactsSectionProps) => {
|
||||
const appId = useStore(s => s.appId)
|
||||
|
||||
const [isExpanded, setIsExpanded] = useState(false)
|
||||
const isWorkflowRunning = useStore(
|
||||
s => s.workflowRunningData?.result?.status === WorkflowRunningStatus.Running,
|
||||
)
|
||||
const isResponding = useStore(s => s.isResponding)
|
||||
|
||||
const { data: treeData, hasFiles, isLoading } = useSandboxFilesTree(appId)
|
||||
const { data: treeData, hasFiles, isLoading } = useSandboxFilesTree(appId, {
|
||||
refetchInterval: (isWorkflowRunning || isResponding) ? 5000 : false,
|
||||
})
|
||||
|
||||
const { mutateAsync: fetchDownloadUrl, isPending: isDownloading } = useDownloadSandboxFile(appId)
|
||||
const storeApi = useWorkflowStore()
|
||||
|
||||
Reference in New Issue
Block a user