"use client"; import { useEffect } from "react"; import { OrchestratorPanel } from "@/components/mission-control/OrchestratorPanel"; import { Button } from "@/components/ui/button"; export interface PanelConfig { sessionId?: string; expanded?: boolean; } interface MissionControlPanelProps { panels: PanelConfig[]; onAddPanel: () => void; onRemovePanel: (index: number) => void; onExpandPanel: (index: number) => void; } export const MIN_PANEL_COUNT = 1; export const MAX_PANEL_COUNT = 6; export function MissionControlPanel({ panels, onAddPanel, onRemovePanel, onExpandPanel, }: MissionControlPanelProps): React.JSX.Element { const expandedPanelIndex = panels.findIndex((panel) => panel.expanded); const expandedPanel = expandedPanelIndex >= 0 ? panels[expandedPanelIndex] : undefined; const canAddPanel = panels.length < MAX_PANEL_COUNT; const canRemovePanel = panels.length > MIN_PANEL_COUNT; useEffect(() => { if (expandedPanelIndex < 0) { return; } const handleKeyDown = (event: KeyboardEvent): void => { if (event.key === "Escape") { onExpandPanel(expandedPanelIndex); } }; window.addEventListener("keydown", handleKeyDown); return (): void => { window.removeEventListener("keydown", handleKeyDown); }; }, [expandedPanelIndex, onExpandPanel]); return (

Panels

{expandedPanelIndex >= 0 && expandedPanel ? (
{ onRemovePanel(expandedPanelIndex); }} closeDisabled={!canRemovePanel} onExpand={() => { onExpandPanel(expandedPanelIndex); }} expanded />
) : (
{panels.map((panel, index) => ( { onRemovePanel(index); }} closeDisabled={!canRemovePanel} onExpand={() => { onExpandPanel(index); }} expanded={panel.expanded ?? false} /> ))}
)}
); }