From 9a78ac4d15b05ea698b104419ff4eba5cd6896e8 Mon Sep 17 00:00:00 2001 From: Adnaan Ali Date: Sun, 5 Apr 2026 11:24:14 +0000 Subject: [PATCH 1/3] fix: correct worktree path handling on Windows --- src/main/services/ssh/SshService.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/services/ssh/SshService.ts b/src/main/services/ssh/SshService.ts index 6ae59be2e..d5d73b393 100644 --- a/src/main/services/ssh/SshService.ts +++ b/src/main/services/ssh/SshService.ts @@ -368,7 +368,9 @@ export class SshService extends EventEmitter { // Build the command with optional cwd, wrapped in a login shell so that // ~/.ssh/config, ~/.gitconfig, and other user-level configuration files // are available (ssh2's client.exec() uses a non-login shell by default). - const innerCommand = cwd ? `cd ${quoteShellArg(cwd)} && ${command}` : command; + const safeCwd = cwd ? cwd.replace(/\\/g, '/').replace(/"/g, '\\"') : undefined; + const innerCommand = safeCwd ? `cd ${quoteShellArg(safeCwd)} && ${command}` : command; + const fullCommand = `bash -l -c ${quoteShellArg(innerCommand)}`; return new Promise((resolve, reject) => { From 714c833b697fe91e18cd0b9bfd8d6a89e1ebeb11 Mon Sep 17 00:00:00 2001 From: Adnaan Ali Date: Sun, 5 Apr 2026 13:35:43 +0000 Subject: [PATCH 2/3] fix: address review comments for path normalization --- src/main/services/ssh/SshService.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/services/ssh/SshService.ts b/src/main/services/ssh/SshService.ts index d5d73b393..955d387d2 100644 --- a/src/main/services/ssh/SshService.ts +++ b/src/main/services/ssh/SshService.ts @@ -368,7 +368,7 @@ export class SshService extends EventEmitter { // Build the command with optional cwd, wrapped in a login shell so that // ~/.ssh/config, ~/.gitconfig, and other user-level configuration files // are available (ssh2's client.exec() uses a non-login shell by default). - const safeCwd = cwd ? cwd.replace(/\\/g, '/').replace(/"/g, '\\"') : undefined; + const safeCwd = cwd ? cwd.replace(/\\/g, '/') : undefined; const innerCommand = safeCwd ? `cd ${quoteShellArg(safeCwd)} && ${command}` : command; const fullCommand = `bash -l -c ${quoteShellArg(innerCommand)}`; From 2042d4c60b52ea638832a587cd88307fa83a821f Mon Sep 17 00:00:00 2001 From: Adnaan Ali Date: Sun, 5 Apr 2026 14:40:14 +0000 Subject: [PATCH 3/3] fix: normalize cwd executeCommandViaCli for Windows paths --- src/main/services/ssh/SshService.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/services/ssh/SshService.ts b/src/main/services/ssh/SshService.ts index 955d387d2..ca4d1a4fa 100644 --- a/src/main/services/ssh/SshService.ts +++ b/src/main/services/ssh/SshService.ts @@ -448,7 +448,10 @@ export class SshService extends EventEmitter { } const target = row.username ? `${row.username}@${row.host}` : row.host; - const innerCommand = cwd ? `cd ${quoteShellArg(cwd)} && ${command}` : command; + + const safeCwd = cwd ? cwd.replace(/\\/g, '/') : undefined; + const innerCommand = safeCwd ? `cd ${quoteShellArg(safeCwd)} && ${command}` : command; + const fullCommand = `bash -l -c ${quoteShellArg(innerCommand)}`; try {