Repository navigation
fix(linux): keep Wayland clipboard text current - #27772
Conversation
📝 Walkthrough
Priority: ➖ Normal Severity of issue fixed: Medium Merge Risk: 🔵 Low · up to 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 |
|
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
168aa035-c6e3-471b-83c0-454048119920
📒 Files selected for processing (26)
config/electron-builder.config.cjsconfig/scripts/build-native-for-platform.mjsconfig/scripts/build-native-for-platform.test.mjsconfig/scripts/build-wayland-clipboard.mjsconfig/scripts/build-wayland-clipboard.test.mjsconfig/scripts/electron-builder-config.test.mjsconfig/scripts/electron-builder-runtime-resources.test.mjsconfig/wayland-clipboard-resources.cjsnative/wayland-clipboard/.dockerignorenative/wayland-clipboard/Dockerfilenative/wayland-clipboard/README.mdnative/wayland-clipboard/protocol_test.pynative/wayland-clipboard/wayland-clipboard.cnative/wayland-clipboard/x11-clipboard-publisher.cnative/wayland-clipboard/x11-clipboard-publisher.hnative/wayland-clipboard/x11_test.pysrc/main/startup/configure-process.tssrc/main/window/clipboard-dashboard-popout-access.test.tssrc/main/window/clipboard-ipc-handlers.test.tssrc/main/window/clipboard-ipc-handlers.tssrc/main/window/clipboard-publisher-executable.test.tssrc/main/window/clipboard-publisher-executable.tssrc/main/window/clipboard-text-publisher.test.tssrc/main/window/clipboard-text-publisher.tssrc/shared/linux-wayland-session.test.tssrc/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.
There was a problem hiding this comment.
Actionable comments posted: 2
♻️ Duplicate comments (1)
src/shared/linux-wayland-session.ts (1)
15-15: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winMatch Electron’s default selection when the Ozone switch is absent.
If an X11 session retains
WAYLAND_DISPLAYand the caller supplies noozonePlatform, this fallback selects Wayland. Electron’s default automatic selection usesXDG_SESSION_TYPE, so clipboard writes could take the wrong backend. Treat an absent switch likeauto, or confirm that callers always supply Electron’s resolved backend. This is distinct from the previously fixed explicit-autocase. (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
📒 Files selected for processing (6)
.github/CONTRIBUTING.mdnative/wayland-clipboard/README.mdsrc/main/window/clipboard-platform-routing.test.tssrc/main/window/clipboard-text-publisher.tssrc/shared/linux-wayland-session.test.tssrc/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.
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.
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.
Testing
ORCA_BACKGROUND_LAUNCH=1.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 buildpass after updating with currentmain. 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
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