ROCMAI-84: Modularize crates/rocm-dash-tui/src/app/mod.rs - #476
jussielo-amd wants to merge 5 commits into
Conversation
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The extraction unintentionally removes two public API paths and introduces an unresolved documentation link.
Review effort: Balanced
Findings: 1
Open (2)
What changed in this PR
Modularizes the dashboard’s monolithic application module while preserving its reducer architecture and intended public API.
Changes:
- Extracts shared types, event-loop logic, input actions, and scrollbar handling.
- Retains
AppStateand reducer logic inmod.rs. - Updates the architecture documentation.
| File | Description |
|---|---|
docs/architecture.md |
Documents the new module structure. |
app/mod.rs |
Retains reducer state and re-exports extracted APIs. |
app/types.rs |
Contains shared application types. |
app/event_loop.rs |
Contains terminal lifecycle and event processing. |
app/scrollbar.rs |
Contains mouse and scrollbar hit-testing. |
app/actions.rs |
Contains input translation and action dispatch. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Code review on PR #476 caught two more instances of the same bug classes already fixed once in 96a44fd: NO_CHAT_BACKEND_MSG was moved to types.rs but dropped from the pub(crate) re-export list, and the focused_should_exit doc comment's intra-doc link to focused_close_key_blocked no longer resolves now that the two live in separate modules (the fn is private to event_loop, so de-link rather than widen its visibility). Signed-off-by: Jussi Elo <jussi.elo@amd.com>
Code review on PR #476 caught two more instances of the same bug classes already fixed once in 96a44fd: NO_CHAT_BACKEND_MSG was moved to types.rs but dropped from the pub(crate) re-export list, and the focused_should_exit doc comment's intra-doc link to focused_close_key_blocked no longer resolves now that the two live in separate modules (the fn is private to event_loop, so de-link rather than widen its visibility). Signed-off-by: Jussi Elo <jussi.elo@amd.com>
b02ab85 to
c5b5c5e
Compare
Code review on PR #476 caught two more instances of the same bug classes already fixed once in 96a44fd: NO_CHAT_BACKEND_MSG was moved to types.rs but dropped from the pub(crate) re-export list, and the focused_should_exit doc comment's intra-doc link to focused_close_key_blocked no longer resolves now that the two live in separate modules (the fn is private to event_loop, so de-link rather than widen its visibility). Signed-off-by: Jussi Elo <jussi.elo@amd.com>
c5b5c5e to
a5ea2ea
Compare
Split the 8,967-line app/mod.rs into app/{types,event_loop,scrollbar,actions}.rs
following the full-domain-extraction convention, keeping mod.rs to AppState and
its apply_event/apply_action-adjacent reducer impl. crate::app::* paths for
everything moved out are preserved via re-exports. Updates the architecture
module map in the same PR per the modularization plan's rules.
Signed-off-by: Jussi Elo <jussi.elo@amd.com>
Review (Copilot) caught two regressions from the mechanical move: - handle_mouse/tab_bar_hit were pub at crate::app:: before extraction but landed in the private actions module unre-exported, silently shrinking the public API surface this PR claims to preserve. - The ClientMsg intra-doc link in PlannedAction's doc comment stopped resolving once the comment moved to types.rs, which doesn't import it. Signed-off-by: Jussi Elo <jussi.elo@amd.com>
Code review on PR #476 caught two more instances of the same bug classes already fixed once in 96a44fd: NO_CHAT_BACKEND_MSG was moved to types.rs but dropped from the pub(crate) re-export list, and the focused_should_exit doc comment's intra-doc link to focused_close_key_blocked no longer resolves now that the two live in separate modules (the fn is private to event_loop, so de-link rather than widen its visibility). Signed-off-by: Jussi Elo <jussi.elo@amd.com>
a5ea2ea to
94e251d
Compare
|
🔴 Automated review · pr-review-watcher · 04289b0 This automation never files a GitHub approval, so no approving review will SummarySince 94e251d, this PR has fixed three comments that still pointed at the old Reviewed: commit range 94e251d..04289b0 ( Previous round's blockers: the stale-path blocker ( Verified: in Blocking: 1 · Non-blocking: 6. 🚫 Blocking (must fix before merge)
Non-blocking
|
rominf
left a comment
There was a problem hiding this comment.
🔴 Automated review · pr-review-watcher · 94e251d
Requesting changes for the two blocking findings in this round's review comment:
- Comments in other files still point at the old location.
apps/rocm/src/main.rs:29733namesapp/mod.rsas the home ofstartup_focus_gate_only_opens_onboarding_for_explicit_setup_focus, but that test is now inapp/event_loop.rs.crates/rocm-dash-tui/tests/dash_journeys.rs:16-17namessrc/app/mod.rsfor the keystroke tests, which are now insrc/app/actions.rs.crates/rocm-dash-tui/src/agent/mod.rs:21-26describesappas not re-exporting its submodules, which it now does. To resolve: correct the two paths and reword theagent/mod.rssentence. crates/rocm-dash-tui/src/app/mod.rs:50-54adds thepub(crate) use types::NO_CHAT_BACKEND_MSGre-export. Nothing reaches it through that path, and it only compiles cleanly because of#[allow(unused_imports)]. To resolve: delete the re-export and itsallow.
The automation withdraws this request itself once a later round confirms both points are fixed.
|
Addressing the two blocking findings from the automated review round (commit
|
Signed-off-by: Jussi Elo <jussi.elo@amd.com>
adea8ed to
04289b0
Compare
|
Re the reply above, on the two blocking findings from the 94e251d round: Finding 1 (stale path references) — confirmed fixed at 04289b0. Finding 2 (
This round's review re-derived the same finding from the code, so it stays blocking and the change request stays in place for this point only. If you and the maintainers decide parity should also cover crate-private paths, a human reviewer can make that call. Otherwise, deleting the comment, the |
Withdrawing: objection 1 (stale path comments) is fixed at 04289b0. Objection 2 (the documented crate-private NO_CHAT_BACKEND_MSG re-export under allow(unused_imports)) is a style preference with no consequence after merge, so it stays a non-blocking comment rather than a gate.
Signed-off-by: Jussi Elo <jussi.elo@amd.com>
|
Fair — the public/crate-private distinction is correct and I was conflating two different kinds of parity. Fixed in a647de4: removed the Also narrowed the architecture doc and PR description's "Design decisions" section so this doesn't recur: the parity guarantee is scoped to the module's public surface (what the ticket's acceptance criteria actually requires), not incidental |


Summary
app/mod.rs(8,967 lines) into anapp/directory following the modularization effort's full-domain-extraction convention:types.rs— shared type/enum defs (Focus,ResolvedArgs, connection/tab/chat/replay state,Modal,UpdateStatus, slash/plan/approval payload types). NoAppStateaccess.event_loop.rs— terminal lifecycle, signal handling, and the tick loop (run,event_loop, the termination-signal watcher, startup-focus/Updates-tile tick helpers).scrollbar.rs— mouse/scroll hit-testing: resolving a rawMouseEventagainst recorded scrollbar tracks, the tab bar, and footer-legend chips into aKeyAction.actions.rs—KeyActiondispatch:handle_key/handle_mouse/tab_bar_hit,apply_action/run_approvedreducer glue.mod.rskeeps onlyAppStateand itsapply_event-adjacent reducer impl — "the reducer's reason to exist," per the ticket.crate::app::*paths for the module's public surface are preserved via re-exports frommod.rs, soui/,apps/rocm, and the dash e2e/example targets that reference them are unaffected.docs/architecture.md's module map in this same PR (not deferred), per the modularization plan's documentation rule.Design decisions
mod.rs's re-exports preservecrate::app::*for the module's public surface — the scope the ticket's acceptance criteria and "no behavior change" actually cover (AppState's public surface used byui/, plus anything externally reachable). They do not preserve incidental reachability ofpub(crate)items that have no caller throughcrate::app::— apub(crate)symbol with zero current callers on that path can't silently break anyone if the path disappears (any real in-crate need would be a compile error, not a runtime regression), so there's nothing for parity to protect there.handle_mouse/tab_bar_hitare the converse case: realpubsurface a downstream consumer of the crate could depend on, which is why those got re-added per Copilot's review.Notes
mainby grep/structure rather than trusting the ticket's (stale, pre-drift) line numbers — the file had grown from 6.7k to 8,967 lines since epic-authoring time.#[test]+ 1#[tokio::test]functions (209 total) were partitioned across the 5 files by what they actually exercise (verified against call-sites), not by position. Test count is unchanged.agent.rs, ROCMAI-51) to avoid two large concurrent diffs on this crate. ROCMAI-51 is still in progress, so this PR is landing slightly out of the stated order — flagging for awareness; there's no code dependency between the two, just review/merge-overlap risk.Test plan
cargo check --workspace --all-targets— clean.cargo clippy --workspace --all-targets -- -D warnings— clean.cargo test --lib(rocm-dash-tui) — 804 passed, 0 failed, 4 ignored; app-module test count (209) matches pre-refactor exactly.cargo xtask manifest --check— passed.prekhooks (fmt, license headers, etc.) — all passed.AppState's public surface used byui/views is unaffected (workspace build covers all consumers, includingapps/rocm, the dash e2e tests, and thegen_cast/gen_screenshotsexamples).