mirror of
https://github.com/langgenius/dify.git
synced 2026-03-23 07:17:55 +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()
|
||||
|
||||
@ -17,6 +17,7 @@ import { useDownloadSandboxFile, useSandboxFileDownloadUrl, useSandboxFilesTree
|
||||
import { cn } from '@/utils/classnames'
|
||||
import { downloadUrl } from '@/utils/download'
|
||||
import { useStore } from '../store'
|
||||
import { WorkflowRunningStatus } from '../types'
|
||||
import InspectLayout from './inspect-layout'
|
||||
import SplitPanel from './split-panel'
|
||||
|
||||
@ -56,9 +57,14 @@ const formatFileSize = (bytes: number | null): string => {
|
||||
const ArtifactsTab = (headerProps: InspectHeaderProps) => {
|
||||
const { t } = useTranslation('workflow')
|
||||
const appId = useStore(s => s.appId)
|
||||
const isWorkflowRunning = useStore(
|
||||
s => s.workflowRunningData?.result?.status === WorkflowRunningStatus.Running,
|
||||
)
|
||||
const isResponding = useStore(s => s.isResponding)
|
||||
|
||||
const { data: treeData, hasFiles, isLoading } = useSandboxFilesTree(appId, {
|
||||
enabled: !!appId,
|
||||
refetchInterval: (isWorkflowRunning || isResponding) ? 5000 : false,
|
||||
})
|
||||
const { mutateAsync: fetchDownloadUrl, isPending: isDownloading } = useDownloadSandboxFile(appId)
|
||||
const [selectedFile, setSelectedFile] = useState<SandboxFileTreeNode | null>(null)
|
||||
|
||||
Reference in New Issue
Block a user