fix: file progress

This commit is contained in:
StyleZhang 2024-09-26 16:32:11 +08:00
parent 3f16caf244
commit 543503c398
5 changed files with 19 additions and 5 deletions

View File

@ -5,6 +5,7 @@ import {
} from '@remixicon/react'
import FileTypeIcon from '../file-type-icon'
import {
fileIsUploaded,
getFileAppearanceType,
getFileExtension,
} from '../utils'
@ -81,7 +82,7 @@ const FileInAttachmentItem = ({
</div>
<div className='shrink-0 flex items-center'>
{
progress >= 0 && !file.uploadedId && (
progress >= 0 && !fileIsUploaded(file) && (
<ProgressCircle
className='mr-2.5'
percentage={progress}

View File

@ -1,6 +1,7 @@
import { RiCloseLine } from '@remixicon/react'
import FileImageRender from '../file-image-render'
import type { FileEntity } from '../types'
import { fileIsUploaded } from '../utils'
import Button from '@/app/components/base/button'
import ProgressCircle from '@/app/components/base/progress-bar/progress-circle'
import { ReplayLine } from '@/app/components/base/icons/src/vender/other'
@ -39,7 +40,7 @@ const FileImageItem = ({
showDownloadAction={showDownloadAction}
/>
{
progress > 0 && progress < 100 && (
progress >= 0 && !fileIsUploaded(file) && (
<div className='absolute inset-0 flex items-center justify-center border-[2px] border-effects-image-frame bg-background-overlay-alt z-10'>
<ProgressCircle
percentage={progress}

View File

@ -3,6 +3,7 @@ import {
RiDownloadLine,
} from '@remixicon/react'
import {
fileIsUploaded,
getFileAppearanceType,
getFileExtension,
} from '../utils'
@ -84,7 +85,7 @@ const FileItem = ({
)
}
{
progress >= 0 && !file.uploadedId && (
progress >= 0 && !fileIsUploaded(file) && (
<ProgressCircle
percentage={progress}
size={12}

View File

@ -6,6 +6,7 @@ import { upload } from '@/service/base'
import { FILE_EXTS } from '@/app/components/base/prompt-editor/constants'
import { SupportUploadFileTypes } from '@/app/components/workflow/types'
import type { FileResponse } from '@/types/workflow'
import { TransferMethod } from '@/types/app'
type FileUploadParams = {
file: File
@ -158,3 +159,10 @@ export const getFilesInLogs = (rawData: any) => {
}).filter(Boolean)).filter(item => item?.model_identity === '__dify__file__')
return getProcessedFilesFromResponse(originalFiles)
}
export const fileIsUploaded = (file: FileEntity) => {
const localFileUploaded = file.transferMethod === TransferMethod.local_file && file.uploadedId
const fromUrlFileUploaded = file.transferMethod === TransferMethod.remote_url && file.progress === 100
return localFileUploaded || fromUrlFileUploaded
}

View File

@ -20,6 +20,9 @@ import type { StartNodeType } from '../nodes/start/types'
import { TransferMethod } from '../../base/text-generation/types'
import Button from '@/app/components/base/button'
import { useFeatures } from '@/app/components/base/features/hooks'
import {
getProcessedInputs,
} from '@/app/components/base/chat/chat/utils'
type Props = {
onRun: () => void
@ -76,8 +79,8 @@ const InputsPanel = ({ onRun }: Props) => {
const doRun = useCallback(() => {
onRun()
handleRun({ inputs, files })
}, [files, handleRun, inputs, onRun])
handleRun({ inputs: getProcessedInputs(inputs, variables as any), files })
}, [files, handleRun, inputs, onRun, variables])
const canRun = useMemo(() => {
if (files?.some(item => (item.transfer_method as any) === TransferMethod.local_file && !item.upload_file_id))