import type { UIMessage } from 'ai' import { Loader2, RotateCcw, Square, X } from 'lucide-react' import type { FC } from 'react' import { Button } from '@/components/ui/button' import { Dialog, DialogContent, DialogHeader, DialogTitle, } from '@/components/ui/dialog' interface RunWorkflowDialogProps { open: boolean workflowName: string messages: UIMessage[] status: 'streaming' | 'submitted' | 'ready' | 'error' wasCancelled: boolean error: Error | undefined onStop: () => void onRetry: () => void onClose: () => void } export const RunWorkflowDialog: FC = ({ open, workflowName, messages, status, wasCancelled, error, onStop, onRetry, onClose, }) => { const isProcessing = status === 'streaming' || status === 'submitted' const _isComplete = !isProcessing const getStatusText = () => { if (status === 'submitted') return 'Starting workflow...' if (status === 'streaming') return 'Running...' if (wasCancelled) return 'Execution cancelled' if (status === 'error') return 'Error occurred' return 'Completed' } const getMessageContent = (message: UIMessage) => { return message.parts .filter((part) => part.type === 'text') .map((part) => part.text) .join('') } const assistantMessages = messages.filter((m) => m.role === 'assistant') return ( {}}> e.preventDefault()} onEscapeKeyDown={(e) => e.preventDefault()} > {isProcessing && ( )} Running: {workflowName}
{isProcessing ? ( ) : ( <> )}
{getStatusText()}
{error && (
Error Details
{error.message}
)}
{assistantMessages.length === 0 ? (
{isProcessing ? 'Waiting for response...' : 'No output available.'}
) : (
{assistantMessages.map((message) => (
{getMessageContent(message)}
))}
)}
) }