fix(agent): reuse inventory channels for input capture - #522
Conversation
Greptile SummaryThe PR makes Agent input capture reuse channels owned by persistent HID inventory, coordinating channel publication, retirement, revocation, teardown, and replacement without changing IPC or configuration schemas.
Confidence Score: 5/5The PR appears safe to merge, with no concrete changed-code failure remaining after reviewing channel publication, retirement, capture revocation, replacement ordering, and pairing exclusion. Registry removal makes stale capture connections observable, capture teardown releases listeners and channel references before acknowledgement, and deferred reopening prevents concurrent ownership of the same HID node while preserving standalone route-opening behavior.
|
| Filename | Overview |
|---|---|
| crates/openlogi-hid/src/channel_registry.rs | Introduces exact-route publication, stable collision winners, identity-based currentness checks, and poison-safe publisher updates. |
| crates/openlogi-hid/src/inventory.rs | Adds active/retiring channel ownership, registry publication from settled inventory, and deferred reopening after stale channels become quiescent. |
| crates/openlogi-hid/src/gesture.rs | Refactors capture onto supplied shared channels and distinguishes graceful disarming from stale-connection revocation. |
| crates/openlogi-agent-core/src/watchers/gesture.rs | Adds registry-backed capture lifecycle management and waits for stopped epochs to release resources before replacement. |
| crates/openlogi-agent-core/src/watchers/inventory.rs | Adds a registry-aware persistent inventory watcher while preserving the standalone watcher entry point. |
| crates/openlogi-agent-core/src/orchestrator.rs | Adds one shared channel registry to the Agent runtime. |
| crates/openlogi-agent/src/main.rs | Passes the same registry to inventory and gesture watchers so capture reuses inventory-owned channels. |
Sequence Diagram
sequenceDiagram
participant Inventory as Inventory watcher
participant Registry as ChannelRegistry
participant Capture as Gesture watcher
participant Device as HID++ channel
Inventory->>Device: Open and probe node
Inventory->>Registry: Publish exact routes and channel
Capture->>Registry: Lookup active target route
Registry-->>Capture: Shared inventory-owned channel
Capture->>Device: Arm controls and listen
Inventory->>Registry: Remove stale publication
Capture->>Registry: Check channel identity
Registry-->>Capture: Connection revoked
Capture->>Capture: Clear slot and drop listener/channel
Capture-->>Inventory: Old channel becomes quiescent
Inventory->>Device: Reopen on a later poll
Inventory->>Registry: Publish replacement channel
Capture->>Registry: Lookup and start replacement
Reviews (1): Last reviewed commit: "fix(agent): wire shared capture registry" | Re-trigger Greptile
Summary
Make Agent input capture reuse the HID++ channel already owned by persistent
inventory instead of opening a competing handle for the same OS node.
This is an infrastructure-only change. It does not change the IPC or config
schema and does not add GUI behavior.
Changes
ChannelRegistrythat publishes exact direct,Bolt, and Unifying routes from settled inventory, with stable collision
handling and quiescent retirement before a node is reopened.
closed on a registry miss, and preserve route-opening behavior for standalone
callers.
revocation, and wait for the old capture epoch to release its listener and
channel before starting a replacement.
SharedRuntimeand pass it to both thepersistent inventory and gesture watchers.
recovery, publication and retirement, registry misses, stale connection
revocation, teardown ordering, replacement acknowledgement, and standalone
compatibility.
Testing
The same registry/capture implementation was runtime-tested on macOS with an
MX Keys connected over Bluetooth-direct while validating the full feature
stack: inventory remained visible and the keyboard remained usable. This
reduced branch was not rerun independently on hardware after extraction.
Receiver hardware was not runtime-tested for this PR.
Part of #521