fix: infer compound node color from descendants when no own overlay state
All checks were successful
CI / cleanup-branch (push) Has been skipped
CI / build (push) Successful in 1m17s
CI / docker (push) Successful in 1m9s
CI / deploy-feature (push) Has been skipped
CI / deploy (push) Successful in 49s

Path containers (EIP_WHEN, EIP_OTHERWISE, etc.) don't have their own
processor records, so they never get an overlay entry. Now inferred
from descendants: green if any descendant executed, red if any failed.
Gated (amber) only when no descendants executed at all.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
hsiegeln
2026-04-01 17:37:47 +02:00
parent 40ce4a57b4
commit ce4abaf862

View File

@@ -68,18 +68,19 @@ export function CompoundNode({
// Execution overlay state for this compound
const ownState = node.id ? executionOverlay?.get(node.id) : undefined;
const hasExecutedChild = ownState && hasExecutedDescendant(node, executionOverlay);
const executedDescendant = hasExecutedDescendant(node, executionOverlay);
const isCompleted = ownState?.status === 'COMPLETED';
const isFailed = ownState?.status === 'FAILED';
const descendantFailed = executedDescendant && hasFailedDescendant(node, executionOverlay);
// Gated = gate processor (filter/idempotent) blocked all children from executing
const isGated = ownState && !hasExecutedChild
// Gated = gate processor blocked all children from executing
const isGated = ownState && !executedDescendant
&& (ownState.filterMatched === false || ownState.duplicateMessage === true);
// Color priority: gated (amber) > failed (red) > completed (green) > default
// Color: own status first, then infer from descendants (for path containers like when/otherwise)
const effectiveColor = isGated ? 'var(--amber)'
: isFailed ? '#C0392B'
: isCompleted ? '#3D7C47'
: isFailed || descendantFailed ? '#C0392B'
: isCompleted || executedDescendant ? '#3D7C47'
: color;
// Dim compound when overlay is active but neither the compound nor any
@@ -295,3 +296,18 @@ function hasExecutedDescendant(
}
return false;
}
function hasFailedDescendant(
node: DiagramNodeType,
overlay?: Map<string, NodeExecutionState>,
): boolean {
if (!overlay || !node.children) return false;
for (const child of node.children) {
if (child.id) {
const state = overlay.get(child.id);
if (state?.status === 'FAILED') return true;
}
if (child.children && hasFailedDescendant(child, overlay)) return true;
}
return false;
}