Skip to content

fix(linux): keep Wayland clipboard text current - #27772

Merged
nwparker merged 5 commits into
mainfrom
nwparker/copy-issues-clipboard
Oct 12, 2026
Merged

nwparker merged 5 commits into
mainfrom
nwparker/copy-issues-clipboard

Conversation

@nwparker

@nwparker nwparker commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 10 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​679 $\color{#cf222e}{\Huge{\mathbf{−}}}$​13 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​666
Prod 18 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1299 $\color{#cf222e}{\Huge{\mathbf{−}}}$​18 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1281

ELI5

On Linux Wayland, copying text from Orca can leave it pasting an old value after another app copies something new. This makes text copies reach the system clipboard and lets Orca see later external copies, while preserving native Wayland rendering.

What Changed

On native Wayland, ordinary UI text and terminal text copies share a bounded, ordered publisher. A bundled native owner publishes without Chromium's input-event bookkeeping: Wayland data control where available, or GTK's Xwayland clipboard bridge on GNOME/Mutter. Only after publication succeeds does Orca discard Chromium's stale clipboard source. Failures reject without retrying through the broken Electron writer.

AppImage owners use a private, content-addressed executable outside the app mount and the existing environment cleanup. Linux builds and packaging check x64/arm64 binaries against the Ubuntu 20.04 library floor. X11, macOS and Windows bypass the native queue and retain their existing text backends, including terminal write verification. Platform-routing tests exercise both write kinds without helper startup, executable staging or clipboard cache clearing. The unrelated terminal focus change has been removed from this PR.

Why

Electron can return its rejected copy from its cache, so write-then-read verification falsely succeeds. Duplicate suppression cannot fix different-text copies. This reuses the data-control implementation from #25789 and fixes its GNOME fallback and AppImage lifetime, without requiring clipboard commands at runtime or switching Orca's rendering backend.

Temporary workaround for Electron #54645. Stock Electron 43.7.9 and 44.7.0 still reproduce the defect; a dependency bump alone did not fix it. The native README lists the checks and files needed to remove the workaround once upstream repairs it.

Linked Issue

Fixes #26917
Fixes #23229

Visual Proof

Native Ctrl+V on an isolated GNOME/Mutter display, Electron 43.7.5. These before/after captures show the Electron/native-helper reproduction: cached B pastes despite external C before the fix; later external E pastes after publication and cache reset. They are not the full Orca UI.

Before: cached text pastes

After: external text pastes

Full rebuilt Orca on native Wayland, same isolated display: a folder-workspace terminal publishes OSC 52 before native input, then real Mutter Ctrl+Shift+V pastes an external command and Enter executes it. The test launcher allows painting only on this private display; production clipboard sender authorization remains intact.

Orca: native Wayland external paste executes

Testing

  • Manually tested on SSH-accessed Ubuntu 24.04 x64 using private Mutter 46 and Sway 1.9 displays; user clipboard/display untouched. All app/test launches use ORCA_BACKGROUND_LAUNCH=1.
  • Automated regression tests added/updated.

258 focused tests across 15 clipboard, platform-routing, IPC-authority, startup, build and packaging suites pass. All 14 native fake-compositor/GTK tests pass, including cancellation, stalled readers, repeated pastes and a 16 MiB incremental transfer. x64/arm64 binary and library-floor checks, changed-code quality and the complete pnpm build pass after updating with current main. This includes all typechecks, relay/CLI/renderer/web/mobile bundles and macOS native components. An unpacked macOS arm64 package also passes its real packaged-terminal-host PTY check and contains no Linux clipboard helper; release signing/notarization was not exercised.

Full Orca on Mutter: OSC 52 before native input, later external replacement, ordinary text IPC, duplicate/different copies, Unicode/CRLF and 1.1 MB text agree between Orca and the system clipboard. Actual Ctrl+Shift+V paste executes with no cancellation banner; copies and external replacement still pass after native input. Native-helper tests on both compositors also cover 30 copies after real keyboard input and 50 immediate GNOME copies.

All fresh CI checks pass on the reviewed commit: all five unit shards, relay integration, static checks, Linux/Windows packaging, macOS native checks, Windows x64/arm64 persistence, and Linux compatibility checks. Review threads are resolved: explicit automatic backend detection follows session type, and Linux Docker build prerequisites are documented in the contributor guide.

Remaining coverage: hardware compositor configurations, KDE runtime, Linux arm64 runtime, full release installers and two-host paired-runtime routing.

Review

Checked sender authority, byte and queue bounds, ordering, failed publication, owner acknowledgement/cancellation, GTK incremental transfers, AppImage lifetime, packaged resources and explicit rendering-backend overrides. OSC 52 publication stays on the desktop client for local, folder and SSH terminals; no remote wire changes.

Agent skill upstream boundary

  • Not applicable; no agent skill implementation changes.

Notes

The sweep read 47 complete substantive/adjacent issue threads and 174 comments. This addresses text ownership; PRIMARY, images/files, browser-native copy, selection formatting and agents writing to a remote virtual display remain separate paths.

Checklist

  • Focused on Linux clipboard text publication.
  • User-facing behavior, mechanism and alternatives explained.
  • Before/after evidence attached with coverage stated.
  • Self-reviewed for correctness, security and performance.
  • Cross-platform, SSH/folder and compatibility impact considered.
  • All required CI checks pass on the reviewed commit.

@nwparker nwparker changed the title fix(linux): repair Wayland clipboard ownership and paste refocus fix(linux): keep Wayland clipboard text current Oct 12, 2026
@nwparker
nwparker marked this pull request as ready for review October 12, 2026 08:28
@coderabbitai

coderabbitai Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough

Walkthrough

The change adds a native clipboard publisher for Linux Wayland, with an X11/GTK publishing path when the required Wayland data-control support is unavailable. Build and packaging scripts produce architecture-specific executables and include them in Linux resources. Application clipboard writes use the helper on Wayland and retain the Electron clipboard path elsewhere. A shared Linux Wayland session detector also informs GPU startup options.


Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: 🔵 Low · up to a6b77

Rapid copies on non-Wayland platforms could be overwritten out of order, and queued multibyte text can exceed the intended byte budget. Linux native builds now need Docker. These are bounded issues that should be fixed or accepted before merge.

Pre-merge checks | Passed 4 | Failed 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 4.23% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 71 functions across 24 files. (2 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check Passed The PR meets the coding requirements for [#26917] and [#23229]. Linux Wayland text writes use the native publisher, with Wayland data-control and GTK/Xwayland fallback paths. The publisher clears Elec…
Out of Scope Changes check Passed The changes remain within the linked clipboard scope. Native helper code, GTK/Xwayland fallback, IPC routing, AppImage staging, Linux packaging checks, session detection, documentation, and tests supp…
Title check Passed The title clearly identifies the Linux Wayland clipboard fix and matches the primary change in the pull request.
Description check Passed The description is complete and follows the template. It explains the user impact, implementation, rationale, linked issues, visual evidence, testing, review scope, compatibility considerations, and c…

Full details: Docstring Coverage

Explanation

Docstring coverage is 4.23% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 71 functions across 24 files. (2 skipped: 2 unsupported.)


  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 168aa035-c6e3-471b-83c0-454048119920
📥 Commits

Reviewing files that changed from the base of the PR and between 6c3ce44 and 8723e84.

📒 Files selected for processing (26)
  • config/electron-builder.config.cjs
  • config/scripts/build-native-for-platform.mjs
  • config/scripts/build-native-for-platform.test.mjs
  • config/scripts/build-wayland-clipboard.mjs
  • config/scripts/build-wayland-clipboard.test.mjs
  • config/scripts/electron-builder-config.test.mjs
  • config/scripts/electron-builder-runtime-resources.test.mjs
  • config/wayland-clipboard-resources.cjs
  • native/wayland-clipboard/.dockerignore
  • native/wayland-clipboard/Dockerfile
  • native/wayland-clipboard/README.md
  • native/wayland-clipboard/protocol_test.py
  • native/wayland-clipboard/wayland-clipboard.c
  • native/wayland-clipboard/x11-clipboard-publisher.c
  • native/wayland-clipboard/x11-clipboard-publisher.h
  • native/wayland-clipboard/x11_test.py
  • src/main/startup/configure-process.ts
  • src/main/window/clipboard-dashboard-popout-access.test.ts
  • src/main/window/clipboard-ipc-handlers.test.ts
  • src/main/window/clipboard-ipc-handlers.ts
  • src/main/window/clipboard-publisher-executable.test.ts
  • src/main/window/clipboard-publisher-executable.ts
  • src/main/window/clipboard-text-publisher.test.ts
  • src/main/window/clipboard-text-publisher.ts
  • src/shared/linux-wayland-session.test.ts
  • src/shared/linux-wayland-session.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.

Comment thread src/shared/linux-wayland-session.ts Resolved

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

♻️ Duplicate comments (1)
src/shared/linux-wayland-session.ts (1)

15-15: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Match Electron’s default selection when the Ozone switch is absent.

If an X11 session retains WAYLAND_DISPLAY and the caller supplies no ozonePlatform, this fallback selects Wayland. Electron’s default automatic selection uses XDG_SESSION_TYPE, so clipboard writes could take the wrong backend. Treat an absent switch like auto, or confirm that callers always supply Electron’s resolved backend. This is distinct from the previously fixed explicit-auto case. (electronjs.org)

Verify whether the startup and clipboard callers can pass an absent switch:

#!/bin/bash
rg -n -C 8 'isLinuxWaylandSession\(|getSwitchValue\(|ozonePlatform' src/main/startup/configure-process.ts src/main/window/clipboard-text-publisher.ts

ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 25379c63-cf7f-4c62-834d-aeae9c4ca3bf
📥 Commits

Reviewing files that changed from the base of the PR and between 8723e84 and a6b77be.

📒 Files selected for processing (6)
  • .github/CONTRIBUTING.md
  • native/wayland-clipboard/README.md
  • src/main/window/clipboard-platform-routing.test.ts
  • src/main/window/clipboard-text-publisher.ts
  • src/shared/linux-wayland-session.test.ts
  • src/shared/linux-wayland-session.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • native/wayland-clipboard/README.md

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant