fix: use native Tauri clipboard plugin on all platforms (fixes terminal copy/paste on Windows)#923
fix: use native Tauri clipboard plugin on all platforms (fixes terminal copy/paste on Windows)#923baoyu0 wants to merge 1 commit into
Conversation
The terminal clipboard functions (`writeTerminalClipboard`, `readTerminalClipboard`, `writeSystemClipboard`) only used the native `@tauri-apps/plugin-clipboard-manager` on Linux via an `IS_LINUX` guard. On Windows and macOS they fell back to `navigator.clipboard.writeText()`, which silently fails in Tauri's WebView2 renderer, making Ctrl+Shift+C/V and OSC 52 clipboard operations non-functional. - Remove the `IS_LINUX` guard from `terminalClipboard.ts` so the native plugin is tried on every platform first, with `navigator.clipboard` as fallback. - Update `writeSystemClipboard` in `osc-handlers.ts` to use the native plugin with the same pattern.
|
Caution Review failedAn error occurred during the review process. Please try again later. 📝 WalkthroughWalkthroughOSC7 CWD path parsing uses a revised file:// regex, OSC52 clipboard payload strips whitespace before base64 validation, and clipboard read/write functions across osc-handlers.ts and terminalClipboard.ts now prefer the Tauri clipboard-manager plugin (dynamic import) before falling back to navigator.clipboard, removing prior Linux-only gating. ChangesClipboard and OSC parsing fixes
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Poem: A rabbit hopped past WebView2's wall, Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Problem
The terminal clipboard functions (
writeTerminalClipboard,readTerminalClipboard,writeSystemClipboard) only used the native@tauri-apps/plugin-clipboard-manageron Linux via anIS_LINUXguard. On Windows and macOS they fell back tonavigator.clipboard.writeText(), which silently fails in Tauri's WebView2 renderer (and macOS WKWebView), making:Ctrl+Shift+C/Ctrl+Shift+Vkeyboard copy/pasteall non-functional on Windows.
The
.catch(() => {})in the existing code swallows the error, so users see no feedback — the copy/paste just silently does nothing.Root Cause
terminalClipboard.tshad exclusive Linux guard:osc-handlers.tshad no native plugin path at all — it always callednavigator.clipboard.writeText()directly.Fix
src/modules/terminal/lib/terminalClipboard.ts— Remove theIS_LINUXguard. Try the native@tauri-apps/plugin-clipboard-manageron every platform first, withnavigator.clipboardas a last-resort fallback for non-Tauri environments (e.g. unit tests, dev in plain browser).src/modules/terminal/lib/osc-handlers.ts— UpdatewriteSystemClipboardto use the native plugin with the same try/catch pattern.The
@tauri-apps/plugin-clipboard-manageris already a dependency inpackage.json— no new dependencies needed.Related Issues
muda)Summary by CodeRabbit