Skip to content

fix(service): show the battery right away when the mouse shows up just after Bridge starts - #118

Merged
snekxs merged 1 commit into
OpenMouse-Project:mainfrom
HighestFidelity:pr/first-scan-battery
Nov 13, 2026
Merged

snekxs merged 1 commit into
OpenMouse-Project:mainfrom
HighestFidelity:pr/first-scan-battery

Conversation

@HighestFidelity

Copy link
Copy Markdown
Contributor

Refs #79 (the "tray stays blank" part only, not the Redragon reader).

The device scanner reads batteries when a mouse appears compared with the previous scan. The first scan has no previous scan, so it never triggers a read. If the dongle enumerated just after the startup battery poll (common right after boot or login), the tray had no battery until the next poll, 5 minutes later.

What changed:

  • On the first scan, if a mouse is on the bus and the startup poll left no reading, Bridge reads the batteries once.
  • A scan that lands while a poll is still running is judged after that poll ends, instead of spawning a read the running poll's guard would just drop. So the first scan sees what the startup poll found.
  • No retry loop, and the poll interval is unchanged.

Tested:

  • New unit test the_first_scan_reads_a_mouse_already_on_the_bus_when_no_reading_landed for the decision (scan_wants_read): first scan with a mouse and no reading reads; with a reading, or with no mouse, it doesn't; later scans read only when a new mouse appears.
  • cargo fmt --check, cargo test --locked, and clippy with -D warnings for Linux and x86_64-pc-windows-gnu all pass.
  • A fork build with this change passed a quick Windows test with a real mouse, battery included. I didn't reproduce the boot-time race on purpose, so that part isn't hardware verified.

🤖 Generated with Claude Code

…t after Bridge starts

The device scanner only triggered a battery read when a mouse appeared
versus the previous scan, and the first scan has no previous, so a dongle
that enumerated after the startup poll left the tray blank until the next
5 minute poll. The first scan now reads once if a mouse is on the bus and
no reading exists; scans during a running poll are judged after it ends
instead of spawning a read the poll guard would drop. No retry loop, poll
interval unchanged.

Refs OpenMouse-Project#79

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 13, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 59 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 86974b1 and 48c5835.

Files selected for processing: 1

  • src/service.rs
  • 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.

Share

@github-actions github-actions Bot added type: bug PR title category: bug area: native Native bridge and platform services labels Nov 13, 2026
@snekxs
snekxs merged commit f2c12bf into OpenMouse-Project:main Nov 13, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: native Native bridge and platform services type: bug PR title category: bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants