Skip to content

Split the UI crate into modules - #27

Merged
Timtam merged 5 commits into
Timtam:mainfrom
trypsynth:refactor/split-ui-crate
Oct 6, 2026
Merged

Timtam merged 5 commits into
Timtam:mainfrom
trypsynth:refactor/split-ui-crate

Conversation

@trypsynth

Copy link
Copy Markdown
Contributor

What changed

rabbit-ui-wxdragon was two files: lib.rs (6114 lines) and wx_app.rs (6922 lines). Both are now split by topic. No behavior change: this is a move of code, not a rewrite.

Wizard data layer (lib.rs to wizard/)

lib.rs is now 17 lines and only declares the modules and run_gui. The wizard logic moved into wizard.rs plus:

File What lives there
model.rs the page data structs and the install request/outcome types
bootstrap.rs detection, plan build, first WizardModel
text.rs localized labels and wx mnemonic encoding
target.rs target page rows, including the custom portable folder
packages.rs package rows, selection, checkbox toggles
configuration.rs configuration steps and their package dependencies
request.rs page selections to WizardInstallRequest
review.rs review page lines and manual step notes
install.rs runs the install and reports progress
self_update.rs update check, apply, and their summaries
outcome.rs outcome reports and error summaries
summary.rs SetupReport to done page text
labels.rs labels shared by the row builders and the run summary

The 2446-line test module became wizard/tests/ with one file per area and shared fixtures in tests/support.rs. All 54 tests kept, all pass.

wx shell (wx_app.rs to wx_app/)

wx_app.rs keeps run and the step constants (1079 lines). The rest moved to:

File What lives there
globals.rs the process wide localizer, frame, post install hook, version check dispatcher
close_guard.rs what closing the window means while an install runs
self_update_ui.rs status line, prompt with release notes, progress window
progress_ui.rs ProgressEvent to gauge, status line, log
packages_page.rs shared aliases plus the per platform module wiring
packages_page/native.rs the Windows TreeCtrl page
packages_page/native_tree_checkboxes.rs the Win32 TVS_CHECKBOXES helpers
packages_page/dataview.rs the non Windows DataViewCtrl page
pages.rs every build_*_page and add_pages
version_check.rs the version check page and its worker threads
widgets.rs WizardWidgets plus the small readers, sync helpers, and update_navigation
shell.rs open a URL or folder, launch REAPER, relaunch with a locale

The two can_launch_reaper_path / planned_reaper_launch_path_for_target tests moved with their code into widgets.rs.

