/**
 * AgentStatusView - Render agent status
 * INV: renders projection only; never mutates domain tables.
 *
 * @module packages/tui/src/components/AgentStatusView
 */

import type { AgentProjection } from '../types.js'

export interface AgentStatusViewProps {
  agents: AgentProjection[]
}

export function AgentStatusView({ agents }: AgentStatusViewProps): string {
  if (agents.length === 0) return '(no agents)'

  const lines: string[] = ['Agents:', '']

  for (const agent of agents) {
    const status_icon = agent.status === 'running' ? '🟢' : agent.status === 'completed' ? '✅' : agent.status === 'error' ? '🔴' : '⚪'
    const heartbeat = agent.last_heartbeat ? ` (hb: ${agent.last_heartbeat})` : ''
    lines.push(`  ${status_icon} ${agent.id}  [${agent.type}]${heartbeat}`)
  }

  return lines.join('\n')
}
