fix(terminal): restore copy and paste on Linux and Windows - #91
Merged
Merged
Conversation
On macOS the Wails Edit menu turns ⌘C / ⌘V into native clipboard commands and xterm.js leaves ⌘-chords alone, so copy and paste always worked there. Linux (WebKit2GTK) and Windows (WebView2) have no such menu; xterm.js maps Ctrl+C / Ctrl+V to the ^C / ^V control bytes and cancels the browser default, so the webview never fires a copy or paste event and xterm's own clipboard handlers never run. Bind the terminal-convention chords through attachCustomKeyEventHandler: Ctrl+Shift+C / Ctrl+Insert copy, Ctrl+Shift+V / Shift+Insert paste, and a plain Ctrl+C copies while text is selected (SIGINT otherwise, matching Windows Terminal and VS Code). macOS keeps its native path untouched. Clipboard I/O goes through the Wails runtime first — WebKitGTK has no navigator.clipboard.readText and WebView2 permission-gates it — and paste uses term.paste() so bracketed paste and newline normalisation survive. Wired into Exec, Node shell, the terminal drawer and (copy only) both Logs viewers. Refs: #90 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Release builds do not enable the webview's default context menu, so right-clicking a terminal did nothing and mouse-only users on Linux and Windows had no way to paste at all. Wrap every xterm host in a Radix context menu with Copy / Paste / Select all (copy-only in the Logs viewers) that reuses the clipboard helpers and hands focus back to xterm on close. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
SametKUM
force-pushed
the
fix/terminal-clipboard
branch
from
September 5, 2026 18:04
239c73f to
baae902
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Copy and paste never worked in Klustr's terminals on Linux and Windows — Exec, Node shell, the terminal drawer, and copying from the Logs viewers. Reported in discussion #90.
Root cause. On macOS the Wails Edit menu turns ⌘C / ⌘V into native clipboard commands and xterm.js leaves ⌘-chords alone, so it always worked there. Linux (WebKit2GTK) and Windows (WebView2) have no such menu; xterm.js maps Ctrl+C / Ctrl+V to the
^C/^Vcontrol bytes and callspreventDefault(), so the webview never fires acopy/pasteevent and xterm's own clipboard handlers never run. Right-click was dead as well: release builds don't enable the webview's default context menu.Fix.
xtermClipboard.ts—attachCustomKeyEventHandlerbinds the terminal-convention chords on Linux/Windows:Ctrl+Shift+C/Ctrl+Insertcopy,Ctrl+Shift+V/Shift+Insertpaste, and a plainCtrl+Ccopies while text is selected (SIGINT otherwise, matching Windows Terminal and VS Code). macOS is untouched — the matcher returnsnullthere.ClipboardGetText/ClipboardSetText) first: WebKitGTK has nonavigator.clipboard.readTextand WebView2 permission-gates it. Paste usesterm.paste()so bracketed paste and newline normalisation survive.TerminalContextMenu.tsx— right-click Copy / Paste / Select all on every terminal surface (copy-only in the Logs viewers), focus handed back to xterm on close.Verification
npm test(188 passing, 7 new for the chord matcher),npm run lint,npm run typecheck,npm run build.wails build -tags webkit2_41, WebKitGTK 2.52): Exec, Node shell, drawer and Logs — chords, selection-aware Ctrl+C followed by SIGINT, right-click menu, multi-line paste into bash and vim; no regressions on Ctrl+D/L/R, arrows, Tab.Refs #90
🤖 Generated with Claude Code