feat(clipboard): implement GFN paste protocol - #583
Conversation
… behavior Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit eba0fd1. Configure here.
| const sentOfficialPaste = await client.pasteClipboardText(); | ||
| if (sentOfficialPaste) { | ||
| return; | ||
| } |
There was a problem hiding this comment.
Oversized clipboard skips sendText
Medium Severity
When the control channel is open, pasteClipboardText returns true after sending the paste shortcut even if clampClipboardText rejected the clipboard (for example over clipboardMaxBytes). sendStreamClipboardPaste then exits early and never uses sendText, which previously could still inject the full local clipboard via chunked text input.
Additional Locations (2)
Reviewed by Cursor Bugbot for commit eba0fd1. Configure here.
|
|
||
| await this.refreshClipboardAvailability(); | ||
| return this.sendPasteShortcut(false); | ||
| } |
There was a problem hiding this comment.
Empty clipboard sends paste shortcut
Medium Severity
With an open control channel, pasteClipboardText always calls sendPasteShortcut and reports success, even when local clipboard text is empty after clampClipboardText. The old sendStreamClipboardPaste path returned after a successful read without injecting Ctrl+V when there was no text.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit eba0fd1. Configure here.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: eba0fd1fc0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| await this.refreshClipboardAvailability(); | ||
| return this.sendPasteShortcut(false); |
There was a problem hiding this comment.
Honor unavailable clipboard before sending paste
When the official paste path is available but refreshClipboardAvailability() returns false (for example the local clipboard is empty, unreadable, or exceeds clipboardMaxBytes), this still sends Ctrl+V and reports success to sendStreamClipboardPaste(). That suppresses the existing text-input fallback and can cause the remote session to paste stale remote clipboard contents even though the client just advertised CLIENT_REMOVED_DATA; return false or skip the shortcut when no clipboard data is available.
Useful? React with 👍 / 👎.
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
* Implement GFN-style clipboard paste protocol to match official client behavior Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * Fix clipboard paste no-op when unavailable Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> --------- Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>


This PR implements official-style clipboard paste for OpenNOW using the GFN PASTE custom-message protocol over the data channel, with client-side availability advertisement and server request/response handling that mirrors the official JavaScript client's behavior.
src/renderer/src/gfn/clipboardProtocol.tsimplementing the GFN PASTE custom-message envelope, CLIENT_ADDED_DATA/CLIENT_REMOVED_DATA/CLIENT_DATA_RESPONSE and SERVER_DATA_REQUEST message types, trace ID generation, and UTF-8 byte size clamping.src/renderer/src/gfn/clipboardProtocol.test.tswith 3 test cases validating message construction and parsing.src/renderer/src/gfn/webrtcClient.tsviasetClipboardPasteEnabledandrefreshClipboardAvailability, and server data request handling inonControlChannelMessage, with control channel open/close lifecycle hooks.src/renderer/src/App.tsxto callclient.pasteClipboardText()before falling back tosendText/sendPasteShortcut, and passclipboardPaste/readClipboardTextoptions to the client, with runtime setting changes propagated viasetClipboardPasteEnabled.Verification
Note
Medium Risk
Changes streaming paste behavior and sends clipboard content over the control channel when enabled, though it remains behind the clipboardPaste setting with legacy fallbacks.
Overview
Adds official GFN clipboard paste over the WebRTC
control_channelusing the PASTE custom-message protocol, so paste can follow the same request/response flow as the official client instead of only injecting text or simulating shortcuts.A new
clipboardProtocolmodule builds and parses the PASTE envelope (CLIENT_ADDED_DATA/CLIENT_REMOVED_DATA/CLIENT_DATA_RESPONSE/SERVER_DATA_REQUEST), generates trace IDs, and clamps clipboard text by UTF-8 byte size (with unit tests).GfnWebRtcClientadvertises clipboard availability when the control channel opens and on window focus, answers server data requests with host clipboard text, and exposespasteClipboardText()(refresh availability then trigger paste). TheclipboardPastesetting is passed in at connect and can be toggled live viasetClipboardPasteEnabled.Approutes paste throughclient.pasteClipboardText()first, then falls back tosendText/sendPasteShortcut. Paste shortcut detection now ignores Shift and treats Ctrl/Cmd consistently; fallback paste shortcut always uses Ctrl.Reviewed by Cursor Bugbot for commit eba0fd1. Configure here.