'use client' import { Badge } from '@sim/emcn' import { ChevronDown, Clipboard, Download, Search } from 'lucide-react' import { resolveIcon } from '@/components/workflow-preview/block-icons' type ValueType = 'string' | 'number' | 'boolean' | 'object' | 'array' | 'null' /** Output value type → emcn Badge color variant. */ const TYPE_VARIANT = { string: 'green', number: 'blue', boolean: 'orange', array: 'purple', object: 'gray', null: 'gray', } as const interface OutputNode { key: string type?: ValueType /** Primitive value shown beneath the key when expanded. */ value?: string /** Nested fields for object/array nodes. */ children?: OutputNode[] /** Collapse the node (chevron points right, nothing rendered beneath). */ expanded?: boolean /** Emphasize this row as the one being read by the tag below. */ highlight?: boolean } interface LogRow { name: string type?: string color?: string duration?: string selected?: boolean } interface OutputBundleProps { /** The block's name (unique within the workflow), e.g. "classify". */ blockName: string blockType?: string blockColor?: string /** Duration shown on the selected log row. */ duration?: string /** Override the Logs column; defaults to Start + this block (selected). */ logs?: LogRow[] values: OutputNode[] } function TypeBadge({ type }: { type: ValueType }) { return ( {type} ) } function TreeNode({ node, depth = 0 }: { node: OutputNode; depth?: number }) { const type = node.type ?? 'string' const expanded = node.expanded ?? Boolean(node.children || node.value !== undefined) return (
{node.key}
{expanded && (node.children || node.value !== undefined) && (
{node.children ? node.children.map((child) => ( )) : node.value !== undefined && (
{node.value}
)}
)}
) } /** * A miniature of the app's run inspector — the Logs list beside the Output * panel's typed tree — teaching what a block's output is: named, typed values * remembered under the block's name, read with a `` tag. */ export function OutputBundle({ blockName, blockType = 'agent', blockColor = '#33C482', duration = '1.2s', logs, values, }: OutputBundleProps) { const logRows: LogRow[] = logs ?? [ { name: 'Start', type: 'start_trigger', color: '#2FB3FF', duration: '9ms' }, { name: blockName, type: blockType, color: blockColor, duration, selected: true }, ] return (
Logs
{logRows.map((row) => { const Icon = row.type ? resolveIcon(row.type) : null return (
{Icon && }
{row.name} {row.duration && ( {row.duration} )}
) })}
Output Input
{values.map((node) => ( ))}
) }