Skip to content

fix: prefer native clipboard on WSL - #2168

Closed
aka-luan wants to merge 1 commit into
herdrdev:masterfrom
aka-luan:fix/wsl-native-clipboard
Closed

aka-luan wants to merge 1 commit into
herdrdev:masterfrom
aka-luan:fix/wsl-native-clipboard

Conversation

@aka-luan

@aka-luan aka-luan commented Aug 1, 2026

Copy link
Copy Markdown

Summary

  • prefer the native platform clipboard for local WSL sessions
  • keep OSC 52 preferred for SSH sessions
  • retain OSC 52 as the fallback when native clipboard writing fails
  • add regression coverage for local WSL clipboard routing

Problem

Herdr 0.7.5 forced OSC 52 for every WSL session. In Hyper under WSL, the OSC 52 sequence was not applied to the host clipboard, leaving the clipboard stale after selecting text in a pane. The native WSL clipboard bridge works correctly.

Testing

  • (19 passed)

@coderabbitai

coderabbitai Bot commented Aug 1, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 5a63e4ee-b839-40aa-9e82-d65ef043abd7

📥 Commits

Reviewing files that changed from the base of the PR and between 219e0be and f445e08.

📒 Files selected for processing (1)
  • src/selection.rs

📝 Walkthrough

Walkthrough

WSL sessions no longer prefer OSC 52 clipboard writes. SSH sessions retain OSC 52 preference. The WSL clipboard test now expects native clipboard handling.

Changes

Clipboard selection

Layer / File(s) Summary
Update WSL clipboard preference
src/selection.rs
should_prefer_osc52_for_env retains SSH-based preference and no longer selects OSC 52 for WSL. The WSL test verifies native clipboard selection.

Estimated code review effort: 1 (Trivial) | ~5 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: preferring the native clipboard on WSL.
Description check ✅ Passed The description explains the WSL clipboard routing changes, fallback behavior, regression coverage, and testing.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@kangal-bot kangal-bot added the ai-review Trigger automated AI reviews for pull requests admitted by the PR gate label Aug 1, 2026
@greptile-apps

greptile-apps Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR changes clipboard routing so local WSL sessions try the native platform clipboard first while SSH sessions continue to prefer OSC 52.

  • Removes WSL alone as a reason to prefer OSC 52.
  • Retains OSC 52 fallback when native clipboard writing fails.
  • Updates regression coverage for local WSL routing.

Confidence Score: 5/5

The PR appears safe to merge with native clipboard failure still falling back to OSC 52.

Local WSL now attempts the native clipboard first, SSH sessions still select OSC 52 directly, and unsuccessful native writes continue through the existing OSC 52 fallback.

Important Files Changed

Filename Overview
src/selection.rs Updates the WSL clipboard preference decision and its regression test while preserving SSH routing and native-write fallback behavior.

Reviews (1): Last reviewed commit: "fix: prefer native clipboard on WSL" | Re-trigger Greptile

@ogulcancelik

Copy link
Copy Markdown
Collaborator

thanks for the report. osc 52 is the widely supported terminal-native clipboard path and is currently the most robust option for wsl because the attaching terminal writes directly to the windows clipboard. we intentionally made it the wsl default in #333 after wslg tools such as wl-copy succeeded without populating windows clipboard history.

this appears to be a hyper limitation. hyper’s osc 52 support request remains open, although xterm.js added support in xtermjs/xterm.js#4220.

this pr is therefore not a safe general fix. it changes clipboard routing for every local wsl session and would restore the behavior that caused #333. the osc 52 fallback does not prevent that regression because a wslg clipboard command can return success without updating windows clipboard history. hyper should add osc 52 support rather than changing herdr’s wsl default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-review Trigger automated AI reviews for pull requests admitted by the PR gate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants