Skip to content

Every #[tauri::command] looks like dead code #1543

Closed

Description

@vdavid

tl;dr: in a Tauri app, callers and impact come back empty for every #[tauri::command], even when the whole frontend calls it.

Details here:

The frontend reaches Rust through a runtime IPC hop, so there's no call for tree-sitter to see. With tauri-specta there's a name change on top (get_mcp_port becomes getMcpPort), so even a name-based guess misses.

Repro, ~30 seconds, no Tauri toolchain needed

mkdir -p /tmp/tauri-probe/src-tauri/src /tmp/tauri-probe/src
cd /tmp/tauri-probe

cat > src-tauri/src/main.rs <<'EOF'
#[tauri::command]
fn get_mcp_port() -> u16 {
    4000
}

fn main() {
    tauri::Builder::default()
        .invoke_handler(tauri::generate_handler![get_mcp_port])
        .run(tauri::generate_context!())
        .expect("error while running tauri application");
}
EOF

cat > src/app.ts <<'EOF'
import { invoke } from '@tauri-apps/api/core';

export async function loadPort(): Promise<number> {
  return invoke('get_mcp_port');
}
EOF

cat > src-tauri/tauri.conf.json <<'EOF'
{
  "productName": "tauri-probe",
  "version": "0.1.0",
  "identifier": "com.example.tauri-probe",
  "build": { "frontendDist": "../dist" },
  "app": { "windows": [{ "title": "tauri-probe" }] }
}
EOF

codegraph init && codegraph callers get_mcp_port

On main (c6aaa20): ℹ No callers found for "get_mcp_port", 6 nodes and 4 edges.
With #878: Callers of "get_mcp_port" (1): src/app.ts:1, 6 nodes and 5 edges.

On real apps

  • Cmdr (tauri-specta, Tauri 2 + Svelte 5, ~25k nodes): 291 commands gain their frontend callers, events bridge across the case change too.
  • clash-verge-rev (raw invoke): 76 of 79 commands bridge through its cmds.ts wrapper.
  • pot-desktop (raw invoke): 3 of 3.

#878 has the fix: one new file, a 4-line registration, 23 tests, no new deps. Rebased on current main today.

Reframing my earlier #772, which asked whether you'd want this. Closing that one in favor of this.

Activity

  1. colbymchenry commented on Sep 27, 2026

    @colbymchenry
    Owner

    Thanks for the detailed report, @vdavid, and thanks for using CodeGraph! This is fixed on main by #2019: Rust functions annotated #[tauri::command] are now recorded as decorated entry points, so the dead-code report no longer lists them (they're invoked from the frontend at runtime). The fix will be in the next release.

  2. vdavid commented on Sep 27, 2026

    @vdavid
    Author

    @colbymchenry, unfortunately, this doesn't solve my problem. callers and impact still return nothing for a #[tauri::command] that the frontend calls. The repro in the issue body still gives No callers found for "get_mcp_port" on main, because #2019 marks commands as used but adds no edges from the frontend invoke(...) calls. In my app Cmdr, that's ~290 commands where impact can't see the frontend at all.

    Could you reopen this issue? Or I can open a new issue just for callers/impact if you'd prefer.

    If you want the bridge in CodeGraph, I'm happy to rework my earlier PR #878 (got no reviews so far). My ideas:

    And if an IPC bridge isn't something you want in CodeGraph, that's fine too. Just say so and I'll close #878.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions