mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-07-24 04:36:23 +00:00
fix(web): Fix auto-scroll issue in chat dashboard
This commit is contained in:
parent
ef7b17f9ab
commit
f97c15b7ed
@ -98,12 +98,15 @@ const Completion = ({ messages, onSubmit, onFormatContent }: Props) => {
|
||||
|
||||
// Process message content - if onFormatContent is provided and this is a dashboard chat,
|
||||
// we'll extract the thinking part from vis-thinking code blocks
|
||||
const processMessageContent = (content: any) => {
|
||||
const processMessageContent = useCallback(
|
||||
(content: any) => {
|
||||
if (isChartChat && onFormatContent && typeof content === 'string') {
|
||||
return onFormatContent(content);
|
||||
}
|
||||
return content;
|
||||
};
|
||||
},
|
||||
[isChartChat, onFormatContent],
|
||||
);
|
||||
|
||||
const [messageApi, contextHolder] = message.useMessage();
|
||||
|
||||
@ -198,7 +201,7 @@ const Completion = ({ messages, onSubmit, onFormatContent }: Props) => {
|
||||
useEffect(() => {
|
||||
console.log('Completion updating prevMessageCountRef:', {
|
||||
currentLength: showMessages.length,
|
||||
prevCount: prevMessageCountRef.current
|
||||
prevCount: prevMessageCountRef.current,
|
||||
});
|
||||
|
||||
// Only update if this is the first time (count is 0)
|
||||
@ -241,7 +244,7 @@ const Completion = ({ messages, onSubmit, onFormatContent }: Props) => {
|
||||
showMessagesLength: showMessages.length,
|
||||
userRecentlyScrolled,
|
||||
isUserScrolling: isUserScrollingRef.current,
|
||||
isAutoScrolling: isAutoScrollingRef.current
|
||||
isAutoScrolling: isAutoScrollingRef.current,
|
||||
});
|
||||
|
||||
// Always handle new messages first - this is the highest priority
|
||||
@ -285,7 +288,7 @@ const Completion = ({ messages, onSubmit, onFormatContent }: Props) => {
|
||||
currentHeight,
|
||||
lastHeight: lastContentHeightRef.current,
|
||||
heightDiff,
|
||||
threshold: 12
|
||||
threshold: 12,
|
||||
});
|
||||
|
||||
// Only scroll if content height increased by at least ~0.5 lines (12px) for smoother experience
|
||||
@ -314,7 +317,7 @@ const Completion = ({ messages, onSubmit, onFormatContent }: Props) => {
|
||||
console.log('Completion streaming blocked:', {
|
||||
userRecentlyScrolled,
|
||||
isUserScrolling: isUserScrollingRef.current,
|
||||
isAutoScrolling: isAutoScrollingRef.current
|
||||
isAutoScrolling: isAutoScrollingRef.current,
|
||||
});
|
||||
}
|
||||
}, [showMessages, scene]);
|
||||
|
Loading…
Reference in New Issue
Block a user