[PR #13161] fix(tui): make Windows image paste reliable #14536

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

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

State: open
Merged: No


What does this PR do?

This fixes slow/unstable image paste behavior in the TUI on Windows. (Fixes #12547)

Context:

  • On my machine, screenshot paste in the TUI was inconsistent and often very slow.

Changes:

  1. packages/opencode/src/cli/cmd/tui/util/clipboard.ts

    • Reworked Windows image read path to:
      • save clipboard image to a temp PNG,
      • read it with Bun,
      • clean up locally with rmSync.
    • Added in-flight reuse for concurrent reads so repeated triggers don't spawn duplicate work.
  2. packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx

    • Unified image paste handling via tryPasteClipboardImage(...).
    • On Windows, image probing is now applied consistently for:
      • paste key handling (Ctrl+V / Shift+Insert path),
      • onPaste flow before falling back to text.
    • Added a render refresh after image insertion to make the placeholder update reliable.

Why this works:

  • The temp-file path avoids fragile stdout/base64 transport from PowerShell.
  • Prompt-side flow now consistently prefers real clipboard image data over ambiguous pasted text payloads.

How did you verify your code works?

  • Verification on Windows:
    • Press screenshot key on your keyboard, Then copy it, Paste it in the TUI.
    • Screenshot clipboard image paste now goes through the same image path and inserts image parts in prompt
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/13161 **State:** open **Merged:** No --- ### What does this PR do? This fixes slow/unstable image paste behavior in the TUI on Windows. (Fixes #12547) Context: - On my machine, screenshot paste in the TUI was inconsistent and often very slow. Changes: 1. `packages/opencode/src/cli/cmd/tui/util/clipboard.ts` - Reworked Windows image read path to: - save clipboard image to a temp PNG, - read it with Bun, - clean up locally with `rmSync`. - Added in-flight reuse for concurrent reads so repeated triggers don't spawn duplicate work. 2. `packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx` - Unified image paste handling via `tryPasteClipboardImage(...)`. - On Windows, image probing is now applied consistently for: - paste key handling (`Ctrl+V` / `Shift+Insert` path), - `onPaste` flow before falling back to text. - Added a render refresh after image insertion to make the placeholder update reliable. Why this works: - The temp-file path avoids fragile stdout/base64 transport from PowerShell. - Prompt-side flow now consistently prefers real clipboard image data over ambiguous pasted text payloads. ### How did you verify your code works? - Verification on Windows: - Press screenshot key on your keyboard, Then copy it, Paste it in the TUI. - Screenshot clipboard image paste now goes through the same image path and inserts image parts in prompt
yindo added the pull-request label 2026-02-16 18:19:19 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#14536