Skip to content

fix(clipboard): route terminal copy through main process for Wayland (port of upstream #55) - #18

Merged
JeanBaptisteRenard merged 1 commit into
mainfrom
port/wayland-clipboard
May 30, 2026
Merged

fix(clipboard): route terminal copy through main process for Wayland (port of upstream #55)#18
JeanBaptisteRenard merged 1 commit into
mainfrom
port/wayland-clipboard

Conversation

@JeanBaptisteRenard

Copy link
Copy Markdown
Collaborator

What

Ports upstream PR doctly#55 by @ymajoros to our fork.

Why

`navigator.clipboard.writeText` is gated on focus/user-activation by Chromium. On Linux/Wayland (Ozone), the renderer fails the focus check silently and Ctrl+C in the terminal produces nothing in the system clipboard. JB hit this daily.

How

  • Add `clipboard-write-text` IPC handler in `main.js` using Electron's main-process `clipboard.writeText` (no focus gate).
  • Expose as `window.api.writeClipboard` via preload.
  • Replace the `navigator.clipboard.writeText` call in the terminal's Ctrl+C path with the IPC route.
  • Register an xterm OSC 52 handler so programs inside the terminal can set the clipboard (Claude Code uses OSC 52 to copy from its UI). Routes through the same IPC for the same Wayland reason.

Checks

  • `npm test` — 53/53 pass
  • `npm run lint` — 0 errors (220 pre-existing warnings)

Credit

@ymajoros for the original upstream PR. Diff applied unchanged to the corresponding files in our fork — the only minor difference is that our `main.js` is much larger so insertion points sit elsewhere by line number.

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.
@JeanBaptisteRenard
JeanBaptisteRenard merged commit 280b4e0 into main May 30, 2026
7 checks passed
@JeanBaptisteRenard
JeanBaptisteRenard deleted the port/wayland-clipboard branch May 30, 2026 01:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant