Repository navigation
Keep low-battery warnings latched through AC flaps - #19293
Conversation
The battery service checks on every UPower onBattery change. Clearing the warning latch whenever the battery is not currently discharging lets each brief AC or device-state change re-arm the same low-battery warning. Keep the latch through these transitions and missing readings, and clear it only after the displayed charge rises above the warning threshold so a later low-battery episode can warn again. Retains the latch semantics proposed by fresh3nough in the unmerged #9883, with regression coverage for AC flaps, missing readings and recovery. Fixes #9670 Co-Authored-By: fresh3nough <anonwurcod@proton.me> Co-Authored-By: GPT-6 (Codex, effort not exposed) <noreply@openai.com>
The recovery check already requires a cleared latch, and the existing initial-warning test verifies the next low reading with that latch. Repeating the initial-warning assertion after recovery adds no coverage. Keep the threshold boundary and the regressions that fail on base. Co-Authored-By: Opus 5.5 High <noreply@anthropic.com> Co-Authored-By: GPT-6 (Codex, effort not exposed) <noreply@openai.com>
[Medium impact] The PR appears safe to merge. SummaryKeeps low-battery warnings from repeating while the displayed charge stays at or below 10%.
No actionable issues found. Tests were inspected but not run. Reviews (3) · Last reviewed commit: "Drop a redundant low-battery recovery as..." · Reviewed by Greptile |
|
The repeat-warning sequence is reproduced and fixed at The CLI suite and focused battery, battery-status, battery-presence, notification-send and notification tests passed. GPT-6 in Codex (effort not exposed) ran these checks and found no code defect. The Opus 5.5 High second-opinion run terminated before returning a report; its subsequent health probe answered. The The older latch fixes #9883 and #10081 were closed without merging. The open external-power warning changes address a separate initial-warning condition; preserving this latch remains necessary when charging or missing readings interrupt a low-battery episode. Before, with the fix reverted: four warning cards from four low-battery checks separated by synthetic AC changes. After, on this head: the same sequence leaves one warning card. |
…tery (#19689) #19293 added tests that still passed UPower's onBattery, which #11161 had already removed from shouldWarnLowBattery, so every argument landed one slot over and the AC-flap test failed. Plugging in and out now shows as the battery's own state, so the flap test alternates it between discharging and charging. The test still fails on the model from before #19293. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>


Every AC status change checks the battery again. The warning latch was reset whenever the battery was not currently low and discharging, so a brief AC-online or battery-state change re-armed the warning while the charge remained below 10%.
Keep an existing warning latched through power-source changes, temporary charging states and missing battery readings. Clear it only after the displayed charge rises above 10%, allowing a later low-battery episode to warn again. The initial warning still requires a present, low, discharging battery on battery power.
Based on @fresh3nough's latch fix in #9883, with their contribution credited in the commit.
Fixes #9670.