How it was checked

  • Code content was compared before and after with whitespace and imports normalized away. The only differences are rustfmt trailing commas, plus two attributes that are now obsolete (#[allow(unused_imports)] on an import that no longer exists, and the mod native_tree_checkboxes wrapper).
  • cargo fmt --all --check, cargo clippy --workspace --all-targets, cargo clippy -p rabbit-ui-wxdragon --features gui --all-targets, and cargo test --workspace are clean.
  • cargo test -p rabbit-ui-wxdragon --features gui runs 56 tests, all pass.
  • Items that only needed to be visible inside the crate are pub(crate), so the public API is still run_gui plus the wizard types.

Not done

run in wx_app.rs is still about 1000 lines. Its event handler blocks each capture a dozen Rc/Arc clones from the surrounding scope, so pulling them out means either 20 parameter functions or first bundling that state into a struct. That is a design change rather than a move, so it is left for a follow up.

Timtam and others added 3 commits October 6, 2026 08:01
main changed lib.rs and wx_app.rs after this branch split them into
modules (expert mode and channels, the version-check generation, row
channel tags, the wizard summary's Program line, the GitHub token fix and
more), so those changes are carried into the modules the code moved to:

- 53 of 61 hunks applied where their code now lives; the other 8 (struct
  fields, a changed signature, imports, a hunk spanning two new modules)
  were ported by hand.
- New code got homes in the same spirit as the split: wizard/expert_mode.rs
  for the RABBIT_EXPERT switch and the run's channels, wx_app/expert_mode.rs
  for the unlock chord, build choices and run state; the row channel
  helpers sit next to package_rows in wizard/packages.rs.
- The channel and row tests moved to wizard/tests/packages.rs, and the
  OSARA list-order test into wx_app/expert_mode.rs.

A three-way comparison of every item (base, main, this branch, merged)
found no change from either side lost: 442 of 446 match exactly, and the
other 4 differ only in rustfmt line wrapping.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CI installed whatever stable Rust was current, so Rust 1.99 (released
2026-09-28) started failing clippy on code nobody had changed. All
workflows now install 1.99 explicitly, and the workspace declares it as
rust-version, so a new Rust release can't turn CI red on its own and
every build uses the same compiler.

1.99's new lints are fixed: chunks_exact with a constant size becomes
as_chunks in text_file.rs and in a reapack.rs test, and a test's
std::io::{Read, Write} import that 1.99 reports as unused is dropped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Pinning dtolnay/rust-toolchain to 1.99 installs a fresh toolchain with
only the components listed. @stable had been borrowing rustfmt from the
runner's preinstalled Rust, so cargo fmt --check failed in CI and would
have failed release validation too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Timtam
Timtam merged commit 90f2af2 into Timtam:main Oct 6, 2026
5 checks passed
Timtam added a commit to math65/rabbit that referenced this pull request Oct 6, 2026
main split the UI crate into modules (Timtam#27) after this branch was made, so
its changes to lib.rs and wx_app.rs are carried into the modules the code
moved to:

- The voiceover module is declared in the new lib.rs, and the two new
  strings join WizardText in wizard/model.rs and wizard/text.rs.
- The Mac package list changes (the shared toggle, its state helper, the
  Space key handler and the model's new return type) go into
  wx_app/packages_page/dataview.rs. That module is gated as a whole, so
  the per-item cfg(not(target_os = "windows")) lines are dropped.

A three-way comparison of every item (base, this branch, main, merged)
found nothing lost on either side. dataview.rs only builds on macOS, so it
was also type-checked on Windows by pointing the package page at it for
the check: no errors.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Timtam added a commit to math65/rabbit that referenced this pull request Oct 6, 2026
The module split (Timtam#27) gave dataview.rs its own imports, and six of them
were never used there: two Enter key codes the Windows-side widgets use,
and four functions the toggle code calls with crate:: paths or doesn't
call at all. macOS builds only warned about them, but they hid any new
warning in the file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Timtam added a commit to math65/rabbit that referenced this pull request Oct 6, 2026
main now has the UI crate split (Timtam#27) and Timtam#29 as merged there, so this
branch's own changes to wx_app.rs are carried into the modules the code
moved to:

- The announce helper and its priority go into wx_app/globals.rs, made
  crate-visible because the progress page, the version check and the Mac
  package list all call it.
- The announcements land in wx_app/progress_ui.rs, wx_app/version_check.rs
  and wx_app/packages_page/dataview.rs; the toggle's new return type drops
  the per-item cfg, as the whole module is macOS-only.
- choice_shown_note moves next to its only caller in dataview.rs: in
  widgets.rs it was dead code on Windows, and it had been placed between
  set_optional_choice_shown and that function's doc comment.

A three-way comparison of every item (base, this branch, main, merged)
found nothing lost. dataview.rs was also type-checked on Windows by
pointing the package page at it: no errors, no warnings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Timtam added a commit to math65/rabbit that referenced this pull request Oct 6, 2026
main split the UI crate into modules (Timtam#27) and gained the issue Timtam#32 check
for an open REAPER in the Install handler since this branch was made:

- The Install handler becomes the shared start_install closure as this
  branch intended. Timtam#32's REAPER check is its first statement, so Enter on
  the Review summary runs the same check as the button.
- bind_review_enter_installs moves to wx_app/widgets.rs, next to
  bind_done_page_enter_closes it is modelled on, made crate-visible.
- The CHANGELOG entry keeps its place among main's Fixed entries.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

2 participants