'use client'; import { useEffect, useState } from 'react'; import type { AgentRecord, AgentLiveness } from '../../lib/agent-registry'; import { ProjectScopeControls } from '../shared/project-scope-controls'; import type { ProjectScopeOption } from '../../lib/project-scope'; interface SessionsHeaderProps { agents: AgentRecord[]; activeAgentId: string | null; onSelectAgent: (id: string | null) => void; projectScopeKey: string; projectScopeMode: 'single' | 'aggregate'; projectScopeOptions: ProjectScopeOption[]; stats?: { active: number; needsInput: number; completed: number; }; livenessMap?: Record; } export function SessionsHeader({ agents, activeAgentId, onSelectAgent, projectScopeKey, projectScopeMode, projectScopeOptions, stats, livenessMap = {}, }: SessionsHeaderProps) { return (
{/* Row 1: Agent Command Deck */}

Command

OPERATIVES

{agents.map((agent) => ( ))}
{/* Row 2: Management & Meta */}
Load Pulse {stats && (
)}
); } function useTimeAgo(isoTimestamp: string) { const [timeAgo, setTimeAgo] = useState(''); useEffect(() => { const update = () => { const seconds = Math.floor((new Date().getTime() - new Date(isoTimestamp).getTime()) / 1000); if (seconds < 60) setTimeAgo(`${seconds}s`); else if (seconds < 3600) setTimeAgo(`${Math.floor(seconds / 60)}m`); else setTimeAgo(`${Math.floor(seconds / 3600)}h`); }; update(); const interval = setInterval(update, 10000); return () => clearInterval(interval); }, [isoTimestamp]); return timeAgo; } function AgentStation({ agent, isSelected, onSelect, liveness }: { agent: AgentRecord, isSelected: boolean, onSelect: (id: string | null) => void, liveness: AgentLiveness }) { const timeAgo = useTimeAgo(agent.last_seen_at); const statusStyles = { active: { dot: 'bg-emerald-500 animate-pulse shadow-[0_0_10px_rgba(16,185,129,0.8)]', label: 'On Mission', color: 'text-emerald-400/60' }, stale: { dot: 'bg-amber-500 shadow-[0_0_8px_rgba(245,158,11,0.5)]', label: 'Lease Expiring', color: 'text-amber-400/60' }, evicted: { dot: 'bg-rose-500/50 shadow-none', label: 'Disconnected', color: 'text-rose-400/40' }, idle: { dot: 'bg-zinc-700 shadow-none', label: 'Idle', color: 'text-zinc-500/30' } }[liveness]; return ( ); } function StatPill({ label, value, color }: { label: string, value: number, color: string }) { return (
{label} {value}
); }