import { useState } from 'react' /** * WorkflowResultViewer - Zeigt Execution-Ergebnisse eines Workflows * * Features: * - Aggregated Result (Final Output) * - Node States (wenn Debug Mode aktiv) * - Collapsible Sections * - Copy to Clipboard * * Part 2: Frontend Execute Integration */ export function WorkflowResultViewer({ result, onClose }) { const [expandedNodes, setExpandedNodes] = useState({}) if (!result) { return null } const toggleNode = (nodeId) => { setExpandedNodes((prev) => ({ ...prev, [nodeId]: !prev[nodeId] })) } const copyToClipboard = (text) => { navigator.clipboard.writeText(text) alert('In Zwischenablage kopiert') } const aggregated = result.aggregated_result || {} const nodeStates = result.node_states || [] return (
{/* Header */}

Workflow-Ergebnis {result.status === 'completed' && ( βœ“ )} {result.status === 'failed' && ( βœ— )}

{/* Content */}
{/* Execution Info */}
Execution ID: {result.execution_id}
Status: {result.status}
{aggregated.total_nodes && (
Nodes: {aggregated.executed_nodes}/{aggregated.total_nodes}
)} {aggregated.failed_nodes > 0 && (
Failed Nodes: {aggregated.failed_nodes}
)}
{/* Final Output */}

Final Output

{aggregated.analysis_core && ( )}
{aggregated.analysis_core || '(Kein Output)'}
{/* All Signals */} {aggregated.all_signals && aggregated.all_signals.length > 0 && (

All Signals ({aggregated.all_signals.length})

{aggregated.all_signals.map((signal, idx) => (
{signal.question_type || 'unknown'}:{' '} {signal.normalized_value || signal.raw_value || 'null'}{' '} ({signal.status})
))}
)} {/* Node States (Debug Info) */} {nodeStates.length > 0 && (

Node States (Debug)

{nodeStates.map((node) => { const hasFailed = node.status === 'failed' return (
{/* Node Header */}
toggleNode(node.node_id)} style={{ padding: '10px 12px', background: 'var(--surface2)', cursor: 'pointer', display: 'flex', justifyContent: 'space-between', alignItems: 'center', fontSize: '13px', fontWeight: 500 }} >
{(node.debug_node_type || node.node_type) === 'start' && 'πŸš€'} {(node.debug_node_type || node.node_type) === 'analysis' && 'πŸ€–'} {(node.debug_node_type || node.node_type) === 'logic' && '⚑'} {(node.debug_node_type || node.node_type) === 'join' && 'πŸ”€'} {(node.debug_node_type || node.node_type) === 'end' && '🏁'} {' '} {node.debug_prompt_slug || node.node_label || ((node.debug_node_type || node.node_type) ? `${node.debug_node_type || node.node_type}-${node.node_id.substring(0, 8)}` : node.node_id)} {node.status === 'skipped' && ( (skipped) )}
{expandedNodes[node.node_id] ? 'β–Ό' : 'β–Ά'}
{/* Node Details */} {expandedNodes[node.node_id] && (
{/* Error (show first) */} {node.error && (
Error:
{node.error}
)} {/* Debug Prompt */} {node.debug_prompt && (
Prompt:
{node.debug_prompt}
)} {/* Debug Raw Response */} {node.debug_raw_response && (
Rohe Antwort:
{node.debug_raw_response}
)} {/* Analysis Core */} {node.analysis_core && (
Ergebnis:
{node.analysis_core}
)} {/* Normalized Signals */} {node.normalized_signals && node.normalized_signals.length > 0 && (
Signale ({node.normalized_signals.length}):
{node.normalized_signals.map((sig, i) => (
{sig.question_type}: "{sig.raw_value}" β†’ "{sig.normalized_value}" {sig.status}
))}
)} {/* Output (fallback) */} {node.output && !node.analysis_core && (
Output:
                            {typeof node.output === 'string' ? node.output : JSON.stringify(node.output, null, 2)}
                          
)} {/* Metadata */} {node.metadata && (
Metadata:
                            {JSON.stringify(node.metadata, null, 2)}
                          
)}
)}
)})}
)} {/* Error (if failed) */} {result.error && (
Error: {result.error}
)}
) }