From c34fc64688396bb9f2e17a2a89251a63f58ee4f7 Mon Sep 17 00:00:00 2001 From: Eva H <63033505+hoyyeva@users.noreply.github.com> Date: Wed, 10 Dec 2025 15:29:48 -0500 Subject: [PATCH] app/ui: use requestAnimationFrame to prevent bottom line cutoff in streaming thinking display (#13137) --- app/ui/app/src/components/Thinking.tsx | 30 ++++++++++++++++++-------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/app/ui/app/src/components/Thinking.tsx b/app/ui/app/src/components/Thinking.tsx index 7ab23e726..e82364240 100644 --- a/app/ui/app/src/components/Thinking.tsx +++ b/app/ui/app/src/components/Thinking.tsx @@ -50,21 +50,33 @@ export default function Thinking({ // Position content to show bottom when collapsed useEffect(() => { if (isCollapsed && contentRef.current && wrapperRef.current) { - const contentHeight = contentRef.current.scrollHeight; - const wrapperHeight = wrapperRef.current.clientHeight; - if (contentHeight > wrapperHeight) { - const translateY = -(contentHeight - wrapperHeight); - contentRef.current.style.transform = `translateY(${translateY}px)`; - setHasOverflow(true); - } else { - setHasOverflow(false); - } + requestAnimationFrame(() => { + if (!contentRef.current || !wrapperRef.current) return; + + const contentHeight = contentRef.current.scrollHeight; + const wrapperHeight = wrapperRef.current.clientHeight; + if (contentHeight > wrapperHeight) { + const translateY = -(contentHeight - wrapperHeight); + contentRef.current.style.transform = `translateY(${translateY}px)`; + setHasOverflow(true); + } else { + contentRef.current.style.transform = "translateY(0)"; + setHasOverflow(false); + } + }); } else if (contentRef.current) { contentRef.current.style.transform = "translateY(0)"; setHasOverflow(false); } }, [thinking, isCollapsed]); + useEffect(() => { + if (activelyThinking && wrapperRef.current && !isCollapsed) { + // When expanded and actively thinking, scroll to bottom + wrapperRef.current.scrollTop = wrapperRef.current.scrollHeight; + } + }, [thinking, activelyThinking, isCollapsed]); + const handleToggle = () => { setIsCollapsed(!isCollapsed); setHasUserInteracted(true);