Improve the local to native and remote to local copy, paste, and DND experience#320685
Conversation
There was a problem hiding this comment.
Pull request overview
This PR improves cross-environment file transfer in VS Code desktop by enhancing clipboard and drag-and-drop handling for local vs remote resources, and by adding a cross-window proxy for accessing vscode-remote:// files from windows that don’t own the remote connection.
Changes:
- Write/read platform-native file clipboard formats (macOS/Linux/Windows) in the Electron clipboard service to improve native paste into OS file managers.
- Download remote explorer selections to a local temp cache for native paste support, with a fallback path that relies on a new cross-window remote filesystem proxy.
- Introduce a main/renderer IPC-based “remote filesystem proxy” so local windows can read
vscode-remote://resources via the window that owns the remote connection, plus basic unit tests.
Show a summary per file
| File | Description |
|---|---|
| src/vs/workbench/services/clipboard/electron-browser/clipboardService.ts | Adds platform-native clipboard formats for file copy/paste and fallback reading behavior. |
| src/vs/workbench/electron-browser/desktop.main.ts | Wires proxy server/client registration into desktop workbench startup. |
| src/vs/workbench/contrib/files/browser/explorerService.ts | Downloads remote clipboard resources to local temp file:// URIs for native paste. |
| src/vs/workbench/browser/dnd.ts | Avoids exporting remote URIs as plain text during drag to native apps (prevents e.g. macOS .webloc). |
| src/vs/platform/files/test/electron-main/remoteFileSystemProxy.test.ts | Adds coverage for main-process routing logic. |
| src/vs/platform/files/electron-main/remoteFileSystemProxyMainHandler.ts | Adds main-process router that forwards operations to the correct renderer window by remote authority. |
| src/vs/platform/files/electron-browser/remoteFileSystemProxyServer.ts | Adds renderer-side server channel exposing file operations to other windows via main routing. |
| src/vs/platform/files/electron-browser/remoteFileSystemProxyClient.ts | Adds local-window proxy provider for vscode-remote scheme (read-only) routed via the main process. |
| src/vs/platform/files/common/remoteFileSystemProxy.ts | Defines IPC channel name constants for proxy wiring. |
| src/vs/code/electron-main/app.ts | Registers the main-process proxy handler channel during app startup. |
Copilot's findings
- Files reviewed: 10/10 changed files
- Comments generated: 4
| // We replace remote URIs with local file:// URIs pointing to temp copies. | ||
| const clipboardResources = await this.resolveClipboardResources(resources); | ||
|
|
||
| await this.clipboardService.writeResources(clipboardResources); |
There was a problem hiding this comment.
Not sure if this idea will work but I feel like the temp file stuff isn't right. A few concerns:
- We are creating the file eagerly on copy and blocking the copy on this.
- I worry about leaking the
/tmpfile path
Instead, the web clipboard api should support writing a Promise that resolves to a Blob: https://developer.mozilla.org/en-US/docs/Web/API/ClipboardItem/ClipboardItem
I believe that electron is exploring aligning their clipboard API more with this web api too: electron/electron#51707
Maybe @deepak1556 can weight on what we can do for electron
Fix microsoft/vscode-remote-release#2008