Skip to content

fix(tui): clipboard image paste on WSL via WSLg and alternative keybinds - #5

Closed
477174 wants to merge 3 commits into
RobertWsp:devfrom
477174:fix/wsl-clipboard-image-paste
Closed

fix(tui): clipboard image paste on WSL via WSLg and alternative keybinds#5
477174 wants to merge 3 commits into
RobertWsp:devfrom
477174:fix/wsl-clipboard-image-paste

Conversation

@477174

@477174 477174 commented Mar 2, 2026

Copy link
Copy Markdown

Summary

Fixes #2 — Clipboard image paste doesn't work on WSL (Windows Terminal intercepts Ctrl+V).

Commits

  1. fix(tui): fix clipboard image paste on WSL via WSLg Wayland bridge

    • Skips PowerShell clipboard on WSL (can't access Windows clipboard session)
    • Fixes wl-paste/wl-copy to use XDG_RUNTIME_DIR=/mnt/wslg/runtime-dir (WSLg socket location)
  2. fix(tui): convert BMP clipboard images to PNG for API compatibility

    • Windows clipboard stores screenshots as BMP, which LLM APIs reject
    • Auto-converts BMP → PNG using ffmpeg, ImageMagick magick, or convert
    • Only triggers when clipboard offers BMP and no other supported format
  3. feat(tui): add Ctrl+Alt+V keybind and /image command for clipboard image paste

    • Windows Terminal intercepts Ctrl+V before it reaches terminal apps; Ctrl+Alt+V passes through (confirmed via raw stdin testing)
    • Adds input_paste_image keybind (default: Ctrl+Alt+V)
    • Adds /image slash command (alias: /paste-image)
    • Adds "Paste image from clipboard" in command palette (Ctrl+P)
    • All existing Ctrl+V behavior is unchanged

Why Ctrl+V can't work directly

Windows Terminal intercepts Ctrl+V at the emulator level. When clipboard has text, WT sends it as bracketed paste. When clipboard has only an image, WT sends nothing — zero bytes reach stdin. WT doesn't implement the Kitty keyboard protocol, so there's no way to receive the raw keypress. Ctrl+Alt+V is confirmed to pass through WT.

Testing

  1. Run OpenCode in WSL2 via Windows Terminal
  2. Copy an image (e.g., Win+Shift+S screenshot)
  3. Press Ctrl+Alt+V — image should be pasted
  4. Or type /image — same result
  5. Or Ctrl+P → "Paste image from clipboard" — same result
  6. Regular Ctrl+V text paste is unchanged

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>
@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.

@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.

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

1 participant