fix(agent): rearm control capture after device reconnect - #450
Conversation
Greptile SummaryThis PR restores programmable HID++ controls (gesture button, thumb wheel) after a Logitech device reconnects or the system wakes, without requiring an agent restart. It threads a generation counter through the capture stack so the gesture watcher can distinguish a reconnect on the same Unifying route from a routine configuration change, and selects
Confidence Score: 5/5The change is safe to merge; all new code paths are guarded, well-tested, and handle failure cases gracefully. Every new code path has corresponding unit tests including mock HID++ channel implementations that exercise disconnect detection, battery-error fallback, and the Abandon/Restore split. The generation counter is only ever incremented (never reset), Ordering::Relaxed is appropriate for an eventually-consistent tick-polled counter, and the stop_for_transition logic is covered by tests for same-route/different-generation, different-route, and None transitions. The existing done_tx epoch mechanism ensures the watcher recovers quickly from unexpected session exits without the orchestrator's help. No files require special attention; the inventory probe refactor in probe.rs is the most intricate change but is covered by dedicated tests for the battery-error and liveness-cache separation paths. Important Files Changed
Sequence DiagramsequenceDiagram
participant OS as OS/IOHIDManager
participant Inv as Enumerator
participant Orch as Orchestrator
participant Watcher as GestureWatcher
participant Session as CaptureSession
Note over Session: Device disconnects
Session->>Session: HidError::Disconnected → mark_disconnected()
Session->>Session: "health poll: is_connected()=false"
Session->>Watcher: done_tx.send(epoch) [ChannelDisconnected]
Watcher->>Watcher: "should_rearm→true: current=None, stop=None"
OS->>Inv: "enumeration tick (node absent or is_connected=false)"
Inv->>Inv: retained_nodes excludes dead channel
Inv->>Orch: device offline
Note over OS: Device reconnects
OS->>Inv: enumeration tick (new node)
Inv->>Orch: device online (offline→online transition)
Orch->>Orch: selected_needs_capture_rearm→true
Orch->>Watcher: capture_rearm_generation.fetch_add(1)
Watcher->>Watcher: tick: want.rearm_generation changed (same route)
Watcher->>Session: stop_for_transition → CaptureStop::Abandon
Note over Session: skip disarm (firmware state already reset)
Watcher->>Session: spawn new CaptureSession (fresh channel)
Reviews (3): Last reviewed commit: "fix(hid): retain live channels across en..." | Re-trigger Greptile |
f192bb3 to
598386f
Compare
Summary
Restore programmable controls after a Logitech device reconnects or switches between Bluetooth and Unifying, without requiring an agent restart.
Changes
openlogi-hidpp/openlogi-hidopenlogi-agent-core/openlogi-agentTesting
cargo fmt --all -- --checkcargo clippy --workspace --all-targets --locked -- -D warningscargo test --workspace --locked