Skip to content

systems tauri command shell

Douwe de Vries edited this page Jul 1, 2026 · 1 revision

Tauri command shell

Active contributors: Douwe de Vries

Purpose

The Tauri command shell is the desktop boundary between the React renderer and the Rust core. It registers command names, owns managed desktop state, grants file access, offloads blocking work, and adapts Local AI providers for core service calls.

Directory layout

Path Role
src-tauri/src/main.rs Creates the Tauri builder, managed state, dialog plugin, and generated invoke handler.
src-tauri/src/tauri_command_list.rs Single macro list of command names registered with Tauri.
src-tauri/src/commands.rs Module facade that re-exports command handlers.
src-tauri/src/commands/csv.rs CSV, paste, quick, preview, and preflight command handlers.
src-tauri/src/commands/shared.rs Shared authorization, dialogs, spawn_blocking, service factory, and output suffix helpers.
frontend/src/tauri.ts Renderer-side invoke wrappers and browser/test fallbacks.

Key abstractions

  • tauri_command_list! is the source of truth for command names exposed to the renderer.
  • tauri::Builder::manage registers AnonymizeJobStore, LocalAiDownloadStore, PathAccess, and SettingsStore.
  • Command modules convert frontend request DTOs into core params, then return serializable response DTOs.
  • run_blocking moves CPU or file-system work off the async command handler thread.
  • authorize_or_confirm_input_file and authorize_or_confirm_output_file bridge manual paths with Tauri dialog confirmation.
  • frontend/src/tauri.ts keeps command names and argument casing aligned with Rust #[serde(rename_all = "camelCase")] request structs.

How it works

sequenceDiagram
    participant UI as React hooks
    participant Wrap as frontend/src/tauri.ts
    participant Tauri as Tauri invoke handler
    participant Cmd as command handler
    participant Access as PathAccess
    participant Core as AnonymizerService

    UI->>Wrap: analyzeCsv(filePath, sampleRowCount, suffix)
    Wrap->>Tauri: invoke("analyze_csv", args)
    Tauri->>Cmd: analyze_csv()
    Cmd->>Access: authorize or confirm input
    Cmd->>Core: analyze_csv_sampled()
    Core-->>Cmd: HeadersData
    Cmd->>Access: grant output suggestion
    Cmd-->>Wrap: AnalyzeResponse
    Wrap-->>UI: typed Promise result
Loading

src-tauri/src/main.rs includes tauri_command_list.rs and passes the list into tauri::generate_handler! through a small macro adapter. CSV commands call AnonymizerService, direct-input commands call csv_anonymizer_core::direct_input, job commands use Background jobs, and Local AI commands create providers from src-tauri/src/local_ai.

Integration points

Entry points for modification

  • Add or remove command registrations in src-tauri/src/tauri_command_list.rs.
  • Add command modules or exports in src-tauri/src/commands.rs.
  • Change CSV, paste, quick, preview, or preflight behavior in src-tauri/src/commands/csv.rs.
  • Change command-side file authorization helpers in src-tauri/src/commands/shared.rs.
  • Update renderer wrappers and browser/test fallbacks in frontend/src/tauri.ts.

Key source files

  • src-tauri/src/main.rs
  • src-tauri/src/tauri_command_list.rs
  • src-tauri/src/commands.rs
  • src-tauri/src/commands/csv.rs
  • src-tauri/src/commands/shared.rs
  • frontend/src/tauri.ts

Clone this wiki locally