Skip to content

feat: binary HID-RPC wheel dispatch#1462

Open
mcuelenaere wants to merge 3 commits into
jetkvm:devfrom
mcuelenaere:claude/priceless-hellman-d92f06
Open

feat: binary HID-RPC wheel dispatch#1462
mcuelenaere wants to merge 3 commits into
jetkvm:devfrom
mcuelenaere:claude/priceless-hellman-d92f06

Conversation

@mcuelenaere
Copy link
Copy Markdown
Contributor

@mcuelenaere mcuelenaere commented May 14, 2026

Summary

Wires the TypeWheelReport (0x04) binary HID-RPC opcode into firmware dispatch and updates the browser frontend to use it when the HID-RPC channel is ready. The opcode and queue routing already existed in internal/hidrpc/hidrpc.go, but handleHidRPCMessage had no case for it, so binary wheel frames hit the default arm and were silently dropped. Wheel input had to take the JSON-RPC slow path.

Now wheel rides hidrpc-unreliable-ordered like mouse motion: per-event JSON encode/parse is gone, latency drops on the ARM, and the binary path matches the existing mouse/keyboard pattern. Wire format is [0x04][deltaY: int8][deltaX: int8] — both axes carried.

Two commits:

  • feat(hidrpc): dispatch binary TypeWheelReport (0x04) frames — length-strict WheelReport decoder, dispatch case in handleHidRPCMessage, 10 table-driven test cases.
  • feat(ui): send mouse wheel via binary HID-RPC when available — new WheelReportMessage class, reportWheelEvent hook, getMouseWheelHandler switches to rpcHidReady ? binary : send(\"wheelReport\", ...) matching the rel/abs mouse pattern.

The JSON-RPC wheelReport method is unchanged; old clients and the transient WebRTC/handshake window keep working.

Checklist

  • Ran `make test_e2e` locally and passed
  • One problem per PR (no unrelated changes)
  • Lints pass; CI green (locally: `go test ./internal/hidrpc/...` + `tsc --noEmit` + `oxlint`)
  • Tricky parts are commented in code

Note

Medium Risk
Changes the end-to-end mouse wheel input path (new binary opcode handling in Go + new frontend message), which could affect scroll behavior/latency if the wire format or channel selection is wrong; fallback to existing JSON-RPC reduces blast radius.

Overview
Enables mouse wheel events to flow over the binary HID-RPC channel by adding TypeWheelReport handling in the Go dispatcher and a strict WheelReport decoder (with new unit tests) in internal/hidrpc/message.go.

Updates the UI to emit wheel input as a new WheelReportMessage over the unreliable-ordered HID-RPC data channel when rpcHidReady, while keeping the existing JSON-RPC wheelReport path as a backward-compatible fallback. Also tightens a macro marshal error message and logs RTC channel errors using e.type.

Reviewed by Cursor Bugbot for commit a5f6d70. Bugbot is set up for automated code reviews on this repo. Configure here.

@mcuelenaere mcuelenaere changed the title feat: binary HID-RPC wheel dispatch + frontend opt-in feat: binary HID-RPC wheel dispatch May 17, 2026
Comment thread ui/src/hooks/useMouse.ts Outdated
if (rpcHidReady) {
reportWheelEvent(wheelY, wheelX);
} else {
// kept for backward compatibility
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No need to be backwards compatible nowadays. The Cloud SPA is versioned, and the LAN access always serves a matching Go API and JS SPA.

Please remove the wheelReport code path.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed in a5f197b — dropped the JSON-RPC fallback in getMouseWheelHandler and removed the wheelReport entry from the JSON-RPC handler map. Binary 0x04 is now the only path; rpcWheelReport stays but is reached only via handleHidRPCMessage.

mcuelenaere added a commit to mcuelenaere/kvm that referenced this pull request May 18, 2026
Per PR review (jetkvm#1462): the Cloud SPA is versioned and LAN access
always serves a matching Go API and JS SPA, so the backwards-compat
fallback is unnecessary. Drop the `rpcHidReady ? binary : send(...)`
branch from getMouseWheelHandler — always use the binary path —
and remove the `wheelReport` entry from the JSON-RPC handler map.
The binary 0x04 dispatch and rpcWheelReport itself stay; the
function is now reached only via handleHidRPCMessage.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
mcuelenaere added a commit to mcuelenaere/kvm that referenced this pull request May 26, 2026
Per PR review (jetkvm#1462): the Cloud SPA is versioned and LAN access
always serves a matching Go API and JS SPA, so the backwards-compat
fallback is unnecessary. Drop the `rpcHidReady ? binary : send(...)`
branch from getMouseWheelHandler — always use the binary path —
and remove the `wheelReport` entry from the JSON-RPC handler map.
The binary 0x04 dispatch and rpcWheelReport itself stay; the
function is now reached only via handleHidRPCMessage.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@mcuelenaere mcuelenaere force-pushed the claude/priceless-hellman-d92f06 branch from a5f197b to 4992aaa Compare May 26, 2026 18:05
mcuelenaere and others added 3 commits May 29, 2026 14:54
The wheel opcode and its queue routing were already in place, but
handleHidRPCMessage had no case for it, so binary wheel frames hit the
default warn-log arm and were silently dropped. Wheel input had to take
the JSON-RPC slow path, paying a per-event encode/parse on the ARM and
foregoing the unreliable-ordered transport mouse motion already uses.

Add a length-strict WheelReport decoder (Y-only, 1-byte payload) and
route 0x04 through the same rpcWheelReport backend the JSON-RPC handler
uses. The JSON-RPC path is unchanged so old clients keep working.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Mirror the existing rel/abs mouse pattern: when the HID-RPC binary
channel is ready, send a WheelReportMessage (0x04) over the
unreliable-ordered channel instead of the wheelReport JSON-RPC call.
Falls back to JSON-RPC during the WebRTC/handshake window or against
older firmware that does not dispatch the binary opcode.

Also fix two pre-existing oxlint warnings in the same files
(restrict-template-expressions) forced by lint-staged.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Per PR review (jetkvm#1462): the Cloud SPA is versioned and LAN access
always serves a matching Go API and JS SPA, so the backwards-compat
fallback is unnecessary. Drop the `rpcHidReady ? binary : send(...)`
branch from getMouseWheelHandler — always use the binary path —
and remove the `wheelReport` entry from the JSON-RPC handler map.
The binary 0x04 dispatch and rpcWheelReport itself stay; the
function is now reached only via handleHidRPCMessage.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@mcuelenaere mcuelenaere force-pushed the claude/priceless-hellman-d92f06 branch from 4992aaa to a395b66 Compare May 29, 2026 12:54
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.

2 participants