refactor(ui): data-driven ChoicePage for setup-wizard binary questions (R24)#103
Merged
Conversation
…s (R24)
The binary "ask" pages in the setup wizard were the same two-option
component re-typed: `mediator_ask`, `unlock_code_ask`,
`did_keys_export_ask`, and `did_git_sign_ask` duplicated ~320 lines of
identical render + key-handling logic.
Introduce one reusable `ChoicePage` component
(`setup_flow/choice_page.rs`): a `ChoiceSpec { title, intro, options:
[ChoiceOption; 2] }` plus shared `render` / `handle_key_event`. The four
pages become small data constructors supplying their spec; each keeps its
2-variant selection enum so the `SetupFlow` fields and `mod.rs` dispatch
tables are untouched.
Behavior is preserved exactly, including the per-page differences carried
as data: mediator's selection-dependent step title (1/1 vs 1/2),
unlock-code's bold no-code warning line, and the export page's default =
Skip. `start_ask.rs` is intentionally left as-is — it is a genuinely
different two-panel layout (horizontal split, Left/Right keys, no checkbox
list) that does not fit the `ChoiceSpec` shape.
The existing `navigate()` table tests in `setup_flow/navigation.rs` are
untouched and green — they cover the flow logic this refactor preserves.
Gate: cargo fmt --all, clippy --all-targets -D warnings, cargo test -p
openvtc (96 passed) — all green.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Glenn Gore <glenn.g@affinidi.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The binary "ask" pages in the setup wizard were the same two-option component re-typed:
mediator_ask,unlock_code_ask,did_keys_export_ask, anddid_git_sign_askduplicated ~320 lines of identical render + key-handling logic.Fix
One reusable
ChoicePagecomponent (setup_flow/choice_page.rs): aChoiceSpec { title, intro, options: [ChoiceOption; 2] }plus sharedrender/handle_key_event. The four pages become small data constructors supplying their spec; each keeps its 2-variant selection enum soSetupFlowfields and themod.rsdispatch tables are untouched.Per-page differences are preserved as data: mediator's selection-dependent step title (1/1 vs 1/2), unlock-code's bold no-code warning line, and the export page's default = Skip.
start_ask.rsis intentionally left as-is — it is a genuinely different two-panel layout (horizontal split, Left/Right keys, no checkbox list) that does not fit theChoiceSpecshape.Tests
The existing
navigate()table tests insetup_flow/navigation.rsare untouched and green — they cover the wizard flow logic this refactor preserves.Gate
cargo fmt --all,cargo clippy --workspace --all-targets -- -D warnings,cargo test -p openvtc(96 passed) — all green. Net ~−50 source lines; ~457 lines of duplication collapsed into the 139-line component.🤖 Generated with Claude Code