[PR #8626] fix(tui): fix Ctrl+V paste on Windows/WSL2 (#6560 and #8209) #12813

Open
opened 2026-02-16 18:17:42 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/8626

State: open
Merged: No


What does this PR do?

Fixes #6560
Complementary to #8209 which fixes image filename extraction from Windows
file copy. This PR focuses on text paste failures and PowerShell escaping issues.

Ctrl+V paste was silently failing on Windows/WSL2 for text containing file
extensions (e.g., image.png, c:\path\file.txt).
Root cause: Bun.file().type infers MIME from extension without checking if file
exists. Text like image.png was treated as an image file path, failed to load,
and silently dropped. Additionally, on WSL2, clipboardy uses Linux clipboard
tools which cannot access Windows clipboard.

Fix:

  • Added file.exists() check before treating pasted text as file path
  • Added PowerShell clipboard read for Windows/WSL2 (using -EncodedCommand to
    avoid quoting issues with backslash paths)
  • Added explicit text paste handler in onKeyDown for terminals without
    bracketed paste support

How did you verify your code works?

Manually tested - pasting image paths now works perfectly in windows 11 WSL2 environment.

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/8626 **State:** open **Merged:** No --- ### What does this PR do? Fixes #6560 Complementary to #8209 which fixes image filename extraction from Windows file copy. This PR focuses on text paste failures and PowerShell escaping issues. Ctrl+V paste was silently failing on Windows/WSL2 for text containing file extensions (e.g., `image.png`, `c:\path\file.txt`). Root cause: `Bun.file().type` infers MIME from extension without checking if file exists. Text like `image.png` was treated as an image file path, failed to load, and silently dropped. Additionally, on WSL2, `clipboardy` uses Linux clipboard tools which cannot access Windows clipboard. Fix: - Added `file.exists()` check before treating pasted text as file path - Added PowerShell clipboard read for Windows/WSL2 (using `-EncodedCommand` to avoid quoting issues with backslash paths) - Added explicit text paste handler in `onKeyDown` for terminals without bracketed paste support --- ### How did you verify your code works? Manually tested - pasting image paths now works perfectly in windows 11 WSL2 environment.
yindo added the pull-request label 2026-02-16 18:17:42 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#12813