diff --git a/app/components/chat.tsx b/app/components/chat.tsx index 6691403e6..b2abf11ca 100644 --- a/app/components/chat.tsx +++ b/app/components/chat.tsx @@ -449,7 +449,6 @@ export function ChatAction(props: { ); } - function useScrollToBottom( scrollRef: RefObject, detach: boolean = false, @@ -457,15 +456,18 @@ function useScrollToBottom( ) { // for auto-scroll const [autoScroll, setAutoScroll] = useState(true); + const config = useAppConfig(); + const isAutoScrollEnabled: boolean = config.autoScrollMessage; + const scrollDomToBottom = useCallback(() => { const dom = scrollRef.current; if (dom) { requestAnimationFrame(() => { - setAutoScroll(true); + setAutoScroll(isAutoScrollEnabled); dom.scrollTo(0, dom.scrollHeight); }); } - }, [scrollRef]); + }, [scrollRef, isAutoScrollEnabled]); // auto scroll useEffect(() => { @@ -490,7 +492,6 @@ function useScrollToBottom( scrollDomToBottom, }; } - export function ChatActions(props: { uploadImage: () => void; setAttachImages: (images: string[]) => void; @@ -1420,7 +1421,8 @@ function _Chat() { } setHitBottom(isHitBottom); - setAutoScroll(isHitBottom); + let isAutoScrollEnabled: boolean = config.autoScrollMessage; + setAutoScroll(isAutoScrollEnabled); }; function scrollToBottom() { diff --git a/app/components/settings.tsx b/app/components/settings.tsx index 881c12cae..74a853ff8 100644 --- a/app/components/settings.tsx +++ b/app/components/settings.tsx @@ -1707,7 +1707,21 @@ export function Settings() { } > - + + + updateConfig( + (config) => + (config.autoScrollMessage = e.currentTarget.checked), + ) + } + > +