Skip to content

fix(os-services): Linux copy and paste use the Insert shortcuts - #1801

Open
adamshiervani wants to merge 1 commit into
devfrom
fix/linux-copy-paste-shortcuts
Open

adamshiervani wants to merge 1 commit into
devfrom
fix/linux-copy-paste-shortcuts

Conversation

@adamshiervani

@adamshiervani adamshiervani commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

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 ^V for 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 flags in clipboard.capabilities.

  • ClipboardFlagPrimary in internal/osservices/wire.go is the new bit. services.go accepts it, and treats it as a protocol error without the write bit, because clipboard.set does the write.
  • session.go sends "clipboard_primary": true in session.config. A sender sets the bit only for a KVM that sends this, because firmware of before rejects unknown bits.
  • os_services.go passes the bit to the UI as primary, and GuestClipboardState in stores.ts has the field.
  • pasteShortcut in useGuestClipboard.ts returns Shift+Insert when primary is 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. copyShortcut in useGuestClipboard.ts returns 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. The session.config test expects clipboard_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):

Firmware Sender Paste in GNOME Terminal Paste in Text Editor
dev 0.4.5 nothing arrives text arrives
this change with the primary selection change text arrives text arrives

For 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 ClipboardFlagPrimary to OS Services and using Insert-based keyboard chords instead of Ctrl+V / Ctrl+C.

The firmware advertises clipboard_primary: true in session.config, accepts the new capability bit only with write, and surfaces primary on guest clipboard state. The web UI uses pasteShortcut (Shift+Insert when primary) and copyShortcut (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.

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>
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