Skip to content

Clipboard and paste - #1271

Open
simonklee wants to merge 32 commits into
mainfrom
ot-clipboard-and-paste-backend
Open

Clipboard and paste#1271
simonklee wants to merge 32 commits into
mainfrom
ot-clipboard-and-paste-backend

Conversation

@simonklee

@simonklee simonklee commented Jul 16, 2026

Copy link
Copy Markdown
Member

This adds a cross-platform clipboard to OpenTUI. It combines two clipboard mechanisms behind one API:

  • Host clipboard reads and modifies the clipboard of the machine running the OpenTUI process.
  • Terminal clipboard writes or clears the terminal user's clipboard using OSC 52.

References

@simonklee simonklee self-assigned this Jul 16, 2026
@simonklee
simonklee force-pushed the ot-clipboard-and-paste-backend branch 3 times, most recently from 6ca1eef to c69f98a Compare July 29, 2026 14:18
@simonklee
simonklee force-pushed the ot-clipboard-and-paste-backend branch 2 times, most recently from 7a6f116 to 1395a05 Compare August 3, 2026 05:12
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
simonklee force-pushed the ot-clipboard-and-paste-backend branch from 1395a05 to ea6817f Compare August 7, 2026 12:33
@simonklee simonklee changed the title ot clipboard and paste backend Clipboard and paste Aug 7, 2026
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