diff --git a/echo/frontend/src/routes/project/chat/ProjectChatRoute.tsx b/echo/frontend/src/routes/project/chat/ProjectChatRoute.tsx index 232133b1..3f57388e 100644 --- a/echo/frontend/src/routes/project/chat/ProjectChatRoute.tsx +++ b/echo/frontend/src/routes/project/chat/ProjectChatRoute.tsx @@ -44,6 +44,8 @@ import { import SourcesSearch from "@/components/chat/SourcesSearch"; import SpikeMessage from "@/components/participant/SpikeMessage"; import { Logo } from "@/components/common/Logo"; +import { ScrollToBottomButton } from "@/components/common/ScrollToBottom"; +import { useElementOnScreen } from "@/hooks/useElementOnScreen"; const useDembraneChat = ({ chatId }: { chatId: string }) => { const chatHistoryQuery = useChatHistory(chatId); @@ -60,6 +62,12 @@ const useDembraneChat = ({ chatId }: { chatId: string }) => { const lastInput = useRef(""); const lastMessageRef = useRef(null); + const [scrollTargetRef, isVisible] = useElementOnScreen({ + root: null, + rootMargin: "-83px", + threshold: 0.1, + }); + const contextToBeAdded = useMemo(() => { if (!chatContextQuery.data) { return null; @@ -238,6 +246,8 @@ const useDembraneChat = ({ chatId }: { chatId: string }) => { error, lastInputRef: lastInput, lastMessageRef, + scrollTargetRef, + isVisible, reload, setInput, handleInputChange, @@ -267,6 +277,8 @@ export const ProjectChatRoute = () => { error, contextToBeAdded, lastMessageRef, + scrollTargetRef, + isVisible, setInput, handleInputChange, handleSubmit, @@ -447,9 +459,24 @@ export const ProjectChatRoute = () => { )} + + {/* Scroll target for scroll to bottom button */} +