import React, { useMemo } from 'react'; import { Text, View } from 'react-native'; import { Bot, Clock, Database, Plug, Zap, type LucideIcon } from 'lucide-react-native'; import { useConversationFeatureNavigation } from '../../featureNavigationContext'; import { themedColor } from '../../theme'; import type { SuperagentToolRendererProps } from '../../types'; import { ToolWidgetRow } from '../primitives/ToolWidgetRow'; import { WidgetCard } from '../primitives/WidgetCard'; import { toolWidgetStyles } from '../primitives/toolWidgetStyles'; import { getSettledWidgetStatus, getStringArg, parseToolArgs } from '../toolWidgetUtils'; import { describeWorkflowTrigger, getWorkflowBadgeStatus, getWorkflowName, getWorkflowTriggerConfig, type WorkflowTriggerType, } from '../workflowWidgetUtils'; import { ActiveBadge, AutomationCardFooter } from './automationCardParts'; const TRIGGER_ICONS: Record = { scheduled: Clock, entity: Database, connector: Plug, in_app_agent: Bot, }; /** * create_or_update_workflow — native port of the web CreateWorkflowWidget task * card (agent-builder variant): name + Active/Inactive badge, trigger summary, * description, and the shared "runs when triggered" / credits footer. Tapping it * opens the Automations settings modal (workflows and automations share that * tab), mirroring the automation card. */ export function CreateWorkflowWidget({ agent, isLastAssistantMessage, toolCall }: SuperagentToolRendererProps) { const openFeature = useConversationFeatureNavigation(); const args = useMemo(() => parseToolArgs(toolCall), [toolCall]); const status = getSettledWidgetStatus(toolCall, isLastAssistantMessage); if (status === 'running') { return ( ); } if (status === 'error' || status === 'stopped') { return ; } const trigger = getWorkflowTriggerConfig(args); const triggerLabel = trigger ? describeWorkflowTrigger(trigger.type, trigger.config) : null; const TriggerIcon = trigger ? TRIGGER_ICONS[trigger.type] : Zap; const description = getStringArg(args, ['description']); const badgeStatus = getWorkflowBadgeStatus(args, toolCall.results); return ( openFeature('automations') : undefined} > {getWorkflowName(args)} {badgeStatus ? : null} {triggerLabel ? {triggerLabel} : null} {description ? ( {description} ) : null} ); }