Skip to content

Commit 7fce4a8

Browse files
committed
feat(onboard): enhance reactivity by adding optionsVersion for memo re-evaluation
1 parent df20d6f commit 7fce4a8

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

src/cli/tui/routes/onboard/onboard-view.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ export function OnboardView(props: OnboardViewProps) {
4949
const [currentStep, setCurrentStep] = createSignal<OnboardStep>('project_name')
5050
const [projectName, setProjectName] = createSignal("")
5151
const [currentGroupSelections, setCurrentGroupSelections] = createSignal<Set<string>>(new Set())
52+
// Version counter to force memo re-evaluation when service state changes (e.g., condition_group → condition_group)
53+
const [optionsVersion, setOptionsVersion] = createSignal(0)
5254

5355
// Legacy state (for backward compatibility without service)
5456
const [selectedTrackId, setSelectedTrackId] = createSignal<string | undefined>()
@@ -80,8 +82,9 @@ export function OnboardView(props: OnboardViewProps) {
8082

8183
// Question text
8284
const currentQuestion = createMemo(() => {
83-
// Always track currentStep to trigger re-evaluation on step changes
85+
// Always track currentStep and optionsVersion to trigger re-evaluation
8486
const step = currentStep()
87+
const _version = optionsVersion()
8588
if (useService()) {
8689
return props.service!.getCurrentQuestion()
8790
}
@@ -103,8 +106,10 @@ export function OnboardView(props: OnboardViewProps) {
103106

104107
// Current entries for selection - memoized for reactivity
105108
const currentOptions = createMemo(() => {
106-
// Force dependency on currentStep to trigger re-evaluation when step changes
109+
// Force dependency on currentStep and optionsVersion to trigger re-evaluation
110+
// optionsVersion handles cases like condition_group → condition_group where step type is the same
107111
const step = currentStep()
112+
const _version = optionsVersion()
108113
if (useService()) {
109114
return props.service!.getCurrentOptions()
110115
}
@@ -216,6 +221,9 @@ export function OnboardView(props: OnboardViewProps) {
216221
setCurrentStep(event.step)
217222
setSelectedIndex(0)
218223
setCurrentGroupSelections(new Set<string>())
224+
// Increment version to force currentOptions memo to re-evaluate
225+
// (handles condition_group → condition_group transitions where step type doesn't change)
226+
setOptionsVersion(v => v + 1)
219227
})
220228

221229
// Subscribe to condition events to sync checkbox state

0 commit comments

Comments
 (0)