/**
 * ToolRunView - Render tool/command runs
 * INV: renders projection only; never mutates domain tables.
 *
 * @module packages/tui/src/components/ToolRunView
 */

export interface ToolRunProps {
  id: string
  tool_name: string
  status: string
  started_at: string
  completed_at?: string
  duration_ms?: number
}

export function ToolRunView({ runs }: { runs: ToolRunProps[] }): string {
  if (runs.length === 0) return '(no tool runs)'

  const lines: string[] = ['Tool Runs:', '']
  for (const run of runs) {
    const status_icon = run.status === 'ok' ? '✅' : run.status === 'error' ? '❌' : '🔄'
    const dur = run.duration_ms ? ` (${run.duration_ms}ms)` : ''
    lines.push(`  ${status_icon} ${run.tool_name} [${run.status}]${dur}`)
  }
  return lines.join('\n')
}
