'use client'; import React from 'react'; import { ChevronLeft } from 'lucide-react'; import type { BeadIssue } from '../../lib/types'; import { ActivityPanel } from './activity-panel'; import { SwarmCommandFeed } from './swarm-command-feed'; import { ThreadDrawer } from '../shared/thread-drawer'; import { MissionInspector } from '../mission/mission-inspector'; import { useSwarmList } from '../../hooks/use-swarm-list'; import { useUrlState } from '../../hooks/use-url-state'; export interface ContextualRightPanelProps { epicId?: string | null; taskId?: string | null; swarmId?: string | null; issues: BeadIssue[]; projectRoot: string; actor?: string; onMinimize?: () => void; } export function ContextualRightPanel({ epicId, taskId, swarmId, issues, projectRoot, actor, onMinimize }: ContextualRightPanelProps) { const { setTaskId } = useUrlState(); // Task conversation takes priority — user explicitly clicked the conversation icon if (taskId) { const selectedIssue = issues.find(i => i.id === taskId) ?? null; return ( setTaskId(null)} title={selectedIssue?.title ?? taskId} id={taskId} issue={selectedIssue} projectRoot={projectRoot} actor={actor} onIssueUpdated={async () => {}} /> ); } if (epicId) { return (
{onMinimize && (
Epic Command Feed
)}
); } if (swarmId) { return ( ); } // Fallback to Global feed return (
{onMinimize && (
Live Activity Feed
)}
); } // Inner component so hooks can be called conditionally via component boundary function SwarmIdBranch({ swarmId, projectRoot }: { swarmId: string; projectRoot: string }) { const { setSwarmId } = useUrlState(); const { swarms } = useSwarmList(projectRoot); const swarm = swarms.find(s => s.swarmId === swarmId); // Fall back to swarmId as title while swarm list loads const missionTitle = swarm?.title ?? swarmId; // TODO (follow-up): populate assignedAgents from swarm.agents once agent-registry is wired const assignedAgents = swarm?.agents ?? []; return ( setSwarmId(null)} onAssign={async () => {}} /> ); }