From 3dc32dd8fefec92e3b055adc3f4716e2a29e5909 Mon Sep 17 00:00:00 2001 From: Diego Imbert Date: Thu, 25 Jun 2026 12:02:46 +0200 Subject: [PATCH] fix(frontend): use direct parent for nested-loop test-step args evalArg() and updateStepArgs() in stepsInputArgs.svelte.ts selected the parent module via modules[modules.length - 1] from dfs(id, flow, true). dfs returns [module, direct_parent, grandparent, ...] (innermost to outermost), so that index resolved to the outermost ancestor instead of the direct parent. For a step inside a nested for-loop, getFlowInput then computed flow_input using only the outer loop's context, so the "Test this step" tab showed flow_input.iter.value as the outer loop's iteration value instead of the inner loop's. Runtime behavior was already correct. Use modules[1] (the direct parent). For non-nested cases (length == 2) this is identical to the previous index, so behavior is unchanged there. Fixes WIN-2096 Co-Authored-By: Claude Opus 4.8 (1M context) --- .../src/lib/components/flows/stepsInputArgs.svelte.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/frontend/src/lib/components/flows/stepsInputArgs.svelte.ts b/frontend/src/lib/components/flows/stepsInputArgs.svelte.ts index 06a4972ee5..2a700d1a44 100644 --- a/frontend/src/lib/components/flows/stepsInputArgs.svelte.ts +++ b/frontend/src/lib/components/flows/stepsInputArgs.svelte.ts @@ -102,7 +102,10 @@ export class StepsInputArgs { } let parentModule: FlowModule | undefined = undefined if (modules.length > 1) { - parentModule = modules[modules.length - 1] + // dfs returns [module, direct_parent, grandparent, ...], so the direct + // parent is modules[1]. Using the last element would pick the outermost + // ancestor and miss inner-loop iter values for nested loops. + parentModule = modules[1] } const stepPropPicker = getStepPropPicker( flowState, @@ -177,7 +180,10 @@ export class StepsInputArgs { } let parentModule: FlowModule | undefined = undefined if (modules.length > 1) { - parentModule = modules[modules.length - 1] + // dfs returns [module, direct_parent, grandparent, ...], so the direct + // parent is modules[1]. Using the last element would pick the outermost + // ancestor and miss inner-loop iter values for nested loops. + parentModule = modules[1] } const stepPropPicker = getStepPropPicker( flowState,