'use client'; /** * ActionItem Component * * Displays a single action in a multi-intent chain with: * - Sequence number badge * - Status icon (pending, confirming, executing, success, failed, skipped) * - Intent label (Dutch) * - Confidence badge with color coding * - Entity summary * - Confirmation/retry buttons * * Epic: E3 (UI Components) * Story: E3.S2 (ActionItem sub-component) */ import { Circle, AlertCircle, Loader2, Check, X, RotateCcw, } from 'lucide-react'; import { Button } from '@/components/ui/button'; import { cn } from '@/lib/utils'; import type { IntentAction, IntentActionStatus } from '@/lib/cortex/types'; import { INTENT_LABELS, STATUS_STYLES, getConfidenceStyle, formatEntitySummary, } from '@/lib/cortex/intent-labels'; interface ActionItemProps { action: IntentAction; sequence: number; totalActions: number; onConfirm: () => void; onSkip: () => void; onRetry: () => void; } /** * Status icons mapped to each action status */ const STATUS_ICONS: Record = { pending: , confirming: , executing: , success: , failed: , skipped: , }; export function ActionItem({ action, sequence, totalActions, onConfirm, onSkip, onRetry, }: ActionItemProps) { const statusStyle = STATUS_STYLES[action.status]; const confidenceStyle = getConfidenceStyle(action.confidence); const intentLabel = INTENT_LABELS[action.intent] || action.intent; const entitySummary = formatEntitySummary(action.intent, action.entities); const isConfirming = action.status === 'confirming'; const isFailed = action.status === 'failed'; const isCompleted = action.status === 'success' || action.status === 'skipped'; return (
{/* Main row: sequence, icon, label, confidence */}
{/* Sequence badge */}
{sequence}
{/* Status icon */}
{STATUS_ICONS[action.status]}
{/* Intent label */}
{intentLabel}
{/* Confidence badge */}
{Math.round(action.confidence * 100)}%
{/* Entity summary */}
{entitySummary}
{/* Confirmation message and buttons */} {isConfirming && (
{action.confirmationMessage && (

{action.confirmationMessage}

)}
)} {/* Error state with retry option */} {isFailed && action.error && (

{action.error.message}

{action.error.recoverable && ( )}
)} {/* Completion time (optional, for completed actions) */} {isCompleted && action.completedAt && (
{action.status === 'success' ? 'Voltooid' : 'Overgeslagen'}
)}
); }