import { motion } from 'framer-motion' import { CircleDotDashed, GitMerge, X } from 'lucide-react' import { useEffect, useRef } from 'react' import { Button, Card, CardContent, CardHeader, CardTitle } from 'ui' import { ActionRun } from '@/data/actions/action-detail-query' interface WorkflowLogsCardProps { workflowRun: ActionRun | null | undefined logs: string | undefined isLoading?: boolean onClose?: () => void // Override props for failed workflows overrideTitle?: string overrideDescription?: string overrideIcon?: React.ReactNode overrideAction?: React.ReactNode } export const WorkflowLogsCard = ({ workflowRun, logs, isLoading = false, onClose, overrideTitle, overrideDescription, overrideIcon, overrideAction, }: WorkflowLogsCardProps) => { const scrollRef = useRef(null) // Auto-scroll to bottom when logs change useEffect(() => { if (scrollRef.current && logs) { scrollRef.current.scrollTop = scrollRef.current.scrollHeight } }, [logs]) const workflowRunStatus = workflowRun?.status const isSuccess = workflowRunStatus === 'SUCCESS' const isFailed = workflowRunStatus === 'FAILED' const isPolling = workflowRunStatus === 'RUNNING' const displayTitle = overrideTitle || (isPolling ? 'Processing...' : isSuccess ? 'Workflow completed successfully' : isFailed ? 'Workflow failed' : 'Workflow completed') const displayIcon = overrideIcon || (isPolling ? ( ) : isSuccess ? ( ) : null) return (
{displayIcon}
{displayTitle} {overrideDescription && (
{overrideDescription}
)}
{overrideAction} {onClose && (
{/* sticky gradient overlay */}
{logs ? (
{logs}
) : (
            {isLoading || isPolling ? 'Initializing workflow...' : 'Waiting for logs...'}
          
)} ) }