Repository navigation
Conversation
📝 WalkthroughWalkthroughThe change adds a native Wayland clipboard helper that supports two data-control protocols, plus Linux build and packaging steps for x64 and arm64. Terminal clipboard writes use the helper in detected Wayland sessions and retain the verified clipboard path for other sessions and specified unsupported-protocol cases. The change also centralizes Linux Wayland-session detection for startup GPU configuration and adds build, protocol, packaging, and clipboard-writer tests. Priority: ➖ Normal Severity of issue fixed: Medium Merge Risk: 🟡 Moderate · up to Terminal copies on Wayland may be cleared immediately after a successful write. Resolve the post-write clear before merging unless that behavior is explicitly accepted. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The new clipboard path limits input and concurrent work, preserves existing caller checks, and does not turn copied text into commands. No introduced security vulnerability was established. Remaining uncertainty concerns clipboard behavior across desktop implementations and the interaction between native ownership and Electron’s cache clearing. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 55 functions across 18 files. (4 skipped: 4 unsupported.)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
8cea5365-19c1-4a64-b53d-ebbbdbb98111
📒 Files selected for processing (22)
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.cjsdocs/reference/linux-glibc-compatibility.mdnative/wayland-clipboard/.dockerignorenative/wayland-clipboard/Dockerfilenative/wayland-clipboard/README.mdnative/wayland-clipboard/protocol_test.pynative/wayland-clipboard/wayland-clipboard.csrc/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-terminal-text-write.test.tssrc/main/window/clipboard-terminal-text-write.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; 1 remain after this review.
| if (result.code !== 0 || result.timedOut) { | ||
| throw new Error(WAYLAND_CLIPBOARD_WRITE_FAILED_ERROR) | ||
| } | ||
| dataControlAccepted = true | ||
| // Discard any rejected Chromium source after the helper has established the actual owner. | ||
| deps.clearCache() |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
🔎 Supported by static analysis
🌐 Web query:
Chromium 150 wayland_clipboard.cc Write nullptr SetSelectionSource clear source clipboard Electron 43
💡 Result:
If you’re asking whether `Write(nullptr)` clears the Wayland clipboard in Electron 43: **the Chromium implementation says yes, with an important caveat.**
In the Chromium `wayland_clipboard.cc` source, `Write()` treats a null or empty data map as a clear: it clears the cached offered data and resets its local data-source pointer. A failed data-source finish also calls `Write(nullptr)`. ([chromium.googlesource.com](https://chromium.googlesource.com/chromium/src/%2B/278e3bab7718860ba4df7274877acc4eb0636266/ui/ozone/platform/wayland/host/wayland_clipboard.cc))
However, that code path does **not** call `SetSelectionSource(nullptr)`. The shown `WaylandDataDevice::SetSelectionSource()` requires a non-null source (`DCHECK(source)`) and passes its Wayland object to `wl_data_device_set_selection()`. So these sources establish local source cleanup, but **do not establish that `Write(nullptr)` explicitly tells the compositor to clear the selection**. ([chromium.googlesource.com](https://chromium.googlesource.com/chromium/src/%2B/93a6ebbe22f1a093e6a0cb5e72ba78990fe39824/ui/ozone/platform/wayland/host/wayland_data_device.cc))
Electron 43.0.0 bundles Chromium 150.0.7871.46, but the Chromium source snapshot found here is a different, unidentified revision—not confirmed as that exact bundled version. ([releases.electronjs.org](https://releases.electronjs.org/release/v43.0.0?utm_source=openai))
Citations:
- 1: https://chromium.googlesource.com/chromium/src/%2B/278e3bab7718860ba4df7274877acc4eb0636266/ui/ozone/platform/wayland/host/wayland_clipboard.cc
- 2: https://chromium.googlesource.com/chromium/src/%2B/93a6ebbe22f1a093e6a0cb5e72ba78990fe39824/ui/ozone/platform/wayland/host/wayland_data_device.cc
- 3: https://releases.electronjs.org/release/v43.0.0?utm_source=openai
🏁 Script executed:
find node_modules -path '*/ui/ozone/platform/wayland/host/wayland_clipboard.cc' -o -name electron_api_clipboard.cc 2>/dev/null | head -12Repository: stablyai/orca
Length of output: 151
🏁 Script executed:
printf '%s\n' '--- relevant writer and bindings ---'
nl -ba src/main/window/clipboard-terminal-text-write.ts | sed -n '1,135p'
rg -n -F -- 'clearCache: () => clipboard.clear()' src
rg -n -F -- 'writeTerminalClipboardText' src/main/window
printf '%s\n' '--- Electron version pins ---'
rg -n '"electron"|electron@|43\.7\.5|43\.7' package.json package-lock.json npm-shrinkwrap.json pnpm-lock.yaml yarn.lock 2>/dev/null || true
printf '%s\n' '--- Wayland helper selection ownership ---'
nl -ba native/wayland-clipboard/wayland-clipboard.c | sed -n '285,350p'
printf '%s\n' '--- clipboard API references in repository ---'
rg -n -F -- 'clipboard.clear()' src docs README.md native 2>/dev/null || trueRepository: stablyai/orca
Length of output: 8508
🌐 Web query:
Electron 43.7.5 Chromium version DEPS commit Chromium 150 Wayland clipboard Write nullptr SetSelectionSource
💡 Result:
Electron **v43.7.5** uses **Chromium 150.0.7871.250**. Its `DEPS` pins Chromium source to the same version string; the release page lists the Chromium version, and the tag’s `DEPS` confirms the pin. ([releases.electronjs.org](https://releases.electronjs.org/release/v43.7.5))
If you’re asking whether that Chromium revision fixes Wayland clipboard writes involving `SetSelectionSource(nullptr)`: **I couldn’t establish that from the available sources.** The Chromium 150 code/test result I found concerns **ChromeOS Exo’s `Seat::SetSelection(nullptr)`**, and checks that clearing the selection does not overwrite the regular clipboard. That is not evidence of a fix in Ozone’s Wayland clipboard path. ([sources.debian.org](https://sources.debian.org/src/chromium/150.0.7871.100-1~deb13u1/components/exo/seat_unittest.cc?utm_source=openai))
The closest Wayland source I found shows `WaylandDataDevice::SetSelectionSource` asserting that `source` is non-null, so that particular implementation does not support passing `nullptr`. However, it is not verified as the exact Chromium revision bundled by Electron 43.7.5. ([chromium.googlesource.com](https://chromium.googlesource.com/chromium/src/%2B/93a6ebbe22f1a093e6a0cb5e72ba78990fe39824/ui/ozone/platform/wayland/host/wayland_data_device.cc?utm_source=openai))
Citations:
- 1: https://releases.electronjs.org/release/v43.7.5
- 2: https://sources.debian.org/src/chromium/150.0.7871.100-1~deb13u1/components/exo/seat_unittest.cc?utm_source=openai
- 3: https://chromium.googlesource.com/chromium/src/%2B/93a6ebbe22f1a093e6a0cb5e72ba78990fe39824/ui/ozone/platform/wayland/host/wayland_data_device.cc?utm_source=openai
🌐 Web query:
Electron v43.7.5 GitHub DEPS chromium_revision Wayland wayland_clipboard.cc Write nullptr clipboard.clear docs version 43
💡 Result:
For **Electron v43.7.5**:
- **Chromium revision:** `DEPS` pins Chromium **150.0.7871.250**; it specifies that version as the Chromium checkout. ([github.com](https://github.com/electron/electron/blob/v43.7.5/DEPS))
- **Clipboard docs:** `clipboard.clear([type])` clears clipboard content. On Linux, the optional `type` can be `selection` or `clipboard`; `selection` is Linux-only. ([github.com](https://github.com/electron/electron/blob/v43.7.5/docs/api/clipboard.md))
- **Wayland `nullptr` detail:** I couldn’t verify the exact `wayland_clipboard.cc` code against the Chromium revision pinned by v43.7.5, so I can’t establish what the `nullptr` check means in that exact version. The Chromium source surfaced in search is a separate revision and should not be treated as v43.7.5’s source. ([chromium.googlesource.com](https://chromium.googlesource.com/chromium/src/%2B/278e3bab7718860ba4df7274877acc4eb0636266/ui/ozone/platform/wayland/host/wayland_clipboard.cc?utm_source=openai))
Citations:
- 1: https://github.com/electron/electron/blob/v43.7.5/DEPS
- 2: https://github.com/electron/electron/blob/v43.7.5/docs/api/clipboard.md
- 3: https://chromium.googlesource.com/chromium/src/%2B/278e3bab7718860ba4df7274877acc4eb0636266/ui/ozone/platform/wayland/host/wayland_clipboard.cc?utm_source=openai
Do not use clipboard.clear() for cache-only cleanup.
When the helper succeeds and owns the Wayland clipboard selection, clipboard.clear() can clear the text the helper just published. Electron 43.7.5 documents this API as clearing clipboard content, not only Chromium’s cached source. A later paste can therefore lose the copied text.
|
GNOMEでの追加検証結果を#26917にまとめました: #26917 (comment) このPRのhead このMutterでは 新しいclipboard PRは作っていません。data-controlを公開しないGNOMEで残るfallback経路は、このPRの追加対象として扱う方針でしょうか。それとも、このPRの対応範囲を明示して別途設計するのがよいでしょうか。既存の対応環境での価値を否定する意図ではなく、GNOME coverageの不足を具体化する証拠として共有します。 |
|
Superseded by merged #27772: #27772 The merged fix reuses this PR's native data-control implementation and adds the GNOME/Mutter clipboard bridge, ordinary UI text copies, and AppImage owner staging. Real clipboard publication and subsequent native pastes were verified on isolated Mutter and Sway displays, including copies after native input. It also links Electron #54645 and documents when the workaround can be removed. Closing this older implementation to keep one merged fix for #23229 and #26917. Its native implementation and investigation were carried forward. |
ELI5
On Sway and similar Wayland desktops, copying text from a terminal could leave Orca pasting an old value forever. Terminal copies now use a small bundled clipboard owner, and Orca discards the stale value it had kept internally. Users do not need to install
wl-copy.What Changed
The terminal clipboard IPC uses Wayland's data-control protocol, which does not need the last keyboard or mouse event to accept a copy. The helper acknowledges the new owner before Orca clears Electron's old clipboard source/cache. The helper reports success only after its detached owner starts. It serves later pastes, survives Orca exit, and exits when replaced or disconnected. Requests and queued text are bounded; a paste expires only after two seconds without progress.
Desktops exposing neither supported data-control protocol retain the existing Electron backend. X11, macOS and Windows retain their existing verified writes. Linux packages build and validate a bundled x64 or arm64 helper against Ubuntu 20.04. Cached builds recover their executable mode, and packaging checks the actual copied helper before the existing binary compatibility gate.
Why
Electron can silently retain a rejected clipboard source: even its write-then-read verification returns the value that the compositor rejected. Skipping duplicate text only prevents one trigger; copying different text still reproduces the freeze. Publishing through data-control removes the stale input serial from terminal copies, and clearing Electron's old source also repairs an already-stuck session. Bundling the helper avoids an optional system-package dependency.
Upstream research found the same ownership defect in Electron #54645, currently open. Electron's clipboard redesign still uses Chromium's existing native writer. On isolated Sway, both Electron 44.5.1 / Chromium 152 and 45.0.0-alpha.15 / Chromium 156 reproduce the rejection and stale cache, despite awaiting the new Promise API. Renderer clipboard APIs also reproduce it. Clearing the cache alone repairs pastes but loses the attempted copy, so an upgrade or cache-only change does not replace the publisher.
Linked Issue
Fixes #23229
Visual Proof
These are CDP screenshots of an isolated Electron reproduction on headless Sway, exercising Orca's production OSC 52 parser and main clipboard writer through preload IPC. They are not screenshots of the full Orca UI.
Before: after an external app replaces
BwithC, an actual Ctrl+V still pastesB.After: terminal copies succeed, and a later external
remote-externalcopy pastes correctly.Testing
Linux runtime verification used an SSH-accessed Ubuntu 24.04 x64 host, isolated Sway 1.9 / wlroots 0.17.1, and the checkout's Electron 43.7.5. Verified duplicate/different OSC 52 copies, later external copies with actual Ctrl+V, recovery of an already-stuck cache, byte-exact Unicode/CRLF text after Electron exit, and owner cleanup on replacement. All launches/tests used
ORCA_BACKGROUND_LAUNCH=1and native input stayed on the isolated display.310 tests across 17 focused clipboard, OSC 52, shortcut, rejection, startup, process, packaging and compatibility suites passed. All 12 native fake-compositor tests passed, covering both protocols, repeated pastes, unsupported/missing displays, input limits, incoming offers, owner cancellation and bounded stalled receivers. x64 and cross-built arm64 helpers passed ELF architecture and glibc-floor checks.
pnpm tc:nodeandpnpm run check:code-quality:changedpassed.Full Orca UI/Claude sessions, GNOME/KDE runtime, arm64 runtime and complete release installers have not been exercised. The resource-copy test covers the helper's packaged path and executable mode. The full lint/typecheck/test/build suite remains for CI.
Review
Four review passes checked payload limits, request ordering, owner startup/cancellation, capability loss, slow paste readers, cached executable mode, packaged resource presence and cross-platform/SSH boundaries. Six failure cases were reproduced with regression tests and fixed. The final pass has no unresolved findings; the runtime/platform coverage limits above still apply.
Agent skill upstream boundary
Notes
Clipboard ownership remains on the desktop client, including folder workspaces and terminal output from SSH hosts. No remote wire or execution-host requirements change. Ordinary/image clipboard and primary-selection writes are outside this change. Docker is a build prerequisite, not a user runtime dependency.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)