Browse Source

fix(multiplexer): normalize Windows backslash paths in attach --dir (#568)

On Windows, buildOpencodeAttachCommand passed the raw directory (with backslashes) into the attach --dir arg, which gets corrupted when run via sh -lc (Zellij/MSYS2). Normalize backslashes to forward slashes for win32 in both the shared attach builder and herdr's --cwd.
Michael Henke 1 month ago
parent
commit
b60187669b
2 changed files with 6 additions and 2 deletions
  1. 3 1
      src/multiplexer/herdr/index.ts
  2. 3 1
      src/multiplexer/shared.ts

+ 3 - 1
src/multiplexer/herdr/index.ts

@@ -83,7 +83,9 @@ export class HerdrMultiplexer implements Multiplexer {
         '--direction',
         this.paneDirection,
         '--cwd',
-        directory,
+        process.platform === 'win32'
+          ? directory.replace(/\\/g, '/')
+          : directory,
         '--no-focus',
       ];
 

+ 3 - 1
src/multiplexer/shared.ts

@@ -17,6 +17,8 @@ export function buildOpencodeAttachCommand(
   serverUrl: string,
   directory: string,
 ): string {
+  const attachDir =
+    process.platform === 'win32' ? directory.replace(/\\/g, '/') : directory;
   return [
     'opencode',
     'attach',
@@ -24,7 +26,7 @@ export function buildOpencodeAttachCommand(
     '--session',
     quoteShellArg(sessionId),
     '--dir',
-    quoteShellArg(directory),
+    quoteShellArg(attachDir),
   ].join(' ');
 }