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

term_spawn was a synchronous Tauri command, so it ran on the main thread; starting the shell forks the IDE process, which takes tens of milliseconds with a large resident set and froze the UI each time a terminal opened. It is now async like term_is_busy, so the fork runs off the main thread. The frontend already awaited it.

Co-authored-by: brandondurandpro <[email protected]>
Цей коміт міститься в:
Jepmen authored and GitHub committed 2026-10-30 07:33:00 +08:00
1 джерело 0d368ba947
коміт c0626b2728
2 files changed
+7 -1

No files matched your search

+3 -1
Переглянути файл
@@ -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,
+4
Переглянути файл
@@ -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 })),