Skip to content

fix(agent): queue HID requests before response timeout - #936

Open
sh3ll3x3c wants to merge 3 commits into
AprilNEA:masterfrom
sh3ll3x3c:fix/config-reload-wheel-write-contention
Open

fix(agent): queue HID requests before response timeout#936
sh3ll3x3c wants to merge 3 commits into
AprilNEA:masterfrom
sh3ll3x3c:fix/config-reload-wheel-write-contention

Conversation

@sh3ll3x3c

@sh3ll3x3c sh3ll3x3c commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Summary

Queue agent-owned HID++ requests per physical transport before starting their device-response timeout. A slow background wheel reconciliation can now finish without consuming the queued SmartShift write or confirmation read's five-second budget, while the reconciliation itself remains intact for recovery from earlier failures.

Changes

  • agent-core: add FIFO I/O turnstiles keyed by physical transport; all slots on one receiver share a turn while independent devices remain independent
  • agent-core: route awaited IPC operations, background actions, and reconnect reapplication through the same turnstiles, acquiring the turn before the existing response timeout begins
  • agent-core tests: prove receiver slots share a turn, unrelated transports do not, and a queued SmartShift operation retains its full response budget
  • agent: carry the shared turnstiles into action dispatch and pairing test runtime construction

Testing

  • RUSTFLAGS='-D warnings' cargo test -p openlogi-agent-core -p openlogi-agent --locked
  • cargo xtask ci rustfmt clippy rustdoc

Not runtime-tested on hardware. To verify, repeatedly change SmartShift mode and sensitivity on a Bluetooth-direct mouse while a config reload also reconciles native wheel settings; each write should confirm without entering the retry state.

Fixes #780

@sh3ll3x3c
sh3ll3x3c requested a review from AprilNEA as a code owner August 24, 2026 16:42
@greptile-apps

greptile-apps Bot commented Aug 24, 2026

Copy link
Copy Markdown

Greptile Summary

This PR serializes agent-owned HID++ operations per physical transport so queued requests receive their full response timeout while preserving wheel-mode reconciliation on every configuration reload.

  • Adds shared per-transport I/O turnstiles across awaited operations, detached writes, and volatile-setting reapplication.
  • Routes the shared turnstiles through action dispatch and device-operation construction.
  • Keeps unchanged native wheel settings eligible for reload recovery while preventing them from contending with SmartShift writes.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
crates/openlogi-agent-core/src/hardware.rs Adds transport-aware request serialization and moves queue waits outside each HID transaction's response timeout.
crates/openlogi-agent-core/src/orchestrator.rs Owns the shared I/O gates and continues reconciling configured wheel mode on every reload.
crates/openlogi-agent-core/src/hook_runtime.rs Threads the shared transport gates through SmartShift and DPI action dispatch.
crates/openlogi-agent/src/main.rs Supplies the runtime's shared transport gates when constructing the action dispatcher.
crates/openlogi-agent/src/pairing.rs Updates the pairing test runtime fixture for the new shared gate field.

Sequence Diagram

sequenceDiagram
    participant Reload as Config reload
    participant Wheel as Wheel reconciliation
    participant Gate as Transport turnstile
    participant Smart as SmartShift write
    participant HID as HID transport
    Reload->>Wheel: Reapply configured wheel mode
    Wheel->>Gate: Wait for transport turn
    Smart->>Gate: Wait for same transport turn
    Gate->>HID: Run one transaction
    HID-->>Gate: Complete or timeout
    Gate->>HID: Run next transaction with full timeout budget
Loading

Reviews (3): Last reviewed commit: "fix(agent): queue HID requests before re..." | Re-trigger Greptile

Comment thread crates/openlogi-agent-core/src/orchestrator.rs Outdated
Comment thread crates/openlogi-agent-core/src/orchestrator.rs Outdated
@sh3ll3x3c sh3ll3x3c changed the title fix(agent): skip unchanged wheel writes on reload fix(agent): queue HID requests before response timeout Aug 24, 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.

[Bug]: MX Master 3S Bluetooth-direct is online but DPI and SmartShift reads/writes fail on macOS 27

1 participant