From 9dbbce77ad06dfc50248f3d8adb1eba92fe95404 Mon Sep 17 00:00:00 2001 From: QLHazyCoder <2825305047@qq.com> Date: Wed, 20 May 2026 10:29:47 +0800 Subject: [PATCH] Fix step execution range toggle persistence --- shared/settings-schema.js | 8 +++---- sidepanel/sidepanel.js | 15 ++++++++++++- tests/flow-registry-settings-schema.test.js | 24 +++++++++++++++++++++ 3 files changed, 42 insertions(+), 5 deletions(-) diff --git a/shared/settings-schema.js b/shared/settings-schema.js index 8b6f7ad..f200001 100644 --- a/shared/settings-schema.js +++ b/shared/settings-schema.js @@ -341,8 +341,8 @@ }, autoRun: { stepExecutionRange: normalizeStepExecutionRangeEntry( - nested?.flows?.openai?.autoRun?.stepExecutionRange - ?? stepExecutionRangeByFlow.openai + stepExecutionRangeByFlow.openai + ?? nested?.flows?.openai?.autoRun?.stepExecutionRange ?? {}, defaults.flows.openai.autoRun.stepExecutionRange ), @@ -370,8 +370,8 @@ }, autoRun: { stepExecutionRange: normalizeStepExecutionRangeEntry( - nested?.flows?.kiro?.autoRun?.stepExecutionRange - ?? stepExecutionRangeByFlow.kiro + stepExecutionRangeByFlow.kiro + ?? nested?.flows?.kiro?.autoRun?.stepExecutionRange ?? {}, defaults.flows.kiro.autoRun.stepExecutionRange ), diff --git a/sidepanel/sidepanel.js b/sidepanel/sidepanel.js index 34798b9..5b63ba4 100644 --- a/sidepanel/sidepanel.js +++ b/sidepanel/sidepanel.js @@ -2622,6 +2622,19 @@ function getStepExecutionRangeBoundaryNodeId(stepNumber, boundary = 'start') { return String(resolvedNodeId || fallbackNode?.nodeId || '').trim(); } +function getStepExecutionRangeStepOptionLabel(node = {}) { + const nodeId = String(node?.nodeId || '').trim(); + const step = getStepIdByNodeIdForCurrentMode(nodeId); + const displayOrder = Number(node?.displayOrder); + if (Number.isInteger(step) && step > 0) { + return String(step); + } + if (Number.isInteger(displayOrder) && displayOrder > 0) { + return String(displayOrder); + } + return nodeId; +} + function syncStepExecutionRangeSelectOptions(selectedFromNodeId = '', selectedToNodeId = '') { const nodes = getStepExecutionRangeNodes(); const fromSelect = inputStepExecutionRangeFrom; @@ -2632,7 +2645,7 @@ function syncStepExecutionRangeSelectOptions(selectedFromNodeId = '', selectedTo const buildOptions = (selectedValue) => nodes.map((node) => { const nodeId = String(node?.nodeId || '').trim(); - const label = getStepExecutionRangeNodeLabel(node); + const label = getStepExecutionRangeStepOptionLabel(node); return ``; }).join(''); diff --git a/tests/flow-registry-settings-schema.test.js b/tests/flow-registry-settings-schema.test.js index 265a05f..329e18c 100644 --- a/tests/flow-registry-settings-schema.test.js +++ b/tests/flow-registry-settings-schema.test.js @@ -87,6 +87,30 @@ test('settings schema normalizes view input into canonical nested namespaces', ( }); }); +test('settings schema lets explicit flat step range override stale canonical range', () => { + const { settingsSchema } = loadApis(); + const schema = settingsSchema.createSettingsSchema(); + const oldState = schema.normalizeSettingsState({ + activeFlowId: 'openai', + stepExecutionRangeByFlow: { + openai: { enabled: true, fromStep: 3, toStep: 6 }, + }, + }); + + const normalized = schema.normalizeSettingsState({ + settingsState: oldState, + stepExecutionRangeByFlow: { + openai: { enabled: false, fromStep: 3, toStep: 6 }, + }, + }); + + assert.deepEqual(normalized.flows.openai.autoRun.stepExecutionRange, { + enabled: false, + fromStep: 3, + toStep: 6, + }); +}); + test('settings schema can project canonical state into a read view without legacy rebuild helpers', () => { const { settingsSchema } = loadApis(); const schema = settingsSchema.createSettingsSchema();