Skip to content

The IDE you know, rebuilt in Rust. IntelliJ IDEA–style keymap, tool windows and search-everywhere in a fast native app: editor, code insight, debugger, Git, terminal, database and HTTP clients for 60+ languages.

perf(terminal): spawn the shell off the main thread (#295)

Jepmenc0626b272898
diff --git a/src-tauri/src/commands/term.rs b/src-tauri/src/commands/term.rs
index 23e195264..6f2e10eae 100644
--- a/src-tauri/src/commands/term.rs
+++ b/src-tauri/src/commands/term.rs
@@ -4,9 +4,11 @@ use ide_terminal::{TerminalInfo, TerminalOptions};
use tauri::ipc::Channel;
use tauri::{State, Window};
+/// Async to stay off the main thread: forking the IDE (its whole address space)
+/// to start the shell takes tens of milliseconds, a frozen UI if run there.
#[tauri::command]
#[specta::specta]
-pub fn term_spawn(
+pub async fn term_spawn(
window: Window,
state: State<'_, AppState>,
options: TerminalOptions,
diff --git a/src/bindings.ts b/src/bindings.ts
index 7bf4a4797..be8f34ba4 100644
--- a/src/bindings.ts
+++ b/src/bindings.ts
@@ -504,6 +504,10 @@ export const commands = {
vcsChangelistsSave: (changelists: ChangelistState) => typedError<null, IdeError>(__TAURI_INVOKE("vcs_changelists_save", { changelists })),
/** Create Patch › Save to file. */
vcsWritePatch: (path: string, patch: string) => typedError<null, IdeError>(__TAURI_INVOKE("vcs_write_patch", { path, patch })),
+ /**
+ * Async to stay off the main thread: forking the IDE (its whole address space)
+ * to start the shell takes tens of milliseconds, a frozen UI if run there.
+ */
termSpawn: (options: TerminalOptions, onOutput: Channel<string>) => typedError<TerminalInfo, IdeError>(__TAURI_INVOKE("term_spawn", { options, onOutput })),
termWrite: (id: TerminalId, data: string) => typedError<null, IdeError>(__TAURI_INVOKE("term_write", { id, data })),
termResize: (id: TerminalId, cols: number, rows: number) => typedError<null, IdeError>(__TAURI_INVOKE("term_resize", { id, cols, rows })),