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) <noreply@anthropic.com>

* 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) <noreply@anthropic.com>

* test(frontend): remove nested-loop parent selection test

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ruben Fiszel
2026-06-25 10:19:55 +02:00
committed by GitHub
parent f6998ec54c
commit 74ebfc67f0
@@ -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,