'use client' import { ChevronDown, Clipboard, Download, Search } from 'lucide-react' import { blockTypeToIconMap } from '@/components/ui/icon-mapping' import { BLOCK_ICONS } from '@/components/workflow-preview/block-icons' type ValueType = 'string' | 'number' | 'boolean' | 'object' | 'array' | 'null' /** Dark-theme equivalents of the app's type badges (string=green, number=blue, …). */ const BADGE_COLORS: Record = { string: { bg: 'var(--wp-badge-success-bg)', text: 'var(--wp-badge-success-text)' }, number: { bg: 'var(--wp-badge-blue-bg)', text: 'var(--wp-badge-blue-text)' }, boolean: { bg: 'var(--wp-badge-orange-bg)', text: 'var(--wp-badge-orange-text)' }, array: { bg: 'var(--wp-badge-purple-bg)', text: 'var(--wp-badge-purple-text)' }, object: { bg: 'var(--wp-badge-gray-bg)', text: 'var(--wp-badge-gray-text)' }, null: { bg: 'var(--wp-badge-gray-bg)', text: 'var(--wp-badge-gray-text)' }, } 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 resolveIcon(type: string) { return BLOCK_ICONS[type] ?? blockTypeToIconMap[type] ?? null } function TypeBadge({ type }: { type: ValueType }) { const c = BADGE_COLORS[type] 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) => ( ))}
) }