'use client'; import { useState, useEffect } from 'react'; import Link from 'next/link'; import { MessageSquare, Plus, Bot, Search, Clock, Loader2 } from 'lucide-react'; interface Conversation { id: string; agent: string; agentColor: string; title: string; lastMessage: string; timestamp: string; status: 'active' | 'ended'; } const AGENT_COLORS: Record = { lucidia: '#2979FF', alice: '#22c55e', octavia: '#F5A623', cecilia: '#9C27B0', aria: '#FF1D6C', shellfish: '#ef4444', }; const SEED_CONVERSATIONS: Conversation[] = [ { id: 'lucidia-1', agent: 'Lucidia', agentColor: '#2979FF', title: 'What does it mean for a system to understand itself?', lastMessage: 'The question contains its own incompleteness. Gödel would agree.', timestamp: '2 hours ago', status: 'ended', }, { id: 'alice-1', agent: 'Alice', agentColor: '#22c55e', title: 'Deploy the email router worker', lastMessage: 'Deployed to amundsonalexa.workers.dev. MX records are Cloudflare. ✓', timestamp: '4 hours ago', status: 'ended', }, { id: 'octavia-1', agent: 'Octavia', agentColor: '#F5A623', title: 'Pi fleet architecture review', lastMessage: 'aria64 is PRIMARY (22,500 slots), alice is SECONDARY (7,500). Recommend adding a third node.', timestamp: 'Yesterday', status: 'ended', }, { id: 'shellfish-1', agent: 'Shellfish', agentColor: '#ef4444', title: 'Tokenless agent audit', lastMessage: 'verify-tokenless-agents.sh passed. 0 forbidden strings found.', timestamp: 'Yesterday', status: 'ended', }, { id: 'cecilia-1', agent: 'Cecilia', agentColor: '#9C27B0', title: 'K(t) contradiction amplification review', lastMessage: 'K(t) = C(t) · e^(λ|δ_t|). The contradictions are where the growth is.', timestamp: '2 days ago', status: 'ended', }, ]; const AGENTS = [ { name: 'All Agents', value: 'all', color: '' }, { name: 'Lucidia', value: 'Lucidia', color: '#2979FF' }, { name: 'Alice', value: 'Alice', color: '#22c55e' }, { name: 'Octavia', value: 'Octavia', color: '#F5A623' }, { name: 'Cecilia', value: 'Cecilia', color: '#9C27B0' }, { name: 'Aria', value: 'Aria', color: '#FF1D6C' }, { name: 'Shellfish', value: 'Shellfish', color: '#ef4444' }, ]; function formatTimestamp(ts: string): string { try { const d = new Date(ts); const now = Date.now(); const diff = now - d.getTime(); if (diff < 60000) return 'just now'; if (diff < 3600000) return `${Math.floor(diff / 60000)}m ago`; if (diff < 86400000) return `${Math.floor(diff / 3600000)}h ago`; if (diff < 172800000) return 'Yesterday'; return d.toLocaleDateString(); } catch { return ts; } } export default function ConversationsPage() { const [filter, setFilter] = useState('all'); const [search, setSearch] = useState(''); const [conversations, setConversations] = useState(SEED_CONVERSATIONS); const [loading, setLoading] = useState(true); useEffect(() => { fetch('/api/conversations') .then(r => r.ok ? r.json() : null) .then(data => { if (data?.conversations?.length) { const live: Conversation[] = data.conversations.map((c: { id: string; agent?: string; title?: string; updatedAt?: string; messages?: {role: string; content: string}[]; }) => ({ id: c.id, agent: c.agent || 'Agent', agentColor: AGENT_COLORS[(c.agent || '').toLowerCase()] || '#888', title: c.title || 'Untitled', lastMessage: c.messages?.[c.messages.length - 1]?.content?.slice(0, 80) || '—', timestamp: formatTimestamp(c.updatedAt || ''), status: 'ended' as const, })); // Merge: live first, then seed ones not already in live const liveIds = new Set(live.map(c => c.id)); setConversations([...live, ...SEED_CONVERSATIONS.filter(c => !liveIds.has(c.id))]); } }) .catch(() => {}) .finally(() => setLoading(false)); }, []); const filtered = conversations.filter((c) => { if (filter !== 'all' && c.agent !== filter) return false; if (search && !c.title.toLowerCase().includes(search.toLowerCase())) return false; return true; }); return (
{/* Header */}

Conversations

{loading ? : `${conversations.length} conversations`} · All agents

New
{/* Search */}
setSearch(e.target.value)} placeholder="Search conversations..." className="w-full pl-10 pr-4 py-2.5 bg-white/5 border border-white/10 rounded-xl text-sm text-white placeholder-gray-500 focus:outline-none focus:ring-2 focus:ring-[#FF1D6C]/50 transition-all" />
{/* Agent filter pills */}
{AGENTS.map((a) => ( ))}
{/* Conversation list */}
{filtered.map((conv) => ( {/* Agent dot */}
{/* Content */}
{conv.agent} {conv.timestamp}
{conv.title}
{conv.lastMessage}
))} {filtered.length === 0 && (

No conversations match your filter.

Start a new one →
)}
); }