fix(tui): Windows clipboard - use PowerShell directly for text paste#36470
fix(tui): Windows clipboard - use PowerShell directly for text paste#36470MysticDevloper wants to merge 3 commits into
Conversation
… let bracketed paste handle text insertion - Add direct PowerShell Get-Clipboard for Windows text reads (faster than clipboardy) - prompt.paste command now only handles image paste - Text paste relies on bracketed paste (onPaste handler) which is instant - Fixes Ctrl+V paste not working in Windows Terminal
|
This PR doesn't fully meet our contributing guidelines and PR template. What needs to be fixed:
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. |
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
|
The following comment was made by an LLM, it may be inaccurate: Based on my search, here are related PRs that address similar clipboard/paste functionality (though no exact duplicates):
The most relevant is #34123 (plain text paste) as it directly addresses text paste behavior. You should review these PRs to ensure your fix doesn't conflict with or duplicate existing work, particularly around the bracketed paste event handling and PowerShell fallback strategy. |
- Add Win32 API (user32.dll) clipboard read via bun:ffi for admin/elevated terminals - Keep PowerShell Get-Clipboard as fallback for non-Bun runtimes - Delay clearSelection by 150ms to prevent visual reflow when copying - Applies to selection copy, console copy (Ctrl+Y), and Escape dismiss
|
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. |
Problem
clearSelection()triggers an immediate console redraw.Root Cause
Get-Clipboardcan fail in elevated/admin terminal sessions due to session isolation.renderer.clearSelection()is called synchronously after copy, causing the console to reflow and the selected text to visually collapse.Fix
clipboard.ts
bun:ffi(user32.dll OpenClipboard/GetClipboardData/GlobalLock) that works in all terminal privilege levels (admin, elevated, UAC)Get-Clipboard, thenclipboardyselection.ts + app.tsx
clearSelection()after copy operationsChanges
packages/tui/src/clipboard.ts— Win32 API clipboard read for admin terminalspackages/tui/src/util/selection.ts— Delay clearSelection by 150mspackages/tui/src/app.tsx— Delay console clearSelection by 150msTesting
Verified on Windows Terminal (normal + admin) — paste and copy both work without text shrinking.