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.
Kernel commands
Section titled “Kernel commands”ensure_kernel
Section titled “ensure_kernel”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
KernelStatevalue such as"idle". - Returns
"stopped"for an existing stopped sentinel rather than respawning it.
execute_cell
Section titled “execute_cell”invoke<KernelResponse>("execute_cell", { tabIndex: number, cellId: string, code: string,});- Requires an existing, non-stopped kernel entry.
- Enqueues an
executeprotocol request. - Uses
cellIdas the protocol correlation ID. - Resolves to the deserialized Python response object.
- Rejects with a string on lifecycle or transport failure.
restart_kernel
Section titled “restart_kernel”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
KernelStatevalue.
Frontend side effects after success clear outputs, set displayed counts to zero, and set cell states to idle.
stop_kernel
Section titled “stop_kernel”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.
interrupt_kernel
Section titled “interrupt_kernel”invoke<void>("interrupt_kernel", { tabIndex: number });- Sends
SIGINTto the child PID. - Schedules
SIGKILLafter two seconds only if the same execution is still busy. - Rejects when the instance has no process or PID.
get_kernel_status
Section titled “get_kernel_status”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.
Configuration commands
Section titled “Configuration commands”get_config_warning
Section titled “get_config_warning”invoke<string | null>("get_config_warning");Returns the interpreter-validation warning captured during app setup. It does not revalidate.
get_config
Section titled “get_config”invoke<AppConfig>("get_config");Loads the TOML-backed configuration and returns the typed object directly.
save_config
Section titled “save_config”invoke<void>("save_config", { config: appConfig,});- Deserializes the supplied object into the Rust
AppConfigstructure. - Rewrites
config.tomlin canonical form. - Does not update the already-created
KernelManageror validation warning.
set_native_effects
Section titled “set_native_effects”invoke<void>("set_native_effects", { enabled: boolean });- Finds the
mainwindow. - On macOS, applies
NSVisualEffectMaterial::HudWindowor 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.
Persistence commands
Section titled “Persistence commands”load_notebooks
Section titled “load_notebooks”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.
save_notebooks
Section titled “save_notebooks”invoke<void>("save_notebooks", { data: string });- Creates the Application Support directory if necessary.
- Atomically replaces
notebooks.jsonwith the supplied JSON string. - Does not validate the JSON schema in Rust.
Registration
Section titled “Registration”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.
