import { View, Text, Pressable, ScrollView } from 'react-native'; import type { AgentStatus } from '@server/server/acp/types'; export interface ActiveProcessesProps { agents: Array<{ id: string; status: AgentStatus; type: 'claude'; currentModeId?: string; availableModes?: Array<{ id: string; name: string; description?: string | null }>; }>; commands: Array<{ id: string; name: string; workingDirectory: string; currentCommand: string; isDead: boolean; exitCode: number | null; }>; activeProcessId: string | null; activeProcessType: 'agent' | null; onSelectAgent: (id: string) => void; onBackToOrchestrator: () => void; } function getAgentStatusColor(status: AgentStatus): string { switch (status) { case 'initializing': return '#f59e0b'; // orange case 'ready': return '#3b82f6'; // blue case 'processing': return '#fbbf24'; // yellow case 'completed': return '#22c55e'; // green case 'failed': return '#ef4444'; // red case 'killed': return '#9ca3af'; // gray default: return '#9ca3af'; } } function getModeName(modeId?: string, availableModes?: Array<{ id: string; name: string }>): string { if (!modeId) return 'unknown'; const mode = availableModes?.find((m) => m.id === modeId); return mode?.name || modeId; } function getModeColor(modeId?: string): string { if (!modeId) return '#9ca3af'; // gray // Color based on common mode types if (modeId.includes('ask')) return '#f59e0b'; // orange - asks permission if (modeId.includes('code')) return '#22c55e'; // green - writes code if (modeId.includes('architect') || modeId.includes('plan')) return '#3b82f6'; // blue - plans return '#9ca3af'; // gray - unknown } export function ActiveProcesses({ agents, commands, activeProcessId, activeProcessType, onSelectAgent, onBackToOrchestrator, }: ActiveProcessesProps) { const hasActiveProcess = activeProcessId !== null && activeProcessType !== null; if (agents.length === 0 && commands.length === 0) { return null; } return ( {/* Header with Back button */} {hasActiveProcess && ( Back to Chat )} {/* Scrollable process list */} {/* Agents */} {agents.map((agent) => { const modeName = getModeName(agent.currentModeId, agent.availableModes); const isActive = activeProcessType === 'agent' && activeProcessId === agent.id; return ( onSelectAgent(agent.id)} className={`flex-row items-center gap-2 px-3 py-2 rounded-lg ${ isActive ? 'bg-blue-600' : 'bg-zinc-800' } active:opacity-70`} > {/* Agent icon */} {/* Agent ID (shortened) */} {agent.id.substring(0, 8)} {/* Status indicator */} {/* Mode indicator */} {agent.currentModeId && ( )} ); })} {/* Commands */} {commands.map((command) => { const statusColor = command.isDead ? command.exitCode === 0 ? '#22c55e' : '#ef4444' : '#3b82f6'; return ( {/* Command icon */} {/* Command name */} {command.name || command.currentCommand.substring(0, 20)} {/* Status indicator */} ); })} ); }