|
|
@@ -75,16 +75,31 @@ export function ExecutionResultsPanel({
|
|
|
loopEdges.forEach(edge => findLoopBodyNodes(loopNode.id, edge.target, visited))
|
|
|
})
|
|
|
|
|
|
- // Count iterations for each loop based on body node iterations
|
|
|
+ // Count iterations for each loop based on body node iterations or loop node's own output
|
|
|
const loopIterationCounts = new Map<string, number>()
|
|
|
loopBodyMap.forEach((bodyNodes, loopId) => {
|
|
|
let maxIterations = 0
|
|
|
+
|
|
|
+ // First check body node iterations
|
|
|
bodyNodes.forEach(bodyNodeId => {
|
|
|
const nodeState = executionState.nodeStates[bodyNodeId]
|
|
|
if (nodeState?.iterations && nodeState.iterations.length > maxIterations) {
|
|
|
maxIterations = nodeState.iterations.length
|
|
|
}
|
|
|
})
|
|
|
+
|
|
|
+ // Fallback: check the Loop node's own output.items array
|
|
|
+ if (maxIterations === 0) {
|
|
|
+ const loopState = executionState.nodeStates[loopId]
|
|
|
+ if (loopState?.output?.items && Array.isArray(loopState.output.items)) {
|
|
|
+ maxIterations = loopState.output.items.length
|
|
|
+ }
|
|
|
+ // Also check for loop's iterations array
|
|
|
+ if (loopState?.iterations && loopState.iterations.length > maxIterations) {
|
|
|
+ maxIterations = loopState.iterations.length
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
if (maxIterations > 0) {
|
|
|
loopIterationCounts.set(loopId, maxIterations)
|
|
|
}
|
|
|
@@ -375,6 +390,23 @@ export function ExecutionResultsPanel({
|
|
|
)
|
|
|
})()}
|
|
|
</div>
|
|
|
+ ) : isLoopNode && loopIterCount > 0 && nodeState.output?.items ? (
|
|
|
+ /* Loop node with items - show selected item */
|
|
|
+ <div className="space-y-2">
|
|
|
+ {(() => {
|
|
|
+ const selectedIdx = selectedIterations[node.id] ?? 0
|
|
|
+ const selectedItem = nodeState.output.items[selectedIdx]
|
|
|
+ if (!selectedItem) return <div className="text-xs text-gray-400 dark:text-gray-500 italic">No data for this iteration</div>
|
|
|
+
|
|
|
+ return (
|
|
|
+ <pre className="p-2 bg-gray-50 dark:bg-slate-900 border border-gray-200 dark:border-slate-700 rounded text-xs overflow-auto max-h-48 font-mono text-gray-900 dark:text-gray-100">
|
|
|
+ {typeof selectedItem === 'object'
|
|
|
+ ? JSON.stringify(selectedItem, null, 2)
|
|
|
+ : String(selectedItem)}
|
|
|
+ </pre>
|
|
|
+ )
|
|
|
+ })()}
|
|
|
+ </div>
|
|
|
) : nodeState.error ? (
|
|
|
<div className="p-2 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded text-xs text-red-700 dark:text-red-400 font-mono">
|
|
|
{nodeState.error}
|