import React, { useState, useRef, useEffect } from "react"; import { Send, Bot, User, Paperclip, X } from "lucide-react"; import type { TriageMessage } from "@/lib/tauriCommands"; interface ChatWindowProps { messages: TriageMessage[]; onSend: (message: string) => Promise; isLoading?: boolean; placeholder?: string; pendingFiles?: { name: string }[]; onAttach?: () => void; onRemoveFile?: (index: number) => void; } export function ChatWindow({ messages, onSend, isLoading, placeholder, pendingFiles, onAttach, onRemoveFile }: ChatWindowProps) { const [input, setInput] = useState(""); const bottomRef = useRef(null); useEffect(() => { bottomRef.current?.scrollIntoView({ behavior: "smooth" }); }, [messages]); const handleSend = async () => { if (!input.trim() || isLoading) return; const msg = input; setInput(""); await onSend(msg); }; const handleKeyDown = (e: React.KeyboardEvent) => { if (e.key === "Enter" && !e.shiftKey) { e.preventDefault(); handleSend(); } }; return (
{messages.map((msg) => (
{msg.role === "assistant" && (
)}

{msg.content}

{msg.role === "user" && (
)}
))} {isLoading && (
)}
{pendingFiles && pendingFiles.length > 0 && (
{pendingFiles.map((f, i) => ( {f.name} {onRemoveFile && ( )} ))}
)}
{onAttach && ( )}