MingruiZhang's picture
feat: project analysis (#27)
96ac62a unverified
raw
history blame
No virus
1.5 kB
'use client';
import { ChatList } from '@/components/chat/ChatList';
import { Composer } from '@/components/chat/Composer';
import { ChatEntity } from '@/lib/types';
import useVisionAgent from '@/lib/hooks/useVisionAgent';
import { useScrollAnchor } from '@/lib/hooks/useScrollAnchor';
export interface ChatProps extends React.ComponentProps<'div'> {
chat: ChatEntity;
}
export function Chat({ chat }: ChatProps) {
const { url, id } = chat;
const { messages, append, reload, stop, isLoading, input, setInput } =
useVisionAgent(chat);
const { messagesRef, scrollRef, visibilityRef, isAtBottom, scrollToBottom } =
useScrollAnchor();
return (
<>
<div className="h-full overflow-auto relative" ref={scrollRef}>
<div className="pb-[200px] pt-4 md:pt-10" ref={messagesRef}>
<ChatList messages={messages} />
<div className="h-px w-full" ref={visibilityRef} />
</div>
</div>
<div className="fixed inset-x-0 bottom-0 w-full animate-in duration-300 ease-in-out peer-[[data-state=open]]:group-[]:lg:pl-[250px] peer-[[data-state=open]]:group-[]:xl:pl-[300px] h-[178px]">
<Composer
id={id}
url={url}
isLoading={isLoading}
stop={stop}
append={append}
reload={reload}
messages={messages}
input={input}
setInput={setInput}
isAtBottom={isAtBottom}
scrollToBottom={scrollToBottom}
/>
</div>
</>
);
}