GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat(tui): add linux_clipboard_selection config for primary buffer support by bornmw · Pull Request #32370 · anomalyco/opencode

Conversation

@bornmw

@bornmw bornmw commented Jun 15, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Issue for this PR

Closes #43176
Fixes #6110
Supersedes #6370 (extends it with primary/both modes, primary-read support, and the wl-copy MIME fix)

Type of change

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

What does this PR do?

Reimplemented against the v2 branch (per @simonklee's request): the v2 TUI runs on OpenTUI, whose core clipboard already supports the primary selection natively, so this PR adds a config knob on top of that support instead of hand-rolled clipboard plumbing. The v1-only wl-copy --type text/plain MIME workaround and manual OSC52 guards are dropped.

Adds a linux_clipboard_selection config option (tui.json):

  • clipboard: Standard clipboard only (Ctrl+V)
  • primary: Targets the middle-click buffer; TUI paste reads from it too
  • both: Updates both buffers simultaneously (default)

With the default both, copies on Linux now also write the primary selection — this extends existing copy behavior rather than replacing it. On other platforms the primary write simply reports unsupported and is ignored.

Also documents the option in the TUI docs and adds it to the settings dialog.

How did you verify your code works?

Built a local binary from this branch, set the option to Clipboard / Primary / Both, and verified middle-click paste picks up copies from each configured mode. bun typecheck and the TUI test suite pass, including new selection-routing and config tests.

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

bornmw, sbalmer, pdana, PhilipMourdjis, rogercost, astrolox, sshnaidm, afriemann, and klarose reacted with thumbs up emoji kylebakerio reacted with rocket emoji
All reactions
  • 👍 9 reactions
  • 🚀 1 reaction
@github-actions github-actions Bot added the needs:title label Jun 15, 2026
@github-actions

github-actions Bot commented Jun 15, 2026

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions

github-actions Bot commented Jun 15, 2026

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"

    • fix: enable primary clipboard copy for Wayland/X11 to fix Linux middle-click paste #6370
    • Directly addresses PRIMARY clipboard support for Linux middle-click paste, which is the core feature of PR feat(tui): add linux_clipboard_selection config for primary buffer support #32370
  2. PR fix(tui): prevent false clipboard copy success on Linux #31252: "fix(tui): prevent false clipboard copy success on Linux"

    • fix(tui): prevent false clipboard copy success on Linux #31252
    • Related to Linux clipboard handling and validation
  3. PR fix(opencode): report clipboard copy failures #27861: "fix(opencode): report clipboard copy failures"

    • fix(opencode): report clipboard copy failures #27861
    • Related to clipboard copy error handling on Linux

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bornmw

bornmw commented Jun 15, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

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!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot mentioned this pull request Jun 15, 2026
📊 AI CLI 工具社区动态日报 2026-06-15 litang9/big_model_radar#65
Open
@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
@bornmw bornmw changed the title fix(cli) Linux clipboard selection fix(cli): Linux clipboard selection Jun 24, 2026
@github-actions github-actions Bot removed the needs:title label Jun 24, 2026
@github-actions github-actions Bot mentioned this pull request Jul 4, 2026
fix(tui): flush OSC 52 clipboard write, propagate errors on fallback #35289
Closed
3 tasks done
@github-actions github-actions Bot mentioned this pull request Jul 12, 2026
fix(tui): Windows clipboard - use PowerShell directly for text paste #36470
Closed
@bornmw bornmw changed the title fix(cli): Linux clipboard selection feat(opencode): add linux_clipboard_selection config for primary buffer support Aug 18, 2026
@bornmw
bornmw force-pushed the linux-clipboard-selection branch from 693c292 to f5bfa85 Compare August 18, 2026 04:10
bornmw
bornmw commented Aug 19, 2026
View reviewed changes

@bornmw bornmw left a comment

Copy link
Copy Markdown
Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR #32370 — feat(opencode): add linux_clipboard_selection config for primary buffer support

Verdict: Request changes (small)

The feature is sound and the bundled fix is the real value. The issues are formatting, one behavioral gap, and some type hygiene.

What is good

  • The wl-copy --type text/plain;charset=utf-8 fix is the most important line in this PR. Without it, piped wl-copy offers only application/octet-stream (wl-copy dumps stdin to a temp file named stdin, and xdg-mime content-sniffing on an extensionless file returns octet-stream), which text editors reject. This is arguably a hidden bug fix inside a feature PR — worth calling out explicitly in the description.
  • Clean separation: copyCommand stays pure, getCopyMethod routes by selection, Promise.allSettled for "both" is correct.
  • Schema annotation carries the description into the generated tui.json schema.
  • Tests cover all copyCommand branches including the MIME fix.

Issues

  1. OSC52 bypasses the selection setting (most substantive). write() calls writeOsc52(text) unconditionally before routing to the selection-specific method (clipboard.ts). With linux_clipboard_selection: "primary", the regular clipboard is still written via OSC52 whenever the terminal supports it (tmux, kitty, wezterm...). OSC52 also cannot target the primary buffer. "primary" mode is therefore not primary-only. Suggest skipping OSC52 for "primary" (or threading selection into it).

  2. Formatting: the PR introduces Prettier violations in all 4 modified source files. The repo uses prettier (printWidth 120, semi: false) and base dev is clean, but this PR fails bunx prettier --check on clipboard.ts (xsel ternary, copyMethod type), clipboard.tsx (138-char ClipboardProvider signature), config/index.tsx (Resolved Omit), and clipboard.test.ts (long toEqual arrays). CI only runs tsgo typecheck so this will not block, but it deviates from repo convention — run bunx prettier --write on the changed files.

  3. Union types duplicated in three files; exported ClipboardSelection is unused. "clipboard" | "primary" | "both" appears in clipboard.ts, config/index.tsx (Resolved), and clipboard.tsx (ClipboardConfig); copyCommand uses an inline "clipboard" | "primary" instead of the exported ClipboardSelection. Define one shared type and reuse it.

  4. Non-Linux platforms silently ignore the selection. The osascript (macOS) and PowerShell (Windows) branches do not read selection, so primary/both degrade to clipboard-only writes there. Defensible given the linux_ scope, but worth documenting (or gating the option in resolve()).

  5. Minor: props.linuxClipboardSelection! non-null assertion in ClipboardProvider is avoidable; PR history has 2 merge commits + "trigger title check" (squash on merge); PR body says "Closes #43176" while the duplicate-PR comment references #29963 — keep the linked issue consistent.

Note (not a blocker)

  • Runtime write() routing ("both"/allSettled) has no test coverage — acceptable given spawn mocking cost, but a natural follow-up.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bornmw bornmw changed the title feat(opencode): add linux_clipboard_selection config for primary buffer support feat(tui): add linux_clipboard_selection config for primary buffer support Aug 19, 2026
@bornmw

bornmw commented Aug 19, 2026

Copy link
Copy Markdown
Author

Addressed all review comments:

  1. OSC52 now skips for primary selection
  2. Files formatted with prettier
  3. ClipboardSelection type unified across files
  4. Non-null assertion removed in ClipboardProvider
  5. PR title updated to feat(tui): add linux_clipboard_selection config
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bornmw

bornmw commented Aug 19, 2026

Copy link
Copy Markdown
Author

Verified the changes against the latest head (115aa803e). Typecheck passes and all 196 TUI tests pass (195 pass / 1 skip). Four of the five items are solid:

  1. OSC52 skips for primary - write() now guards with if (selection !== "primary") before writeOsc52. Correct for all three selections: primary skips OSC52, both/clipboard keep it.
  2. ClipboardSelection unified - ClipboardConfig removed; clipboard.tsx imports type ClipboardSelection from clipboard.ts, which now includes "both". copyCommand and copyMethod reuse it. Typechecks cleanly.
  3. Non-null assertion removed - write(text, props.linuxClipboardSelection) narrows correctly in the closure; no error.
  4. PR title now feat(tui): add linux_clipboard_selection config for primary buffer support - conventional format.

One item is not actually done:

  • Prettier - bunx prettier --check still fails on the same 4 files. The violations are unchanged: clipboard.ts (xsel ternary), clipboard.tsx (138-char ClipboardProvider signature), config/index.tsx (description string and Resolved Omit), and clipboard.test.ts (long toEqual arrays). These don't block CI (it only runs tsgo), but they still deviate from repo convention. Run bunx prettier --write on the 4 files and the review item is fully closed.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bornmw

bornmw commented Aug 19, 2026

Copy link
Copy Markdown
Author

Fixes applied. Prettier formatting now complete. Commit cb7bf05 updates all 4 files.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bornmw

bornmw commented Aug 19, 2026

Copy link
Copy Markdown
Author

Confirmed — all review items are now closed. cb7bf057c is purely formatting (no logic changes): it reformats exactly the 4 flagged spots (clipboard.ts xsel ternary, clipboard.tsx ClipboardProvider signature, config/index.tsx description + Resolved Omit, clipboard.test.ts toEqual arrays). bunx prettier --check passes on all 4 files, bun typecheck is clean, and all 196 TUI tests pass (195 pass / 1 skip).

LGTM from the review side. Good to merge.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

bornmw
bornmw commented Aug 20, 2026
View reviewed changes

@bornmw bornmw left a comment •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR #32370 — feat(tui): add linux_clipboard_selection config for primary buffer support

Verdict: Request changes (medium)

The previous round's asks are all closed and verified on the current head. The remaining gaps: the selection contract is write-only, a silent no-op failure mode claims success, and the option is missing from tests and docs.

What is good (verified on head 2fdfe1c9b2)

  • All five items from the last review round are done. OSC52 is skipped for "primary" (the write() guard), prettier is clean on all 5 changed files (re-ran bunx prettier --check), ClipboardSelection is unified, the non-null assertion is gone, and the title is conventional.
  • The verification claims hold. bun typecheck is clean and all 196 TUI tests pass (195 pass / 1 skip).
  • Config pipeline integration is sound. The key flows through TuiConfig.Info → resolve() at both call sites, a typo fails loudly like any other key, no committed schema artifact needs regeneration (the tui.json schema is generated from Info at web build time), and tui-migrate correctly needs no change.
  • All write paths route through the context service (useClipboard), so selection routing applies everywhere — nothing bypasses it with a direct write import.

Issues

  1. The selection contract is write-only: read() ignores the selection (most substantive). ClipboardProvider only wraps write with the selection; read is passed through bare. The default ctrl+v (input_paste) routes to prompt.paste → clipboard.read?.(), and read() only ever reads the clipboard buffer (wl-paste default, xclip -selection clipboard, clipboardy). With "primary", every opencode copy lands in the primary buffer only, then opencode's own paste reads the stale clipboard. Middle-click itself is fine (the TUI has no middle-click handler; with mouse capture off the terminal pastes natively from primary), so the gap is specifically opencode's own ctrl+v path. Suggest making read selection-aware (wl-paste --primary / xclip -selection primary for "primary"), or explicitly documenting that the paste keybind is unaffected by the setting.

  2. Silent no-op and unconditional success toast. write() never rejects (.catch(() => undefined) everywhere, Promise.allSettled for "both"), and the clipboardy fallback does if (selection === "primary") return — a silent no-op. Both resolve "successfully" into the "Copied to clipboard" toast, so a failed or skipped copy claims success. At minimum the fallback should fall back to the clipboard instead of no-op'ing, or the failure should surface.

  3. Config tests missing in config.test.tsx. That file already has the pattern: "validates config constraints" decodes Info and asserts invalid values throw (e.g. cursor: { style: "beam" }), and "resolves host-neutral defaults" asserts defaults like mouse: true. Nothing covers linux_clipboard_selection — no valid-value decode, no invalid-value throw, no resolve({}).linux_clipboard_selection === "both". A few lines in an existing file.

  4. Docs: linux_clipboard_selection is missing from the TUI options reference. tui.mdx documents diff_style, cursor, mouse, attention and the rest; this option appears nowhere in the repo's docs. Every user-facing option is listed there.

  5. Non-Linux platforms silently ignore the selection (previous item #4, still open). The osascript branch ignores it; the win32 copyCommand branch returns the same PowerShell command for every selection, so "primary" writes the normal clipboard and "both" spawns the identical command twice in parallel. Defensible given the linux_ scope, but it's still undocumented and un-gated.

Note (not a blocker)

  • The "both" default is a silent behavior change for all Linux users (copies now also write the primary selection). Fine, but the PR body frames it as a new option — one sentence about the default changing existing copy behavior would help, alongside calling out the wl-copy --type text/plain fix.
  • copyCommand accepts "both" but implicitly behaves as "clipboard" — Exclude<ClipboardSelection, "both"> would make the contract honest. Resolved also still inlines the union instead of importing ClipboardSelection (previous item #3 half-closed).
  • PR body: "Also includes a new cursor config" — Cursor already exists on dev; stale from an earlier iteration.
  • History still carries 3 merge commits + "trigger title check" — squash on merge.
  • No test exercises the OSC52 guard or the both/allSettled path — acceptable follow-up as previously noted.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@kylebakerio

kylebakerio commented Aug 21, 2026

Copy link
Copy Markdown

cannot wait for this to be merged in.

donbowman, bornmw, astrolox, and PhilipMourdjis reacted with thumbs up emoji
All reactions
  • 👍 4 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This was referenced Aug 21, 2026
Copy and Paste behaviour under Linux #4754
Closed
[FEATURE]: Add support for Linux PRIMARY selection (middle-click paste) #43176
Open
@bornmw

bornmw commented Aug 21, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Author

All addressed in 23da22c44 (fix(tui): selection-aware clipboard read, config tests and docs). Item by item:

  1. Selection-aware read — the provider now wraps read exactly like write: with "primary", TUI paste (ctrl+v) reads the primary buffer (wl-paste -p / xclip -selection primary), and the image path uses the same buffer. With "both" the paste reads the clipboard (middle-click stays terminal-native). The clipboardy text fallback only addresses the clipboard, but it is also the consistent last resort for "primary" because the write path degrades to clipboardy→clipboard on systems without native tools (see #2), so read and write agree there.

  2. Silent no-op removed — the clipboardy fallback now writes the clipboard instead of returning for a "primary" it cannot service. Genuinely failed native writes are still swallowed by the existing .catch(() => undefined) pattern; surfacing per-buffer toast errors is a larger change (the copy call sites would need to handle rejection) — happy to follow up separately rather than expand this PR.

  3. Config tests — added valid-value decode, invalid-value throw ("middle"), default resolve to "both", and override resolution in config.test.tsx.

  4. Docs — linux_clipboard_selection now listed in the tui.mdx options reference and the example tui.json.

  5. Non-Linux behavior — documented instead of gated: the schema description and docs both state the option is Linux-only and ignored on other platforms (the runtime already resolves to clipboard-only commands there).

Notes addressed as well:

  • new shared ClipboardBuffer = Exclude<ClipboardSelection, "both"> used by both copyCommand and read
  • Resolved references the imported ClipboardSelection instead of inlining the union
  • "both" no longer spawns an identical command twice — on win32 the clipboard and primary commands resolve to the same PowerShell invocation; a JSON.stringify comparison now suppresses the duplicate
  • PR body updated: stale cursor line removed, default-both behavior change called out, wl-copy --type MIME fix described

Verified: bunx prettier --check clean on all changed files, bun typecheck clean, 196 TUI tests pass (195 pass / 1 skip). read("primary") also functionally verified against a live Wayland session.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This was referenced Aug 23, 2026
fix(tui): enable copy on select by default #44393
Closed
fix(tui): clipboard copy on Linux without external binaries #44394
Closed
feat(tui): paste primary selection on middle click #44938
Closed
@bornmw bornmw mentioned this pull request Aug 29, 2026
fix: enable primary clipboard copy for Wayland/X11 to fix Linux middle-click paste #6370
Closed
@github-actions github-actions Bot mentioned this pull request Sep 12, 2026
fix(tui): read text from clipboard directly on Windows (#13800) #48611
Closed
3 of 6 tasks
@bornmw

bornmw commented Sep 14, 2026

Copy link
Copy Markdown
Author

@thdxr Could you review this PR when you get a chance?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@simonklee
simonklee requested review from simonklee and removed request for Brendonovich and Hona October 5, 2026 06:48
@simonklee simonklee self-assigned this Oct 5, 2026
@simonklee
simonklee force-pushed the linux-clipboard-selection branch from a25520c to ba1942a Compare October 7, 2026 20:24
@simonklee

simonklee commented Oct 7, 2026

Copy link
Copy Markdown
Member

@bornmw I've reworked the branch so primary-selection support is off by default and sits under the existing terminal settings.

I dropped two parts of the original design:

  • Primary-only mode. Copy commands like "Copy session ID" should not skip the normal clipboard.
  • Pasting from the primary selection. Ctrl+V and image paste read the clipboard again, as before, so screenshot paste keeps working.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bornmw

bornmw commented Oct 8, 2026

Copy link
Copy Markdown
Author

Copying/pasting changes look good, but I'm not sure why primary selection would be off by default?
Selection copying to primary is any *nix users' expectation, OpenCode is actually the first app I use on Linux that doesn't do that.

kylebakerio reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@simonklee

simonklee commented Oct 8, 2026

Copy link
Copy Markdown
Member

You're right about selections. Went a bit back and forth on this, but i changed it. Mouse selections now go to the primary selection by default on Linux.

Instead of a separate setting, this is part of terminal.copy, which now has four modes:

terminal.copy A mouse selection goes to Default on
manual nowhere; Ctrl+C or right-click copies to the clipboard Windows
select the clipboard macOS
primary the primary selection; Ctrl+C or right-click copies to the clipboard —
both the clipboard and the primary selection Linux

Copy commands like "Copy session ID" always use the clipboard, and so does paste. That keeps the usual Linux split between selecting and explicitly copying.

primary is opt-in on purpose, for now. Over SSH or WSL, the primary selection goes through OSC 52, and some terminals, such as Windows Terminal, ignore the selection type and write it to the clipboard instead. With both that's okay because the clipboard gets the same text anyway. With only primary, it would silently overwrite the clipboard.

Also removed terminal.primary_selection.

kylebakerio reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@simonklee
simonklee force-pushed the linux-clipboard-selection branch from d830f1a to c7d331f Compare October 8, 2026 18:28
@bornmw

bornmw commented Oct 8, 2026

Copy link
Copy Markdown
Author

You're right about selections. Went a bit back and forth on this, but i changed it. Mouse selections now go to the primary selection by default on Linux.

Hooray!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@thdxr
thdxr changed the base branch from v2 to dev October 10, 2026 19:04
@donbowman donbowman mentioned this pull request Oct 18, 2026
Copy To Clipboard is not working #4283
Closed
bornmw and others added 3 commits October 22, 2026 10:09
@bornmw
feat(tui): add linux_clipboard_selection config for primary buffer su…
5267f6d
…pport
@simonklee @bornmw
tui: make primary selection copy opt-in
4dbd0dd
Copying now targets the standard clipboard by default, avoiding
unexpected primary-selection changes. Enable primary copying explicitly
when middle-click paste integration is wanted.
@simonklee @bornmw
feat(tui): add primary and both copy modes to terminal.copy
1adb91f
@bornmw
bornmw force-pushed the linux-clipboard-selection branch from c7d331f to 1adb91f Compare October 22, 2026 14:13
@bornmw

bornmw commented Oct 22, 2026

Copy link
Copy Markdown
Author

what would be the next step @simonklee ?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@EMeowAGENT EMeowAGENT mentioned this pull request Oct 24, 2026
[FEATURE]: tui: support Linux PRIMARY selection (middle-click paste, select-to-copy) #58658
Closed
1 task done
@EMeowAGENT

EMeowAGENT commented Oct 24, 2026

Copy link
Copy Markdown

One gap in the current rework: middle click is still a dead key in the TUI. Mouse capture suppresses the terminal's own middle-click → PRIMARY paste, and app.tsx only handles MouseButton.RIGHT. Keeping Ctrl+V on CLIPBOARD for image paste is reasonable, but middle click reading PRIMARY is a separate native gesture and doesn't conflict with it (#44938 implemented exactly that and was closed unmerged).

Tracking the read half separately in #58658 — happy to keep this PR scoped to the write side.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Thatgfsj Thatgfsj mentioned this pull request Oct 29, 2026
tui: Ctrl+V text paste silently fails on Linux without xsel (v1 line, clipboardy fallback not bundled) #60257
Closed
@axeluhl

axeluhl commented Oct 30, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Following up on @EMeowAGENT's point about middle click: I've implemented middle-click → PRIMARY paste on top of this branch, in one commit: axeluhl@ea9af38

A middle click in the prompt reads the primary selection and inserts it at the cursor, on Linux with mouse capture on. Ctrl+V and image paste keep reading the clipboard, as you set it up. It uses the read(selection) extension of ClipboardService that @bornmw mentioned.

@simonklee @bornmw feel free to cherry-pick it into this PR, or I can open it as a separate PR stacked on this one, whichever is easier for you.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@axeluhl axeluhl mentioned this pull request Oct 30, 2026
[FEATURE]: More control over mouse capture in TUI #43676
Open
1 task done
@opencodejr opencodejr Bot mentioned this pull request Nov 1, 2026
Middle mouse button does not paste on Linux #61078
Closed
@bornmw

bornmw commented Nov 3, 2026

Copy link
Copy Markdown
Author

do you think this could go in @simonklee ?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bornmw

bornmw commented Nov 3, 2026

Copy link
Copy Markdown
Author

middle-click paste is functionally very different from copying, and it's not controlled by the setting that's included in this PR (not sure if it's controlled by any setting), for those reasons I think it's better to keep them separate @axeluhl @EMeowAGENT

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

bornmw added 2 commits November 13, 2026 07:52
@bornmw
Merge branch 'dev' into linux-clipboard-selection
107da41
# Conflicts:
#	packages/tui/test/clipboard.test.ts
@bornmw
Merge branch 'dev' into linux-clipboard-selection
fbea084
@bornmw

bornmw commented Nov 14, 2026

Copy link
Copy Markdown
Author

Hi @kitlangton, @jlongster, @simonklee and @thdxr - I hope you are all doing well!
This PR is soon going to hit half a year anniversary, can we celebrate by approving it?

I'm not sure how Linux users are comfortable using OpenCode with no ability to copy to primary buffer, but maybe I'm missing something? Is modern generation even aware that it exists?

kylebakerio, jakedowns, and donbowman reacted with thumbs up emoji
All reactions
  • 👍 3 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot mentioned this pull request Nov 14, 2026
📊 AI CLI 工具社区动态日报 2026-11-14 96loveslife/big_model_radar#789
Open
@donbowman

donbowman commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

Hi @kitlangton, @jlongster, @simonklee and @thdxr - I hope you are all doing well! This PR is soon going to hit half a year anniversary, can we celebrate by approving it?

I'm not sure how Linux users are comfortable using OpenCode with no ability to copy to primary buffer, but maybe I'm missing something? Is modern generation even aware that it exists?

i normally don't "me too", but here... this is the #1 quality of life improvement for me across all applications on my desktop we could make. not being able to copy/paste in opencode to other windows, to itself... i created a short cut to copy clipboard to primary, but, i cannot retrain my fingers to use it. and, its something i hit 10's of times per day.

if this was a standard terminal tui application it would work, but since its intercepting and moving to the wrong clipboard, its just different, so i select, but then can't paste.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This branch has not been deployed

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

Reviewers

@simonklee simonklee Awaiting requested review from simonklee

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@simonklee simonklee

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

[FEATURE]: Add support for Linux PRIMARY selection (middle-click paste) Wayland clipboard copy doesn't populate primary clipboard selection

Uh oh!

There was an error while loading. Please reload this page.

6 participants

@bornmw @kylebakerio @simonklee @EMeowAGENT @axeluhl @donbowman
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.