Repository navigation
Show the battery level of devices behind a receiver in the device picker - #1487
Conversation
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Resolve receiver battery levels LinearMouse/Device/VendorSpecific/BatteryDeviceMonitor.swift, LinearMouse/Device/VendorSpecific/ConnectedBatteryDeviceInventory.swift, LinearMouseUnitTests/UI/StatusItemBatteryIndicatorTests.swift |
The lookup checks the matching inventory entry before using the receiver identity’s battery level. The test checks the inventory result and the empty-inventory case. |
Publish and display levels LinearMouse/Model/DeviceModel.swift, LinearMouse/UI/Header/DeviceIndicator/DevicePickerSheet/DevicePickerSectionItem.swift |
DeviceModel updates paired receiver battery levels by slot during refresh and clears the map when the device is unavailable. The device picker reads the level for each device’s slot. |
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix
Merge Risk: 
Minimal · up to e17d5
-
Receiver battery levels are ready to merge with no concrete current-head blocker identified.
Pre-merge checks: 
4
Finishing Touches
-
Generate docstrings
-
- Commit to this branch
- Create a new PR
Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
d7dfdf5 to
e17d5a9
Compare
|
@coderabbitai review |
Action performed
|
9c4154f to
7227f3f
Compare
The device picker showed the battery level a device behind a receiver had at discovery. Discovery cannot read it while the device is idle, and the refresh after a reconnection never reads it, so the level was often missing although the battery monitor observes each slot. Prefer the slot's observed level, and fall back to the one from discovery. Co-Authored-By: Claude Opus 5.5 <[email protected]>
7227f3f to
59c212d
Compare
Problem
In the device picker, the devices listed under a Logitech receiver often had no battery level, while the menu bar showed one for the same device.
The picker read
ReceiverLogicalDeviceIdentity.batteryLevel, which is only set when receiver discovery manages to read the battery from the device. Discovery cannot read it while the device is idle, and the refresh after a reconnection (validateReceiverSlotIdentity) never reads it. MeanwhileBatteryDeviceMonitorobserves each receiver slot over HID++ and already feeds the menu bar.Change
ConnectedBatteryDeviceInfo.batteryLevel(of:inventory:)returns a slot's observed level, falling back to the level from discovery.currentDeviceBatteryLevelnow uses it, so its behaviour is unchanged.BatteryDeviceMonitor.batteryLevel(of:)exposes it.DeviceModelpublishespairedReceiverDeviceBatteryLevelsby slot, refreshed with the battery monitor and with the receiver's devices, and the picker shows those.Tests
StatusItemBatteryIndicatorTestsgains a case for an identity without a level (as published after a reconnection) taking the slot's observed level, and for no level at all.xcodebuild test -only-testing:LinearMouseUnitTests: 1182 tests, 0 failures (before #1486 merged; 1187 with it, excluding the window-openingHoverWindowQueryTests).Verified on hardware
MX Master 3S B on a Logi Bolt receiver, launched while the mouse was idle, so discovery reported
battery=(nil). Before the change the picker showed the device under the receiver without a battery level; with it, the level from the slot's observation is shown.🤖 Generated with Claude Code