From b55de8d75e6f92e851a01282bdd9142ad0b27532 Mon Sep 17 00:00:00 2001 From: Josh Knapp Date: Sun, 15 Mar 2026 10:28:28 -0700 Subject: [PATCH] Fix Jump to Current button not appearing on scroll-up The onScroll RAF optimization (only fire when atBottom changes) prevented the button from showing because xterm's onScroll may not fire from wheel events. Fix by setting isAtBottom(false) directly in the wheel handler and removing the RAF guard to always schedule state updates. Co-Authored-By: Claude Opus 4.6 (1M context) --- app/src/components/terminal/TerminalView.tsx | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/app/src/components/terminal/TerminalView.tsx b/app/src/components/terminal/TerminalView.tsx index c7c6650..253d269 100644 --- a/app/src/components/terminal/TerminalView.tsx +++ b/app/src/components/terminal/TerminalView.tsx @@ -144,6 +144,8 @@ export default function TerminalView({ sessionId, active }: Props) { if (e.deltaY < 0) { autoFollowRef.current = false; setIsAutoFollow(false); + isAtBottomRef.current = false; + setIsAtBottom(false); } }; containerRef.current.addEventListener("wheel", handleWheel, { capture: true, passive: true }); @@ -154,7 +156,6 @@ export default function TerminalView({ sessionId, active }: Props) { const scrollDisposable = term.onScroll(() => { const buf = term.buffer.active; const atBottom = buf.viewportY >= buf.baseY; - const prevAtBottom = isAtBottomRef.current; isAtBottomRef.current = atBottom; // Re-enable auto-follow only when USER scrolls to bottom (not write-triggered) @@ -164,14 +165,11 @@ export default function TerminalView({ sessionId, active }: Props) { setIsAutoFollow(true); } - // Only update React state when value changes - if (atBottom !== prevAtBottom) { - if (scrollStateRafId === null) { - scrollStateRafId = requestAnimationFrame(() => { - scrollStateRafId = null; - setIsAtBottom(isAtBottomRef.current); - }); - } + if (scrollStateRafId === null) { + scrollStateRafId = requestAnimationFrame(() => { + scrollStateRafId = null; + setIsAtBottom(isAtBottomRef.current); + }); } });