'use client';
import { ConversationList } from '@/components/conversations';
import { EmbeddedChat, type EmbeddedChatMessage } from '@/components/chat/EmbeddedChat';
import { useDocumentChat } from '@/hooks/useDocumentChat';
import type { Document } from '@/types/document';
interface DocumentChatPanelProps {
documents: Document[];
selectedDocId: string | null;
hasReadyDocuments: boolean;
}
export const DocumentChatPanel = ({
documents,
selectedDocId,
hasReadyDocuments,
}: DocumentChatPanelProps) => {
const {
chatMessages,
chatLoading,
activeConversationId,
conversationRefreshTrigger,
handleChat,
handleSelectConversation,
handleNewConversation,
} = useDocumentChat({ selectedDocId });
const turns: EmbeddedChatMessage[] = chatMessages.map((msg, i) => ({
id: msg.id ?? `turn-${i}`,
role: msg.role,
content: msg.content,
sources: msg.sources?.map((source) => ({
label: source.document_name,
detail: source.preview || undefined,
})),
}));
return (
<>
{/* Conversation History */}
Upload and process documents to start chatting
Ask a question about your documents
{selectedDocId ? 'Searching in selected document only' : 'Searching across all your documents'}