diff --git a/src/frontend/client/src/api/apps.ts b/src/frontend/client/src/api/apps.ts index 352850e9a..053949ec2 100644 --- a/src/frontend/client/src/api/apps.ts +++ b/src/frontend/client/src/api/apps.ts @@ -149,6 +149,7 @@ export async function getChatHistoryApi({ flowId, chatId, flowType, id, shareTok const _category = _isSend ? 'question' : category const _files = (files ? JSON.parse(files) : []).map(file => { return { + ...file, file_name: file.file_name || file.name, file_url: file.file_url || file.path, } diff --git a/src/frontend/client/src/pages/appChat/components/MessageUser.tsx b/src/frontend/client/src/pages/appChat/components/MessageUser.tsx index 6c24c5a1e..b94573b66 100644 --- a/src/frontend/client/src/pages/appChat/components/MessageUser.tsx +++ b/src/frontend/client/src/pages/appChat/components/MessageUser.tsx @@ -21,21 +21,7 @@ export default function MessageUser({ useName, data, showButton, disabledSearch const [config] = useRecoilState(bishengConfState) const localize = useLocalize() - // History returns the attachments as the raw JSON string held in the - // message row, while a live send hands over an array — normalise both. - const files = useMemo(() => { - const raw = data.files - if (Array.isArray(raw)) return raw - if (typeof raw === 'string' && raw) { - try { - const parsed = JSON.parse(raw) - return Array.isArray(parsed) ? parsed : [] - } catch { - return [] - } - } - return [] - }, [data.files]) + const files = useMemo(() => (Array.isArray(data.files) ? data.files : []), [data.files]) const msg = useMemo(() => { const res = typeof data.message === 'string' ? data.message : data.message[data.chatKey]