Repository navigation
fix(os-services): Linux copy and paste use the Insert shortcuts - #1801
Open
adamshiervani wants to merge 1 commit into
Open
adamshiervani wants to merge 1 commit into
adamshiervani wants to merge 1 commit into
Conversation
A paste did nothing in a Linux terminal, and a copy stopped the program that ran in it. The KVM typed Ctrl+V and Ctrl+C after the OS Services clipboard request, and a terminal takes both as control characters. Paste: a Linux sender that also writes the primary selection says so with bit 2 of the flags in clipboard.capabilities. The KVM then types Shift+Insert: a terminal pastes the primary selection, and other applications paste the clipboard. The KVM sends "clipboard_primary": true in session.config, because a sender sets the bit only for a KVM that accepts it. Without the bit the KVM types Ctrl+V as before. Copy: for a Linux target the KVM types Ctrl+Insert, which copies in a terminal and in other applications. The sender reads the clipboard as before, so this needs no flag. macOS and Windows targets do not change. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
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.
Problem
With OS Services on a Linux target, a paste from the web UI does nothing in a terminal, and a copy stops the program that runs in the terminal. Both work in other applications, such as GNOME Text Editor.
Cause
For a paste, the sender writes the text to the target's clipboard, and the KVM then types Ctrl+V. For a copy, the KVM types Ctrl+C, and then asks the sender for the clipboard. A Linux terminal takes Ctrl+V and Ctrl+C as control characters: it prints
^Vfor the first and sends an interrupt for the second.Fix
Paste. Shift+Insert pastes in a terminal and in other applications, but a terminal pastes the primary selection (the text that the user highlighted last), and other applications paste the clipboard. A sender with jetkvm/os-services#5 ("On Linux, a paste also sets the primary selection") writes both, and says so with bit 2 of
flagsinclipboard.capabilities.ClipboardFlagPrimaryininternal/osservices/wire.gois the new bit.services.goaccepts it, and treats it as a protocol error without the write bit, becauseclipboard.setdoes the write.session.gosends"clipboard_primary": trueinsession.config. A sender sets the bit only for a KVM that sends this, because firmware of before rejects unknown bits.os_services.gopasses the bit to the UI asprimary, andGuestClipboardStateinstores.tshas the field.pasteShortcutinuseGuestClipboard.tsreturns Shift+Insert whenprimaryis set, Cmd+V for macOS, and Ctrl+V otherwise.With a sender of before the bit is not set, and the KVM types Ctrl+V as before. Shift+Insert without the bit would paste old highlighted text in a terminal.
Copy.
copyShortcutinuseGuestClipboard.tsreturns Ctrl+Insert for a Linux target, which copies in a terminal and in other applications. The sender reads the clipboard as before, so the copy needs no flag and also works with a sender of before.The KVM does not look at the focused application: each Linux paste and each Linux copy types the same shortcut. macOS and Windows targets do not change.
Testing
go test ./internal/osservices/passes. The capabilities tests have new cases: primary without write is a protocol error, read with primary is a protocol error, and read, write and primary together are accepted with flags 7. Thesession.configtest expectsclipboard_primary. The UI lint and the type check pass.On a JetKVM with this change and an Intel N100 with Ubuntu 26.04 (GNOME 50 on Wayland):
devFor the copy, text was highlighted in GNOME Terminal and the copy action of the web UI ran (Ctrl+Shift+C). The target's clipboard changed to the highlighted text, and the terminal got no interrupt. Ctrl+Insert as a direct key press also copied in Text Editor and in Firefox.
Not in this PR
The copy test read the target's clipboard, and did not check the browser's clipboard, because the test browser had no window. An X11 session, desktops other than GNOME, and terminals other than GNOME Terminal are not tested.
Note
Medium Risk
Changes OS Services clipboard negotiation and the guest keyboard macros users rely on for copy/paste; backward compatible when senders omit the primary flag.
Overview
Fixes Linux guest clipboard in terminals by adding
ClipboardFlagPrimaryto OS Services and using Insert-based keyboard chords instead of Ctrl+V / Ctrl+C.The firmware advertises
clipboard_primary: trueinsession.config, accepts the new capability bit only with write, and surfacesprimaryon guest clipboard state. The web UI usespasteShortcut(Shift+Insert whenprimary) andcopyShortcut(Ctrl+Insert on Linux) when simulating paste/copy on the target.Reviewed by Cursor Bugbot for commit 618fe33. Bugbot is set up for automated code reviews on this repo. Configure here.