Skip to content

Follow the battery state when the plug flag disagrees - #1

Closed
acrogenesis wants to merge 5 commits into
jaderfeijo:fix-power-panel-charge-directionfrom
acrogenesis:fix/power-panel-battery-state
Closed

acrogenesis wants to merge 5 commits into
jaderfeijo:fix-power-panel-charge-directionfrom
acrogenesis:fix/power-panel-battery-state

Conversation

@acrogenesis

@acrogenesis acrogenesis commented Nov 24, 2026 •

Copy link
Copy Markdown

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 39470b123 and 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.sh passes, including Qt tests for a second reconnect, both explicit hold states, stale-rate notifications, native property update order, delayed percentages and repeated direction changes.
  • The original branch's no-battery panel test passes. The focused power suite and headless shell smoke test also pass with the changes integrated into quattro at 6169f05c8.
  • The test cycle measured the bolt returning 1.65 seconds after AC came online, in the same sample as UPower switched to Charging and 8.84 seconds before the first positive rate. The final revision reproduced that recorded sequence in Qt during independent review.
  • The final Astra Max review found no further actionable issues. Repeated reconnections with identical readings and a stuck source flag remain ambiguous until a new measurement arrives.

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 quattro has since removed that standalone test. The tested integration retains the upstream deletion. Compare the integration branch

acrogenesis and others added 5 commits November 24, 2026 12:18
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
acrogenesis marked this pull request as ready for review November 24, 2026 19:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant