"use client"; import { useEffect, useRef, useState } from "react"; import { useChatStore } from "@/lib/store"; import { MessageBubble } from "./MessageBubble"; import { Bot } from "lucide-react"; interface ChatWindowProps { conversationId: string; } export function ChatWindow({ conversationId }: ChatWindowProps) { const bottomRef = useRef(null); const { conversations } = useChatStore(); const conversation = conversations.find((c) => c.id === conversationId); const messages = conversation?.messages ?? []; const isStreaming = messages.some((m) => m.status === "streaming"); // Announce the last completed assistant message to screen readers const [announcement, setAnnouncement] = useState(""); const prevLengthRef = useRef(messages.length); useEffect(() => { bottomRef.current?.scrollIntoView({ behavior: "smooth" }); const lastMsg = messages[messages.length - 1]; if ( messages.length > prevLengthRef.current && lastMsg?.role === "assistant" && lastMsg.status === "complete" ) { // Announce a short preview so screen reader users know a reply arrived const preview = lastMsg.content.slice(0, 100); setAnnouncement(""); setTimeout(() => setAnnouncement(`Claude replied: ${preview}`), 50); } prevLengthRef.current = messages.length; }, [messages.length, messages]); if (messages.length === 0) { return (

How can I help?

Start a conversation with Claude Code

); } return (
{/* Polite live region — announces when Claude finishes a reply */}
{announcement}
{messages.map((message) => ( ))}
); }