Skip to content

Keep the charging icon while the battery's charge rate is still stale - #19046

Merged
birkskyum merged 1 commit into
omacom:quattrofrom
fidecastro:battery-icon-after-plug
Nov 15, 2026
Merged

birkskyum merged 1 commit into
omacom:quattrofrom
fidecastro:battery-icon-after-plug

Conversation

@fidecastro

Copy link
Copy Markdown
Contributor

After plugging in a charger, the bar's battery icon shows the charging mark for an instant, goes back to the plain battery for up to a minute, then shows the charging mark again. The panel says "Threshold" and "Holding" for that minute, on a battery with no charge limit set.

Cause. chargeThresholdActive() takes "charging at 0.2 W or less" for a charge limit holding the battery. Some batteries refresh their rate only every half minute, so right after external power arrives UPower reports charging with the rate from before, 0 W. Recorded once a second on a Surface Laptop 7 (qcom-battmgr), after plugging in at 16:33:42:

16:33:42  state=charging  energy-rate=0 W
   ...    (49 samples, unchanged)
16:34:31  state=charging  energy-rate=40.124 W

The same gap showed on every plug-in I recorded, on both USB-C ports.

Change. The panel tracks whether the rate can be trusted: chargeRateFresh goes false when the laptop comes off battery and true again 90 seconds later, or at once when it goes back on battery. While it is false, the stalled-rate rule is skipped. The explicit signals still count straight away: PendingCharge, and FullyCharged below 99%. With a real limit holding at 80%, this battery reports pending-charge, so that case is unaffected. Model.js takes the flag as an optional last argument, so its other callers and tests behave as before.

90 seconds covers the 49 I measured with room for a slower battery. A laptop that reports charging at 0 W while a limit holds will show the charging mark for those 90 seconds after plugging in, then the plain battery as today.

Tested. test/shell.d/power-test.sh with five new cases (stale rate is not a threshold; fresh stalled rate still is; PendingCharge counts while stale; icon and label while stale), and power-no-battery-test.sh, which loads the panel. Not tested: the changed panel on a running bar through a real plug-in. The battery here is being held at its 80% limit, which is the case the change leaves alone.

Prepared with Claude Fable 5.2.

@greptile-apps

greptile-apps Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] No new code issue blocks merging; the previously requested running-bar check is still owed.

Findings

  1. P2 Running-UI check is missing ▶

Summary

The power panel keeps the charging icon while battery-rate readings settle after plugging in.

  • The power panel keeps showing charging while the charge rate is stale.

Reviews (3) · Last reviewed commit: "Keep the charging icon while the battery..." · Reviewed by Greptile

@birkskyum
birkskyum merged commit d7586fb into omacom:quattro Nov 15, 2026
3 checks passed
omarchybot added a commit to ludagoo/omarchy that referenced this pull request Nov 16, 2026
quattro's omacom#19046 gave the power panel's threshold, icon and mode helpers a rateFresh argument in the slot this branch used for kernelLevel. Both stay: rateFresh keeps quattro's position and kernelLevel follows it, so quattro's callers and tests are untouched and this branch's three latched-battery tests pass true for a fresh rate before the kernel level.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
omarchybot added a commit to jaderfeijo/omarchy that referenced this pull request Nov 17, 2026
Resolves the conflict in shell/plugins/panels/power/Model.js, where omacom#19046 added a rateFresh argument to batteryIcon beside this branch's new drawingFromBattery helper: both are kept. Panel.qml merged on its own, so omacom#19046's chargeRateFresh reset now follows the settled discharging state rather than UPower.onBattery alone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
omarchybot added a commit to jaderfeijo/omarchy that referenced this pull request Nov 17, 2026
omacom#19046 reset chargeRateFresh from onDischargingChanged, which on quattro followed UPower.onBattery. Here discharging also follows the settled battery state, so every Charging/Discharging flip on a weak charger restarted the 90 s window and kept a stalled-rate charge limit from being recognised for as long as the flips continued. Drive the reset from onOnBatteryChanged instead, so it still runs only when external power arrives or leaves.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Codex Medium <noreply@openai.com>
Co-Authored-By: muse-wonder via pi, thinking high <noreply@pi.dev>
omarchybot added a commit to hulingjun/omarchy that referenced this pull request Nov 17, 2026
quattro's omacom#19046 added a rateFresh guard just above the line this branch changes in chargeThresholdActive(), and its own assertions where this branch adds the slow-charge ones in power-test.sh. Model.js merged cleanly; the test conflict keeps both sets of assertions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment on lines +77 to +85
onDischargingChanged: {
chargeRateFresh = discharging
if (discharging) chargeRateSettle.stop()
else chargeRateSettle.restart()
}
Timer {
id: chargeRateSettle
interval: 90000
onTriggered: root.chargeRateFresh = true

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Running-UI check is missing

The repository requires visual changes to be checked in the running UI, but the PR explicitly says this panel was not tested through a real plug-in. The new tests pass rateFresh directly, so they do not check whether onDischargingChanged starts the timer or whether the icon stays correct through plug-in, timeout, and unplug. Check those transitions in the running branch and attach the required visual evidence before merging.

File Used: AGENTS.md (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This merged on 2026-11-15 and went out in the v4-5-1 backport (#19202), so the running-bar check is still owed. @fidecastro, you're on edge with it. Could you plug in, wait out the 90 seconds, and unplug once, and post what the icon and panel show at each step?

ButtercupRobrts pushed a commit to ButtercupRobrts/omarchy that referenced this pull request Nov 28, 2026
@emirb emirb added this to the 4.6.0 milestone Dec 1, 2026
BrahimiMehdi added a commit to BrahimiMehdi/omarchy that referenced this pull request Dec 2, 2026
Resolves the conflicts with omacom#19046 (stale charge rate) and omacom#20379
(charge limit state): the settled charge-limit verdict is now a trailing
argument after rateFresh and limitState, and the detail refresh uses the
queued battery read quattro added instead of a separate process wrapper.

Review fixes:
- Picking a power profile while an unplug is held back saved it as the AC
  preference. setProfile now reads the power source UPower reports, not the
  one the panel shows.
- A widget created on AC treated its own creation as the plug-in, so a real
  charge limit read as charging for a minute. The battery service now
  records when power last arrived, and a widget settles from that; one
  created long after a plug-in shows the limit at once.
- The 90 s charge-rate guard follows the reported power source, so a held
  dropout still restarts it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

3 participants