Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions echo/frontend/src/routes/project/chat/ProjectChatRoute.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -60,6 +62,12 @@ const useDembraneChat = ({ chatId }: { chatId: string }) => {
const lastInput = useRef("");
const lastMessageRef = useRef<HTMLDivElement>(null);

const [scrollTargetRef, isVisible] = useElementOnScreen({
root: null,
rootMargin: "-83px",
threshold: 0.1,
});

const contextToBeAdded = useMemo(() => {
if (!chatContextQuery.data) {
return null;
Expand Down Expand Up @@ -238,6 +246,8 @@ const useDembraneChat = ({ chatId }: { chatId: string }) => {
error,
lastInputRef: lastInput,
lastMessageRef,
scrollTargetRef,
isVisible,
reload,
setInput,
handleInputChange,
Expand Down Expand Up @@ -267,6 +277,8 @@ export const ProjectChatRoute = () => {
error,
contextToBeAdded,
lastMessageRef,
scrollTargetRef,
isVisible,
setInput,
handleInputChange,
handleSubmit,
Expand Down Expand Up @@ -447,9 +459,24 @@ export const ProjectChatRoute = () => {
)}
</Stack>
</Box>

{/* Scroll target for scroll to bottom button */}
<div ref={scrollTargetRef} aria-hidden="true" />

{/* Footer */}
<Box className="bottom-0 w-full bg-white pb-2 pt-4 md:sticky">
<Stack className="pb-2">
{/* Scroll to bottom button */}
<Group
justify="center"
className="absolute bottom-[105%] left-1/2 z-50 hidden translate-x-[-50%] md:flex"
>
<ScrollToBottomButton
elementRef={scrollTargetRef}
isVisible={isVisible}
/>
</Group>

<ChatTemplatesMenu onTemplateSelect={handleTemplateSelect} />

<Divider />
Expand Down