Make copy actually copy on Wayland (main-process clipboard + OSC 52)#55
Open
ymajoros wants to merge 1 commit into
Open
Make copy actually copy on Wayland (main-process clipboard + OSC 52)#55ymajoros wants to merge 1 commit into
ymajoros wants to merge 1 commit into
Conversation
Copying out of the terminal did nothing on Linux/Wayland. Two separate holes:
- Ctrl+C copy used navigator.clipboard.writeText in the renderer. Chromium
gates that on window focus + a user gesture, and it's effectively dead under
Ozone/Wayland. The trailing .catch(() => {}) ate the rejection, so it failed
in total silence.
- OSC 52 (how Claude Code itself copies) wasn't wired up at all — xterm doesn't
do it for you, so those copies just evaporated.
Both now go through the main-process clipboard over IPC, which doesn't care about
focus or gestures. Paste was never affected, so it's left alone.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Author
|
Confirmed working. Built this branch and ran it on Ubuntu / GNOME Shell 49 / native Wayland (Ozone), Electron 41.0.3 — the same box where stock 0.0.30 copies nothing. Both paths now land in the system clipboard and paste cleanly into other apps:
Paste was unaffected throughout. No regressions spotted in normal terminal use. |
JeanBaptisteRenard
added a commit
to JeanBaptisteRenard/switchboard
that referenced
this pull request
May 30, 2026
…18) navigator.clipboard.writeText is gated on focus/user-activation and silently fails on Linux/Wayland (Ozone). Replace with a main-process clipboard.writeText via a new clipboard-write-text IPC. Also register an xterm OSC 52 handler so programs inside the terminal (notably Claude Code's copy-to-clipboard) can set the system clipboard; xterm doesn't wire OSC 52 itself. Port of upstream PR doctly#55 (ymajoros). Closes upstream issue #54 from our fork's perspective; the upstream PR will close it fully when merged.
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.
Fixes #54.
Copy was a black hole on Linux/Wayland — paste fine, copy gone. Two reasons, both about the renderer's rocky relationship with the clipboard:
1.
Ctrl+Cwent through the renderer.navigator.clipboard.writeText(...).catch(() => {})rejects on Ozone/Wayland (Chromium wants window focus + a user gesture) and the empty.catchswallowed it whole. Textbook silent failure.2. OSC 52 wasn't handled at all. That's the sequence Claude Code uses to copy. xterm doesn't register a handler for it on its own, so those copies went nowhere.
What this does
Adds a small
clipboard-write-textIPC that calls the main-processclipboard.writeText. The main process has none of the renderer's focus/gesture hangups, so it just writes on Wayland. Then:Ctrl+C(with a selection) uses it instead ofnavigator.clipboard?read-back query, which we don't answer)Paste was never broken, so it's untouched.
The diff (3 files, ~30 lines)
main.js— importclipboard, add the IPC handlerpreload.js— exposewriteClipboardpublic/terminal-manager.js— use it forCtrl+C, add the OSC 52 handlerterminal.parser.registerOscHandleris stable xterm API andallowProposedApi: trueis already set, so nothing new is required capability-wise.Testing
Ubuntu / GNOME 49 / Wayland, native Ozone.
Ctrl+C, and right-click Copy all dead, no error.Ctrl+C-with-selection both land in the system clipboard and paste cleanly into other apps.I only have the Linux box, so I'd love a second pair of eyes confirming macOS/Windows still behave — though main-process clipboard is the boring-and-reliable option on every platform, so I'd be surprised if it regressed anything.