ROCMAI-51: Modularize crates/rocm-dash-tui/src/agent.rs - #456
jussielo-amd wants to merge 2 commits into
Conversation
Phase 3 of the ROCMAI-27 modularization plan. Splits agent.rs into
agent/{mod,snapshot,tools,clients}.rs, mirroring the app/mod.rs ->
app/chat.rs/slash.rs/summary.rs mechanical-relocation convention.
No behavior change; public agent::* paths are preserved via re-exports.
Signed-off-by: Jussi Elo <jussi.elo@amd.com>
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The mechanical relocation preserves the public surface, behavior, and existing test coverage.
Review effort: Balanced
Findings: None
What changed in this PR
Modularizes the dashboard chat agent while preserving its public API and behavior.
Changes:
- Splits agent logic into snapshot, tool, and client modules.
- Keeps shared types and re-exports in
agent/mod.rs. - Updates architecture documentation.
| File | Description |
|---|---|
docs/architecture.md |
Documents the new module layout. |
agent.rs |
Removes the former monolithic module. |
agent/mod.rs |
Defines shared seams and preserves public exports. |
agent/snapshot.rs |
Contains telemetry JSON helpers and tests. |
agent/tools.rs |
Contains tool definitions, registration, and tests. |
agent/clients.rs |
Contains backend implementations and tests. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
🔴 Automated review · pr-review-watcher · ce02115 This automation never files a GitHub approval, so no approving review will appear here whatever the outcome — the merge decision stays with a human reviewer. SummarySplits the 2,711-line 🚫 Blocking (must fix before merge)
Non-blocking
No prompt-injection content and no internal names, hostnames or internal links were found anywhere in the diff. |
juhovainio
left a comment
There was a problem hiding this comment.
This is a clean, genuinely mechanical split. I diffed every function, macro invocation, tool array, and test byte-for-byte between the old agent.rs and the new agent/{mod,snapshot,tools,clients}.rs files, and the public surface and behavior are fully preserved, no scope creep, no dropped tests. The module boundaries match ROCMAI-51 exactly (snapshot.rs has no rig dependency, tools.rs holds the Skill wrappers, clients.rs holds the backends).
One thing to fix before merge (left as an inline comment): the docs/architecture.md paragraph you're editing still claims app/mod.rs "is not yet modularized", which is already false and contradicted by this very PR's own doc comment describing the app/mod.rs split as the established convention being mirrored. Since you're touching this exact sentence, worth correcting the adjacent stale claim too.
A few minor, non-blocking notes:
- The epic's (ROCMAI-27) verification checklist mentions a Windows full-workspace CI job and
cargo xtask affectedfor scoping test runs; the PR's test plan doesn't mention either explicitly (test-count-diff intent looks satisfied here: 40 tests before and after, none dropped or duplicated). fixture_snapshot()was centralized inmod.rsrather than duplicated per test file — a reasonable call since it's shared setup, just flagging the literal deviation from "tests colocate per module."- Minor Message Chains smell in clients.rs reaching through tools.rs/mod.rs for a couple of items — inherent to the split, not worth undoing.
Correct doc-comment pointers left behind by the agent/ split (skills.rs, llm.rs, approval.rs, dash.rs) and a stale app/mod.rs modularization claim in architecture.md. Also make snapshot.rs's fixture_snapshot() calls consistent with tools.rs/clients.rs, and fix agent/mod.rs's broken intra-doc links to private submodules. Signed-off-by: Jussi Elo <jussi.elo@amd.com>
|
Pushed ce02115 addressing review feedback:
|
siloteemu
left a comment
There was a problem hiding this comment.
🔴 Automated review · pr-review-watcher · ce02115
Change request filed by automation. The finding below is the blocking half of the round published in the report comment on this pull request; the non-blocking notes stay there. This will be withdrawn once it is addressed — no human needs to clear it.
docs/architecture.md:42 — the doc remediation in this PR's head commit replaced a still-accurate statement of outstanding work with one that reads as done.
The base text reads:
rocm-dash-tui'sagent.rsandapp/mod.rsare not yet modularized — see .
Splitting agent.rs out of that sentence is correct and is what this PR does. But the head commit rewrote the whole clause into:
app/mod.rswas already split intoapp/chat.rs,app/slash.rs, andapp/summary.rs, following the same mechanical-relocation convention this phase'sagent.rssplit mirrors.
That sentence is literally true about those three files having been extracted — they were, long before this PR — while deleting both the statement that the module is still unmodularized and its tracking reference. app/mod.rs remains the largest file in the crate, over three times the size of the file this PR just split. The rendered result is prose that no longer describes the code: a reader concludes the dashboard-TUI modularization is finished. The document also now disagrees with itself, since the paragraph immediately above still flags rocm-core's lib.rs as not yet modularized with its tracking reference intact.
This is the standing "claim stated in prose that the code does not provide" pattern, and it was introduced by a commit whose stated purpose was fixing documentation accuracy — which is why it is worth a round rather than a note. Nothing else in the split is at issue: the code motion itself verified clean end to end.
Fix: restore the incompleteness statement and its tracking reference, keeping the accurate observation if it is wanted — for example:
app/chat.rs,app/slash.rs, andapp/summary.rswere previously extracted fromapp/mod.rsfollowing the same mechanical-relocation convention, butapp/mod.rsitself is not yet modularized — see .
Please do not put a line count in the document; it would go stale on the next edit.
Non-blocking observations are in the review comment on this PR.

Summary
crates/rocm-dash-tui/src/agent.rs(2,711 lines) into a directory moduleagent/{mod,snapshot,tools,clients}.rsagent/mod.rskeeps only the sharedAgentClientseam (AgentError,StateSnapshot,InferenceParams,REQUEST_TIMEOUT) plus re-exports preserving the existingcrate::agent::*/rocm_dash_tui::agent::*public surfaceagent/snapshot.rs— pure JSON telemetry helpers, norigdependencyagent/tools.rs— rigToolwrappers/macros and ROCm read/mutating tool dispatchagent/clients.rs— the fourAgentClientbackends (Rig, ChatGPT, Anthropic, Mock)app/mod.rs→app/chat.rs/slash.rs/summary.rsmechanical-relocation conventiondocs/architecture.mdupdated in this same PR to reflect the new module mapmainby function/module name rather than the ticket's stale line-range estimates, per the epic's re-verification ruleROCM_READ_TOOL_NAMESconsumer inapps/rocmverified unaffectedcomplete()body triplicated across the three real backends, now more visible as an extraction candidate in the isolatedagent/clients.rsTest plan
cargo build(workspace) — cleancargo clippy --workspace --all-targets -- -D warnings— zero warningscargo test/cargo nextest run— all pass; agent module test count unchanged (40 tests, same functions, none dropped/duplicated)cargo xtask manifest --check— passes