Skip to content

Conversation

IDisposable
Copy link
Contributor

Suspend KeyDownMessages while processing a macro.
Make sure we don't emit huge debugging traces.
Allow 30 seconds for RPC to finish (not ideal)
Reduced default delay between keys (and allow as low as 0)

@IDisposable
Copy link
Contributor Author

IDisposable commented Sep 25, 2025

There are still some issues to be addressed. Firstly, the macro is being sent on the RPC HID channel and if it takes too long, the RPC HID decides it's timed-out.

We need to either move it back to the plain WebRPC channel (so it doesn't attempt timeout work), or we need to allow some sort of timeout indicator. As it is, the timeout fires and forces the key status to clear, even though the playback continues in another thread.

I've moved the macros to a distinct queue so we could likely just not let those timeout?

Second, if someone pastes a large chunk of text then we end up with a REALLY big RPC call, so it doesn't look like the paste has even been acknowledged until the network call is complete... e.g. the entire set of packets has been sent.

If we try to chunk up the macro into multiple messages, we run into problems because if we don't wait for the chunks IN ORDER to finish then we end up resetting the keyboard and paste state.

@IDisposable IDisposable force-pushed the fix/faster-paste branch 4 times, most recently from bc2953d to 51d80be Compare September 26, 2025 01:59
@IDisposable
Copy link
Contributor Author

IDisposable commented Sep 26, 2025

This is still not complete.

  • The "paste state" messages are not working (so the UI doesn't change the UI).
  • A lint message to fix
  • Add the token UUID to the cancel message
  • Use the cancel token in the client.

@IDisposable IDisposable force-pushed the fix/faster-paste branch 3 times, most recently from b3b8614 to 5c1c665 Compare September 29, 2025 18:32
@adamshiervani adamshiervani marked this pull request as draft September 30, 2025 11:21
@IDisposable IDisposable marked this pull request as ready for review October 4, 2025 05:47
@IDisposable IDisposable requested a review from Copilot October 4, 2025 05:47
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR reduces network traffic during paste operations by implementing better queue management and timeout handling for HID RPC messages. It introduces token-based macro cancellation, suspends keyboard state messages during macro execution, and allows more flexible delay configurations.

Key changes:

  • Replaced single keyboard macro cancellation with token-based tracking for multiple concurrent macros
  • Added timeout support to HID queue messages with different limits per message type
  • Suspended keyboard down state messages during macro execution to reduce traffic
  • Reduced minimum delay between keystrokes from 50ms to 0ms

Reviewed Changes

Copilot reviewed 13 out of 14 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
webrtc.go Refactored HID queue initialization and message handling with timeout support
web.go Updated to use new token-based macro cancellation function
ui/src/hooks/useKeyboard.ts Minor formatting cleanup removing extra blank lines
ui/src/hooks/useHidRpc.ts Updated cancel message to include empty token parameter
ui/src/hooks/hidRpc.ts Added UUID support and token-based cancellation messages
ui/src/components/popovers/PasteModal.tsx Reduced minimum delay from 50ms to 0ms and updated validation
ui/package.json Added uuid dependency for token generation
jsonrpc.go Implemented token-based macro tracking with concurrent execution support
internal/usbgadget/hid_keyboard.go Added message suspension functionality and improved keyboard report descriptor
internal/hidrpc/message.go Enhanced message string representations and added token state support
internal/hidrpc/hidrpc.go Added queue indices and timeout configurations per message type
hidrpc.go Updated message handling for token-based operations and improved logging
cloud.go Updated to use new token-based macro cancellation function
Files not reviewed (1)
  • ui/package-lock.json: Language not supported

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Suspend KeyDownMessages while processing a macro.
Make sure we don't emit huge debugging traces.
Allow 30 seconds for RPC to finish (not ideal)
Reduced default delay between keys (and allow as low as 0)
Move the HID keyboard descriptor LED state
as it seems to interfere with boot mode
Run paste/macros in background on their own queue and return a token for cancellation.
Fixed error in length check for macro key state.
Removed redundant clear operation.
Use Once instead of init()
Add a time limit for each message type/queue.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant