Skip to content

feat(cli): support middle-click paste / 支持 CLI 中键粘贴 - #6589

Merged
SivanCola merged 3 commits into
esengine:main-v2from
ffff2004:feat/middle-click-primary-paste
Jul 19, 2026
Merged

feat(cli): support middle-click paste / 支持 CLI 中键粘贴#6589
SivanCola merged 3 commits into
esengine:main-v2from
ffff2004:feat/middle-click-primary-paste

Conversation

@ffff2004

@ffff2004 ffff2004 commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Summary

Restore conventional middle-click paste while the Reasonix CLI owns terminal
mouse events.

  • Inside tmux, paste the current tmux buffer to match tmux's normal button-2
    behavior.
  • In a local X11/Wayland session, read the PRIMARY selection through
    wl-paste, xclip, or xsel.
  • Over SSH outside tmux, show the existing remote-paste guidance instead of
    probing the remote host's graphical selection.
  • Ignore middle-click paste while a modal panel owns input and the composer is
    hidden.

Security and correctness

  • Run every clipboard/tmux helper with secrets.ProcessEnv() so registered
    credential-store variables are not inherited by subprocesses.
  • Request text explicitly from wl-paste.
  • Preserve the selected text byte-for-byte, including intentional trailing
    newlines.
  • Keep empty selections and unavailable helpers as silent no-ops.

Verification

  • go test ./internal/cli
  • go test -race ./internal/cli
  • go vet ./...
  • git diff --check
  • Synthetic merge with the latest origin/main-v2: focused and race CLI tests
    passed

Compatibility

Field or format Old-data behavior Conclusion
Persisted state/config No persisted format or field changed Backward-safe

Cache impact

  • Cache-impact: none — only CLI input handling and localized UI text changed.
  • Cache-guard: n/a — no provider-visible prompt, tool schema, or request
    serialization paths changed.
  • System-prompt-review: N/A.

@github-actions github-actions Bot added v2 Go rewrite (1.x) — main-v2 branch, active development tui Terminal UI / CLI (internal/cli, internal/control) labels Jul 16, 2026
@ffff2004
ffff2004 force-pushed the feat/middle-click-primary-paste branch 2 times, most recently from 383c294 to 61270b7 Compare July 17, 2026 14:11
@ffff2004
ffff2004 force-pushed the feat/middle-click-primary-paste branch 2 times, most recently from 61a89f8 to b9609af Compare July 18, 2026 15:31
ffff2004 added 2 commits July 19, 2026 14:33
Add pastePrimary() that reads from the X11/Wayland PRIMARY selection
(via wl-paste --primary, xclip -selection primary -o, or xsel
--output --primary) and wire it to the MouseMiddle event in the TUI.

Previously, with mouse capture enabled, middle-click was consumed but
not handled, silently breaking the terminal convention of PRIMARY paste.
Now it works correctly: PRIMARY content is pasted into the composer, and
an empty PRIMARY is a silent no-op.
@ffff2004
ffff2004 force-pushed the feat/middle-click-primary-paste branch from b9609af to 424d20d Compare July 19, 2026 06:36
Problem:
Middle-click paste could expose credential-store variables to clipboard helpers, mutate a hidden composer, read PRIMARY on an SSH host, and alter selected text.

Root cause:
The new subprocesses inherited the full process environment, while the mouse and PRIMARY paths bypassed existing ownership, remote-session, and byte-preservation contracts.

Fix:
Filter every paste helper through secrets.ProcessEnv, respect tmux/SSH/composer boundaries, request text explicitly, preserve selection bytes, and add focused regression coverage.

Verification:
- go test ./internal/cli
- go test -race ./internal/cli
- go vet ./...
- git diff --check

Co-authored-by: SivanCola <32437197+SivanCola@users.noreply.github.com>
@SivanCola SivanCola changed the title feat(cli): support PRIMARY selection paste on middle-click feat(cli): support middle-click paste / 支持 CLI 中键粘贴 Jul 19, 2026
@SivanCola
SivanCola enabled auto-merge (squash) July 19, 2026 11:40
@SivanCola
SivanCola merged commit 4411560 into esengine:main-v2 Jul 19, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tui Terminal UI / CLI (internal/cli, internal/control) v2 Go rewrite (1.x) — main-v2 branch, active development

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants