Skip to main content

Tauri Commands

The frontend calls the backend exclusively through Tauri commands, wrapped in src/lib/tauri.ts. Every command is registered in the invoke_handler in src-tauri/src/lib.rs.

Show persistence (crates/show/src/commands.rs)​

save_show(show, path)​

Validates the serialized show against the schema and writes it to path.

  • Arguments: show: Show, path: string
  • Returns: void (errors as string)

save_show_as(show)​

Opens a native save dialog, ensures the .nque extension, validates, and writes.

  • Arguments: show: Show
  • Returns: the chosen path, or null if cancelled

load_show(path?)​

Loads from path, or opens a native open dialog when path is omitted. Validates and parses the file.

  • Arguments: path?: string
  • Returns: { path: string; showFile: ShowFile } | null

confirm_discard_changes(isDirty)​

Returns true immediately when isDirty is false; otherwise shows a native Yes/No confirmation.

  • Arguments: isDirty: boolean
  • Returns: boolean

PDF import (src-tauri/src/commands.rs)​

import_pdf_show(path?, config?)​

The only command that wires the pipeline together:

  1. Resolves the path (native open dialog when omitted) and reads the bytes.
  2. Calls ocr::pipeline::extract_text on a blocking thread.
  3. Calls show::pipeline::build_show_from_text with the parse config.
  4. Stamps the title from the file name and a description noting the OCR source.
  5. Emits ocr-import-progress events throughout.
  • Arguments: path?: string, config?: TextParseConfig
  • Returns: ShowFile | null (null when cancelled)

Window management (src-tauri/src/lib.rs)​

open_display_window()​

Creates a new live display window with a unique label (live-display-N).

  • Arguments: none
  • Returns: the generated window label

Error handling​

Commands return Result<T, String>. The frontend wrappers surface failures as rejected promises; the file-actions hook reports them via window.alert and logs them. Import failures are also stored in the import slice and shown in the progress dialog.

Full TypeScript signatures: Commands API reference.