import { useState } from 'react'; import { Code2, Play, Terminal, Sparkles } from 'lucide-react'; import { chatApi } from '@/services/api'; import ReactMarkdown from 'react-markdown'; import toast from 'react-hot-toast'; export default function CodePage() { const [prompt, setPrompt] = useState('Write a Python function to parse CSV files and compute row counts.'); const [loading, setLoading] = useState(false); const [codeOutput, setCodeOutput] = useState(null); const handleGenerate = async () => { if (!prompt.trim() || loading) return; setLoading(true); setCodeOutput(null); const toastId = toast.loading('Code Agent generating solution...'); try { const res = await chatApi.sendMessage(prompt); toast.success('Code generation complete!', { id: toastId }); setCodeOutput(res.response || 'No code generated.'); } catch { toast.error('Code Agent request failed.', { id: toastId }); } finally { setLoading(false); } }; return (

Code Engineering Agent

Generate, refactor, review, and explain code scripts in Python, SQL, TypeScript, and Shell.

Active Node
setPrompt(e.target.value)} onKeyDown={(e) => e.key === 'Enter' && handleGenerate()} className="input-glow flex-1 px-4 py-3 rounded-xl bg-dark-800 border border-dark-600 text-white placeholder-dark-500 text-sm" />
{codeOutput && (

Generated Code & Explanation

{codeOutput}
)}
); }