Skip to content

Tauri command API

The frontend uses typed wrappers in src/services/backend.ts; that module invokes these commands through @tauri-apps/api/core. JavaScript argument names use camel case where Tauri maps them to Rust snake-case parameters.

invoke<KernelState>("ensure_kernel", { tabIndex: number });
  • Ensures a map entry for the tab.
  • Spawns a process only when no entry exists.
  • Validates the tab index and performs a five-second protocol readiness handshake for a new process.
  • Returns a KernelState value such as "idle".
  • Returns "stopped" for an existing stopped sentinel rather than respawning it.
invoke<KernelResponse>("execute_cell", {
tabIndex: number,
cellId: string,
code: string,
});
  • Requires an existing, non-stopped kernel entry.
  • Enqueues an execute protocol request.
  • Uses cellId as the protocol correlation ID.
  • Resolves to the deserialized Python response object.
  • Rejects with a string on lifecycle or transport failure.
invoke<KernelState>("restart_kernel", { tabIndex: number });
  • Removes and kills the current instance when present.
  • Spawns a new Python process.
  • Inserts it into the tab map.
  • Returns a KernelState value.

Frontend side effects after success clear outputs, set displayed counts to zero, and set cell states to idle.

invoke<void>("stop_kernel", { tabIndex: number });
  • Kills and removes the process.
  • Inserts a stopped sentinel with no child or request channel.
  • Does not clear frontend source or output.
invoke<void>("interrupt_kernel", { tabIndex: number });
  • Sends SIGINT to the child PID.
  • Schedules SIGKILL after two seconds only if the same execution is still busy.
  • Rejects when the instance has no process or PID.
invoke<KernelState>("get_kernel_status", { tabIndex: number });
  • Returns the current backend state directly.
  • Returns stopped when the tab has no map entry.
  • A wrapper exists in the frontend, but the main execution path does not poll it continuously.
invoke<string | null>("get_config_warning");

Returns the interpreter-validation warning captured during app setup. It does not revalidate.

invoke<AppConfig>("get_config");

Loads the TOML-backed configuration and returns the typed object directly.

invoke<void>("save_config", {
config: appConfig,
});
  • Deserializes the supplied object into the Rust AppConfig structure.
  • Rewrites config.toml in canonical form.
  • Does not update the already-created KernelManager or validation warning.
invoke<void>("set_native_effects", { enabled: boolean });
  • Finds the main window.
  • On macOS, applies NSVisualEffectMaterial::HudWindow or clears vibrancy.
  • Does not itself save configuration.

The settings frontend separately emits a native-effects-changed event so the main document updates its CSS class.

invoke<string | null>("load_notebooks");
  • Returns the raw JSON file as a string.
  • Returns null when the file does not exist.
  • Rejects for other file-read failures.
invoke<void>("save_notebooks", { data: string });
  • Creates the Application Support directory if necessary.
  • Atomically replaces notebooks.json with the supplied JSON string.
  • Does not validate the JSON schema in Rust.

All commands are registered in one tauri::generate_handler! call during application construction. The capability definition grants the main and settings windows core window operations and default tray permissions; permission presence does not mean a tray object is implemented.