Skip to content

Warn about a low battery whenever it is discharging, plugged in or not - #15009

Closed
omarchybot wants to merge 1 commit into
quattrofrom
fix/issue-10939
Closed

omarchybot wants to merge 1 commit into
quattrofrom
fix/issue-10939

Conversation

@omarchybot

@omarchybot omarchybot commented Oct 11, 2026 •

Copy link
Copy Markdown
Collaborator

The low-battery warning only fired when UPower's OnBattery was true as well as the battery reporting Discharging. OnBattery is false whenever any line-power supply is online, so a dock or charger that supplies less than the machine draws keeps it false while the battery drains all the way to UPower's critical action. The warning stayed silent in the one case where the user has the least reason to watch the battery, because they believe they are plugged in.

This drops the onBattery term from isDischarging and shouldWarnLowBattery in BatteryModel.js, so the warning reads the battery's own state, as the 3.x omarchy-battery-monitor did before the warning moved into the shell. A battery held at a charge limit reports PendingCharge, not Discharging, so it still does not warn. UPower.onBattery stays where it means where the power comes from: choosing the power profile and powerSaverOnBattery.

Run on a worker with the shell loaded from this branch: a battery reporting Discharging at 8% with line power online warns here and stays silent on quattro. battery-test.sh covers the model without the parameter, including that a charging battery does not warn. Codex Medium reviewed it and found nothing to change.

#14825 dismisses the warning whenever omarchy-power-present reports line power, which would clear it straight away in the docked case this fixes.

Fixes #10939

The guard also required UPower.onBattery, which is false whenever any line-power supply is online. A dock or charger that supplies less than the machine draws keeps it false while the battery drains to the critical action, so the warning never fired in the case the user is least likely to be watching. The battery's own state already answers whether it is draining; the 3.x battery monitor checked only that.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@greptile-apps

greptile-apps Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium impact] The PR appears safe to merge.

Summary

Low-battery warnings now follow the battery’s discharge state, even when line power is connected.

  • Low-battery warnings follow the battery’s discharge state.

Reviews (1) · Last reviewed commit: "Warn about a low battery whenever it is ..." · Reviewed by Greptile

@jandrusk

Copy link
Copy Markdown

Overlap: #11161 ("Warn on low battery even when line power is online") makes the same change, dropping the onBattery term so the warning follows the battery's own Discharging state, and it's still open. As you noted, #14825, #14739 and #14218 all dismiss the warning when line power is present, which would undo this in the docked case. I think those need one product decision on which behavior wins before any of them merge. Linking them here so they get reviewed together.

@omarchybot omarchybot added the bug Something isn't working label Oct 17, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator Author

#11161 is an older, open fix for #10939, also against quattro, and it makes the same functional change: it drops the onBattery term from isDischarging in BatteryModel.js, so the low-battery warning follows the battery's own Discharging state when a dock or underpowered charger keeps line power online. Older fixes win by default, and #11161 handles every case this one does, so this one is not being verified separately and #11161 is the one to take.

Beyond #11161, this pull request removes the now-unused onBattery parameter from isDischarging and shouldWarnLowBattery and from their callers in Service.qml, adds the comment explaining why onBattery is not used, and adds tests for a missing battery and for a charging battery staying silent. None of that changes behaviour. It has been handed to #11161 to fold in there. This branch also no longer merges cleanly against quattro.

Compared by reading both diffs against quattro. Codex Medium agreed separately that this is a bug fix, and when asked which fix should win without being given this answer, it also picked #11161: it found the two behave the same and #11161 has no defect that would justify taking the newer one. Its independence is not guaranteed. It did not judge them close enough to close this as an exact duplicate, so this stays open and the maintainer decides.

#14825 and #14218 dismiss the warning whenever line power is present, which would clear it at once in the docked case #10939 is about. Choosing between that and warning while docked is the maintainer's decision. Waiting on the maintainer.

omarchybot added a commit to sanjyay/omarchy that referenced this pull request Oct 17, 2026
isDischarging no longer reads onBattery, so taking it only suggests the warning still depends on it. Both callers are in Service.qml. The tests now also cover a missing battery and a charging battery staying silent, folded in from omacom#15009.

Co-Authored-By: Omarchybot <317366263+omarchybot@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dhh pushed a commit that referenced this pull request Nov 21, 2026
* Warn on low battery even when line power is online

When a machine is connected to a dock or power supply that delivers less
power than the system draws, UPower.onBattery is false because a line-power
source is online, but device.state is Discharging.

Previously, isDischarging required onBattery to be true. As a result,
shouldWarnLowBattery returned false throughout the discharge and suppressed
the low-battery warning until the system was force-suspended at critical
charge.

Rely directly on device.state === dischargingState in isDischarging while
preserving the onBattery argument for API compatibility.

Fixes #10939

* Drop the unused onBattery parameter from the low-battery model

isDischarging no longer reads onBattery, so taking it only suggests the warning still depends on it. Both callers are in Service.qml. The tests now also cover a missing battery and a charging battery staying silent, folded in from #15009.

Co-Authored-By: Omarchybot <317366263+omarchybot@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Omarchybot <317366263+omarchybot@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@omarchybot

Copy link
Copy Markdown
Collaborator Author

Closing as obsolete: #11161 merged into quattro and makes the same change — isDischarging and shouldWarnLowBattery drop the onBattery term, so the low-battery warning reads the battery's own Discharging state while a dock or weak charger keeps line power online. BatteryModel.js ends up byte-for-byte the same as this branch, the Service.qml call sites match, and the tests cover the same cases. #10939 is closed by that merge.

Checked by Claude Opus 5.5 comparing the two diffs, with Claude Opus 5.5 at high effort as the second opinion, which independently found nothing here that #11161 lacks.

@omarchybot omarchybot closed this Nov 21, 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Low-battery warning never fires while docked: onBattery guard suppresses it when a dock supplies power but the battery still drains

2 participants