GCWing / GCWing/OpenBitFun

[Bug]: dead_code warnings for three CLI helpers referenced only from test code

Offen Anfängerfreundlich
#2,567 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Rust
Sterne
2.2k
Forks
229
Ø Merge
2 Std. 46 Min.
Gemergte PRs (30 T.)
577

Beschreibung

## Summary

The upstream CI logs for `main` report dead-code warnings for three CLI helpers that are referenced only from test code. Evidence from GitHub Actions run [33035362609](https://github.com/GCWing/BitFun/actions/runs/33035362609) (the same entries repeat across runs 33050974141 and 33047041028):

- `warning: function resolve_session_model_display_id is never used` --> `src/apps/cli/src/model_selection.rs:20:15`
- `warning: method show_modes_only is never used` --> `src/apps/cli/src/ui/agent_selector.rs:79:19`
- `warning: method show_agent_modes_only is never used` --> `src/apps/cli/src/ui/chat/popups.rs:268:19`

Cross-checking the crate shows:

- `resolve_session_model_display_id` is called only by the tests in the same file.
- `AgentSelectorState::show_modes_only` is called only by tests in the same file and via `ChatView::show_agent_modes_only`.
- `ChatView::show_agent_modes_only` is called only by the popup test in the same file.

So the production binary carries three symbols with zero production callers, and rustc reports them as dead code on every full CI run.

## Root Cause Analysis

- All three helpers were kept public to the module/supermodule for test reuse, but after refactors their production call sites disappeared.
- rustc's `dead_code` lint runs on non-test builds, where `#[cfg(test)]` callers do not exist, so the helpers are reported as never used. The warnings are structural: every full CI run of `main` (runs 33035362609 / 33050974141 / 33047041028) reproduces them.

## Proposed Fix

Gate each helper with `#[cfg(test)]` (one attribute line each, before `resolve_session_model_display_id`, `show_modes_only`, and `show_agent_modes_only`), so:

- non-test builds no longer emit the dead-code warnings and no longer carry the dead symbols;
- the unit tests keep compiling and using all three helpers unchanged.

No `#[allow(dead_code)]` suppression is involved.

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Start in src/apps/cli/src/model_selection.rs, src/apps/cli/src/ui/agent_selector.rs, and src/apps/cli/src/ui/chat/popups.rs, locating the three named helpers and their test callers. Verify the unit tests still compile and pass, then check a non-test build or CI run to confirm the dead_code warnings and symbols are gone.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
rust
Bereich
cli, testing
Issue-Typ
Bug
Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Aktivitätsstatus
Aktiv
Klarheit
Klar beschrieben
Anfängerfreundlichkeit
88/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.