diff --git a/core/http/react-ui/src/hooks/useChat.js b/core/http/react-ui/src/hooks/useChat.js index 30538ed12..43a869653 100644 --- a/core/http/react-ui/src/hooks/useChat.js +++ b/core/http/react-ui/src/hooks/useChat.js @@ -218,9 +218,15 @@ export function useChat(initialModel = '') { }) userFiles.push({ name: file.name, type: 'audio' }) } else { - // Text/PDF files - append to content - userFiles.push({ name: file.name, type: 'file', content: file.textContent || '' }) - } + // Text/PDF files - append to content + if (file.textContent) { + messageContent.push({ + type: 'text', + text: `\n\n--- File: ${file.name} ---\n${file.textContent}\n--- End of ${file.name} ---`, + }) + } + userFiles.push({ name: file.name, type: 'file', content: file.textContent || '' }) + } } } else { messageContent = content diff --git a/core/http/react-ui/src/pages/Home.jsx b/core/http/react-ui/src/pages/Home.jsx index fa560a8ca..f57dfb42d 100644 --- a/core/http/react-ui/src/pages/Home.jsx +++ b/core/http/react-ui/src/pages/Home.jsx @@ -161,7 +161,11 @@ export default function Home() { const newFiles = [] for (const file of fileList) { const base64 = await fileToBase64(file) - newFiles.push({ name: file.name, type: file.type, base64 }) + const entry = { name: file.name, type: file.type, base64 } + if (!file.type.startsWith('image/') && !file.type.startsWith('audio/')) { + entry.textContent = await file.text().catch(() => '') + } + newFiles.push(entry) } setter(prev => [...prev, ...newFiles]) }, [])