From 74ebfc67f069047875db738926865bd4bd6fe9e9 Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Thu, 25 Jun 2026 10:19:55 +0200 Subject: [PATCH] fix(frontend): nested-loop "Test this step" resolves iter to innermost loop (#9778) * fix(frontend): nested-loop "Test this step" resolves iter to innermost loop In a loop-inside-a-loop, the inner step's "Test this step" tab prefilled its arguments using the outermost ancestor as the parent module, so flow_input.iter resolved to the parent loop's iteration value instead of the inner loop's. dfs(id, flow, true) returns [step, immediate parent, ..., root], so modules[modules.length - 1] is the outermost ancestor. The prop picker needs the immediate parent (modules[1]) so getFlowInput resolves iter at the innermost loop's level. A single loop was unaffected because both indices coincide; only depth >= 2 broke. Co-Authored-By: Claude Opus 4.8 (1M context) * test(frontend): nested-loop parent selection for test-step args Pins that modules[1] from dfs(stepId, flow, true) is the immediate parent for every step across all container types (for/while loops, branchone, branchall, aiagent tools) and nesting depths, and that getStepPropPicker then resolves flow_input.iter to the innermost enclosing loop. Covers >400 step positions across 107 generated flow shapes, plus explicit single/nested/while/branch iter-resolution cases. Co-Authored-By: Claude Opus 4.8 (1M context) * test(frontend): remove nested-loop parent selection test Co-Authored-By: Claude Opus 4.8 (1M context) --------- Co-authored-by: Claude Opus 4.8 (1M context) --- .../src/lib/components/flows/stepsInputArgs.svelte.ts | 8 ++++++-- 1 file changed, 6 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..8aa7a1f69f 100644 --- a/frontend/src/lib/components/flows/stepsInputArgs.svelte.ts +++ b/frontend/src/lib/components/flows/stepsInputArgs.svelte.ts @@ -100,9 +100,11 @@ export class StepsInputArgs { if (modules.length < 1) { return } + // dfs returns [step, immediate parent, ..., root]; the prop picker needs the + // immediate parent so nested loops resolve flow_input.iter to the innermost loop. let parentModule: FlowModule | undefined = undefined if (modules.length > 1) { - parentModule = modules[modules.length - 1] + parentModule = modules[1] } const stepPropPicker = getStepPropPicker( flowState, @@ -175,9 +177,11 @@ export class StepsInputArgs { if (modules.length < 1) { return } + // dfs returns [step, immediate parent, ..., root]; the prop picker needs the + // immediate parent so nested loops resolve flow_input.iter to the innermost loop. let parentModule: FlowModule | undefined = undefined if (modules.length > 1) { - parentModule = modules[modules.length - 1] + parentModule = modules[1] } const stepPropPicker = getStepPropPicker( flowState,