Repository navigation
Conversation
b88afc8 to
7fd0d5a
Compare
[Medium impact] The change reaches the shell's low-battery warning workflow. The PR appears safe to merge, with a non-blocking gap in tests for the discharge timer. Findings
SummaryAllows low-battery warnings when external power stays online but the battery keeps discharging.
|
| // An online supply must not suppress the warning once discharge has settled. | ||
| const lowOnPower = { isPresent: true, percentage: 0.08, state: discharging } | ||
| assert(!battery.shouldWarnLowBattery(lowOnPower, false, discharging, 10, false, false).notify, 'battery waits out stale discharge after plugging in') | ||
| assertDeepEqual( | ||
| battery.shouldWarnLowBattery(lowOnPower, false, discharging, 10, false, true), | ||
| { level: 8, notify: true, notifiedLowBattery: true }, | ||
| 'battery warns when sustained discharge on external power reaches the threshold' | ||
| ) | ||
| assert(!battery.shouldWarnLowBattery(lowOnPower, false, discharging, 10, true, true).notify, 'battery does not repeat the warning on external power') |
There was a problem hiding this comment.
Discharge timer stays untested
The new tests pass drainingOnPowerHeld directly, so they never exercise the timer in Service.qml. They would still pass if the service warned immediately, failed to cancel a short discharge, or never restarted the hold.
Add a service-level regression test that ends discharge before the deadline, starts another discharge, and checks that the warning waits for a full new hold.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
|
Reviewed at 7fd0d5a by Claude Fable 5.2, with Codex Medium as the second opinion. This was compared by reading the diffs against Competing fixes. Three open pull requests fix the missing low-battery warning from #10939: #11161 (opened 2026-09-10), this one (2026-10-22) and #17881 (2026-11-06). #15009 made the same change as #11161 and was folded into it. Older fixes win by default, and #11161 fixes the cause: it drops the What this one adds over #11161 is the 60-second hold before trusting One defect in the hold, found by Codex Medium and confirmed against the diff.
#11161 keeps the latch through that sequence and warns once. If the hold is kept, waiting to trust the report should not count as recovery. The overlap with #16278, which merged, was also checked: it changes the text of Next: this waits on the maintainer, who chooses between #11161, #17881 and this one. Nothing is needed from you unless they want the hold. |
|
Closing as obsolete: #11161 merged into What this branch adds beyond it is the 60-second hold before believing Checked by Claude Opus 5.5 comparing the two diffs, with Claude Opus 5.5 at high effort as the second opinion, which agreed the hold guards nothing the latch does not already cover (that agreement is not guaranteed independent). If you see a spurious warning on plug-in with #11161, reopen this with what the battery reported. |
A dock or weak charger can report external power while the battery is discharging. The battery service currently requires
UPower.onBatteryfor low-battery warnings, so a battery can drain to empty without a warning in that state. This was observed with a DisplayLink dock on a 16-inch MacBook Pro (M1 Max): the USB-C supply stayed online whilemacsmc-acwas offline and the battery drained at 11–22 W.Allow the low-battery warning after the battery has continuously reported
Dischargingon external power for 60 seconds. The delay avoids warning on the stale discharge state just after plugging into a working charger. A single one-shot timer tracks the hold; charging or leaving the external-power discharge state cancels it. The existing threshold and warning deduplication still apply.This complements #13016 by addressing the missing low-battery warning noted in its review. The power panel and automatic power-profile selection retain their current behavior, including the shared
UPower.onBatterysource for profile selection. Rebased onto currentquattro(d5b32d24d).Validation:
battery-test.sh: all 19 assertions pass, covering the settling delay input, warning on sustained external-power discharge, deduplication, and charging recovery.quattrobattery model: an 8% battery draining on external power still suppresses the warning after the hold.power-test.sh: all 20 assertions pass.qmllintreports no diagnostics for the battery service;git diff --checkpasses.Remaining verification: the visible notification and behavior with the physical weak charger/dock have not been verified in the live desktop shell.