"use client"; import { motion } from "framer-motion"; import type { Finding, AgentKind } from "@/lib/types"; interface AgentBreakdownProps { findings: Finding[]; } const AGENT_META: Record< AgentKind, { icon: React.ReactNode; label: string; color: string; iconBg: string; border: string; } > = { security: { icon: ( ), label: "Security", color: "text-red-400", iconBg: "bg-red-500/10 text-red-400", border: "border-red-500/[0.08]", }, performance: { icon: ( ), label: "Performance", color: "text-amber-400", iconBg: "bg-amber-500/10 text-amber-400", border: "border-amber-500/[0.08]", }, style: { icon: ( ), label: "Style", color: "text-cyan-400", iconBg: "bg-cyan-500/10 text-cyan-400", border: "border-cyan-500/[0.08]", }, }; export default function AgentBreakdown({ findings }: AgentBreakdownProps) { const agents: AgentKind[] = ["security", "performance", "style"]; const stats = agents.map((agent) => { const agentFindings = findings.filter((f) => f.agent === agent); const catCounts: Record = {}; agentFindings.forEach((f) => { catCounts[f.category] = (catCounts[f.category] ?? 0) + 1; }); const topCategory = Object.entries(catCounts).sort((a, b) => b[1] - a[1])[0]?.[0] ?? "—"; return { agent, count: agentFindings.length, topCategory, meta: AGENT_META[agent], }; }); return (
{stats.map(({ agent, count, topCategory, meta }, i) => (
{meta.icon}

{meta.label}

{count}

findings

Top category

{topCategory}

))}
); }