Skip to content

Keep charging visible with long time-to-full estimates - #14141

Open
hulingjun wants to merge 3 commits into
omacom:quattrofrom
hulingjun:fix/power-long-charge-estimate
Open

hulingjun wants to merge 3 commits into
omacom:quattrofrom
hulingjun:fix/power-long-charge-estimate

Conversation

@hulingjun

@hulingjun hulingjun commented Oct 3, 2026 •

Copy link
Copy Markdown

Fixes #9668.

A battery can be actively charging while UPower estimates more than eight hours to full. The power panel currently treats that estimate as a charge-limit hold, showing a plain battery icon and Threshold until the estimate falls below eight hours.

Remove the time-to-full condition from chargeThresholdActive(). The existing pending-charge, fully-charged and low-rate hold detection remains in place. This changes the charging icon, status label and panel flow state together through their shared predicate.

Reproduction

Recorded UPower history on an HP ZHAN 66 Pro A 14 inch G5, Omarchy 4.0.4-1, UPower 1.91.3-1:

Time Battery UPower state Charge rate Time to full Current model result Fixed result
18:22:31 34% Charging 2.191 W 41,783 s (11.6 h) Threshold; plain battery Charging; charging battery
18:23:18 35% Charging 39.402 W 2,281 s (38 min) Charging; charging battery Charging; charging battery

Earlier charging samples at 1.79–2.122 W and estimates of 12.5–14.9 hours showed the same misclassification for several minutes. Replaying the recorded values through the current model reproduces the hidden charging indicator.

Validation

  • bash test/shell.d/power-test.sh: all 26 assertions pass, including the recorded 34% sample, its charging label/icon, and the eight-hour boundary. The new recorded-sample regression fails against the original model.
  • git diff --check: passes.
  • ./test/all: attempted; 11 of 294 shell test files fail locally. Each failing file was rerun against an unmodified checkout of the same base commit and also fails there. Failures involve companion package checkout requirements, migrations and graphical fixtures. The CLI suite also fails its VS Code current-theme-path assertion on both checkouts.
  • Before/after visual verification completed in the running Omarchy shell: a temporary user-owned clone of the actual power panel replayed the same recorded 34% / Charging / 2.191 W / 41,783 s sample against the original and patched models. The original renders Threshold / Holding with a plain battery; the patch renders the charging icon, time to full and charge rate. Desktop configuration was restored afterward.

Before / after screenshots

Controlled replay of the recorded 2026-10-03 18:22:31 UPower sample in the real desktop power component, captured with grim. These are cropped desktop screenshots, not live readings from a second physical plug-in event. The same fixture and layout are used in both captures; only Model.js changes. Captures include the bar battery icon and power panel.

Before After
Before: plain battery icon, Threshold and Holding After: charging battery icon, time to full and 2.191 W

A second recorded occurrence on 2026-10-04 at 07:47:47 confirms the same predicate failure near empty: UPower reported Charging, 0% (rounded), 1.977 W and 66,990 s (18.6 h). Model replay yields Threshold before and Charging after. At 07:48:03, the rate increased to 46.964 W and the estimate fell to 2,812 s, allowing the original model to show charging again.

Related: #8663 addresses initial zero-rate readings; this change addresses a positive measured charge rate with a long estimate.

@hulingjun
hulingjun marked this pull request as ready for review October 4, 2026 04:47
@greptile-apps

greptile-apps Bot commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge.

Summary

Keeps charging visible when UPower reports a long time-to-full estimate.

  • The power panel keeps showing charging when a full-charge estimate runs long.

No new actionable issues found. The previously reported icon-test weakness is fixed.

Reviews (3) · Last reviewed commit: "Merge quattro into fix/power-long-charge..." · Reviewed by Greptile

Comment thread test/shell.d/power-test.sh Resolved

@chessing234 chessing234 left a comment

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.

everything seems fine, ready to merge.

@jandrusk

jandrusk commented Oct 6, 2026

Copy link
Copy Markdown

Thanks for the recorded samples. They make the misclassification easy to see. One thing to consider: the 8-hour ETA rule was presumably there for machines that report Charging with a small positive rate while they sit at a charge limit. Dropping it fixes slow chargers but could bring back Charging on those. #10196 takes the other approach: it only reports a hold when a real charge threshold exists, the same as omarchy-battery-status. That would let the ETA rule stay without misfiring on machines with no threshold.

