Skip to content

feat(tray): show device batteries and low-power alerts - #1588

Open
flowsworld wants to merge 6 commits into
AprilNEA:masterfrom
flowsworld:feat/battery-menu
Open

flowsworld wants to merge 6 commits into
AprilNEA:masterfrom
flowsworld:feat/battery-menu

Conversation

@flowsworld

@flowsworld flowsworld commented Sep 25, 2026 •

Copy link
Copy Markdown

Summary

Show device batteries directly in the existing macOS and Windows tray menus, with optional low-battery warnings. This is separate from the macOS system Batteries widget in #1544. Linux remains out of scope because it has no existing tray integration.

Related Windows work: #964. Its tray message queue approach is adapted here, with contributor credit in the commit.

Changes

  • Agent: native menu rows put the device name on the left and a colored battery badge on the right, with the percentage inside, a charging bolt, or ? for an unavailable reading. Clicking opens that device's settings, including after a cold GUI launch.
  • Core/device/IPC: share battery policy across all supported battery-reporting connections, deduplicate physical devices, distinguish cached readings, and bump the wire protocol to v32.
  • GUI: independent per-device switches for menu visibility and warnings, both on by default, offered only after battery evidence is available. Missing readings retain known controls during the GUI session. Hidden devices can still warn. The brand icon turns orange at 20% and red at 10%; charging/full devices and stale readings do not contribute.
  • Agent: OS notifications occur once per low-battery episode, persisted across restarts and reconnects. Only a measured recovery above 25% rearms the alert. Devices without their own serial or unit ID use session history, cleared when their pairing disappears or its model changes. Sleeping pairings keep their history.

Native macOS captures from an isolated AppKit test app using the actual menu-row implementation:

Light Dark
Light native battery menu Dark native battery menu

Testing

Initial implementation checks passed on macOS arm64:

RUSTFLAGS="-D warnings" cargo fmt --all -- --check
RUSTFLAGS="-D warnings" cargo clippy --workspace --all-targets -- -D warnings
RUSTFLAGS="-D warnings" cargo test --workspace
RUSTFLAGS="-D warnings" RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps --document-private-items --exclude openlogi-ui --exclude openlogi-desktop --exclude openlogi-overlay --exclude openlogi-agent
cargo xtask ci ast-grep typos wasm cargo-deny
RUSTFLAGS="-D warnings" cargo clippy -p openlogi-agent --target x86_64-pc-windows-gnu --all-targets -- -D warnings

Initial workspace tests: 1,774 passed, 2 ignored. Coverage includes freshness/recovery, warning persistence, USB charging precedence, preference reloads, cold/warm device navigation, wire goldens, and locale parity. The battery policy guard also rejects the original inline threshold.

After the review fixes, all 606 affected-package tests passed:

RUSTFLAGS="-D warnings" cargo test -p openlogi-agent-core -p openlogi-agent -p openlogi-desktop

Formatter, full-workspace Clippy, non-GUI rustdoc, ast-grep, typos, and the Windows agent cross-lint above passed again on the final tree. New regressions cover anonymous receiver replacements, sleeping pairings, physical identity recovered from another route, and battery controls for devices with or without battery evidence. Linux cfg changes were manually audited again.

Native macOS keyboard, mouse and accessibility activation passed in isolation. Normal/orange/red status-icon rendering was verified. Windows was cross-linted, not runtime-tested on hardware. Packaged macOS notification delivery and real-device end-to-end behavior remain untested. Linux cfg changes were manually audited; Linux compilation was not run locally.

Hardware check: open the menu with a battery-reporting device, toggle its two preferences independently, click its row with the GUI closed/open, and verify a low-battery alert does not repeat after reconnect/restart. Charge above 25% before testing a new alert episode.

Fixes #959

@greptile-apps

greptile-apps Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

[Medium risk] Adds battery status display to system tray menus.

The PR appears safe to merge based on the changes since the previous review.

Summary

The PR adds battery rows, warning colors, and low-battery notifications to the macOS and Windows trays, with per-device controls and a versioned tray-to-GUI selection request. The latest changes preserve battery controls for model-less offline placeholders.

Reviews (3) · Last reviewed commit: "fix(gui): retain battery controls for of..."

Comment thread crates/openlogi-agent-core/src/battery.rs Outdated
Comment thread crates/openlogi-desktop/src/app/detail.rs
Comment thread crates/openlogi-desktop/src/state/device_store.rs Outdated

This branch has not been deployed

No deployments
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.

[Feature]: Show battery level on tray icon

1 participant