Latch the low-battery warning until the battery recovers - #10081
Open
djbarrios wants to merge 1 commit into
Open
Latch the low-battery warning until the battery recovers#10081djbarrios wants to merge 1 commit into
djbarrios wants to merge 1 commit into
Conversation
The service reset its "already notified" flag the instant the device was not both discharging and at/under the threshold. A brief charging, pending or unknown UPower state at a still-low percentage -- a loose charger, a weak dock, an energy-rate blip -- cleared the latch, so the next 30s poll re-fired the critical "Time to recharge!" notification. Critical notifications never auto-expire, so the copies piled up on screen. Keep the latch set once warned until the battery climbs back to ten points above the threshold, so the warning fires once per discharge and re-arms only after a real recovery. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LVR5pzYf3W2WZqLiJEZRoU
Author
|
Thank you for opening this issue, this has been one of the more annoying bugs. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

What happens
While the notebook discharges near the 10% threshold, the low-battery service fires the critical "Time to recharge! / Battery is down to 10%" notification over and over — dozens of identical copies. They are sent with
-u critical, which never auto-expires (-t 30000is ignored for critical urgency), so they stack up and stay on screen until dismissed one by one.Cause
shell/plugins/services/battery/BatteryModel.js→shouldWarnLowBattery()setsnotifiedLowBattery: lowwhere
lowrequires the device to be currently discharging and<= threshold. Any moment UPower does not report "discharging" — a briefly engaged charger, a weak dock, anenergy-rateblip, apending-charge/unknownstate — makeslowfalse and clears the latch.Service.qmlpolls every 30 s (and on everyonOnBatteryChanged), so the next tick seesalreadyNotified == falseagain and re-fires the warning. There is no hysteresis or recovery check, so a battery parked around 10% with a marginal power source produces an unbounded stack.Fix
Keep the latch set once the warning has fired until the battery genuinely recovers to
threshold + 10. The warning then fires once per discharge episode and re-arms only after a real recovery. Transient non-discharging states at a low percentage no longer reset it.Tests
test/shell.d/battery-test.shgains coverage for:./test/shellpasses (the 3 unrelated failures on my machine —config-test,snapper-test,unowned-system-paths-test— also fail on a pristine checkout here; they check the live system, not the shell code).Repro
Let the battery run down to ~10% with an intermittently connected charger or a weak dock, or on a system whose UPower state flaps near empty, and watch the notifications pile up.