Skip to content

Keep low-battery warnings latched through AC flaps - #19293

Merged
dhh merged 2 commits into
quattrofrom
fix/issue-9670-battery-warning-latch
Nov 21, 2026
Merged

dhh merged 2 commits into
quattrofrom
fix/issue-9670-battery-warning-latch

Conversation

@omarchybot

Copy link
Copy Markdown
Collaborator

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.

omarchybot and others added 2 commits November 18, 2026 03:55
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>
@greptile-apps

greptile-apps Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge.

Summary

Keeps low-battery warnings from repeating while the displayed charge stays at or below 10%.

  • Low-battery warnings stay latched until charge rises above 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

@omarchybot omarchybot added bug Something isn't working verified Omarchy Triage has verified that this issue is ready for final review labels Nov 18, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator Author

The repeat-warning sequence is reproduced and fixed at 5ae196c6ab7de87c71eacabbead05e0c1f4f3804. On a disposable Omarchy worker, my own model probe and synthetic UPower signals through the real shell and notification service produced four warnings on base, one on this head, and four again with the fix reverted. The shell also kept one warning through temporary charging and a missing battery reading, then warned again after recovery to 11% and discharge to 10%. Physical USB-PD negotiation was not tested.

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 ready label was refused because the second opinion did not return a clean result; this run produced no review report. A completed second review is still needed before maintainer consideration.

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.

Before: four low-battery warnings with the fix reverted

After, on this head: the same sequence leaves one warning card.

After: one low-battery warning through the same synthetic AC changes

@dhh
dhh merged commit e0cdfc6 into quattro Nov 21, 2026
3 checks passed
@dhh
dhh deleted the fix/issue-9670-battery-warning-latch branch November 21, 2026 17:11
dhh added a commit that referenced this pull request Nov 21, 2026
…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>
@emirb emirb added this to the 4.6.0 milestone Dec 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working verified Omarchy Triage has verified that this issue is ready for final review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Low-battery warning storm: notification every ~3s when AC online status flaps (latch resets on onBatteryChanged)

3 participants