feat(terminal): copy-on-select and configurable middle/right-click paste (#71)#79
Merged
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What
Adds the terminal clipboard behaviours requested in #71, as two new options under Settings → Terminal → Clipboard:
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-valueapp_settingstable. No schema/migration change.SettingsPage.tsx— a new "Clipboard"SettingsGroupwith the existingToggleandSegmentedControlcomponents.Terminal.tsx— one per-session effect registers an xtermonSelectionChangecopy handler plusmousedown/auxclick/contextmenupaste handlers. The live setting values are read through refs, so toggling them in Settings applies to open terminals without a remount. Paste routes throughterm.paste()so bracketed-paste mode is preserved and the existingonData → ssh_send_inputpath is reused.Tests
settings-store.test.ts: defaults, both setters (state + persisted value),loadSettingsparsing, and the fallback for an unknown paste-button value.tsc --noEmitclean.Verification note
Middle/right-click paste reads the clipboard via
navigator.clipboard.readText()(the first read-from-clipboard in the app — copies elsewhere usewriteText). 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