import React, { useEffect, useRef } from 'react'; import MessageBubble from './MessageBubble'; export default function ChatWindow({ messages, loadingHistory, streaming, onSendMessage, onCancel, activeSession, onTogglePanel, onBack, canGoBack, loadedModel, summarising, }) { const bottomRef = useRef(null); const inputRef = useRef(null); const [input, setInput] = React.useState(''); useEffect(() => { bottomRef.current?.scrollIntoView({ behavior: 'smooth' }); }, [messages]); function handleSend() { const text = input.trim(); if (!text || streaming) return; setInput(''); onSendMessage(text); } function handleKeyDown(e) { if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault(); handleSend(); } } // Trim .gguf for display const modelLabel = loadedModel ? loadedModel.replace('.gguf', '') : null; return (
{/* Header */}
{/* Back button */} {canGoBack && ( )} {/* Session name */} {activeSession ? (activeSession.name || activeSession.external_id) : 'New chat'}
{/* Loaded model pill */} {modelLabel && ( {modelLabel} )} {!modelLabel && ( No model loaded )} {summarising && (
Summarising…
)}
{/* Message thread */}
{!activeSession && (

Start typing to begin

)} {loadingHistory && (
Loading history...
)} {!loadingHistory && messages.map(msg => ( ))}
{/* Input bar */}