Skip to content

feat(terminal): copy-on-select and configurable middle/right-click paste (#71)#79

Merged
macnev2013 merged 2 commits into
mainfrom
feat/71-terminal-clipboard
Jun 15, 2026
Merged

feat(terminal): copy-on-select and configurable middle/right-click paste (#71)#79
macnev2013 merged 2 commits into
mainfrom
feat/71-terminal-clipboard

Conversation

@macnev2013

Copy link
Copy Markdown
Owner

What

Adds the terminal clipboard behaviours requested in #71, as two new options under Settings → Terminal → Clipboard:

  • Copy on Select — automatically copies the highlighted selection to the system clipboard, like iTerm / gnome-terminal. Default: off.
  • Paste Button — choose which mouse button pastes the clipboard into the terminal: Off / Right-click / Middle-click. The right-click option covers the "select = copy, right-click = paste" workflow raised in the issue comments. Default: off.

Both default to off so existing behaviour is unchanged until a user opts in.

Implementation

  • settings-store.ts — two persisted keys (terminal_copy_on_select, terminal_paste_button) in the existing key-value app_settings table. No schema/migration change.
  • SettingsPage.tsx — a new "Clipboard" SettingsGroup with the existing Toggle and SegmentedControl components.
  • Terminal.tsx — one per-session effect registers an xterm onSelectionChange copy handler plus mousedown/auxclick/contextmenu paste handlers. The live setting values are read through refs, so toggling them in Settings applies to open terminals without a remount. Paste routes through term.paste() so bracketed-paste mode is preserved and the existing onData → ssh_send_input path is reused.

Tests

  • New settings-store.test.ts: defaults, both setters (state + persisted value), loadSettings parsing, and the fallback for an unknown paste-button value. tsc --noEmit clean.

Verification note

Middle/right-click paste reads the clipboard via navigator.clipboard.readText() (the first read-from-clipboard in the app — copies elsewhere use writeText). It runs inside a click gesture, which should satisfy WKWebView, but it's worth a quick check in the packaged macOS build. If it proves unreliable there, the fallback is the Tauri clipboard plugin (@tauri-apps/plugin-clipboard-manager).

Addresses #71

…ste (#71)

Adds two Settings → Terminal → Clipboard options:

- Copy on Select — automatically copies the highlighted selection to the
  system clipboard (mirrors iTerm / gnome-terminal). Off by default.
- Paste Button — choose which mouse button pastes the clipboard into the
  terminal: Off, Right-click, or Middle-click. The right-click option covers
  the "select = copy, right-click = paste" workflow raised in the issue
  comments. Off by default.

Implementation:
- settings-store: two persisted keys (terminal_copy_on_select,
  terminal_paste_button) in the existing key-value store — no migration.
- SettingsPage: a new "Clipboard" group with a Toggle and a SegmentedControl.
- Terminal: one per-session effect registers an xterm onSelectionChange copy
  plus mousedown/auxclick/contextmenu paste handlers, reading the live setting
  values via refs so changes apply without remounting the terminal. Paste
  routes through term.paste() to preserve bracketed-paste mode.

Tests: settings-store unit tests for the new setters and load parsing,
including the fallback for an unknown paste-button value.
…k work (#71)

navigator.clipboard.readText() is blocked in the macOS WKWebView, so the
paste handlers silently no-opped — clicking middle/right did nothing. Read
and write the clipboard through the Tauri clipboard-manager plugin (native,
via Rust) instead, which works in every webview.

- Add tauri-plugin-clipboard-manager (Rust + JS) and the read-text /
  write-text capability permissions.
- Terminal: route copy-on-select and paste through the plugin.
- Paste the middle button on mousedown rather than auxclick (WebKit drops
  auxclick once mousedown's default is prevented), and attach both mouse
  listeners in the capture phase so xterm's own handling can't swallow them.
@macnev2013 macnev2013 merged commit 5180120 into main Jun 15, 2026
7 checks passed
@macnev2013 macnev2013 deleted the feat/71-terminal-clipboard branch June 15, 2026 19:45
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.

1 participant