Skip to content

chore(dead-code): remove unused crates, ipc, and helpers - #1960

Merged
Harry19081 merged 9 commits into
developfrom
chore/remove-unused-dead-code
Sep 18, 2026
Merged

Harry19081 merged 9 commits into
developfrom
chore/remove-unused-dead-code

Conversation

@beruro

@beruro beruro commented Sep 18, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

An unused-code audit found several production-gated leftovers that nothing called: the unwired orgtrack-graph / orgtrack-sync crates, registered but unused git/GitHub/perf Tauri commands, a deprecated SessionService.resume duplicate, unused agent session/tool TypeScript wrappers, a dead handoff exhaustiveness stub with stale allow(dead_code) attributes, LSP #[tauri::command] macros that were never registered, leftover HTTP session stubs, unused search/repo/mobile TypeScript wrappers, superseded usage-dashboard IPC, and unused LSP State wrappers after the macros were stripped.

Solution

Remove those unused surfaces in nine stacked commits (kept separate for review):

  1. Drop unused orgtrack graph/sync crates and sync_export adapters.
  2. Unregister unused git_commit, github_fetch_profile, and perf JSON/hash IPC; keep the library helpers.
  3. Delete SessionService.resume and unused hosted-session factory exports; keep resumeCli and isHostedFromSearchParams.
  4. Delete unused agent session/tool TypeScript wrappers; keep live RPC procedures and wrappers that still have callers.
  5. Delete the unused handoff exhaustiveness stub and stale admission allow(dead_code) attributes.
  6. Strip unregistered LSP #[tauri::command] macros; keep manage_lsp / LspManager as library code.
  7. Delete the unused src/api/http/session/local.ts no-op stubs.
  8. Delete unused search/repo/lineage/perf/mobile TypeScript wrappers; keep RPC procedures and live named helpers.
  9. Unregister superseded usage-dashboard and unused GitHub/skills IPC; delete unused LSP commands/server.rs State wrappers. Keep GitHub library helpers for tests.

This supersedes #1950, #1951, #1956, #1957, #1958, and #1959. SqlEditor cleanup already landed in #1948.

Potential risks

Reviving Database query UI, orgtrack graph sync, GitHub profile/list/clone IPC, Merkle TS wrappers, or the removed TypeScript wrappers requires restoring them from git history. Store removeSession / updateSessionStatus, RPC procedures, resumeCli, manage_lsp, usage_dashboard_overview, and live git/perf/GitHub library APIs are unchanged. GroupChatContext, manage_nodes, and unused SessionService methods were left in place because they need product confirmation or a coordinated ChatPanel refactor. cargo check -p org2 was not rerun here because sidecar binaries are missing in the worktree.

Verification

