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' interface WorkflowRun { id: string status: string branch_id?: string check_run_id?: number | null created_at?: string updated_at?: string workdir?: string | null git_config?: unknown } interface WorkflowLogsCardProps { workflowRun: WorkflowRun | null | undefined logs: string | undefined isLoading?: boolean onClose?: () => void // Override props for failed workflows overrideTitle?: string overrideDescription?: string overrideIcon?: React.ReactNode overrideAction?: React.ReactNode } 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 showSuccessIcon = workflowRun?.status === 'FUNCTIONS_DEPLOYED' const isFailed = workflowRun?.status && ['MIGRATIONS_FAILED', 'FUNCTIONS_FAILED'].includes(workflowRun.status) const isPolling = workflowRun?.status !== 'FUNCTIONS_DEPLOYED' && (!workflowRun?.status || !['MIGRATIONS_FAILED', 'FUNCTIONS_FAILED'].includes(workflowRun.status)) const displayTitle = overrideTitle || (isPolling ? 'Processing...' : showSuccessIcon ? 'Workflow completed successfully' : isFailed ? 'Workflow failed' : 'Workflow completed') const displayIcon = overrideIcon || (isPolling ? ( ) : showSuccessIcon ? ( ) : null) return (
{displayIcon}
{displayTitle} {overrideDescription && (
{overrideDescription}
)}
{overrideAction} {onClose && (
{/* sticky gradient overlay */}
{logs ? (
{logs}
) : (
            {isLoading || isPolling ? 'Initializing workflow...' : 'Waiting for logs...'}
          
)} ) } export default WorkflowLogsCard