diff --git a/web/app/components/base/chat/chat/chat-input-area/index.tsx b/web/app/components/base/chat/chat/chat-input-area/index.tsx index f96d15b8ac..7f6510665b 100644 --- a/web/app/components/base/chat/chat/chat-input-area/index.tsx +++ b/web/app/components/base/chat/chat/chat-input-area/index.tsx @@ -1,5 +1,4 @@ import { - memo, useCallback, useRef, useState, @@ -16,11 +15,15 @@ import { useTextAreaHeight } from './hooks' import Operation from './operation' import cn from '@/utils/classnames' import { FileListInChatInput } from '@/app/components/base/file-uploader' -import { FileContextProvider } from '@/app/components/base/file-uploader/store' +import { + FileContextProvider, + useStore, +} from '@/app/components/base/file-uploader/store' import VoiceInput from '@/app/components/base/voice-input' import { useToastContext } from '@/app/components/base/toast' import FeatureBar from '@/app/components/base/features/new-feature-panel/feature-bar' import type { FileUpload } from '@/app/components/base/features/types' +import { TransferMethod } from '@/types/app' type ChatInputAreaProps = { showFeatureBar?: boolean @@ -55,15 +58,27 @@ const ChatInputArea = ({ const [query, setQuery] = useState('') const isUseInputMethod = useRef(false) const [showVoiceInput, setShowVoiceInput] = useState(false) + const files = useStore(s => s.files) + const setFiles = useStore(s => s.setFiles) const handleSend = () => { if (onSend) { + if (files.find(item => item.type === TransferMethod.local_file && !item.fileStorageId)) { + notify({ type: 'info', message: t('appDebug.errorMessage.waitForImgUpload') }) + return + } if (!query || !query.trim()) { notify({ type: 'info', message: t('appAnnotation.errorMessage.queryRequired') }) return } - onSend(query) + onSend(query, files.filter(file => file.progress !== -1).map(fileItem => ({ + type: fileItem.fileType, + transfer_method: fileItem.type, + url: fileItem.url || '', + upload_file_id: fileItem.fileStorageId || '', + }))) setQuery('') + setFiles([]) } } @@ -103,64 +118,70 @@ const ChatInputArea = ({ ) return ( - {}}> - <> -
-
- -
-
-
- {query} -
-