Repository navigation
Follow the battery state when the plug flag disagrees - #1
Closed
acrogenesis wants to merge 5 commits into
Closed
acrogenesis wants to merge 5 commits into
acrogenesis wants to merge 5 commits into
Conversation
Use the battery's own direction for the power widget. Keep the charge-rate timer tied to plug changes and also start it when the battery begins charging with the plug flag already online. On the affected M1 Max, UPower reported Charging at 0 W before its rate caught up, with OnBattery unchanged through the real plug event. Repeated direction changes leave a running timer's deadline intact. Build on Jader Feijo's original omacom#13016 commit 39470b1 and use the battery-state precedence from z23's omacom#12259 commit 7159a14. Co-authored-by: z23 <z23@users.noreply.github.com>
Remember the battery level of a settled, rate-based charge hold while the source and level remain stable. A brief change in direction at that level no longer starts another rate timer. Give each unconfirmed charging transition the full grace period, even if the previous period has yet to expire. This covers a second connection while UPower's source flag stays stuck.
Remember explicit holds as well as settled rate-based holds. Preserve confirmed evidence until the battery level moves or a new charging rate arrives, since a new direction can arrive before the telemetry from the previous direction has changed. Restart settling when a delayed percentage change invalidates a hold. Keep the timer and evidence together in ChargeRate and exercise real Qt signal ordering in the focused power suite.
Reevaluate a remembered hold when the time estimate catches up with a rate sampled while Charging. Do not carry a rate notification delivered while Discharging into a new charge. Allow one unconfirmed renewal at a battery level. Known source changes and new charging measurements can start another window, but repeated direction flips alone cannot defer a hold forever.
Use a newly reported positive time estimate to corroborate a charging rate applied before the direction in the same UPower update. Keep rate notifications from an earlier discharge from clearing the hold on their own. Treat the first Charging state after a real source change as part of the same plug, leaving the renewal available for the first later reconnect hidden from the source flag.
acrogenesis
marked this pull request as ready for review
November 24, 2026 19:47
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 changes
Follow-up for omacom#13016 and omacom#12005. The icon and labels follow the battery's reported direction. The plug flag still selects the power profile and starts rate settling when external power arrives.
On a 16-inch M1 Max, a USB-C port could stay online after unplugging. On reconnect, UPower could report Charging at 0 W while the global plug flag stayed unchanged. The widget now protects that first rate reading from the charge-limit heuristic and remembers confirmed holds through brief load spikes. A new rate or time estimate can release a hold once it indicates active charging. An unconfirmed attempt at the same level can renew its settling interval once, which covers a second hidden reconnect without letting repeated state changes postpone rate-only hold detection indefinitely.
This branch retains Jader Feijo's original commit
39470b123and the rest of omacom#13016's history. The follow-up credits z23 for the battery-state precedence from omacom#12259.Verification
test/shell.d/power-test.shpasses, including Qt tests for a second reconnect, both explicit hold states, stale-rate notifications, native property update order, delayed percentages and repeated direction changes.quattroat6169f05c8.Screenshots
Captured the live charging panel and an unplugged before/after comparison locally.
Upstream integration
The companion branch keeps the legacy no-battery test working on omacom#13016's base. Current
quattrohas since removed that standalone test. The tested integration retains the upstream deletion. Compare the integration branch