From 18ca83d763b0d2289d075ea6c9a6d3903ec14cb0 Mon Sep 17 00:00:00 2001 From: zhaoying Date: Thu, 19 Mar 2026 10:12:33 +0800 Subject: [PATCH 1/3] fix(web): local file support preview --- web/src/components/Chat/ChatContent.tsx | 31 ++++++++++++------- .../FeaturesConfig/FileUploadSettingModal.tsx | 3 +- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/web/src/components/Chat/ChatContent.tsx b/web/src/components/Chat/ChatContent.tsx index 2f2552db..4295a7c7 100644 --- a/web/src/components/Chat/ChatContent.tsx +++ b/web/src/components/Chat/ChatContent.tsx @@ -2,15 +2,20 @@ * @Author: ZhaoYing * @Date: 2025-12-10 16:46:17 * @Last Modified by: ZhaoYing - * @Last Modified time: 2026-03-18 20:48:03 + * @Last Modified time: 2026-03-19 10:06:31 */ import { type FC, useRef, useEffect, useState } from 'react' import clsx from 'clsx' import Markdown from '@/components/Markdown' import type { ChatContentProps } from './types' -import { Spin, Divider, Space } from 'antd' +import { Spin, Divider, Space, Image, Flex } from 'antd' import { SoundOutlined } from '@ant-design/icons' + +const getFileUrl = (file: any) => { + return file.thumbUrl || file.url || (file.originFileObj ? URL.createObjectURL(file.originFileObj) : undefined) +} + /** * Chat Content Display Component * Responsible for rendering chat message list, supports different role message styles and auto-scrolling @@ -88,6 +93,10 @@ const ChatContent: FC = ({ } }, 0); }, [data]) + + const handleDownload = (file: any) => { + window.open(getFileUrl(file), '_blank') + } return (
{data.length === 0 @@ -108,31 +117,31 @@ const ChatContent: FC = ({ {labelFormat(item)}
} - {item.meta_data?.files && item.meta_data?.files.length > 0 &&
+ {item.meta_data?.files && item.meta_data?.files.length > 0 && {item.meta_data?.files?.map((file) => { if (file.type.includes('image')) { return (
- {file.name} + {file.name}
) } if (file.type.includes('video')) { return ( -
-
} +
} {/* Message bubble */}
Date: Thu, 19 Mar 2026 10:35:35 +0800 Subject: [PATCH 2/3] fix(web): file ui update --- web/src/components/Chat/ChatContent.tsx | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/web/src/components/Chat/ChatContent.tsx b/web/src/components/Chat/ChatContent.tsx index 4295a7c7..31b43064 100644 --- a/web/src/components/Chat/ChatContent.tsx +++ b/web/src/components/Chat/ChatContent.tsx @@ -2,7 +2,7 @@ * @Author: ZhaoYing * @Date: 2025-12-10 16:46:17 * @Last Modified by: ZhaoYing - * @Last Modified time: 2026-03-19 10:06:31 + * @Last Modified time: 2026-03-19 10:35:21 */ import { type FC, useRef, useEffect, useState } from 'react' import clsx from 'clsx' @@ -141,21 +141,17 @@ const ChatContent: FC = ({ ) } return ( - handleDownload(file)}> +
handleDownload(file)}> {(file.type.includes('doc') || file.type.includes('docx') || file.type.includes('word') || file.type.includes('wordprocessingml.document')) &&
} {(file.type.includes('pdf')) &&
} {(file.type.includes('excel') || file.type.includes('spreadsheetml.sheet') || file.type.includes('csv')) &&
} -
-
{file.name}
-
{file.type} · {file.size}
-
- +
) })}
} From b42815ee7a3e25055999e2f0edf2eb5a728d3a10 Mon Sep 17 00:00:00 2001 From: zhaoying Date: Thu, 19 Mar 2026 10:51:33 +0800 Subject: [PATCH 3/3] fix(web): chat content scroll --- web/src/components/Chat/ChatContent.tsx | 7 ++++--- web/src/components/Markdown/index.tsx | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/web/src/components/Chat/ChatContent.tsx b/web/src/components/Chat/ChatContent.tsx index 31b43064..c73d91f5 100644 --- a/web/src/components/Chat/ChatContent.tsx +++ b/web/src/components/Chat/ChatContent.tsx @@ -2,7 +2,7 @@ * @Author: ZhaoYing * @Date: 2025-12-10 16:46:17 * @Last Modified by: ZhaoYing - * @Last Modified time: 2026-03-19 10:35:21 + * @Last Modified time: 2026-03-19 10:37:01 */ import { type FC, useRef, useEffect, useState } from 'react' import clsx from 'clsx' @@ -59,8 +59,8 @@ const ChatContent: FC = ({ const handleScroll = () => { if (scrollContainerRef.current) { const { scrollTop, scrollHeight, clientHeight } = scrollContainerRef.current; - // Consider user is at bottom if within 20px of the bottom - isScrolledToBottomRef.current = scrollHeight - scrollTop - clientHeight < 20; + // Consider user is at bottom if within 100px of the bottom + isScrolledToBottomRef.current = scrollHeight - scrollTop - clientHeight < 100; } }; @@ -88,6 +88,7 @@ const ChatContent: FC = ({ // Auto-scroll if data length changed OR user is currently at bottom if (data.length !== prevDataLengthRef.current || isScrolledToBottomRef.current) { scrollContainerRef.current.scrollTop = scrollContainerRef.current.scrollHeight; + isScrolledToBottomRef.current = true; } prevDataLengthRef.current = data.length; } diff --git a/web/src/components/Markdown/index.tsx b/web/src/components/Markdown/index.tsx index 9d3c482b..3a0712ec 100644 --- a/web/src/components/Markdown/index.tsx +++ b/web/src/components/Markdown/index.tsx @@ -136,7 +136,7 @@ const RbMarkdown: FC = ({ /** Sync edit content when external content changes */ useEffect(() => { - setEditContent(content) + setEditContent(prev => prev !== content ? content : prev) }, [content]) /** Handle textarea content changes and trigger callback */