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