refactor: drop crate-wide allow(dead_code) and sweep true dead code (#36) #65

Merged
timur merged 1 commit from 36-remove-dead-code-allow into development 2026-04-15 14:31:30 +00:00
Owner

Fifth slice on #36. hero_os_app/src/main.rs:6 had a crate-wide #![allow(dead_code)] hiding a large amount of accumulated unused code. Removing the blanket allow surfaced 57 items, all of which were genuinely dead. This PR deletes them.

Whole modules removed (never imported)

  • commands.rs (329 LOC) — AiCommand enum + dispatcher, superseded by mcp
  • dom_automation.rs (585 LOC) — DOM query/click helpers, never wired up

Trimmed modules

  • ai_service.rs — kept extract_tool_calls; dropped the Groq HTTP client (call_groq, system prompt, Message/GroqRequest/GroqResponse/GroqChoice/GroqMessage, constants, is_tool_call). The AI Bar talks to the Chat service via chatservice_completion (see components/ai_bar.rs:176), not Groq directly.
  • mcp.rs — kept McpResult, McpToolCall, execute_tool, and helper parse_island_id. Dropped McpTool/McpParameters schema types, get_available_tools, parse_tool_call, and get_tools_prompt (all unused after the ai_service slim).

Scattered dead items

  • config.rs: books_url, forge_url, brand_name, brand_display_name, profile_name, display_name, brand_logo
  • controller.rs: can_go_back, close_all_except, get_focused_window, get_current_context
  • registry.rs: islands_for_archipelago, has_island, len, is_empty
  • theme.rs: darken, primary_rgba, COLOR_PRESETS
  • services/env_service.rs: http_get (orphan after the auth Bearer removal in #37)
  • services/theme_service.rs: fetch_default_theme (only fetch_all_themes is used)
  • storage.rs: save_session_token, load_session_token, load_theme_preference (only clear_* helpers are still called; kept as stale-token scrubbers for upgrades)

Net impact

-1712 LOC of dead code removed. hero_os_app warning count drops 22 → 13; every removed warning was a genuine dead-code hit. Remaining 13 warnings are unused_variables + pre-existing cfg warnings for other feature flags — tackled in follow-ups.

Verification

cargo check --workspace                                # OK
cargo check -p hero_os_app                             # OK, 0 dead_code warnings
cargo check -p hero_os_app --features legacy-auth-ui   # OK

Test plan

  • Fresh build starts; desktop renders
  • AI bar still functions (tool-call dispatch via execute_toolcontroller.*)
  • Theme list still loads (fetch_all_themes path)

Refs #36.

🤖 Generated with Claude Code

Fifth slice on #36. `hero_os_app/src/main.rs:6` had a crate-wide `#![allow(dead_code)]` hiding a large amount of accumulated unused code. Removing the blanket allow surfaced **57 items**, all of which were genuinely dead. This PR deletes them. ## Whole modules removed (never imported) - `commands.rs` (329 LOC) — `AiCommand` enum + dispatcher, superseded by `mcp` - `dom_automation.rs` (585 LOC) — DOM query/click helpers, never wired up ## Trimmed modules - **`ai_service.rs`** — kept `extract_tool_calls`; dropped the Groq HTTP client (`call_groq`, system prompt, `Message`/`GroqRequest`/`GroqResponse`/`GroqChoice`/`GroqMessage`, constants, `is_tool_call`). The AI Bar talks to the Chat service via `chatservice_completion` (see `components/ai_bar.rs:176`), not Groq directly. - **`mcp.rs`** — kept `McpResult`, `McpToolCall`, `execute_tool`, and helper `parse_island_id`. Dropped `McpTool`/`McpParameters` schema types, `get_available_tools`, `parse_tool_call`, and `get_tools_prompt` (all unused after the ai_service slim). ## Scattered dead items - `config.rs`: `books_url`, `forge_url`, `brand_name`, `brand_display_name`, `profile_name`, `display_name`, `brand_logo` - `controller.rs`: `can_go_back`, `close_all_except`, `get_focused_window`, `get_current_context` - `registry.rs`: `islands_for_archipelago`, `has_island`, `len`, `is_empty` - `theme.rs`: `darken`, `primary_rgba`, `COLOR_PRESETS` - `services/env_service.rs`: `http_get` (orphan after the auth Bearer removal in #37) - `services/theme_service.rs`: `fetch_default_theme` (only `fetch_all_themes` is used) - `storage.rs`: `save_session_token`, `load_session_token`, `load_theme_preference` (only `clear_*` helpers are still called; kept as stale-token scrubbers for upgrades) ## Net impact **-1712 LOC** of dead code removed. `hero_os_app` warning count drops 22 → 13; every removed warning was a genuine dead-code hit. Remaining 13 warnings are unused_variables + pre-existing cfg warnings for other feature flags — tackled in follow-ups. ## Verification ``` cargo check --workspace # OK cargo check -p hero_os_app # OK, 0 dead_code warnings cargo check -p hero_os_app --features legacy-auth-ui # OK ``` ## Test plan - [ ] Fresh build starts; desktop renders - [ ] AI bar still functions (tool-call dispatch via `execute_tool` → `controller.*`) - [ ] Theme list still loads (`fetch_all_themes` path) Refs #36. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
refactor: drop crate-wide allow(dead_code) and sweep true dead code (#36)
Some checks failed
Build and Test / test (pull_request) Failing after 38s
1665946ac7
hero_os_app had a crate-wide `#![allow(dead_code)]` at main.rs top,
hiding a large amount of unused code accumulated over time. Remove the
blanket allow and delete what it was hiding:

Whole modules (never imported):
- commands.rs (329 LOC) — AiCommand enum + dispatcher, replaced by mcp
- dom_automation.rs (585 LOC) — DOM helpers, never wired up

Trimmed modules:
- ai_service.rs — kept `extract_tool_calls`; dropped the Groq HTTP
  client + all its request/response structs. The AI Bar talks to the
  Chat service via `chatservice_completion`, not Groq directly.
- mcp.rs — kept `McpResult`, `McpToolCall`, `execute_tool`, and their
  private helper `parse_island_id`. Dropped `McpTool`/`McpParameters`
  schema types, `get_available_tools`, `parse_tool_call`, and
  `get_tools_prompt` (all unused after ai_service slim).

Scattered dead items:
- config.rs: `books_url`, `forge_url`, `brand_name`,
  `brand_display_name`, `profile_name`, `display_name`, `brand_logo`
- controller.rs: `can_go_back`, `close_all_except`,
  `get_focused_window`, `get_current_context`
- registry.rs: `islands_for_archipelago`, `has_island`, `len`,
  `is_empty`
- theme.rs: `darken`, `primary_rgba`, `COLOR_PRESETS`
- services/env_service.rs: `http_get` (orphan after the auth Bearer
  removal)
- services/theme_service.rs: `fetch_default_theme` (only
  `fetch_all_themes` is used)
- storage.rs: `save_session_token`, `load_session_token`,
  `load_theme_preference` (only `clear_*` helpers are still called;
  kept as stale-token scrubbers for upgrades)

Net: -1712 LOC of dead code. Both `cargo check --workspace` and
`cargo check -p hero_os_app --features legacy-auth-ui` pass with zero
`dead_code` warnings in hero_os_app.

Refs #36.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
timur merged commit 4631f48aab into development 2026-04-15 14:31:30 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lhumina_code/hero_os!65
No description provided.