diff --git a/src/pages/views/workspace/ChatStream.tsx b/src/pages/views/workspace/ChatStream.tsx index 01bb66f..26e0ece 100644 --- a/src/pages/views/workspace/ChatStream.tsx +++ b/src/pages/views/workspace/ChatStream.tsx @@ -40,6 +40,8 @@ export const ChatStream: React.FC = ({ messages, }) => { const { t } = useLanguage(); const bottomRef = useRef(null); + const scrollContainerRef = useRef(null); + const isAtBottomRef = useRef(true); const audioQueue = useAudioQueue(); const enqueuedIdsRef = useRef>(new Set()); const [copiedId, setCopiedId] = useState(null); @@ -51,8 +53,17 @@ export const ChatStream: React.FC = ({ messages, }).catch(() => {}); }, []); + const _handleScroll = useCallback(() => { + const el = scrollContainerRef.current; + if (!el) return; + const threshold = 80; + isAtBottomRef.current = el.scrollHeight - el.scrollTop - el.clientHeight < threshold; + }, []); + useEffect(() => { - bottomRef.current?.scrollIntoView({ behavior: 'smooth' }); + if (isAtBottomRef.current) { + bottomRef.current?.scrollIntoView({ behavior: 'smooth' }); + } }, [messages, agentProgress]); useEffect(() => { @@ -71,15 +82,19 @@ export const ChatStream: React.FC = ({ messages, }, [messages, audioQueue]); return ( -
+
{messages.map((msg) => (
void; onDataSourceDrop?: (params: { connectionId: string; sourceType: string; path: string; label: string; displayPath?: string }) => void; pendingAttachDsId?: string; + pendingAttachDsLabel?: string; onPendingAttachDsConsumed?: () => void; pendingAttachFdsId?: string; onPendingAttachFdsConsumed?: () => void; @@ -124,6 +125,7 @@ export const WorkspaceInput = forwardRef([]); const [neutralizeActive, setNeutralizeActive] = useState(false); const textareaRef = useRef(null); + const dsLabelCache = useRef>(new Map()); const _appendAttachment = useCallback((item: AttachmentItem) => { setAttachments(prev => prev.some(a => a.id === item.id) ? prev : [...prev, item]); @@ -182,6 +185,9 @@ export const WorkspaceInput = forwardRef { if (!pendingAttachDsId) return; + if (pendingAttachDsLabel) { + dsLabelCache.current.set(pendingAttachDsId, pendingAttachDsLabel); + } setAttachedDataSourceIds(prev => { if (prev.includes(pendingAttachDsId)) return prev; const next = [...prev, pendingAttachDsId]; @@ -189,7 +195,7 @@ export const WorkspaceInput = forwardRef { if (!pendingAttachFdsId) return; @@ -657,7 +663,7 @@ export const WorkspaceInput = forwardRef - 🔗 {ds?.label || ds?.path || dsId} + 🔗 {ds?.label || ds?.path || dsLabelCache.current.get(dsId) || dsId}