Skip to content

dash-tui: replace inline AppState::new(...) literals with st() fixture across app/ tests - #670

Merged
jussielo-amd merged 1 commit into
ROCm:mainfrom
jussielo-amd:dash-tui/st-literal-dedup
Oct 14, 2026
Merged

jussielo-amd merged 1 commit into
ROCm:mainfrom
jussielo-amd:dash-tui/st-literal-dedup

Conversation

@jussielo-amd

Copy link
Copy Markdown
Collaborator

Why

The st() test fixture (app/test_support.rs) wraps AppState::new("t".into(), "default-dark".into()) so app/'s test modules don't each redefine or repeat the same construction call. Despite that, three of those modules still spell out the literal at every call site instead of invoking st():

  • crates/rocm-dash-tui/src/app/mod.rs
  • crates/rocm-dash-tui/src/app/actions.rs
  • crates/rocm-dash-tui/src/app/scrollbar.rs

This predates both the ROCMAI-84 test split and st()'s introduction — mod.rs itself still carried its own copies.

What changes

Every exact-literal call site (60 across the three files) now calls st(). actions.rs and scrollbar.rs gain the missing use ...test_support::st; import (folded into the existing press import in actions.rs); mod.rs already imported st. No production code changes, no behavior change — this is pure test-code deduplication.

Scope

A handful of differently-themed literals in mod.rs — AppState::new("test".into(), "dracula".into()) and AppState::new("test".into(), "nope".into()) — are not st()'s signature and are left untouched. The related ui/ fn key() duplication is a separate, already-tracked backlog item (ROCMAI-200) and is out of scope here.

Closes #639.

  • If this PR fixes a bug — n/a, no bug fix (test-code dedup, closes a cleanup issue).
  • If this PR adds a new subcommand or subsystem — n/a.
  • Every new or changed user-facing message — n/a, test-code-only change with no user-facing output.

Verification

  • cargo test -p rocm-dash-tui --all-targets — all existing tests pass unchanged.
  • cargo clippy -p rocm-dash-tui --all-targets -- -D warnings — clean.
  • cargo fmt -p rocm-dash-tui -- --check — clean.
  • Grepped all three files for the original literal afterward: zero remaining matches.

app/mod.rs, app/actions.rs, and app/scrollbar.rs each wrote
AppState::new("t".into(), "default-dark".into()) inline at every test
call site instead of using the st() fixture that app/test_support.rs
already provides. Switch all 57 call sites to st(), adding the import
where it was missing. No behavior change.

Closes ROCm#639.

Signed-off-by: Jussi Elo <jussi.elo@amd.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

All replacements are behaviorally equivalent and correctly scoped to tests.

0 open findings

What changed in this PR

Deduplicates test setup by consistently using the shared st() fixture without changing behavior.

Changes:

  • Replaces matching inline AppState::new(...) calls with st().
  • Adds the required fixture imports.
File Description
app/​mod.rs Uses the existing fixture in tests.
app/​actions.rs Imports and uses st().
app/​scrollbar.rs Imports and uses st().

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@jussielo-amd
jussielo-amd marked this pull request as ready for review October 14, 2026 07:52
@jussielo-amd
jussielo-amd requested a review from a team as a code owner October 14, 2026 07:52

@juhovainio juhovainio left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed this (mechanical test-only refactor closing #639) with a fan-out correctness pass plus a separate Standards/Spec pass. The substitution itself checks out completely: I independently recounted 57 replaced call sites across the 3 touched files (actions.rs 23, mod.rs 17, scrollbar.rs 17), confirmed st() is byte-for-byte identical to the literal it replaces, verified imports and mutability are handled correctly at every site, and confirmed the 6 intentionally-different literals in mod.rs are correctly left untouched. No production code touched, no scope creep.

Two non-blocking notes:

  1. The PR description says "60" replacements; the actual count (and issue #639 itself) says 57. Cosmetic only - the diff itself is complete and correct.
  2. Minor: the commit/PR title uses a bare dash-tui: scope with no Conventional Commits type prefix (repo precedent is typically test(dash-tui): or similar). Worth tightening for consistency, not blocking.

One CI item for awareness: the E2E tests check is failing on scenario chat-tool-definitions-accepted, which doesn't match the known-flaky patterns I check for - but this PR only touches unit tests in an unrelated crate, so there's no plausible causal link. Worth confirming it's pre-existing/unrelated, not something to hold this PR on.

Approving - nothing here blocks merge.

@jussielo-amd
jussielo-amd added this pull request to the merge queue Oct 14, 2026
Merged via the queue into ROCm:main with commit 0cde0aa Oct 14, 2026
66 of 68 checks passed
@jussielo-amd
jussielo-amd deleted the dash-tui/st-literal-dedup branch October 14, 2026 11:55

@rominf rominf left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Automated review · pr-review-watcher · 9529d42

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.

Review — no blocking findings

Full review of the whole change.
Closes #639 and fully does what it asks: all 57 AppState::new("t".into(), "default-dark".into()) calls in app/mod.rs (17), app/actions.rs (23) and app/scrollbar.rs (17) now use st(). The description matches the diff.

Blocking

None

Non-blocking

None

Decisions for the author

None

Positive signals

  • The sweep stays inside app/, where st() is visible (it is pub(super)). It leaves alone the same literal in ui/ and the AppState::new("test".into(), …) calls in app/mod.rs that pass different arguments. That keeps the change at exactly the scope #639 sets.

Deployment notes

None

What this covered

  • What was read: the whole diff 666cb34a…9529d421, plus app/test_support.rs, the use lines of each touched test module, and the history of st() (#635) and the earlier press() dedup (#586).
  • Replacements are identical: every removed line exactly matches the body of st(). let versus let mut is unchanged at every site.
  • Nothing missed: a grep found no remaining matching literal under app/ other than st()'s own body.
  • Test verdicts: the change adds no tests and changes no production code. Each changed test swaps an inline constructor for an identical fixture, so "passes with the production change reverted" has nothing to revert against. No branch is introduced.
  • What was run:
    • cargo test -p rocm-dash-tui --lib, using the checkout's own target/ with no RUSTC_WRAPPER: 815 passed, 3 failed. The 177 tests in the touched app:: test modules all passed.
    • The 3 failures are in agent::clients::tests, a file this change does not touch. They fail with cannot create token cache dir: Permission denied, which comes from this environment. CI reports all checks green on this head.
    • cargo clippy -p rocm-dash-tui --all-targets -- -D warnings exited 0.
  • How it was split: the change is small, so one fan-out worker took the code pass, agent-instruction adherence and history together, and the driver ran tests and the intent check.
  • Did not run: the prior-changes pass, because this review must not read earlier PR comments or reviews.
  • Not reconciled against any discussion here.

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.

dash-tui: replace inline AppState::new(...) literals with st() fixture across app/ tests

4 participants