Skip to content

feat(tui): support Windows and WSL UNC paths in file drag-and-drop - #1

Closed
477174 wants to merge 2 commits into
RobertWsp:devfrom
477174:feat/wsl-windows-drag-and-drop
Closed

feat(tui): support Windows and WSL UNC paths in file drag-and-drop#1
477174 wants to merge 2 commits into
RobertWsp:devfrom
477174:feat/wsl-windows-drag-and-drop

Conversation

@477174

@477174 477174 commented Mar 2, 2026

Copy link
Copy Markdown

Summary

Two WSL clipboard/file issues fixed:

  1. File drag-and-drop: Dragging files from Windows Explorer into opencode on WSL pasted Windows paths (C:\Users\..., \\wsl$\distro\...) which were treated as plain text instead of file attachments
  2. Image clipboard paste: Ctrl+V with an image on the clipboard never worked on WSL because PowerShell can't access the Windows clipboard session from WSL, and WSLg's Wayland bridge was unreachable due to wrong XDG_RUNTIME_DIR

Changes

Commit 1: feat(tui): support Windows and WSL UNC paths in file drag-and-drop

File: packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx

  • Add isWindowsPath(), isFilePath(), resolveDroppedPath() helpers
  • Convert drive-letter paths (C:\Users\foo) → /mnt/c/Users/foo on WSL
  • Convert UNC paths (\\wsl$\Ubuntu\home\foo) → /home/foo on WSL
  • Update all 4 paste handler code paths to detect and resolve Windows paths
  • Strip double quotes from dropped paths (Windows terminal behavior)
  • Zero behavior change on native Unix, native Windows, macOS

Commit 2: fix(tui): fix clipboard image paste on WSL via WSLg Wayland bridge

File: packages/opencode/src/cli/cmd/tui/util/clipboard.ts

  • Skip PowerShell clipboard on WSL (always fails — session isolation)
  • Fix wl-paste/wl-copy on WSLg: override XDG_RUNTIME_DIR to /mnt/wslg/runtime-dir where the Wayland socket actually lives
  • Requires wl-clipboard package (apt install wl-clipboard)

Platform behavior

Scenario Before After
WSL + drag from Windows (C:\...) Plain text ❌ File attached ✅
WSL + drag WSL file via Explorer (\\wsl$\...) Plain text ❌ File attached ✅
WSL + paste image from clipboard Silent failure ❌ Image attached ✅ (needs wl-clipboard)
Native Windows Worked ✅ Still works ✅
Linux/macOS Worked ✅ Still works ✅

Prerequisites for WSL image paste

sudo apt install wl-clipboard

WSLg must be enabled (default on Windows 11 with recent WSL2).

When running opencode in WSL, dragging files from Windows Explorer
pastes Windows-style paths (C:\Users\...) or WSL UNC paths
(\\wsl$\distro\...) which were not recognized by the paste handler.

- Add isWindowsPath/isFilePath/resolveDroppedPath helpers for
  platform-aware path detection and conversion
- Update all path detection guards in onPaste to accept Windows paths
- Convert drive-letter paths to /mnt/<drive>/... on WSL
- Convert \\wsl$/\\wsl.localhost UNC paths to native WSL paths
- Strip double quotes from dropped paths (Windows terminal behavior)
- Pass-through on native Windows and other platforms (no behavior change)

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
@github-actions

github-actions Bot commented Mar 2, 2026

Copy link
Copy Markdown

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

Please edit this PR description to address the above within 2 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

PowerShell processes spawned from WSL cannot access the Windows
clipboard session (fundamental session isolation). The previous code
tried PowerShell on WSL, which always failed silently.

- Skip PowerShell clipboard read on WSL (dead code, ~500ms wasted)
- Fix wl-paste/wl-copy on WSLg: override XDG_RUNTIME_DIR to
  /mnt/wslg/runtime-dir where the Wayland socket actually lives
- Requires wl-clipboard package (apt install wl-clipboard)

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
@github-actions

github-actions Bot commented Mar 2, 2026

Copy link
Copy Markdown

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions

github-actions Bot commented Mar 2, 2026

Copy link
Copy Markdown

This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window.

Feel free to open a new pull request that follows our guidelines.

@github-actions github-actions Bot closed this Mar 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant