From 86f9e93e979c57c7967e3d3d4d8f94b2edb8970b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?George=C2=B7Dong?= <98630204+GeorgeDong32@users.noreply.github.com> Date: Tue, 9 Sep 2025 10:02:53 +0800 Subject: [PATCH] fix(codetool): incorrect codetool workdir on macOS (#10056) fix(codetool): run command and cd in same shell on macOS --- src/main/services/CodeToolsService.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/services/CodeToolsService.ts b/src/main/services/CodeToolsService.ts index 66575870c7..12da4896be 100644 --- a/src/main/services/CodeToolsService.ts +++ b/src/main/services/CodeToolsService.ts @@ -332,14 +332,15 @@ class CodeToolsService { // macOS - Use osascript to launch terminal and execute command directly, without showing startup command const envPrefix = buildEnvPrefix(false) const command = envPrefix ? `${envPrefix} && ${baseCommand}` : baseCommand + // Combine directory change with the main command to ensure they execute in the same shell session + const fullCommand = `cd '${directory.replace(/'/g, "\\'")}' && clear && ${command}` terminalCommand = 'osascript' terminalArgs = [ '-e', `tell application "Terminal" - set newTab to do script "cd '${directory.replace(/'/g, "\\'")}' && clear" + do script "${fullCommand.replace(/"/g, '\\"')}" activate - do script "${command.replace(/"/g, '\\"')}" in newTab end tell` ] break