import React, { useEffect, useRef } from 'react'; import { useChat } from '../../hooks/useChat'; import MessageBubble from './MessageBubble'; import MessageInput from './MessageInput'; import StepSequencePanel from './StepSequencePanel'; import './ChatWindow.css'; /** * ChatWindow — main chat container. * * - Full-height layout with scrollable message list above input * - Auto-scrolls to the latest message * - Shows "PC Pal is typing..." indicator */ function ChatWindow({ userId }) { const { messages, sendMessage, isConnected, isTyping, activeSequence } = useChat(userId); const bottomRef = useRef(null); // Auto-scroll to the newest message useEffect(() => { if (bottomRef.current) { bottomRef.current.scrollIntoView({ behavior: 'smooth' }); } }, [messages, isTyping]); return (
{/* Connection status banner */} {!isConnected && (
Connecting to PC Pal... please wait.
)} {/* Scrollable message list */}
{messages.length === 0 && (

Hello! I'm PC Pal, your friendly tech helper.
Ask me anything about your computer!

)} {messages.map((msg) => ( ))} {/* Typing indicator */} {isTyping && (
PC Pal is typing...
)} {/* Invisible anchor to scroll to */} {/* Step sequence guidance panel — shown above input when active */} {/* Input area */}
); } export default ChatWindow;