Clipboard and paste - #1271
Open
simonklee wants to merge 32 commits into
Open
Conversation
simonklee
force-pushed
the
ot-clipboard-and-paste-backend
branch
3 times, most recently
from
July 29, 2026 14:18
6ca1eef to
c69f98a
Compare
simonklee
force-pushed
the
ot-clipboard-and-paste-backend
branch
2 times, most recently
from
August 3, 2026 05:12
7a6f116 to
1395a05
Compare
create portable boundary so applications can negotiate clipboard content and choose host or terminal writes without platform dependencies. Make selection, remote consent, cancellation, and partial outcomes explicit.
Provide a bounded, cancellable lifecycle for host clipboard work and route writes safely between host and OSC 52 destinations. The callback-free native worker boundary prepares for platform APIs without blocking JavaScript.
Back the host clipboard service with Wayland on Linux so applications can access clipboard and primary selections without terminal escape sequences. Keep published data available after writes complete while preserving bounded, cancellable operations.
Initialize X11 clipboard state incrementally so backend startup cannot stall the render loop. Preserve deterministic Wayland selection updates across successful, deferred, and failed flushes.
Enable native clipboard operations on X11 hosts and fall back to X11 when Wayland is unavailable or cannot serve an operation. Support incremental transfers so large clipboard payloads remain reliable.
Use native pasteboard APIs outside Linux so host clipboard operations work across all supported desktop platforms. Keep cancellation, timeout, and size-limit semantics in the shared service, and accept real-world X11 INCR/text behavior seen from xclip and xsel.
Keep the runtime alive while clipboard work is pending and honor each host's cancellation, timeout, text, and selection semantics. This prevents idle exits and platform quirks from losing clipboard data.
Prevent non-Linux builds from reaching unavailable POSIX paths and skip Linux-specific clipboard tests outside their supported platform.
Windows applications often publish images only as CF_DIB or CF_DIBV5. Convert these formats to PNG so image reads succeed without a native PNG format while honoring resource, cancellation, and timeout limits.
WSLg lacks data-control extensions used by the Wayland backend. Fall back to its core data-device protocol so clipboard reads work, including BMP images converted to PNG for callers.
Serialize platform mutations and reject stale asynchronous results so clipboard reads, writes, and shutdown cannot publish invalid state.
Keep clipboard shutdown and selection cleanup independent so pending operations do not block unrelated selections or leave stale state.
Selection events only dispatch while the connection is driven, so an offer cached across idle time can predate the read.
Confirm X11 selection ownership before reporting writes and clears, while keeping confirmation bounded by cancellation and operation deadlines. Clean up INCR event subscriptions and preserve compatible TEXT fallbacks. Recognize WAYLAND_SOCKET sessions, keep transferred write descriptors blocking, order all reads behind selection barriers, and release callbacks when a Wayland connection fails. Preserve macOS TIFF orientation, reject unsupported Windows DIB color profiles, and keep DIB compression responsive to cancellation.
Keep Wayland and X11 lifecycle tests restricted to Linux while preserving portable backend state-machine coverage on every target. Remove a redundant WSL assertion that incorrectly exercised macOS platform dispatch. Decode mocked XCB events without assuming pointer alignment, preventing ARM64 test aborts, and skip Linux-specific X11 socket, Xauthority, and connection integration tests on unsupported targets.
Validate before abort short-circuits and skip terminal fallback after cancel. Fail fatal Wayland flushes without taking ownership, honor explicit BI_RGB alpha in V4/V5 DIBs, accept xsel TEXT→STRING and equal-time SelectionClear, and block recreate on inherited Wayland.
Mark the not-attempted status fixture as const so its literal types match the service result shape under strict equality checks.
simonklee
force-pushed
the
ot-clipboard-and-paste-backend
branch
from
August 7, 2026 12:33
1395a05 to
ea6817f
Compare
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.
This adds a cross-platform clipboard to OpenTUI. It combines two clipboard mechanisms behind one API:
References