Skip to content

refactor(ui): data-driven ChoicePage for setup-wizard binary questions (R24)#103

Merged
stormer78 merged 1 commit into
mainfrom
r24-choicepage-setup-wizard
Jun 12, 2026
Merged

refactor(ui): data-driven ChoicePage for setup-wizard binary questions (R24)#103
stormer78 merged 1 commit into
mainfrom
r24-choicepage-setup-wizard

Conversation

@stormer78

Copy link
Copy Markdown
Contributor

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, and did_git_sign_ask duplicated ~320 lines of identical render + key-handling logic.

Fix

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 SetupFlow fields and the mod.rs dispatch 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.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.

Tests

The existing navigate() table tests in setup_flow/navigation.rs are 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

…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>
@stormer78 stormer78 requested a review from a team as a code owner June 12, 2026 02:06
@stormer78 stormer78 merged commit 01048fa into main Jun 12, 2026
11 of 13 checks passed
@stormer78 stormer78 deleted the r24-choicepage-setup-wizard branch June 12, 2026 02:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant