import React, { useState, useRef, useEffect } from 'react'; import { ChatMessage, ProjectFile } from '../types'; import { ThreeAwakenedMatrix } from './ThreeAwakenedMatrix'; import { Send, Sparkles, Bot, User, Copy, Check, Code, Play, Zap, MessageSquare, } from 'lucide-react'; interface ChatPanelProps { messages: ChatMessage[]; isGenerating: boolean; onSendMessage: (text: string) => void; onApplyCodeToProject?: (files: { name: string; content: string }[]) => void; tokensGenerated?: number; currentFiles: ProjectFile[]; } export const ChatPanel: React.FC = ({ messages, isGenerating, onSendMessage, onApplyCodeToProject, tokensGenerated = 0, }) => { const [input, setInput] = useState(''); const [copiedId, setCopiedId] = useState(null); const messagesEndRef = useRef(null); const textareaRef = useRef(null); useEffect(() => { messagesEndRef.current?.scrollIntoView({ behavior: 'smooth' }); }, [messages, isGenerating]); const handleSubmit = (e: React.FormEvent) => { e.preventDefault(); if (!input.trim() || isGenerating) return; onSendMessage(input.trim()); setInput(''); }; const handleKeyDown = (e: React.KeyboardEvent) => { if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault(); handleSubmit(e); } }; const handleCopy = (text: string, id: string) => { navigator.clipboard.writeText(text); setCopiedId(id); setTimeout(() => setCopiedId(null), 2000); }; const samplePrompts = [ { label: 'Explain the philosophy of Vibe Coding & modern AI', icon: '🧠' }, { label: 'Brainstorm 3 multi-million dollar SaaS micro-apps', icon: '💡' }, { label: 'Synthesize a luxury glassmorphism fintech dashboard', icon: '💎' }, { label: 'Add an interactive particle trail on cursor movement', icon: '⚡' }, ]; const renderMessageContent = (msg: ChatMessage) => { const content = msg.content; const parts = content.split(/(```[\s\S]*?```)/g); return parts.map((part, idx) => { if (part.startsWith('```') && part.endsWith('```')) { const lines = part.slice(3, -3).trim().split('\n'); const header = lines[0].trim(); const codeBody = lines.slice(1).join('\n'); const codeId = `${msg.id}-${idx}`; let filename = header; if (header.includes('file:')) { filename = header.split('file:')[1].replace(/[/*\->#]/g, '').trim(); } else if (header.includes(' ')) { filename = header.split(' ')[1].trim(); } return (
{filename || 'code'}
{onApplyCodeToProject && filename && ( )}
              {codeBody}
            
); } return (
{part}
); }); }; return (
{/* Chat Header: RiShre Awakened Unified Agent Badge */}
RiShre Awakened

Omniscient AI Agent & Vibe Engine

AUTONOMOUS
{/* Message Stream */}
{messages.length === 0 && (

RiShre Awakened Model Ready

I am your versatile AI partner. Talk with me about high-level ideas, request architectural design, or describe apps and watch them come to life in the live preview.

Suggested Prompts: {samplePrompts.map((p, i) => ( ))}
)} {messages.map((msg) => (
{msg.role !== 'user' && (
)}
{msg.role === 'user' ? 'You' : 'RiShre Awakened'} {new Date(msg.timestamp).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })}
{renderMessageContent(msg)}
{msg.role === 'user' && (
)}
))} {isGenerating && (
)}
{/* Input Form */}