Repository navigation
ROCMAI-817: split ui/modal.rs into help, warnings, theme-picker and menu modules - #843
jussielo-amd wants to merge 4 commits into
Conversation
Move draw_theme_picker, draw_theme_list, draw_theme_preview and badge out of ui/modal.rs, unchanged, so the file keeps one concern per module. The picker has no tests of its own, so none move. Non-move edits: the module is private (mod theme_picker in ui/mod.rs) and draw_theme_picker is pub(super) for the one caller in ui/mod.rs, which now calls it by its new path; draw_theme_preview, which nothing outside the picker calls, drops from pub to private. The popup helpers are imported from ui/panel.rs directly rather than through the modal.rs re-export, and modal.rs loses the imports it no longer uses. rustfmt re-wrapped the moved call in ui/mod.rs for its longer path. docs/architecture.md gains an entry for the new file and drops the theme picker from the modal.rs entry. Signed-off-by: Jussi Elo <jussi.elo@amd.com>
Move draw_help, draw_global_help and their helpers (help_title, popup_height_for, key_line, help_columns, help_group_lines) out of ui/modal.rs, with the six tests that exercise them, unchanged. The three test fixtures the help and warnings tests share (flat, rows and bottom_border_row) move to the ui/mod.rs test module as pub(in crate::ui), so the help tests and the tests still in modal.rs use one copy; this is the only test code that is not in the file of the code it exercises. Non-move edits: the module is private (mod help_modal in ui/mod.rs); draw_help and draw_global_help are pub(super) for their callers in ui/mod.rs, which now call them by the new path, and popup_height_for is pub(super) because modal.rs still calls it for the warnings modal. The test module is named tests rather than ported_chrome_tests, so the comment in draw_help that names it follows, and the doc link to draw_warnings in popup_height_for now spells out its path. The doc link to draw_help in ui/panel.rs is repointed. The popup helpers are imported from ui/panel.rs directly, and modal.rs loses the imports it no longer uses. rustfmt re-wrapped lines that its new indentation changed. docs/architecture.md gains an entry for the new file and drops the Help modals from the modal.rs entry. Signed-off-by: Jussi Elo <jussi.elo@amd.com>
Move draw_warnings, warning_lines and WARNING_MAX_LINES out of ui/modal.rs, with the eleven tests that exercise them (including the painted_multi_line_warning helper that only they use), unchanged. Non-move edits: the module is private (mod warnings_modal in ui/mod.rs); draw_warnings is pub(super) for its caller in ui/mod.rs, which now calls it by the new path. popup_height_for, which modal.rs used for the warnings modal, is now imported from ui/help_modal.rs by the new module, and modal.rs drops that import and the imports it no longer uses. The doc links to draw_help in draw_warnings now spell out the path of ui/help_modal.rs, and the link to draw_warnings in popup_height_for points at the new module. The test fixtures rows and bottom_border_row come from the ui/mod.rs test module. docs/architecture.md gains an entry for the new file, drops the warnings modal from the modal.rs entry, and the help_modal.rs entry names its new caller. Signed-off-by: Jussi Elo <jussi.elo@amd.com>
…nel into ui/menu.rs Move draw_menu, draw_palette, draw_options, draw_logo and opt_row, the menu sizing constants and menu_fits, with the tests that exercise them (including p4_overlays_render_key_content, which also renders the global help and so imports draw_global_help from ui/help_modal.rs), out of ui/modal.rs, unchanged. What is left in modal.rs is its module doc and the re-export of the four popup helpers, which keeps their ui::modal paths resolving; nothing else is re-exported. Non-move edits: the module is private (mod menu in ui/mod.rs); draw_menu, draw_palette and draw_options are pub(super) for their callers in ui/mod.rs, which now call them by the new path, and draw_logo and opt_row, which only this module and its tests call, drop from pub to private. The test module is named tests rather than ported_chrome_tests. The banner comment above the overlays no longer lists the global Help, which is in ui/help_modal.rs, and the module doc of modal.rs is rewritten to say what the file now holds. The comments that name ui/modal.rs for the grey_overlay test (ui/mod.rs), the Esc menu items (the e2e dash step) and the importers of the popup geometry (ui/panel.rs) are repointed. docs/architecture.md gains an entry for the new file, rewrites the modal.rs entry to say it is only the re-export, lists the four new renderer files as importers of the popup geometry, and corrects the app/types.rs entry, which said modal.rs renders MENU_ITEMS (the menu renders its own item list and count, not that constant). Signed-off-by: Jussi Elo <jussi.elo@amd.com>
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the extraction of dashboard modal renderers into focused modules.
No open issues 🎉
What changed in this PR
Completes ROCMAI-817 by splitting the remaining dashboard modal renderers into focused modules, building on #827’s extraction of shared popup geometry. Rendering logic remains unchanged, while the former public renderer paths are deliberately removed.
Changes:
- Moves help, warnings, theme-picker, and menu renderers into four modules, alongside their existing tests.
- Updates dispatch paths and visibility, centralizes shared test fixtures, and preserves the four public geometry-helper re-exports.
- Updates architecture documentation and source comments to reflect the new layout.
| File | Description |
|---|---|
tests/e2e-cucumber/tests/e2e/dash_steps.rs |
Updates a comment naming the Esc-menu renderer’s location. |
docs/architecture.md |
Documents the extracted modules and their dependencies. |
crates/rocm-dash-tui/src/ui/warnings_modal.rs |
Houses warning rendering, truncation helpers, and existing tests. |
crates/rocm-dash-tui/src/ui/theme_picker.rs |
Houses the theme list and live-preview rendering. |
crates/rocm-dash-tui/src/ui/panel.rs |
Updates documentation references to the relocated renderers. |
crates/rocm-dash-tui/src/ui/modal.rs |
Retains only documentation and four geometry-helper re-exports. |
crates/rocm-dash-tui/src/ui/mod.rs |
Registers modules, redirects rendering calls, and shares test fixtures. |
crates/rocm-dash-tui/src/ui/menu.rs |
Houses menu, palette, Options, logo helpers, and existing tests. |
crates/rocm-dash-tui/src/ui/help_modal.rs |
Houses both help renderers, shared content-height sizing, and existing tests. |
Review effort: Balanced
|
ROCMAI-817 says the crate's public surface stays as it is after the earlier dash-tui split. On main, The simplest fix that keeps the move pure is to widen the renderers to Separately, the branch is based on |
Why
ROCMAI-817: after the dash-tui module split (#827) moved the popup geometry and the menu data out of
crates/rocm-dash-tui/src/ui/modal.rs, the file still held the renderers for several unrelated modals (Help, global help, warnings, theme picker, Esc menu, command palette, Options) plus about 600 lines of their tests in one 1,483-line file. This PR splits it into focused modules as a pure, behaviour-preserving move, and delivers the whole ticket.What changes
One commit per new module, each one compiling and passing clippy on its own:
ui/theme_picker.rs:draw_theme_picker,draw_theme_list,draw_theme_preview,badge. It has no tests of its own.ui/help_modal.rs:draw_help,draw_global_helpand their helpers (help_title,popup_height_for,key_line,help_columns,help_group_lines), with the six tests that exercise them.ui/warnings_modal.rs:draw_warnings,warning_lines,WARNING_MAX_LINES, with the eleven warnings tests (including thepainted_multi_line_warninghelper). It importspopup_height_forfromhelp_modal.rs, which does not import it back, so there is no new cycle.ui/menu.rs:draw_menu,draw_palette,draw_options,draw_logo,opt_row, the menu sizing constants andmenu_fits, with their tests.p4_overlays_render_key_contentalso renders the global help, so it importsdraw_global_helpfromhelp_modal.rs; I kept it whole rather than splitting it so the test inventory stays identical.ui/modal.rsis now its module doc and thepub useof the four popup helpers from #827 (centered_rect,centered_width,draw_popup_frame,grey_overlay); nothing else is re-exported. I used the grouping the ticket proposes, since it matched the code: help and global help share the sizing helpers, the warnings modal shares onlypopup_height_forwith them, and the menu, palette and Options panel share the logo and the settings row.Everything besides the moved code is one of these edits, each also listed in the commit message that makes it:
modinui/mod.rs, and the render functionsui/mod.rscalls arepub(super); the call sites inui/mod.rsuse the new paths (rustfmt re-wrapped the longer theme picker call).draw_theme_preview,draw_logoandopt_row, which only their own module calls, dropped frompubto private.popup_height_forispub(super)becausewarnings_modal.rscalls it.flat,rows,bottom_border_row) moved to theui/mod.rstest module aspub(in crate::ui), next to the helpers ROCMAI-758: split the dash-tui app module, event loop and ui modules into focused files #827 already widened there. The test modules are namedtestsrather thanported_chrome_tests.ui/panel.rsrather than through themodal.rsre-export, andmodal.rslost the imports it no longer needs.draw_helpthat names the test module, the doc links betweendraw_help,draw_warningsandpopup_height_for(now explicit paths), the banner above the overlays inmenu.rs(it listed the global Help, which is now inhelp_modal.rs), the doc link inpanel.rs, the module doc ofpanel.rs, the comment inui/mod.rsthat names where thegrey_overlaytest lives, and the comment in the e2e dash step that names where the Esc menu items are.docs/architecture.md: one entry per new file, themodal.rsentry rewritten to say it is only the re-export, thepanel.rsentry lists the four renderer files as importers of the popup geometry, and theapp/types.rsentry now saysui/menu.rsrenders the palette destinations and options tabs. The old text saidmodal.rsrendersMENU_ITEMS, which was never true (the menu draws its own item list and count), so I corrected it rather than carrying it over.One point on the public surface:
uideclarespub mod modal, so the functions that werepubin it (draw_help,draw_warnings,draw_theme_picker,draw_menu, and so on) were reachable asrocm_dash_tui::ui::modal::*. Because the new modules are private and only the four geometry helpers are re-exported, those paths no longer exist. Nothing in the workspace uses them (I greppedapps/,crates/,tests/andxtask/; the only external users ofui::modalare the four helpers pinned bytests/dash_characterization.rs, which still resolve), and thedraw_detailmove in #827 set the same precedent, but it is a surface change I would rather state than leave implicit.Verification
Run locally:
cargo test -p rocm-dash-tui --all-targets -- --listand the same with--ignored, keeping lines ending: test, stripping the module path and sorting without-u, before and after the change. Both lists are identical (999 and 4 names).cargo test -p rocm-dash-tui --all-targetspasses (960 lib tests, 4 ignored, plus the integration targets).cargo fmt --all --check,cargo clippy -p rocm-dash-tui --all-targets -- -D warnings,cargo check -p rocm,cargo xtask manifest --checkandcargo xtask check-crate-edgesall pass.modal.rsagainst the five resulting files shows only the edits listed above, and the leak scan of the diff againstorigin/mainis clean.cargo doc --document-private-itemsreports no new warnings for the touched files (it still reports the unresolvedgradient::lerp3_tlink in thedraw_logodoc, which was already unresolved inmodal.rs).Not run locally: the full workspace tests, the
tests/e2e-cucumbersuite and the Windows lane, which run in CI. The only e2e-visible change is a comment in a dash step. No test was added or changed in behaviour, so there is no new test to break-check; the move is covered by the existing tests, which are unchanged apart from their imports.Scope
A pure move of the
Modal::*renderer bodies and their tests, with the visibility, import, comment and architecture-doc edits above and no behaviour change. Out of scope: any behaviour change and the other dash-tui and workspace refactoring tickets.