From 7d1f1f4b9a4d08a777f1880d43a9226fa56a3fea Mon Sep 17 00:00:00 2001 From: megaproxy Date: Fri, 22 May 2026 21:43:38 +0100 Subject: [PATCH] Default new panes to WSL home (~) instead of inherited Windows cwd MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously: spawn_wsl(cwd=None) passed no --cd to wsl.exe, so each pane inherited the launcher's cwd — which is typically C:\Users\, surfacing inside WSL as /mnt/c/Users/. Annoying because the first thing you do in a new pane is `cd ~`. Now: if the caller didn't specify a cwd, we explicitly pass `--cd ~` so the pane lands in the WSL user's home. Existing panes keep their saved cwd from the workspace.json. Co-Authored-By: Claude Opus 4.7 (1M context) --- src-tauri/src/pty.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src-tauri/src/pty.rs b/src-tauri/src/pty.rs index fb45a9f..094d847 100644 --- a/src-tauri/src/pty.rs +++ b/src-tauri/src/pty.rs @@ -67,10 +67,13 @@ impl PtyManager { cmd.arg("-d"); cmd.arg(d); } - if let Some(c) = cwd.as_deref() { - cmd.arg("--cd"); - cmd.arg(c); - } + // Default new panes to the WSL user's home (~) rather than the + // Windows-side cwd we inherit from the launcher (typically + // C:\Users\, which shows up as /mnt/c/Users/ inside WSL). + // wsl.exe resolves `~` against the distro's default shell. + let resolved_cwd = cwd.as_deref().unwrap_or("~"); + cmd.arg("--cd"); + cmd.arg(resolved_cwd); // Force a login shell so .bashrc etc. run and PATH is populated. // wsl.exe without an explicit command launches the default shell // interactively, which is exactly what we want.