From 4bc237cc1815e69252344874281fd6da4a69086b Mon Sep 17 00:00:00 2001 From: Jinwoo Hong <73622457+Jinwoo-H@users.noreply.github.com> Date: Sat, 30 May 2026 15:20:16 -0400 Subject: [PATCH] fix: translate dropped paths for wsl worktrees (#3851) --- src/main/ipc/dropped-path-resolution.test.ts | 30 ++++++++++++++++++++ src/main/ipc/dropped-path-resolution.ts | 7 +++++ src/main/ipc/filesystem-mutations.ts | 7 ++++- 3 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 src/main/ipc/dropped-path-resolution.test.ts create mode 100644 src/main/ipc/dropped-path-resolution.ts diff --git a/src/main/ipc/dropped-path-resolution.test.ts b/src/main/ipc/dropped-path-resolution.test.ts new file mode 100644 index 000000000..2d5c16c37 --- /dev/null +++ b/src/main/ipc/dropped-path-resolution.test.ts @@ -0,0 +1,30 @@ +import { describe, expect, it } from 'vitest' +import { resolveLocalDroppedPathsForAgent } from './dropped-path-resolution' + +describe('resolveLocalDroppedPathsForAgent', () => { + it('translates dropped Windows paths for local WSL worktrees', () => { + const originalPlatform = Object.getOwnPropertyDescriptor(process, 'platform') + Object.defineProperty(process, 'platform', { configurable: true, value: 'win32' }) + try { + expect( + resolveLocalDroppedPathsForAgent( + [ + 'C:\\Users\\alice\\Desktop\\notes.txt', + '\\\\wsl.localhost\\Ubuntu\\home\\alice\\repo\\README.md' + ], + '\\\\wsl.localhost\\Ubuntu\\home\\alice\\repo' + ) + ).toEqual(['/mnt/c/Users/alice/Desktop/notes.txt', '/home/alice/repo/README.md']) + } finally { + if (originalPlatform) { + Object.defineProperty(process, 'platform', originalPlatform) + } + } + }) + + it('leaves dropped paths unchanged for non-WSL worktrees', () => { + const paths = ['C:\\Users\\alice\\Desktop\\notes.txt'] + + expect(resolveLocalDroppedPathsForAgent(paths, 'C:\\Users\\alice\\repo')).toBe(paths) + }) +}) diff --git a/src/main/ipc/dropped-path-resolution.ts b/src/main/ipc/dropped-path-resolution.ts new file mode 100644 index 000000000..5ef94ca13 --- /dev/null +++ b/src/main/ipc/dropped-path-resolution.ts @@ -0,0 +1,7 @@ +import { parseWslPath, toLinuxPath } from '../wsl' + +export function resolveLocalDroppedPathsForAgent(paths: string[], worktreePath: string): string[] { + // Why: a local WSL PTY runs inside Linux, so Windows drop paths must be + // rewritten to paths the shell and agent can read. + return parseWslPath(worktreePath) ? paths.map((droppedPath) => toLinuxPath(droppedPath)) : paths +} diff --git a/src/main/ipc/filesystem-mutations.ts b/src/main/ipc/filesystem-mutations.ts index 38c9d7981..0eecac354 100644 --- a/src/main/ipc/filesystem-mutations.ts +++ b/src/main/ipc/filesystem-mutations.ts @@ -19,6 +19,7 @@ import { pipeline } from 'stream/promises' import type { Store } from '../persistence' import { authorizeExternalPath, resolveAuthorizedPath, isENOENT } from './filesystem-auth' import { requireSshFilesystemProvider } from '../providers/ssh-filesystem-dispatch' +import { resolveLocalDroppedPathsForAgent } from './dropped-path-resolution' import { importExternalPathsSsh } from './filesystem-import-ssh' import { assertNoClobberRenameDestinationAvailable } from '../../shared/filesystem-rename-collision' @@ -209,7 +210,11 @@ export function registerFilesystemMutationHandlers(store: Store): void { // Why: `== null` (not `!args.connectionId`) so an empty string is // treated as a renderer error, not silently routed to the local branch. if (args.connectionId == null) { - return { resolvedPaths: args.paths, skipped: [], failed: [] } + return { + resolvedPaths: resolveLocalDroppedPathsForAgent(args.paths, args.worktreePath), + skipped: [], + failed: [] + } } const worktreePath = args.worktreePath.replace(/\/+$/, '') const destDir = `${worktreePath}/.orca/drops`