From eab2ac1e045f2e4ba994cb7371b8e3a8e8aaf4b7 Mon Sep 17 00:00:00 2001 From: shanevcantwell <153727980+shanevcantwell@users.noreply.github.com> Date: Fri, 26 Dec 2025 05:10:13 -0700 Subject: [PATCH] fix: properly resolve WSL2 workspace paths in runTerminalCommand MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Parse vscode-remote://wsl+distro/path URIs to extract the actual workspace path instead of falling back to Windows HOME directory. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- core/tools/implementations/runTerminalCommand.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/core/tools/implementations/runTerminalCommand.ts b/core/tools/implementations/runTerminalCommand.ts index 7fc26e9d7..747e53fa3 100644 --- a/core/tools/implementations/runTerminalCommand.ts +++ b/core/tools/implementations/runTerminalCommand.ts @@ -48,6 +48,20 @@ import { getBooleanArg, getStringArg } from "../parseArgs"; * Falls back to home directory or temp directory if no workspace is available. */ function resolveWorkingDirectory(workspaceDirs: string[]): string { + // Handle vscode-remote://wsl+distro/path URIs (WSL2 remote workspaces) + const wslWorkspaceDir = workspaceDirs.find((dir) => + dir.startsWith("vscode-remote://wsl"), + ); + if (wslWorkspaceDir) { + try { + const url = new URL(wslWorkspaceDir); + return url.pathname; // e.g., "/home/user/project" + } catch { + // Fall through to other handlers + } + } + + // Handle file:// URIs (local workspaces) const fileWorkspaceDir = workspaceDirs.find((dir) => dir.startsWith("file:/"), ); @@ -59,6 +73,7 @@ function resolveWorkingDirectory(workspaceDirs: string[]): string { // Fall through to default handling } } + // Default to user's home directory with fallbacks try { return process.env.HOME || process.env.USERPROFILE || process.cwd();