diff --git a/web/src/app/chat/ChatPage.tsx b/web/src/app/chat/ChatPage.tsx index cf5481e2ff1..f4f00692c1a 100644 --- a/web/src/app/chat/ChatPage.tsx +++ b/web/src/app/chat/ChatPage.tsx @@ -142,6 +142,16 @@ export function ChatPage({ refreshChatSessions, } = useChatContext(); + // handle redirect if chat page is disabled + // NOTE: this must be done here, in a client component since + // settings are passed in via Context and therefore aren't + // available in server-side components + const settings = useContext(SettingsContext); + const enterpriseSettings = settings?.enterpriseSettings; + if (settings?.settings?.chat_page_enabled === false) { + router.push("/search"); + } + const { assistants: availableAssistants, finalAssistants } = useAssistants(); const [showApiKeyModal, setShowApiKeyModal] = useState( @@ -881,7 +891,6 @@ export function ChatPage({ }, 1500); }; - const distance = 500; // distance that should "engage" the scroll const debounceNumber = 100; // time for debouncing const [hasPerformedInitialScroll, setHasPerformedInitialScroll] = useState( @@ -1545,17 +1554,6 @@ export function ChatPage({ } }); }; - - // handle redirect if chat page is disabled - // NOTE: this must be done here, in a client component since - // settings are passed in via Context and therefore aren't - // available in server-side components - const settings = useContext(SettingsContext); - const enterpriseSettings = settings?.enterpriseSettings; - if (settings?.settings?.chat_page_enabled === false) { - router.push("/search"); - } - const [showDocSidebar, setShowDocSidebar] = useState(false); // State to track if sidebar is open // Used to maintain a "time out" for history sidebar so our existing refs can have time to process change @@ -1603,9 +1601,9 @@ export function ChatPage({ scrollableDivRef, scrollDist, endDivRef, - distance, debounceNumber, waitForScrollRef, + mobile: settings?.isMobile, }); // Virtualization + Scrolling related effects and functions diff --git a/web/src/app/chat/lib.tsx b/web/src/app/chat/lib.tsx index 41a83eee1b8..a64c605a095 100644 --- a/web/src/app/chat/lib.tsx +++ b/web/src/app/chat/lib.tsx @@ -639,19 +639,22 @@ export async function useScrollonStream({ scrollableDivRef, scrollDist, endDivRef, - distance, debounceNumber, - waitForScrollRef, + mobile, }: { chatState: ChatState; scrollableDivRef: RefObject; waitForScrollRef: RefObject; scrollDist: MutableRefObject; endDivRef: RefObject; - distance: number; debounceNumber: number; mobile?: boolean; }) { + const mobileDistance = 900; // distance that should "engage" the scroll + const desktopDistance = 500; // distance that should "engage" the scroll + + const distance = mobile ? mobileDistance : desktopDistance; + const preventScrollInterference = useRef(false); const preventScroll = useRef(false); const blockActionRef = useRef(false); @@ -692,7 +695,7 @@ export async function useScrollonStream({ endDivRef.current ) { // catch up if necessary! - const scrollAmount = scrollDist.current + 10000; + const scrollAmount = scrollDist.current + (mobile ? 1000 : 10000); if (scrollDist.current > 300) { // if (scrollDist.current > 140) { endDivRef.current.scrollIntoView();