import { type TParsedDomCommand } from '@pulse/shared'; import { CheckCircle2, ChevronDown, ChevronRight, Loader2, Terminal, XCircle } from 'lucide-react'; import { memo, useCallback, useState } from 'react'; import { OverrideLayout } from './layout'; type TCommandOverrideProps = { command: TParsedDomCommand; }; const CommandOverride = memo(({ command }: TCommandOverrideProps) => { const [isExpanded, setIsExpanded] = useState(false); const formatValue = useCallback((value: unknown): string => { if (value === undefined || value === null || value === '') { return 'undefined'; } if (typeof value === 'string') { return value; } return JSON.stringify(value); }, []); const getStatusIcon = useCallback(() => { switch (command.status) { case 'completed': return ; case 'failed': return ; case 'pending': default: return ( ); } }, [command.status]); const getStatusText = useCallback(() => { switch (command.status) { case 'completed': return 'Completed'; case 'failed': return 'Failed'; case 'pending': default: return 'Pending'; } }, [command.status]); return ( {command.logo ? ( ) : ( )} {command.commandName} {getStatusIcon()} {getStatusText()} {command.pluginId} {command.args.length > 0 && ( {command.args.map((arg, index) => ( {arg.name}: {formatValue(arg.value)} ))} )} {command.response && ( setIsExpanded(!isExpanded)} className="flex w-full items-center gap-2 px-2 py-1.5 text-left transition-colors hover:bg-muted/50" > {isExpanded ? ( ) : ( )} Response {isExpanded && ( {command.response} )} )} ); }); export { CommandOverride };
{command.response}