Skip to content

fix(tui): clipboard image paste on WSL via WSLg and Ctrl+Alt+V keybind#7

Merged
RobertWsp merged 3 commits intoRobertWsp:devfrom
477174:fix/wsl-clipboard-image-paste
Mar 5, 2026
Merged

fix(tui): clipboard image paste on WSL via WSLg and Ctrl+Alt+V keybind#7
RobertWsp merged 3 commits intoRobertWsp:devfrom
477174:fix/wsl-clipboard-image-paste

Conversation

@477174
Copy link
Copy Markdown

@477174 477174 commented Mar 4, 2026

Issue for this PR

Closes #2

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Fixes clipboard image paste when running OpenCode in WSL. Three issues addressed:

  1. WSLg clipboard accesswl-paste needs XDG_RUNTIME_DIR=/mnt/wslg/runtime-dir on WSLg, not the default /run/user/0/. Fixed in the clipboard util.
  2. BMP→PNG conversion — Windows clipboard stores screenshots as BMP, which the LLM API rejects. Added automatic conversion via ffmpeg/ImageMagick when BMP is detected.
  3. Ctrl+Alt+V keybind — Windows Terminal intercepts Ctrl+V before it reaches the app. Added a new input_paste_image keybind (default: Ctrl+Alt+V) and a /image command in the command palette as alternatives. Existing Ctrl+V behavior is unchanged.

No changes to behavior on native Linux/macOS — WSLg detection only activates when WSL is detected. The keybind and command work on all platforms.

How did you verify your code works?

  • Tested Ctrl+Alt+V pastes screenshot from Windows clipboard in WSL2
  • Verified BMP screenshots are converted to PNG before sending to API
  • Verified /image command appears in command palette (Ctrl+P)
  • Verified existing Ctrl+V text paste still works as before
  • Build passes (bun run build), typecheck passes

Screenshots / recordings

N/A (terminal-based interaction)

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

477174 and others added 3 commits March 2, 2026 17:32
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>
Windows clipboard stores screenshots as BMP, which LLM APIs reject. When the clipboard only offers image/bmp (common on WSL via WSLg), convert to PNG using ffmpeg, ImageMagick magick, or convert before returning.

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

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
…age paste

Windows Terminal intercepts Ctrl+V and doesn't pass it to terminal apps when the clipboard contains only an image. Add alternative mechanisms that bypass WT: - input_paste_image keybind (Ctrl+Alt+V) confirmed to pass through WT - /image slash command (aliases: /paste-image) - 'Paste image from clipboard' in command palette (Ctrl+P)

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

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
@RobertWsp RobertWsp merged commit f51102f into RobertWsp:dev Mar 5, 2026
8 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Clipboard image paste doesn't work on WSL (Windows Terminal intercepts Ctrl+V)

2 participants