Skip to content

fix(hid): preserve delayed macOS HID++ responses - #654

Open
safonin wants to merge 4 commits into
AprilNEA:masterfrom
safonin:fix/macos-hid-write-timeout
Open

fix(hid): preserve delayed macOS HID++ responses#654
safonin wants to merge 4 commits into
AprilNEA:masterfrom
safonin:fix/macos-hid-write-timeout

Conversation

@safonin

@safonin safonin commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Preserve delayed HID++ responses after a macOS output-write callback timeout.
  • Treat only the exact kIOReturnTimeout callback status as an unknown completion result.
  • Keep the existing total request timeout and avoid retrying potentially delivered reports.

Changes

  • hidpp: add a typed raw-write outcome that distinguishes definitive failures from unknown completion.
  • hidpp: keep the pending response matcher after unknown completion and wait within the existing request budget.
  • hidpp: continue surfacing unknown completion as an error for response-less and raw report writes.
  • hid: classify the exact macOS 0xE00002D6 callback status without changing other platform behavior.
  • tests: cover delayed responses, request timeout, definitive failures, response-less writes, and macOS error classification.
  • docs: document the observed macOS behavior and implementation plan.

Testing

  • cargo fmt --all -- --check
  • cargo clippy --workspace --all-targets -- -D warnings
  • cargo test --workspace
  • RUSTDOCFLAGS="-D warnings" cargo doc -p openlogi-hid -p openlogi-hidpp -p openlogi-hidpp-derive --no-deps --document-private-items
  • cargo clippy -p openlogi-hidpp -p openlogi-hid --all-targets --target x86_64-pc-windows-gnu -- -D warnings

Hardware validation:

  • macOS 26.6.1 on Apple Silicon.
  • Original MX Keys over direct Bluetooth (046d:b35b, firmware MPK12.01_0013).
  • Five sequential probes succeeded; three exercised the 0xE00002D6 path and matched the delayed response.
  • The keyboard appeared in the GUI and remained available after a power cycle and reconnect.
  • Feature discovery, controls, battery, and Backlight2 reads succeeded.
  • Backlight off/on writes were confirmed by read-back and the original enabled state was restored.

Part of #521

@greptile-apps

greptile-apps Bot commented Aug 17, 2026

Copy link
Copy Markdown

Greptile Summary

The PR distinguishes ambiguous macOS HID write completion from definitive failure so delayed HID++ responses remain eligible for matching within the existing request deadline.

  • Adds a typed raw-write error and adapts all in-workspace transport implementations.
  • Continues waiting for a response after the exact macOS callback timeout without retrying the report.
  • Preserves errors for definitive failures, response-less writes, and raw-report writes.
  • Adds focused channel and macOS-classification tests plus implementation documentation.

Confidence Score: 5/5

The PR appears safe to merge with no actionable correctness or security defects identified.

The typed outcome is propagated through every in-workspace raw channel implementation, ambiguous macOS completion retains the matcher without retrying, and all definitive or response-less failure paths continue returning errors.

Important Files Changed

Filename Overview
crates/openlogi-hidpp/src/channel.rs Preserves pending response matching after unknown write completion while retaining the existing total request timeout and cleanup behavior.
crates/openlogi-hidpp/src/channel/raw.rs Introduces the typed raw-write outcome used to distinguish definitive failure from unknown completion.
crates/openlogi-hid/src/transport.rs Classifies only the exact macOS callback timeout as unknown completion and preserves disconnect handling.
crates/openlogi-hid/src/transport/windows.rs Adapts the Windows transport to the typed error without changing its definitive-failure semantics.
crates/openlogi-hidpp/src/channel/tests.rs Covers delayed-response recovery, final timeout, definitive failure, and response-less write behavior.

Reviews (1): Last reviewed commit: "fix(hid): classify macos callback timeou..." | Re-trigger Greptile

@davidbudnick davidbudnick added type: bug Something is broken or behaves incorrectly platform: all Cross-platform issue labels Aug 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

platform: all Cross-platform issue type: bug Something is broken or behaves incorrectly

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants