fix(cli): gate test-only selector and model helpers behind cfg(test) - #2573
Open
1688mengdie wants to merge 1 commit into
Open
fix(cli): gate test-only selector and model helpers behind cfg(test)#25731688mengdie wants to merge 1 commit into
1688mengdie wants to merge 1 commit into
Conversation
Three CLI helpers are referenced exclusively from #[cfg(test)] modules, so release builds report them as dead code in the upstream CI logs: - resolve_session_model_display_id in model_selection.rs (called only by the tests in the same file) - AgentSelectorState::show_modes_only in ui/agent_selector.rs (called only by tests in the same file and via ChatView::show_agent_modes_only) - ChatView::show_agent_modes_only in ui/chat/popups.rs (called only by the popup test in the same file) Gate each helper with #[cfg(test)] so the production binary no longer carries dead symbols while the unit tests keep using them. Adopted-from: taiji 8082098 (cfg(test) gate hunks). Test: cargo check --locked -p bitfun-cli exit 0 with no dead_code warnings for the three symbols; cargo test -p bitfun-cli --bin bitfun model_selection exit 0 (6 passed); cargo test -p bitfun-cli --bin bitfun agent_selector exit 0 (12 passed); cargo test -p bitfun-cli --bin bitfun pending_mode_update (the show_agent_modes_only consumer) exit 0 (1 passed). AI: implemented with AI assistance, lightly tested (cargo check + targeted unit tests).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #2567
Gate three CLI helpers that are referenced exclusively from
#[cfg(test)]modules behind#[cfg(test)](one attribute line each):resolve_session_model_display_idinsrc/apps/cli/src/model_selection.rsAgentSelectorState::show_modes_onlyinsrc/apps/cli/src/ui/agent_selector.rsChatView::show_agent_modes_onlyinsrc/apps/cli/src/ui/chat/popups.rsProduction builds no longer carry the three dead symbols or emit their dead-code warnings; the unit tests keep using the helpers unchanged (see issue #2567 for the run evidence with file:line and rule names).
Type and Areas
Type: bug fix (build warnings cleanup)
Areas: Rust CLI
Motivation / Impact
No direct user-facing change. Non-test builds stop emitting 3 dead-code warnings on every full CI run of
main, and the production binary stops carrying test-only symbols.Verification
cargo check --locked -p bitfun-clion Windows: exit 0, the three dead_code warnings gone (crate baseline 19 warnings down to 16 on Windows; the remaining ones are other symbols covered by separate PRs).cargo test --locked -p bitfun-cli --bin bitfun model_selection(6 passed),... agent_selector(12 passed),... pending_mode_update— theshow_agent_modes_onlyconsumer test (1 passed), 0 failed overall.Reviewer Notes
#[allow]suppression is introduced.Checklist