Also, #8663 and #10196 both edit chargeThresholdActive() too, so the three will conflict. It'd be worth landing them in a deliberate order.

@hulingjun

Copy link
Copy Markdown
Author

Thanks @jandrusk — good point about machines that report a small positive rate while held at a charge limit. I agree that this is worth considering alongside #10196 and #8663.

Happy to follow the maintainers’ preferred merge order and rebase this PR or resolve conflicts as needed once that order is decided.

@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed at ac70989 by Claude Opus 5.5 and run on a disposable Omarchy VM. Codex Medium, the configured second opinion, did not run: its daily review budget was spent. Nothing in the diff needed changing.

The fix works. Your slowCharge assertion in test/shell.d/power-test.sh (34%, Charging, 2.191 W, 41,783 s to full) fails on quattro (246f33a), passes on this head, and fails again with Model.js reverted. With this branch merged into current quattro, ./test/cli, power-test.sh (30 assertions), battery-status-test.sh and battery-test.sh all pass. On this head alone, ./test/cli still fails the VS Code current-theme-path test you mentioned. That failure comes from the branch's older fork point: it fails before your change too and passes on quattro.

It matches the CLI. omarchy-battery-status treats a battery that is still charging as holding only when the rate is 0.2 W or less. It has no time-to-full rule, so this change makes the panel agree with what the CLI prints. One case gets less coverage, the one @jandrusk raised: a machine held at a limit that keeps reporting Charging with more than 0.2 W. The eight-hour rule caught that case, and after this change the panel shows Charging there, as the CLI already does. Whether that trade-off is acceptable is for the maintainer to decide.

The other pull requests that edit chargeThresholdActive():

This is waiting on a second opinion, which runs when the review budget resets, and then on the maintainer. Nothing is needed from you.

@omarchybot omarchybot removed the verified Omarchy Triage has verified that this issue is ready for final review label Nov 16, 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>
@omarchybot omarchybot added verified Omarchy Triage has verified that this issue is ready for final review ready Good to merge labels Nov 17, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

This had stopped merging cleanly. #19046 landed on quattro with a stale-rate guard right above the line you change, and with its own assertions where yours go in power-test.sh. I merged quattro into your branch as 6f3cb21. Model.js merged without conflicts, and the test conflict keeps both sets of assertions. Against quattro the diff is still exactly your change. Pull before you push anything else.

Checked at 6f3cb21, on a disposable Omarchy VM, by Claude Opus 5.5:

  • Your slowCharge assertion fails on quattro (3b36b9e) and passes on the merge, along with the other 28 in power-test.sh. With Model.js reverted, the tree is identical to quattro, so it fails there too.
  • ./test/cli, power-no-battery-test.sh, battery-status-test.sh and battery-test.sh all pass.
  • I swapped the VM's UPower for a mock reporting your recorded 18:22:31 sample: 34%, Charging, 2.191 W, 41,783 s to full. On quattro, the bar draws a plain battery and the panel says Threshold. On the merge, it draws the charging icon and the panel shows a charging subtitle. The battery is simulated, so this shows how the shell draws that reading, not how a particular laptop reports it.

Before, on quattro: plain battery icon in the bar, power panel subtitle THRESHOLD
After, on this branch: charging battery icon in the bar, power panel shows a charging subtitle

Second opinion: the October review ran without one. This time Codex Medium and muse-wonder via pi (thinking high) both reviewed the merge and found no defect in the change or in the conflict resolution. That is agreement with my reading, and its independence is not guaranteed. Both describe the cost the same way @jandrusk did. A machine held at a charge limit that still reports Charging above 0.2 W, with an estimate of eight hours or more, will now show Charging. omarchy-battery-status already reports it that way, and nothing else in the panel catches that case.

#10076 no longer touches the eight-hour rule since its rebase, so nothing here competes with this fix. #8663, #10196 and #17616 also edit chargeThresholdActive(), for different bugs. Whichever of them lands after this one will need a small conflict resolved.

This now waits on the maintainer, including the trade-off above. Nothing is needed from you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working ready Good to merge 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.

Battery bar icon shows 'not charging' when actually charging, due to bogus time-to-full estimate

4 participants