diff --git a/frontend/src/lib/components/FlowRestartButton.svelte b/frontend/src/lib/components/FlowRestartButton.svelte index 7dc8f7b204..d470c51b54 100644 --- a/frontend/src/lib/components/FlowRestartButton.svelte +++ b/frontend/src/lib/components/FlowRestartButton.svelte @@ -40,9 +40,18 @@ * Map from ForLoop step id to the number of iterations that ran in the * original execution (i.e. `flow_jobs.length`). When provided for a step, * the popup renders a `` shows. Step ids are globally unique within a - // single flow value, so the collision only happens across subflow boundaries. + // Iteration counts indexed by the graph module-state key (i.e. the prefixed + // `subflow:...:` for in-subflow loops, or the bare `step_id` for + // top-level loops). Used by the popup for the SELECTED step's iteration + // picker — that step is always at the unprefixed top level (the run page's + // graph-state key matches the bare step_id), so the lookup is unambiguous. + // For nested-path iteration fields, see `nestedPathIterationCounts` instead, + // which is keyed by the popup's field-key ('top' / 'inner-N') and pulled + // from the path-aware graph key — avoiding collisions when the same step + // id appears at both the parent flow and inside a subflow. const iterationCounts = $derived.by((): Record => { const out: Record = {} for (const [id, state] of Object.entries(opts.graphModuleStates())) { const n = state.flow_jobs?.length if (typeof n !== 'number' || n <= 0) continue out[id] = n - const lastColon = id.lastIndexOf(':') - if (lastColon >= 0) { - out[id.slice(lastColon + 1)] = n - } } return out }) @@ -318,6 +341,9 @@ export function useNestedRestartState(opts: { }, get iterationCounts() { return iterationCounts + }, + get nestedPathIterationCounts() { + return nestedPathIterationCounts } } } diff --git a/frontend/src/routes/(root)/(logged)/run/[...run]/+page.svelte b/frontend/src/routes/(root)/(logged)/run/[...run]/+page.svelte index e8cd9b7287..69e9ff0b96 100644 --- a/frontend/src/routes/(root)/(logged)/run/[...run]/+page.svelte +++ b/frontend/src/routes/(root)/(logged)/run/[...run]/+page.svelte @@ -633,6 +633,7 @@ nestedTopBranchOrIterationN={restart.nestedRestartTopBranchOrIterationN} presetIterationN={restart.topLevelLoopIteration} iterationCounts={restart.iterationCounts} + nestedPathIterationCounts={restart.nestedPathIterationCounts} onRestartComplete={(newJobId) => { goto('/run/' + newJobId + '?workspace=' + $workspaceStore) }}