From 7e2a60e4b64f31e82f45292538afcf81662d092b Mon Sep 17 00:00:00 2001 From: Alexander Mayo Date: Sat, 19 Sep 2026 14:52:55 -0500 Subject: [PATCH] =?UTF-8?q?fix(desktop):=20the=20engine=20starts=20in=20th?= =?UTF-8?q?e=20home=20folder,=20not=20/=20=E2=80=94=20chat=20writes=20stop?= =?UTF-8?q?=20targeting=20/.iris=20(#186118)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit An app opened from Finder or the Dock starts with cwd /, and spawn_sidecar did not set one, so the engine inherited it. A chat with no project folder ran its shell at the read-only root: every relative write (playbook install, exports, file saves) targeted /.iris. Found live on a client QA call — install failed until the agent ran cd ~. spawn_sidecar sets .current_dir(home) on both platform branches (dirs_next_home(), falling back to /). NOT compiled locally (no Rust toolchain on the authoring machine); the desktop release build compiles all platforms before anything is promoted. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_0121oCnNCeZBewSyiQSQ8bin --- packages/desktop/src-tauri/src/lib.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/desktop/src-tauri/src/lib.rs b/packages/desktop/src-tauri/src/lib.rs index 4dc86d8b37f4..5dbc4925e796 100644 --- a/packages/desktop/src-tauri/src/lib.rs +++ b/packages/desktop/src-tauri/src/lib.rs @@ -591,6 +591,13 @@ fn spawn_sidecar(app: &AppHandle, port: u32) -> CommandChild { .resolve("", BaseDirectory::AppLocalData) .expect("Failed to resolve app local data dir"); + // The engine's working directory (#186118). An app opened from Finder / the Dock starts at `/`, + // and the sidecar inherited it — so a chat with no project folder ran its shell at the read-only + // root, and every relative write ("iris playbook install", exports, saves) targeted `/.iris`. + // Observed on a client's QA call: install failed until the agent `cd ~`'d. Home is where a person + // expects "here" to be when they have not opened a folder. + let engine_cwd = dirs_next_home().unwrap_or_else(|| std::path::PathBuf::from("/")); + #[cfg(target_os = "windows")] let (mut rx, child) = app .shell() @@ -600,6 +607,7 @@ fn spawn_sidecar(app: &AppHandle, port: u32) -> CommandChild { .env("OPENCODE_CLIENT", "desktop") .env("XDG_STATE_HOME", &state_dir) .env("IRIS_API_KEY", &iris_api_key) + .current_dir(&engine_cwd) .args(["serve", &format!("--port={port}")]) .spawn() .expect("Failed to spawn opencode"); @@ -613,6 +621,7 @@ fn spawn_sidecar(app: &AppHandle, port: u32) -> CommandChild { .env("OPENCODE_CLIENT", "desktop") .env("XDG_STATE_HOME", &state_dir) .env("IRIS_API_KEY", &iris_api_key) + .current_dir(&engine_cwd) .args(["serve", &format!("--port={port}")]) .spawn() .expect("Failed to spawn opencode");