anomalyco / anomalyco/opencode

tui: image paste fails silently on WSL when no clipboard tool is installed (V2)

Open
#49,895 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

Summary

opencode V2 on WSL2: pasting an image (Ctrl+V) does nothing when the Linux
clipboard tools (wl-clipboard/xclip) are not installed. No error, no hint.
opencode should either read the Windows clipboard directly (zero Linux
dependencies) or show a clear install message.

Reproduction

  1. WSL2 without wl-paste/xclip (default state).
  2. Install opencode V2: curl -fsSL https://opencode.ai/v2/install | bash.
  3. On Windows, copy an image (e.g. Win+Shift+S screenshot).
  4. In the TUI (Windows Terminal), press Ctrl+V.
  5. Result: nothing happens. No attachment, no error message.

Windows Terminal (1.24.11911.0) sends an empty bracketed paste for
image-only clipboards (microsoft/terminal #20037), so the TUI reaches
prompt.paste -> clipboard.read(), which returns undefined silently.

Root cause (what to look for)

packages/tui/src/clipboard.ts read() on Linux tries, in order:
wl-paste -t image/png -> xclip -t image/png -o -> clipboardy.
When the first two are missing, the clipboardy fallback fails silently in
standalone binaries (same root cause as #13800 / PR #48611), and
prompt.paste treats undefined as "nothing to paste" with no feedback.

Proposed solutions

  1. WSL: read the Windows clipboard via powershell.exe interop first
    (when os.release() contains "WSL"). Requires no Linux packages; verified
    working on the reporter's machine.
  2. read() should report failure instead of returning undefined, so the TUI
    can show an actionable message (e.g. sudo apt install xclip wl-clipboard).
  3. Accept image/bmp from wl-paste: WSLg syncs the image as image/bmp,
    so requesting only image/png misses it.
  4. Optional: offer the one-line install command (never install silently).

Environment

  • opencode v2.0.8 (V2 standalone binary, curl installer)
  • WSL2, kernel 6.18.33.1-microsoft-standard-WSL2 (Windows 11)
  • Windows Terminal 1.24.11911.0, bash, no plugins

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with packages/tui/src/clipboard.ts and trace read() through prompt.paste, focusing on the Linux tool fallbacks and the undefined result. Compare the WSL2 clipboard behavior and proposed approaches, then define completion as either successful image attachment without Linux clipboard packages or an actionable failure message.

Written by the indexing model from the issue text.

Assessment

Tech stack
linux, powershell, typescript
Domain
cli, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.