Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Tauri Commands (API)

These are the IPC commands callable from the frontend via invoke().

All commands return Result<T, String> on the Rust side; errors are thrown as strings in JS.


list_commands

invoke<Command[]>("list_commands", { sort?: SortOrder })

Returns all saved commands in the specified order.

Parameters:

NameTypeDefaultDescription
sort"recently_added" | "most_used" | "recently_used" | "alphabetical""recently_added"Sort order

Returns: Command[]


add_command

invoke<Command>("add_command", { payload: CommandPayload })

Creates a new command and generates its embedding.

Parameters:

NameTypeDescription
payload.descriptionstringHuman-readable label
payload.commandstringThe shell command
payload.aliasesstringSpace/comma-separated tags

Returns: Command (the newly created row)

Errors: "AI model still loading — try again in a moment." if model not ready.


update_command

invoke<Command>("update_command", { id: number, payload: CommandPayload })

Updates an existing command and regenerates its embedding.

Returns: Command (updated row)


delete_command

invoke<void>("delete_command", { id: number })

Deletes a command and its embedding (cascade).


record_copy

invoke<void>("record_copy", { id: number })

Increments use_count and sets last_used for the given command. Called on every clipboard copy.


search_commands

invoke<SearchResult[]>("search_commands", { query: string, limit: number })

Runs semantic search over all stored embeddings.

Parameters:

NameTypeDescription
querystringNatural language query
limitnumberMax results to return (before score filter)

Returns: SearchResult[] — sorted by score descending, filtered by RECALL_MIN_SCORE (default 0.50).


find_similar

invoke<string | null>("find_similar", { payload: CommandPayload, exclude_id?: number })

Finds an existing command semantically similar (>90%) to the given payload. Used for duplicate detection in the add/edit modal.

Returns: The matching command string, or null if none found or model not ready.


model_status

invoke<"downloading" | "loading" | "ready">("model_status")

Returns the current state of the AI model:

  • "downloading" — first run, fetching ~120 MB
  • "loading" — files present, ONNX initializing
  • "ready" — ready for inference

embedder_ready

invoke<boolean>("embedder_ready")

Shorthand boolean for model_status() === "ready".


export_commands

invoke<string>("export_commands")

Returns all commands as pretty-printed JSON (array of CommandPayload-compatible objects).


import_commands

invoke<number>("import_commands", { json: string })

Parses a JSON array of commands and inserts those not already present (matched by exact command string).

Returns: Count of newly inserted commands.


get_history_suggestions

invoke<HistorySuggestion[]>("get_history_suggestions", { limit: number })

Parses ~/.zsh_history and ~/.bash_history, counts command frequency, and returns the top limit entries.

Returns:

interface HistorySuggestion {
  command: string;
  count: number;
}

import_from_history

invoke<number>("import_from_history", { commands: string[] })

Inserts the given command strings as new recall commands (description = command). Skips exact duplicates.

Returns: Count of newly inserted commands.


check_cli_in_path

invoke<boolean>("check_cli_in_path")

Returns true if ~/.local/bin is present in the PATH environment variable.


Type Definitions

interface Command {
  id: number;
  description: string;
  command: string;
  aliases: string;
  created_at: number;     // Unix timestamp
  updated_at: number;
  use_count: number;
  last_used: number | null;
}

interface CommandPayload {
  description: string;
  command: string;
  aliases: string;
}

interface SearchResult {
  command: Command;
  score: number;          // 0–1 cosine similarity
}