Fix: Fixed the issue where the agent's chat box could not automatically scroll to the bottom #3221 (#9219)

### What problem does this PR solve?

Fix: Fixed the issue where the agent's chat box could not automatically
scroll to the bottom #3221

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
balibabu
2025-08-05 09:26:15 +08:00
committed by GitHub
parent 9db999ccae
commit dda5a0080a
6 changed files with 44 additions and 27 deletions

View File

@ -1,7 +1,6 @@
import MessageItem from '@/components/message-item';
import { MessageType } from '@/constants/chat';
import { Flex, Spin } from 'antd';
import { useRef } from 'react';
import {
useCreateConversationBeforeUploadDocument,
useGetFileIcon,
@ -19,7 +18,6 @@ import {
useFetchNextDialog,
useGetChatSearchParams,
} from '@/hooks/chat-hooks';
import { useScrollToBottom } from '@/hooks/logic-hooks';
import { useFetchUserInfo } from '@/hooks/user-setting-hooks';
import { buildMessageUuidWithRole } from '@/utils/chat';
import { memo } from 'react';
@ -34,10 +32,10 @@ const ChatContainer = ({ controller }: IProps) => {
const { data: conversation } = useFetchNextConversation();
const { data: currentDialog } = useFetchNextDialog();
const messageContainerRef = useRef<HTMLDivElement>(null);
const {
value,
ref,
scrollRef,
messageContainerRef,
loading,
sendLoading,
derivedMessages,
@ -47,10 +45,6 @@ const ChatContainer = ({ controller }: IProps) => {
removeMessageById,
stopOutputMessage,
} = useSendNextMessage(controller);
const { scrollRef, isAtBottom, scrollToBottom } = useScrollToBottom(
derivedMessages,
messageContainerRef,
);
const { visible, hideModal, documentId, selectedChunk, clickDocumentButton } =
useClickDrawer();
@ -61,11 +55,6 @@ const ChatContainer = ({ controller }: IProps) => {
const { createConversationBeforeUploadDocument } =
useCreateConversationBeforeUploadDocument();
const handleSend = (msg) => {
// your send logic
setTimeout(scrollToBottom, 0);
};
return (
<>
<Flex flex={1} className={styles.chatContainer} vertical>