"use client"; import { CheckCircleIcon, Loader2Icon, SquareTerminalIcon, WrenchIcon, XCircleIcon } from "lucide-react"; import { MessageResponse } from "@/components/ai-elements/message"; import { useI18n } from "@/core/i18n/hooks"; import { cn } from "@/lib/utils"; import type { SubagentState } from "@/core/threads/types"; interface SubagentCardProps { subagentType: string; state?: SubagentState; isLoading?: boolean; prompt?: string; } export function SubagentCard({ subagentType, state, isLoading, prompt }: SubagentCardProps) { const { t } = useI18n(); const getSubagentIcon = (type: string) => { switch (type) { case "bash": return SquareTerminalIcon; case "general-purpose": return WrenchIcon; default: return WrenchIcon; } }; const getSubagentLabel = (type: string) => { switch (type) { case "bash": return t.subagents.bash; case "general-purpose": return t.subagents.generalPurpose; default: return t.subagents.unknown; } }; const IconComponent = getSubagentIcon(subagentType); const label = getSubagentLabel(subagentType); // Determine status based on state, not isLoading const status = state?.status || "running"; const isRunning = status === "running"; const isCompleted = status === "completed"; const isFailed = status === "failed"; const getStatusIcon = () => { if (isCompleted) { return ; } if (isFailed) { return ; } if (isRunning) { return ; } return null; }; const borderColorClass = isCompleted ? "border-green-200 bg-green-50/30" : isFailed ? "border-red-200 bg-red-50/30" : "border-blue-200 bg-blue-50/30"; return (
{/* Header */}
{label} {getStatusIcon()}
{prompt && (
{prompt}
)}
{/* Status message for running state */} {isRunning && !state?.result && (
{t.subagents.running}
)} {/* Result */} {state?.result && (
{state.result}
)} {/* Error */} {state?.status === "failed" && state.error && (
{t.subagents.failed}
{state.error}
)}
); }