fix(tui): read text from clipboard directly on Windows (#13800) by Mushfiqtaief · Pull Request #48611 · anomalyco/opencode · GitHub
Skip to content

fix(tui): read text from clipboard directly on Windows (#13800) - #48611

Closed
Mushfiqtaief wants to merge 1 commit into
anomalyco:devfrom
Mushfiqtaief:fix/windows-ctrl-v-paste
Closed

Mushfiqtaief wants to merge 1 commit into
anomalyco:devfrom
Mushfiqtaief:fix/windows-ctrl-v-paste

Conversation

@Mushfiqtaief

@Mushfiqtaief Mushfiqtaief commented Sep 12, 2026 •

Copy link
Copy Markdown

Issue for this PR

Closes #13800

Type of change

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

What does this PR do?

On Windows 11, pressing Ctrl+V or clicking clipboard history (Win+V) in the TUI prompt fails to paste text.

In packages/tui/src/clipboard.ts, the Windows implementation only checks for images with PowerShell and then falls through to clipboardy.read() for text. In compiled standalone binaries, clipboardy fails or is blocked by execution policy, causing clipboard reading to silently return undefined.

This PR updates the Windows/WSL read() implementation in packages/tui/src/clipboard.ts to use PowerShell's built-in Get-Clipboard cmdlet:

  • Reads text first via Get-Clipboard -Raw and outputs directly as UTF-8.
  • Falls back to Get-Clipboard -Format Image if no text is present to handle images as base64 PNG.
  • Employs [Console]::Out.Write to stream output without appending extraneous trailing newlines.

How did you verify your code works?

Tested locally on Windows 11 in Windows Terminal, PowerShell, and cmd.exe:

  • Pasting single-line plain text via Ctrl+V
  • Pasting multi-line text via Ctrl+V
  • Pasting text with UTF-8 / emoji characters
  • Pasting image from clipboard (screenshots)

Screenshots / recordings

If this is a UI change, please include a screenshot or recording.

N/A (TUI clipboard behavior fix)

Checklist

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

@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Sep 12, 2026
@github-actions

Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Sep 12, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@github-actions

Copy link
Copy Markdown
Contributor

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.

Ctrl+V paste not working on Windows 11 TUI

1 participant