From 5da6577d62beeb21ce6f43ae85893c26e1028601 Mon Sep 17 00:00:00 2001
From: Nate Sesti <sestinj@gmail.com>
Date: Wed, 14 Jun 2023 22:43:49 -0700
Subject: scrolling fix

---
 extension/react-app/src/tabs/gui.tsx | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

(limited to 'extension/react-app/src/tabs/gui.tsx')

diff --git a/extension/react-app/src/tabs/gui.tsx b/extension/react-app/src/tabs/gui.tsx
index 70bab352..5316f42b 100644
--- a/extension/react-app/src/tabs/gui.tsx
+++ b/extension/react-app/src/tabs/gui.tsx
@@ -212,12 +212,15 @@ function GUI(props: GUIProps) {
   useEffect(() => {
     console.log("CLIENT ON STATE UPDATE: ", client, client?.onStateUpdate);
     client?.onStateUpdate((state) => {
-      console.log("Received state update: ", state);
+      // Scroll only if user is at very bottom of the window.
+      const shouldScrollToBottom = window.outerHeight - window.scrollY < 200;
       setWaitingForSteps(state.active);
       setHistory(state.history);
       setUserInputQueue(state.user_input_queue);
 
-      scrollToBottom();
+      if (shouldScrollToBottom) {
+        scrollToBottom();
+      }
     });
     client?.onAvailableSlashCommands((commands) => {
       console.log("Received available slash commands: ", commands);
-- 
cgit v1.2.3-70-g09d2

