diff --git a/frontend/src/core/components/chatbot/ChatbotDrawer.tsx b/frontend/src/core/components/chatbot/ChatbotDrawer.tsx index de6557212..08d784e82 100644 --- a/frontend/src/core/components/chatbot/ChatbotDrawer.tsx +++ b/frontend/src/core/components/chatbot/ChatbotDrawer.tsx @@ -39,6 +39,8 @@ interface ChatMessage { confidence?: number; modelUsed?: string; createdAt: Date; + documentId?: string; + documentName?: string; } function createMessageId() { @@ -89,6 +91,7 @@ const ChatbotDrawer = () => { const sessionStatus = selectedSessionEntry?.status ?? 'idle'; const sessionError = selectedSessionEntry?.error; const sessionInfo: ChatbotSessionInfo | null = selectedSessionEntry?.session ?? null; + const selectedDocumentName = selectedFile?.name ?? selectedSessionEntry?.fileName; const contextStats = selectedSessionEntry?.status === 'ready' && selectedSessionEntry?.characterCount !== undefined ? { @@ -163,11 +166,6 @@ const ChatbotDrawer = () => { } }, [sessionInfo?.sessionId]); - useEffect(() => { - setMessages([]); - setWarnings([]); - }, [selectedFileId]); - const maybeShowUsageWarning = (usage?: ChatbotUsageSummary | null) => { if (!usage) { return; @@ -286,6 +284,8 @@ const ChatbotDrawer = () => { role: 'user', content: trimmedPrompt, createdAt: new Date(), + documentId: selectedFileId, + documentName: selectedDocumentName, }; setMessages((prev) => [...prev, userMessage]); setPrompt(''); @@ -322,6 +322,8 @@ const ChatbotDrawer = () => { confidence: reply.confidence, modelUsed: reply.modelUsed, createdAt: new Date(), + documentId: selectedFileId, + documentName: selectedDocumentName, }); const fileOptions = useMemo( @@ -398,7 +400,7 @@ const ChatbotDrawer = () => { boxShadow: '0 2px 12px rgba(16,24,40,0.06)', }} > - + {isUser ? t('chatbot.userLabel', 'You') : t('chatbot.botLabel', 'Stirling Bot')} @@ -422,6 +424,16 @@ const ChatbotDrawer = () => { {t('chatbot.modelTag', 'Model: {{name}}', { name: message.modelUsed })} )} + {message.documentName && ( + + {message.documentName} + + )} );