From 9d1e4e8134faa9a3081259fc974ea31d66b0173c Mon Sep 17 00:00:00 2001 From: user Date: Fri, 28 Aug 2026 02:30:07 +0800 Subject: [PATCH] fix(cli): gate test-only selector and model helpers behind cfg(test) 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 80820986b (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). --- src/apps/cli/src/model_selection.rs | 1 + src/apps/cli/src/ui/agent_selector.rs | 1 + src/apps/cli/src/ui/chat/popups.rs | 1 + 3 files changed, 3 insertions(+) diff --git a/src/apps/cli/src/model_selection.rs b/src/apps/cli/src/model_selection.rs index 0c0e0ec9c3..7cea572033 100644 --- a/src/apps/cli/src/model_selection.rs +++ b/src/apps/cli/src/model_selection.rs @@ -17,6 +17,7 @@ pub(crate) fn resolve_mode_model_id(ai_config: &AIConfig) -> Option { /// Resolve the Runtime-owned Session selector to the concrete catalog model /// used by CLI display surfaces. A missing selector is limited to the fresh /// Session fallback; it does not become Session authority in the Client. +#[cfg(test)] pub(crate) fn resolve_session_model_display_id( ai_config: &AIConfig, session_selector: Option<&str>, diff --git a/src/apps/cli/src/ui/agent_selector.rs b/src/apps/cli/src/ui/agent_selector.rs index ad7b45c0d4..b8786e6348 100644 --- a/src/apps/cli/src/ui/agent_selector.rs +++ b/src/apps/cli/src/ui/agent_selector.rs @@ -76,6 +76,7 @@ impl AgentSelectorState { ); } + #[cfg(test)] pub(super) fn show_modes_only( &mut self, agents: Vec, diff --git a/src/apps/cli/src/ui/chat/popups.rs b/src/apps/cli/src/ui/chat/popups.rs index 18a86dc755..6f6f7bcf9f 100644 --- a/src/apps/cli/src/ui/chat/popups.rs +++ b/src/apps/cli/src/ui/chat/popups.rs @@ -265,6 +265,7 @@ impl ChatView { self.popup_stack.push(PopupType::AgentSelector); } + #[cfg(test)] pub(crate) fn show_agent_modes_only( &mut self, agents: Vec,