Move blocking host work off the main thread and fix Git SSH settings

Window close no longer waits on the main thread. The handler revokes
browser sessions and plugin leases with short locks. A cleanup thread
stops terminals, closes browser tabs, and erases plugin review folders.
The browser cleanup sends closeTab without a wait for the reply, and
stops the engine outside the engine lock.

Terminal, plugin, background, and browser commands do their file,
process, and plugin-lock work on blocking workers. Terminal events go
to the window that opened the session. Command names, arguments,
results, and events do not change.

The Git service keeps GIT_SSH, GIT_SSH_COMMAND, GIT_SSH_VARIANT, and a
configured core.sshCommand. It adds its SSH defaults only when the user
has none. It still removes other inherited GIT_* variables.

After the first check, Git status starts 2 processes and an unstaged
diff starts 1. The service finds Git once, checks Git once per run,
caches the repository check per root until the Git metadata changes,
waits on its pipes instead of a 15 ms poll, and locks each root
separately.

Lease errors name the plugin. A profile copy rejects junctions.
This commit is contained in:
Knotty Wyvern
2026-10-27 23:08:59 -07:00
parent 70510a114f
commit 2448c68abf
8 changed files with 738 additions and 217 deletions
+18 -3
View File
@@ -106,13 +106,28 @@ pub fn run() {
.expect("error while building tauri application")
.run(|app, event| {
if let tauri::RunEvent::WindowEvent { label, event: tauri::WindowEvent::Destroyed, .. } = &event {
// This handler runs on the main thread. Here, revoke the window's access
// with short locks only. A cleanup thread stops processes and erases files.
settings::close_owned_window(app, label);
spelling::close_window(app, label);
app.state::<PtyState>().close_window(label);
app.state::<completion::CompletionState>().close_window(label);
app.state::<browser::BrowserState>().close_window(label);
app.state::<plugins::PluginState>().close_window(label);
let browser_tabs = app.state::<browser::BrowserState>().release_window(label);
let staging = app.state::<plugins::PluginState>().try_release_window(label);
app.state::<WorkspaceState>().close_window(label);
let app = app.clone();
let label = label.clone();
let cleanup = std::thread::Builder::new().name("window-cleanup".into()).spawn(move || {
app.state::<PtyState>().close_window(&label);
app.state::<browser::BrowserState>().close_tabs(browser_tabs);
match staging {
Some(staging) => staging.erase(),
// Another plugin command held the lock. Wait for it here.
None => app.state::<plugins::PluginState>().close_window(&label),
}
});
if let Err(error) = cleanup {
eprintln!("RuneStone could not start the window cleanup: {error}");
}
}
if matches!(event, tauri::RunEvent::Exit) {
app.state::<PtyState>().close_all();