From 943c7bd96368702f8926fa370d97f23d0f1b99be Mon Sep 17 00:00:00 2001 From: Sean O'Connor Date: Wed, 8 Apr 2026 13:15:58 -0400 Subject: [PATCH] fix(wizard): skip unchosen branch steps during linear progression MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When the wizard makes a branch choice, mark all other branch targets as skipped. Linear progression now advances past skipped steps, so path 1→2→4 no longer executes step 3 when branch A was chosen. Co-Authored-By: Claude Sonnet 4.6 --- .../trials/wizard/WizardInterface.tsx | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/components/trials/wizard/WizardInterface.tsx b/src/components/trials/wizard/WizardInterface.tsx index fb71f0e..218d800 100755 --- a/src/components/trials/wizard/WizardInterface.tsx +++ b/src/components/trials/wizard/WizardInterface.tsx @@ -792,8 +792,11 @@ export const WizardInterface = React.memo(function WizardInterface({ ); } - // Default: Linear progression - const nextIndex = currentStepIndex + 1; + // Default: Linear progression (skip steps marked as skipped by branching) + let nextIndex = currentStepIndex + 1; + while (nextIndex < steps.length && skippedSteps.has(nextIndex)) { + nextIndex++; + } if (nextIndex < steps.length) { // Mark current step as complete setCompletedSteps((prev) => { @@ -942,6 +945,24 @@ export const WizardInterface = React.memo(function WizardInterface({ console.log( `[WizardInterface] Choice-based jump to step ${targetIndex} (${nextId})`, ); + + // Mark other branch targets as skipped so linear progression bypasses them + const branchingStep = steps[currentStepIndex]; + const allOptions = + (branchingStep?.conditions?.options as any[]) ?? []; + setSkippedSteps((prev) => { + const next = new Set(prev); + for (const opt of allOptions) { + if (opt.nextStepId && opt.nextStepId !== nextId) { + const otherIdx = steps.findIndex( + (s) => s.id === opt.nextStepId, + ); + if (otherIdx !== -1) next.add(otherIdx); + } + } + return next; + }); + handleNextStep(targetIndex); return; // Exit after jump } else {