Skip to content

fix(cli) Linux clipboard selection#32370

Open
bornmw wants to merge 1 commit into
anomalyco:devfrom
bornmw:linux-clipboard-selection
Open

fix(cli) Linux clipboard selection#32370
bornmw wants to merge 1 commit into
anomalyco:devfrom
bornmw:linux-clipboard-selection

Conversation

@bornmw

@bornmw bornmw commented Jun 15, 2026

Copy link
Copy Markdown

Linux clipboard selection support (fixes #29963)

Issue for this PR

Closes #29963

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

When I select text in Linux terminal it is expected that it's copied to PRIMARY buffer and I can paste it with a mouse middle button click. Opencode only copies to Clipboard (pasted with Ctrl-V).
Added a config option to selected between Clipboard / Primary / Both (default) and added additional calls to xclip and others.
I implemented Promise.allSettled to update both buffers in parallel

How did you verify your code works?

I select text and selection goes to the configured destination - Clipboard / Primary / Both (default)

Screenshots / recordings

there's no way to record a video that would show difference between pasting via Ctrl-V and middle button click

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

If you do not follow this template your PR will be automatically rejected.

@github-actions

Copy link
Copy Markdown
Contributor

Hey! Your PR title Linux clipboard selection doesn't follow conventional commit format.

Please update it to start with one of:

  • feat: or feat(scope): new feature
  • fix: or fix(scope): bug fix
  • docs: or docs(scope): documentation changes
  • chore: or chore(scope): maintenance tasks
  • refactor: or refactor(scope): code refactoring
  • test: or test(scope): adding or updating tests

Where scope is the package name (e.g., app, desktop, opencode).

See CONTRIBUTING.md for details.

@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Potential Duplicate PRs Found

  1. PR fix: enable primary clipboard copy for Wayland/X11 to fix Linux middle-click paste #6370: "fix: enable primary clipboard copy for Wayland/X11 to fix Linux middle-click paste"

  2. PR fix(tui): prevent false clipboard copy success on Linux #31252: "fix(tui): prevent false clipboard copy success on Linux"

  3. PR fix(opencode): report clipboard copy failures #27861: "fix(opencode): report clipboard copy failures"

Note: PR #6370 appears to be the most relevant, as it specifically addresses enabling PRIMARY clipboard copy for Linux middle-click paste functionality—the exact feature being implemented in PR #32370.

@bornmw

bornmw commented Jun 15, 2026

Copy link
Copy Markdown
Author

The following comment was made by an LLM, it may be inaccurate:

Potential Duplicate PRs Found

I reviewed the potential duplicates flagged by the bot, and here is how this PR compares:

PR #31252 and PR #27861 are not duplicates. They handle clipboard failure reporting and error validation rather than the primary selection buffer.

PR #6370 attempts to solve the same underlying issue (adding PRIMARY selection for Linux middle-click paste), but there are a few key differences. First, that PR has been stalled since December. Second, my implementation introduces a more flexible configuration approach—letting the user explicitly choose between Clipboard, Primary, or Both (defaulting to Both)—whereas #6370 uses a simple boolean toggle. Finally, this PR optimizes the copy operation under the hood by utilizing Promise.allSettled to update the buffers in parallel.

Given these architectural differences and the inactivity on #6370, I believe this PR provides a more robust and complete solution to closing #29963. Let me know if any changes are needed!

@bornmw bornmw force-pushed the linux-clipboard-selection branch from b1cb38a to c6e0c83 Compare June 15, 2026 04:19
@bornmw bornmw changed the title Linux clipboard selection fix(cli) Linux clipboard selection Jun 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE]: Add support for Linux PRIMARY selection (middle-click paste)

1 participant