From 223d72d2c01e8836f6c2d2f0ce9e9fee3cd1fbb9 Mon Sep 17 00:00:00 2001 From: dolphin Date: Wed, 29 Jul 2026 17:09:55 +0800 Subject: [PATCH] fix(workflow-chat): stop the history mapper from dropping attachment fields MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit History rebuilt each attachment as just a name and a url, so the id an image is resolved by — and the object name behind it — never reached the bubble: a refreshed conversation showed the picture stuck loading forever. It now spreads the stored entry instead of listing fields, which also keeps whatever the backend adds next. --- src/frontend/client/src/api/apps.ts | 1 + .../src/pages/appChat/components/MessageUser.tsx | 16 +--------------- 2 files changed, 2 insertions(+), 15 deletions(-) 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]