import { Rocket, ChevronDown, ChevronUp, Activity } from 'lucide-react' import { useState } from 'react' import { AgentCard, AgentLogModal } from './AgentCard' import { ActivityFeed } from './ActivityFeed' import { OrchestratorStatusCard } from './OrchestratorStatusCard' import type { ActiveAgent, AgentLogEntry, OrchestratorStatus } from '../lib/types' import { Card, CardContent } from '@/components/ui/card' import { Badge } from '@/components/ui/badge' import { Button } from '@/components/ui/button' const ACTIVITY_COLLAPSED_KEY = 'autocoder-activity-collapsed' interface AgentMissionControlProps { agents: ActiveAgent[] orchestratorStatus: OrchestratorStatus | null recentActivity: Array<{ agentName: string thought: string timestamp: string featureId: number }> isExpanded?: boolean getAgentLogs?: (agentIndex: number) => AgentLogEntry[] } export function AgentMissionControl({ agents, orchestratorStatus, recentActivity, isExpanded: defaultExpanded = true, getAgentLogs, }: AgentMissionControlProps) { const [isExpanded, setIsExpanded] = useState(defaultExpanded) const [activityCollapsed, setActivityCollapsed] = useState(() => { try { return localStorage.getItem(ACTIVITY_COLLAPSED_KEY) === 'true' } catch { return false } }) const [selectedAgentForLogs, setSelectedAgentForLogs] = useState(null) const toggleActivityCollapsed = () => { const newValue = !activityCollapsed setActivityCollapsed(newValue) try { localStorage.setItem(ACTIVITY_COLLAPSED_KEY, String(newValue)) } catch { // localStorage not available } } // Don't render if no orchestrator status and no agents if (!orchestratorStatus && agents.length === 0) { return null } return ( {/* Header */} {/* Content */}
{/* Orchestrator Status Card */} {orchestratorStatus && ( )} {/* Agent Cards Row */} {agents.length > 0 && (
{agents.map((agent) => ( { const agentToShow = agents.find(a => a.agentIndex === agentIndex) if (agentToShow) { setSelectedAgentForLogs(agentToShow) } }} /> ))}
)} {/* Collapsible Activity Feed */} {recentActivity.length > 0 && (
)}
{/* Log Modal */} {selectedAgentForLogs && getAgentLogs && ( setSelectedAgentForLogs(null)} /> )}
) }