Cherry-pick of the original six commits onto current develop (5984416aa, including #1948) applied cleanly. The three follow-up commits were made on the stacked branch.

  • pnpm exec vitest run --config config/vitest.config.ts src/engines/ChatPanel/hooks/useWorkspaceChat/useWorkspaceChat.test.ts — 4 passed
  • pnpm exec vitest run --config config/vitest.config.ts src/hooks/fileReview/__tests__/useFileReview.test.ts — 2 passed
  • pnpm exec vitest run --config config/vitest.config.ts src/modules/WorkStation/CodeEditor/Panels/EditorPrimarySidebar/content/SearchContent/useSearchContent/__tests__/useSearchResults.loadMoreListeners.test.ts src/services/navigation/CodeNavigationService.test.ts src/modules/MainApp/Settings/sections/__tests__/MobileRemoteSettingsSection.relayPreset.test.ts src/api/tauri/usageDashboard/index.test.ts — 4 files, 48 passed
  • cargo test -p agent_core --lib coordination::agent_org_turn_contexts — 24 passed
  • cargo check -p lsp — passed after deleting commands/server.rs
  • Commit hooks: lint-staged / oxlint / eslint / prettier / staged TypeScript / clippy on agent_core and lsp (org2 clippy issues in unstaged files ignored)

NOT RUN on the stacked branch: full pnpm test / pnpm typecheck / cargo test -p agent_core / cargo check -p org2 / browser, Wingman, or GitHub clone UI.

orgtrack-graph and orgtrack-sync were never wired into the app. Drop them
and the unused sync_export adapters that only fed that pipeline.
These handlers were registered but never invoked from the frontend.
Keep the git commit helper and perf_utils library APIs for tests.
CLI resume already goes through resumeCli, and the hosted session factory
was a no-op after local-only routing.
Callers already use the RPC procedures or store mutations. Keep the
live wrappers and the RPC layer itself.
The handoff exhaustiveness stub was unused, and the admission builders
are already called from production paths.
These helpers are library entry points for manage_lsp and tests, not
registered IPC commands.

@Harry19081 Harry19081 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Went through all six commits against develop. Everything removed here is genuinely unused: no frontend or Rust callers for the orgtrack graph/sync crates and sync_export adapters, the 13 IPC registrations, the TS wrappers (every remaining call goes through rpc.* procedures), or SessionService.resume. The four AgentOrgTurnAdmission constructors all have non-test callers, so dropping their allow(dead_code) is safe, and TaskExecutionHandoffState::as_wire already matches every variant with no wildcard, so the exhaustiveness stub was redundant.

The main issue: in three places the PR unregisters something but keeps a body that nothing calls, and describes it as a "library helper". Inline comments below. Two more that aren't on diff lines:

  • perf_utils still carries the IPC surface. All 10 unregistered functions keep #[command] and use tauri::command in perf-utils/src/hash.rs and json_fast.rs, and perf-utils/Cargo.toml:9 still says they are "re-registered from commands/handler_list.inc". Four of them (parse_json_file, parse_json_batch, compute_sha256_bytes, compute_blake3_bytes) have no caller at all. The other six are only called from perf-utils/src/tests/ and src-tauri/tests/perf_pipeline.rs. Deleting both modules also lets sha2, blake3 and simd-json go from perf-utils; nothing else in that crate uses them.
  • Stale LSP doc comments now say these are Tauri commands: lsp/src/manager.rs:5 ("the Tauri lsp_start_server command"), manager.rs:572, log_buffer.rs:102, server/lifecycle.rs:187.

Description:

  • The tauri-ipc verification line greps for compute_json_hash|json_canonicalize. Neither of those names is in this PR (the removed ones are compute_sha256*, compute_blake3*, *_json_*), so that search couldn't have verified anything.
  • Potential risks mentions "Reviving Database query UI", but this PR doesn't touch the Database UI (that was #1948).
  • cargo check -p org2 is the build that expands handler_list.inc; CI will cover it, but please confirm it's green before merge.

Follow-up, not blocking this PR: 33 more commands in handler_list.inc have no frontend caller and no Rust caller. Most were orphaned when the frontend wrappers were deleted in earlier unused-export sweeps (243061b, fbd8f0c, cabadcf):

  • {cline,kimi,mimo_code,omp,pi,qoder_cli,qwen_code,trae,workbuddy}_recent_paths and external_history_auto_import_recent_paths
  • usage_dashboard_{rounds,sessions,summary,trends}
  • github_{check_token,clone_repo,create_branch,list_branches,list_repos} and server_check_github_visibility
  • agent_session_{apply,delete,enter}_worktree
  • browser_webview_{bring_to_front,send_to_back}
  • builder_profile_exemplars, get_session_tool_usage_attributions_for_call, get_local_lan_ip, skills_hub_update
  • project_cancel_routine_run and project_{list,share,unshare}_org_skill(s): these were added 2026-09-06 and never had a caller, so they may be backend-first work waiting on UI. Worth checking with the author before deleting.

/// Create a commit with the given message
/// Uses run_git_command helper with retries and clean environment
#[tauri::command(rename_all = "camelCase")]
pub fn git_commit(folder_path: String, message: String) -> Result<(), String> {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the registration gone, git_commit has no production caller; the only caller is git_commit_treats_clean_tree_as_ok in tests/bundle_tests.rs. That leaves bundle.rs entirely dead: this function plus the private run_git_command it uses. I'd delete bundle.rs, its test module, and the pub use bundle::* line in git/src/lib.rs rather than keep it as a "library helper" that nothing calls.

While you're here: the git2 comment in git/Cargo.toml still says git2 is "only used by bundle::calculate_ahead_behind". That function is gone; git2 is actually used by watch/git_status.rs.

@@ -274,7 +273,6 @@ session_persistence::get_session_tool_usage_attributions_for_call,
// Git Bundle commands (for cloud session upload - preserves git history)
// Git Bundle Sync commands (for pull/push during cloud sessions)
// Git operations for conflict resolution

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This leaves four section comments in a row with nothing under them. "Git Bundle commands" and "Git Bundle Sync commands" were already empty; "Git operations for conflict resolution" becomes empty with this PR. Please drop lines 273–275.

@@ -618,18 +616,6 @@ file_ops::filter_ignored_paths,
file_ops::list_directory_filtered,
file_ops::list_directory_tree,
// Performance optimization commands

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See the review summary: the 10 unregistered perf_utils functions still have #[command] on them, and none has a production caller (4 have no caller at all; 6 are only called from tests). They're dead code rather than in-crate APIs, so I'd delete hash.rs / json_fast.rs along with their tests and the sha2 / blake3 / simd-json dependencies.

//! LSP command helpers
//!
//! Exposes LSP functionality to the frontend via Tauri commands.
//! Library helpers used by agent-core (`manage_lsp`) and tests. These

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only holds for part of the module. manage_lsp imports 6 of these (lsp_check_installed, lsp_get_install_command, lsp_get_uninstall_command, lsp_get_supported_languages, lsp_get_workspace_config, lsp_set_server_enabled). The other 17 have no caller anywhere: everything in server.rs, plus lsp_get_cached and lsp_is_server_enabled. (The lsp_did_open in e2e-test/src/lsp.rs is a local helper with the same name.) Stripping the macros turns a dead IPC surface into a dead library surface; I'd delete them instead.


/// Start an LSP server for a specific language
#[tauri::command]
pub async fn lsp_start_server(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing calls any function in this file. They all take tauri::State<'_, LspManagerState>, so they only ever made sense as commands; agent-core goes to LspManager directly. I'd delete the file along with GlobalLspConfig / BrokenServerInfo, which only these functions use.


/// Return cached LSP servers if fresh, otherwise empty (caller should fetch fresh).
#[tauri::command]
pub fn lsp_get_cached() -> Vec<LanguageServerInfo> {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lsp_get_cached has no callers, and it's the only reader of cache::load_lsp. Meanwhile lsp_check_installed (used by manage_lsp) still calls cache::save_lsp on every scan, so the LSP cache becomes write-only disk I/O. I'd delete this function and the cache write, or the whole cache module.

return searchParams.get("source") === "market";
}

export function isHostedFromSearchParams(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unified.ts was the only importer of ./local, so this change orphans src/api/http/session/local.ts: about 140 lines of no-op stubs that exported sessionApi, under a header saying they're "kept for UnifiedSessionApi shape". That file can go in this PR too.

The hosted factory is gone and nothing imported the no-op local
session API. Live session ops stay on Tauri/RPC.
Callers already use live RPC, store, or other named helpers. Keep the
RPC procedures and the wrappers that still have production imports.
Frontend already uses usage_dashboard_overview and LspManager directly.
Unregister the leftover IPC names and delete the unused LSP State
wrappers. Keep GitHub library helpers for tests.
@Harry19081
Harry19081 merged commit 7cf6d30 into develop Sep 18, 2026
16 of 17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dev-tooling Developer tooling, build, CI, tests, diagnostics, or release maintenance Maintenance, CI, build, release, cleanup, or tooling work

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants