import { AGENT_STEPS, AGENT_STEP_LABELS, STEP_PHASE } from '@/lib/types/run' import type { AgentStep } from '@/lib/types/run' import type { StepStatus } from '@/lib/types/agents' type Phase = 'analysts' | 'researchers' | 'trader' | 'risk' const MULTI_TURN_STEPS = new Set([ 'bull_researcher', 'bear_researcher', 'aggressive_analyst', 'conservative_analyst', 'neutral_analyst', ]) // Color accent per step for visual differentiation const STEP_ACCENT: Record = { market_analyst: '#4480FF', news_analyst: '#A78BFA', fundamentals_analyst: '#00CE68', social_analyst: '#F59E0B', bull_researcher: '#00CE68', bear_researcher: '#FF3355', research_manager: '#4480FF', trader: '#F59E0B', aggressive_analyst: '#FF3355', conservative_analyst: '#4480FF', neutral_analyst: '#A78BFA', risk_judge: '#F59E0B', } type Props = { phase: Phase steps: Record reports: Record } export default function AnalystReports({ phase, steps, reports }: Props) { const phaseSteps = AGENT_STEPS.filter((s) => STEP_PHASE[s] === phase) return (
{phaseSteps.map((step) => { const stepStatus = steps[step] ?? 'pending' const turns = reports[step] ?? [] const isRunning = stepStatus === 'running' const isDone = stepStatus === 'done' const isMulti = MULTI_TURN_STEPS.has(step) const accent = STEP_ACCENT[step] return (
{/* ── Completed turns ─────────────────────────────── */} {turns.map((report, i) => (
{/* Header */}
{AGENT_STEP_LABELS[step]} {isMulti && ( Turn {i + 1} )}
Done
{/* Report text */}

{report}

))} {/* ── Running spinner ──────────────────────────────── */} {isRunning && (
{AGENT_STEP_LABELS[step]} {isMulti && turns.length > 0 && ( Turn {turns.length + 1} )}
Analyzing
{/* Shimmer lines */}
)} {/* ── Pending placeholder ──────────────────────────── */} {turns.length === 0 && !isRunning && (
{AGENT_STEP_LABELS[step]}
Queued
)}
) })}
) }