From 1cbcb2a150440c2d7291e666f156902d281db419 Mon Sep 17 00:00:00 2001 From: yangdx Date: Wed, 23 Apr 2025 21:54:21 +0800 Subject: [PATCH] Optimize scrolling login of query view --- lightrag_webui/src/features/RetrievalTesting.tsx | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lightrag_webui/src/features/RetrievalTesting.tsx b/lightrag_webui/src/features/RetrievalTesting.tsx index b54103e0..c1b8c14a 100644 --- a/lightrag_webui/src/features/RetrievalTesting.tsx +++ b/lightrag_webui/src/features/RetrievalTesting.tsx @@ -198,9 +198,17 @@ export default function RetrievalTesting() { return; } - // If we're receiving a response, be more conservative about disabling auto-scroll - if (!isFormInteractionRef.current && !isReceivingResponseRef.current) { - shouldFollowScrollRef.current = false; + // Check if scrolled to bottom or very close to bottom + const container = messagesContainerRef.current; + if (container) { + const isAtBottom = container.scrollHeight - container.scrollTop - container.clientHeight < 20; + + // If at bottom, enable auto-scroll, otherwise disable it + if (isAtBottom) { + shouldFollowScrollRef.current = true; + } else if (!isFormInteractionRef.current && !isReceivingResponseRef.current) { + shouldFollowScrollRef.current = false; + } } }, 30);