Skip to content

Conversation

@ym
Copy link
Contributor

@ym ym commented Nov 14, 2025

fixes #806

@ym ym requested review from IDisposable, adamshiervani and Copilot and removed request for IDisposable and adamshiervani November 14, 2025 14:41
Copilot finished reviewing on behalf of ym November 14, 2025 14:47
Copy link
Contributor

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 refactors the HID RPC handshake mechanism to ensure the handshake packet is sent only once per connection. The changes move handshake logic from a React useEffect hook (which could trigger multiple times) to a dedicated doRpcHidHandshake function called once during channel creation.

  • Extracted handshake logic into a standalone doRpcHidHandshake function with retry logic and timeouts
  • Added tslog library for structured logging throughout the HID RPC module
  • Removed redundant handshake triggers from useEffect and event handlers that caused duplicate handshakes
  • Configured Vite to tree-shake logger.debug calls in production builds

Reviewed Changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
ui/vite.config.ts Added logger.debug to the esbuild pure array for production builds to remove debug logs
ui/src/routes/devices.$id.tsx Imported and called doRpcHidHandshake during channel setup; added setRpcHidProtocolVersion to dependencies
ui/src/hooks/useHidRpc.ts Extracted handshake logic to doRpcHidHandshake function with retry/timeout logic; replaced console logging with tslog logger; removed old handshake triggering code from useEffect
ui/package.json Added tslog ^4.10.2 dependency
ui/package-lock.json Added tslog package lock entry
Files not reviewed (1)
  • ui/package-lock.json: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ym ym requested a review from IDisposable November 18, 2025 15:24
@ym ym force-pushed the fix/hidrpc-handshake branch from 6196bfd to a9a495a Compare November 18, 2025 15:35
@ym ym force-pushed the fix/hidrpc-handshake branch from a9a495a to f7b51fb Compare November 18, 2025 15:36
Copy link
Contributor

@IDisposable IDisposable left a comment

Choose a reason for hiding this comment

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

Just a little suggestion, not required.

@ym ym requested a review from IDisposable November 19, 2025 09:04
@ym ym merged commit c472752 into dev Nov 21, 2025
4 of 5 checks passed
@ym ym deleted the fix/hidrpc-handshake branch November 21, 2025 12:31
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.

HidRPC handshake packet being sent multiple times

3 participants