Skip to content

fix(agent): route hardware operations through inventory channels - #532

Merged
davidbudnick merged 4 commits into
AprilNEA:masterfrom
safonin:fix/agent-hardware-routing
Aug 9, 2026
Merged

fix(agent): route hardware operations through inventory channels#532
davidbudnick merged 4 commits into
AprilNEA:masterfrom
safonin:fix/agent-hardware-routing

Conversation

@safonin

@safonin safonin commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Route all Agent-side, route-addressed HID++ reads and writes through the exact inventory-owned channel introduced by #522. This avoids competing HID opens while the inventory or capture watcher already owns the device and provides the shared-channel foundation needed by the MX Keys work.

Changes

  • openlogi-hidpp: add bounded raw report writes for 64-byte 0x12 lighting frames and route 0x12 through the Windows long-report endpoint
  • openlogi-hid: add existing-channel variants for DPI, SmartShift, and keyboard lighting; move per-key lighting reports onto the owned HidppChannel
  • openlogi-agent-core / openlogi-agent: use a registry-confirmed capture channel or the exact current inventory channel for IPC calls, reconnect reapply, hook actions, and gesture actions
  • keep the route-opening APIs available for standalone CLI/library callers; an Agent registry miss does not open a fallback channel

Testing

  • cargo fmt --all -- --check
  • cargo clippy --workspace --all-targets -- -D warnings
  • cargo test --workspace
  • RUSTDOCFLAGS="-D warnings" cargo doc -p openlogi-hidpp -p openlogi-hid --no-deps
  • Hardware: these commits were exercised on an MX Keys over Bluetooth in the full feature branch; discovery, normal key input, and lighting on/off worked. The isolated rebased branch was not rerun on hardware.
  • Windows: the 0x12 endpoint selection is unit-tested, but the change was not runtime-tested on Windows hardware.

Part of #521

@greptile-apps

greptile-apps Bot commented Aug 9, 2026

Copy link
Copy Markdown

Greptile Summary

The PR routes Agent hardware operations through inventory-owned HID++ channels instead of opening competing connections.

  • Adds registry-aware channel selection across IPC, hooks, gesture actions, and reconnect reapplication.
  • Adds existing-channel DPI, SmartShift, wheel, and keyboard-lighting operations.
  • Supports bounded 64-byte raw lighting reports and routes Windows 0x12 reports through the long endpoint.

Confidence Score: 5/5

The PR appears safe to merge because no blocking failure remains in the eligible follow-up review scope.

No blocking failure remains.

Important Files Changed

Filename Overview
crates/openlogi-agent-core/src/hardware.rs Centralizes Agent hardware reads and writes on registry-confirmed capture or inventory channels and removes route-open fallback.
crates/openlogi-agent-core/src/hook_runtime.rs Threads the channel registry into hardware actions dispatched by OS hooks.
crates/openlogi-agent-core/src/orchestrator.rs Supplies the shared registry to volatile-setting reapplication and related hardware operations.
crates/openlogi-agent-core/src/watchers/gesture.rs Coordinates capture sessions and gesture-triggered actions with inventory channel ownership.
crates/openlogi-agent/src/server.rs Routes immediate IPC hardware operations through the Agent's capture channel and inventory registry.
crates/openlogi-hid/src/write/shared.rs Adds existing-channel variants that preserve route-derived device indices for feature operations.
crates/openlogi-hid/src/write/lighting.rs Moves keyboard lighting onto an existing HID++ channel and emits bounded per-key raw reports.
crates/openlogi-hid/src/transport/windows.rs Routes 0x12 lighting reports through the Windows long-report endpoint and its native fallback.
crates/openlogi-hidpp/src/channel.rs Adds timeout-bounded raw report writes with a 64-byte maximum.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  IPC[Agent IPC] --> Select[Select authoritative channel]
  Hook[Hook and gesture actions] --> Select
  Reapply[Reconnect reapply] --> Select
  Capture[Current capture channel] --> Select
  Registry[Inventory channel registry] --> Select
  Select --> Shared[SharedChannel]
  Shared --> Features[DPI / SmartShift / wheel]
  Shared --> Lighting[Keyboard lighting]
  Features --> Device[HID++ device]
  Lighting --> Raw[Bounded 0x12 raw reports]
  Raw --> Device
Loading

Reviews (3): Last reviewed commit: "fix(windows): gate non-windows hid write..." | Re-trigger Greptile

@davidbudnick

Copy link
Copy Markdown
Collaborator

@safonin Can you please fix the issues with the pipeline?

@safonin

safonin commented Aug 9, 2026

Copy link
Copy Markdown
Contributor Author

sure thing
worked on it

@safonin

safonin commented Aug 9, 2026

Copy link
Copy Markdown
Contributor Author

Fixed in 6392871. The non-Windows DeviceWriter import is now properly cfg-gated. Windows clippy and all other checks are green.

@davidbudnick
davidbudnick force-pushed the fix/agent-hardware-routing branch from 6392871 to eef6696 Compare August 9, 2026 23:47
@davidbudnick
davidbudnick merged commit f252aa8 into AprilNEA:master Aug 9, 2026
17 checks passed
@davidbudnick davidbudnick added this to the v0.6.24 milestone Aug 10, 2026
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