Skip to content

feat(clipboard): Add persistent WSL clipboard bridge - #25

Merged
Unique-Divine merged 13 commits into
mainfrom
feat/wsl-clipboard
Aug 11, 2026
Merged

feat(clipboard): Add persistent WSL clipboard bridge#25
Unique-Divine merged 13 commits into
mainfrom
feat/wsl-clipboard

Conversation

@Unique-Divine

Copy link
Copy Markdown
Owner

Add persistent WSL clipboard bridge

This branch replaces one-shot WSL clipboard commands with a persistent Rust
bridge, while carrying the Rust workspace, CI, and local tooling work already
present on the branch.

Rationale

Each legacy paste launched a fresh powershell.exe, making process creation
the dominant cost and exposing fragile UTF-8/UTF-16 clipboard boundaries. A
per-user daemon keeps one constrained PowerShell process warm and exposes only
copy, paste, status, and stop operations over an owner-only Unix socket.

The public pbcopy and pbpaste interface remains unchanged for Neovim and
shell tooling. Image paste remains separate, and the old one-shot commands are
retained under legacy-* names for regression and performance comparison.

Key Changes

  1. Add a Rust workspace, persistent WSL clipboard daemon, lifecycle handling,
    framing, and a release installation path.
  2. Preserve command compatibility with pbcopy/pbpaste symlinks that
    dispatch to one installed binary by invocation name.
  3. Add Rust CI, Unicode-focused clipboard coverage, benchmark baselines, and
    related branch-local Herdr and Codex configuration updates.

1 - Clipboard lifecycle and compatibility

pbcopy / pbpaste symlink
            |
            v
wsl-clipboard argv[0] dispatch
            |
            v
owner-only Unix socket -> persistent PowerShell (-STA) -> Windows clipboard

just sync installs one release binary and creates same-directory aliases in
~/.local/bin. The first copy or paste lazily starts the daemon; subsequent
clients reuse its single serialized PowerShell request/response stream. The
bridge accepts lossless valid UTF-8 text and performs the Windows UTF-16
conversion inside PowerShell, rather than requiring callers such as Neovim to
pipe UTF-16LE bytes.

The aliases add no Bash process. A short benchmark measured pbpaste through
the symlink at 11.0 ms median versus 10.6 ms for direct binary invocation,
which is within subprocess timing noise.

2 - Performance and text fidelity

legacy pbpaste: spawn PowerShell -> read clipboard -> exit
bridge pbpaste: socket request -> warm PowerShell -> response

The reusable benchmark preserves the legacy commands under explicit names and
compares them with the bridge. In the latest short run, the bridge measured
about 10.7x faster copy, 31.0x faster paste, and 21.4x faster round trips than
the retained legacy wrappers. The lower-level persistent PowerShell protocol
remains sub-millisecond after startup; end-to-end CLI timing also includes the
Linux client process and socket hop.

Unicode coverage includes multiline and trailing-newline cases, punctuation,
winfixtext-style mojibake fixtures, combining characters, Japanese, astral
Unicode, emoji, ZWJ emoji, and flags. The old image-paste workflow remains
unchanged.

3 - Branch context

This branch also contains the root Cargo workspace and Rust CI integration,
plus existing Herdr and Codex configuration changes that were already ahead of
origin/main. They are not required for the clipboard protocol itself, but
the workspace and CI changes provide its build and lint surface.

@Unique-Divine
Unique-Divine merged commit bc9e3e5 into main Aug 11, 2026
2 checks passed
@Unique-Divine
Unique-Divine deleted the feat/wsl-clipboard branch August 11, 2026 09:40
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.

[perf] Improve WSL clipboard copy and paste latency

1 participant