'use client' import { Session } from '@/types' import { formatAge, parseTokenUsage, getStatusBadgeColor } from '@/lib/utils' interface SessionsListProps { sessions: Session[] } interface SessionCardProps { session: Session } function SessionCard({ session }: SessionCardProps) { const tokenUsage = parseTokenUsage(session.tokens) const statusColor = session.active ? 'success' : 'warning' const getSessionTypeIcon = (key: string) => { if (key.includes('main:main')) return '👑' if (key.includes('subagent')) return '🤖' if (key.includes('cron')) return '⏰' if (key.includes('group')) return '👥' return '📄' } const getModelColor = (model: string) => { if (model.includes('opus')) return 'text-purple-400' if (model.includes('sonnet')) return 'text-blue-400' if (model.includes('haiku')) return 'text-green-400' return 'text-gray-400' } const getRoleBadge = (key: string) => { if (key.includes('main:main')) { return { label: 'LEAD', color: 'bg-purple-500/20 text-purple-400 border-purple-500/30' } } if (key.includes('subagent')) { return { label: 'WORKER', color: 'bg-blue-500/20 text-blue-400 border-blue-500/30' } } if (key.includes('cron')) { return { label: 'CRON', color: 'bg-orange-500/20 text-orange-400 border-orange-500/30' } } return { label: 'SYSTEM', color: 'bg-gray-500/20 text-gray-400 border-gray-500/30' } } const getCurrentTask = (session: Session) => { // Extract task from session label or key if (session.label && session.label !== session.key.split(':').pop()) { return session.label } // For sub-agents, try to extract task from key const parts = session.key.split(':') if (parts.length > 3 && parts[2] === 'subagent') { return parts[3] || 'Unknown task' } return session.active ? 'Active' : 'Idle' } const roleBadge = getRoleBadge(session.key) const currentTask = getCurrentTask(session) return (
{getSessionTypeIcon(session.key)}

{session.key.split(':').pop() || session.key}

{/* Role Badge */} {roleBadge.label}
{/* Current Task/Status */}
{currentTask}

{session.key}

{session.model} • {formatAge(session.age)}
{/* Working/Status Badge */}
{session.active ? 'WORKING' : 'IDLE'}
{/* Token Usage */} {session.tokens !== '-' && (
{session.tokens}
{tokenUsage.total > 0 && (
80 ? 'bg-red-400' : tokenUsage.percentage > 60 ? 'bg-yellow-400' : 'bg-green-400' }`} style={{ width: `${Math.min(tokenUsage.percentage, 100)}%` }} />
)}
)}
{/* Flags */} {session.flags.length > 0 && (
{session.flags.map((flag, index) => ( {flag} ))}
)}
) } export function SessionsList({ sessions }: SessionsListProps) { const activeSessions = sessions.filter(s => s.active) const idleSessions = sessions.filter(s => !s.active) return (

Active Sessions

{sessions.length} total • {activeSessions.length} active

{sessions.length === 0 ? (
🤖

No sessions active

Sessions will appear here when agents start

) : (
{/* Active Sessions */} {activeSessions.length > 0 && (

Active ({activeSessions.length})

{activeSessions.map((session) => ( ))}
)} {/* Idle Sessions */} {idleSessions.length > 0 && (

Idle ({idleSessions.length})

{idleSessions.map((session) => ( ))}
)}
)}
) }