[Bug]: unused import / dead method warnings in CLI startup.rs, runtime/mod.rs and external_editor.rs
- Ngôn ngữ chính
- Rust
- Star
- 2.3k
- Fork
- 231
- Merge trung bình
- 2 giờ 49 phút
- Pull request đã merge (30 ngày)
- 589
Mô tả
## Summary
The upstream CI logs for `main` report three cross-platform unused-import/dead-code warnings in the CLI. Evidence from GitHub Actions run [33035362609](https://github.com/GCWing/BitFun/actions/runs/33035362609) (reproduced on ubuntu/macos/windows compilation units and across runs 33050974141 and 33047041028):
- `warning: unused import: bitfun_core_types::model::ModelMutation` --> `src/apps/cli/src/ui/startup.rs:33:5`
- `warning: method agent_event_source is never used` --> `src/apps/cli/src/runtime/mod.rs:121:19`
- `warning: unused import: OsStr` --> `src/apps/cli/src/modes/chat/external_editor.rs:1:16`
Cross-checking the crate:
- The `ModelMutation` import in `ui/startup.rs` has no consumer in that file; upstream mutation handling goes through the model selection module. It is pure refactoring leftover.
- `CliRuntimeContext::agent_event_source` has no caller left anywhere in the crate: its only historical consumer (the embedded app server) was removed upstream.
- In `external_editor.rs`, `OsStr` is consumed only by the Windows batch-quoting helper, while `OsString` is used unconditionally; the combined `use std::ffi::{OsStr, OsString};` therefore triggers `unused import: OsStr` on non-Windows builds.
## Root Cause Analysis
- One leftover import after a refactor, one accessor whose only consumer was removed upstream, and one combined import mixing a Windows-only symbol with a cross-platform symbol. Each of the three warnings is structural and reproduced by every full CI run of `main` (runs 33035362609 / 33050974141 / 33047041028).
## Proposed Fix
- Delete the unused `ModelMutation` import line in `ui/startup.rs`.
- Delete the unused `agent_event_source` method in `runtime/mod.rs` (keep the underscore-prefixed `_agent_event_queue_owner` field and the `AgentEventSource` import, which still have live consumers).
- Split the import in `external_editor.rs` into `#[cfg(windows)] use std::ffi::OsStr;` plus an unconditional `use std::ffi::OsString;`.
No `#[allow]` suppression is involved; the dead symbols are removed and the platform-scoped import is scoped precisely.
Hướng dẫn đóng góp
Hướng nghiên cứu
Bắt đầu với ba tệp được báo cáo: src/apps/cli/src/ui/startup.rs, src/apps/cli/src/runtime/mod.rs và src/apps/cli/src/modes/chat/external_editor.rs. Chạy việc biên dịch hoặc các bước kiểm tra CLI trên các nền tảng, sau đó xóa các symbol không được sử dụng và giới hạn phạm vi của OsStr cho Windows như đã mô tả. Hoàn tất khi các cảnh báo không còn xuất hiện và helper dành riêng cho nền tảng vẫn build được.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- rust
- Lĩnh vực
- cli
- Loại issue
- Lỗi
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức độ hoạt động
- Sôi nổi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức phù hợp với người mới
- 88/100