Repository navigation
Stop a stalled charge reading as a charge-limit hold - #7895
chessing234 wants to merge 3 commits into
Conversation
upower's pending-charge means only that AC is present and the EC is not charging the pack. A failed battery, an insufficient supply and charge_behaviour=inhibit-charge all report it, so classifying it as a hold on its own labels a dead pack at 0% "Holding at 75-80%". Claim a hold only when a limit is really configured and the level has reached its band, which is the discriminator the charging branch already applied. Say "Not charging" otherwise: there is no time estimate for a stall, so the plain line would print an empty "left".
Model.chargeThresholdActive read pending-charge as a hold unconditionally, without ever consulting a threshold value, so the panel showed "Charge limit: Holding" and a "Threshold" mode label on a pack no limit was holding. Pass down the threshold string the panel already reads from omarchy-battery-status and require both a configured limit and a level inside its band, matching the rule the command now applies.
There was a problem hiding this comment.
Pull request overview
Refines battery hold detection so stalled charging is not incorrectly reported as a configured charge-limit hold.
Changes:
- Gates pending-charge holds on configured thresholds and battery level.
- Propagates threshold data into the power panel model.
- Adds shell and model regression tests.
Tip
If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
bin/omarchy-battery-status |
Refines hold detection and adds “Not charging” output. |
shell/plugins/panels/power/Model.js |
Parses thresholds and uses them for pending-charge classification. |
shell/plugins/panels/power/Panel.qml |
Passes threshold data into model helpers. |
test/shell.d/battery-status-test.sh |
Adds battery-status regression scenarios. |
test/shell.d/power-test.sh |
Adds threshold model tests. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| return (start > 0 ? start : end) / 100 | ||
| } | ||
|
|
||
| function chargeThresholdActive(device, onBattery, states, threshold) { |
There was a problem hiding this comment.
all three hold branches require a configured threshold now, matching omarchy-battery-status.
| return Model.batteryIcon(device, root.discharging, upowerStates(), root.batteryInfo.threshold) | ||
| } | ||
|
|
||
| function modeLabel() { | ||
| var device = UPower.displayDevice | ||
| return Model.modeLabel(device, root.discharging, upowerStates()) | ||
| return Model.modeLabel(device, root.discharging, upowerStates(), root.batteryInfo.threshold) |
There was a problem hiding this comment.
no running quickshell here — the model tests cover unheld stall vs a real threshold hold. visual check still needed on a machine with the panel.
omarchy-battery-status gates all three of its hold branches on a configured limit; the panel gated only pending charge, so the two layers disagreed on the same battery. A stalled charge and a pack reporting FullyCharged short of full still read as "Charge limit" in the panel with no limit set, which is the case this branch was opened to remove. Gate the stalled-charge branch on the limit and on the level reaching it, and the FullyCharged branch on the limit, matching the shell script's thresholds exactly. modeLabel then had to read the state: a worn pack reporting FullyCharged at 80% no longer takes the Threshold branch, and the percentage alone cannot tell it apart from a charge in progress. The icon already read the state, so the two were free to disagree.
|
the Model.js one is right and it was the more important half of the branch — omarchy-battery-status gates all three hold branches on a configured limit, and the panel gated only pending charge, so the two layers described the same battery differently. both branches are gated now: stalled charging on the limit and on the level reaching it (matching that shook out one more: with no limit set, a worn pack reporting FullyCharged at 80% used to take the Threshold branch, and on Panel.qml — you are right about the guidance and I cannot meet it. no Hyprland/Quickshell on this machine, so the panel was never opened. what the diff does there is pass an existing |
|
Confirming this on hardware, including the panel-rendering half you flagged as unverified. Machine: ASUS Zenbook 14 UX3405CA, omarchy 4.0.1-1, quickshell 0.3.1, upower 1.91.3, Arch. Single BAT0, 75Wh. It is also a #7374 machine: sysfs has What stock 4.0.1 doesPlugged in at 17%, drawing about 30W, the panel showed: It is the
Every dip in that estimate pushes That clause had no test coverage before this PR — Your branch fixes itDriving both
The rendered panelYou wrote that you never opened the panel in a running Quickshell. I did. I applied this PR's three non-test files onto a copy of the released 4.0.1 tree (not master) —
Two honest caveats
I did not run the graphical acceptance suite either. AI-assisted, on my own hardware. |
|
@dhh @ryanrhughes ready for review |
|
folded into #12115 with the other battery/bar panel fixes. |
Fixes #7803.
pending-chargeonly means "AC is present and the EC is not charging the pack". A threshold hold reports it, but so does a failed battery, an insufficient supply, andcharge_behaviour=inhibit-charge. Two implementations collapsed that to "a charge limit is holding it":shell/plugins/panels/power/Model.jsreturnedtrueforPendingChargeunconditionally and never read a threshold value at all, driving theCharge limit/Holdingpair, theThresholdmode label, and the battery icon.bin/omarchy-battery-statusguarded on a threshold existing but not on the level, while thechargingbranch two lines below already appliedpercentage >= threshold_end.Both now claim a hold only when a limit is really configured and the level has reached its band.
Model.jsgets the threshold string the panel already reads fromomarchy-battery-status --shell, so the QML side stops classifying on state alone. A stall with no hold behind it printsNot chargingrather than falling through to theleftbranch, which has no time estimate to print.Two details worth calling out:
charge_control_end_thresholdof100is sysfs saying no limit is configured, so it no longer counts as one. That alone cures the T14 Gen 6 report in Power panel shows UPower's hwdb charge limit (75-80%) instead of the real asusctl-set limit, and a bogus 0 cycle count #7374's comments.0is "no start threshold", not "holds from empty", so the band floor falls back to the end value there.The reporter's machine also hits #7374 — upower's hwdb default supplies a
75-80limit it never set — so the level check, not the100check, is what fixes it there. The two are independent; this holds either way.Evidence
Rebuilt the reporter's X1 Yoga as a fake
OMARCHY_POWER_SUPPLY_PATHplus aupowerstub: dead pack at 0%,pending-charge, sysfs0/100, upower reporting the hwdb75-80. Before:byte-for-byte what the issue reports. After:
and a genuine hold is untouched — same machine at 80% in a real 75-80 band still prints
Battery 80% · Holding at 75-80% · 0W / 58Wh.Same on the JS side, driving
Model.jsdirectly:chargeThresholdActiveon that pack wenttrue→falseandmodeLabelwentThreshold→Charging, while a pack at 80% with a75-80%limit still returnstrue.Tests are in both suites — seven new cases in
battery-status-test.sh, six inpower-test.sh, covering the unheld stall, the below-band stall, the real hold, the100end, and the0start. I checked they have teeth by reverting the fix and confirming each file fails.test/shell.d/{battery-status,power,power-present,battery,system-power,bin-style}-test.shall pass.What I did not run
I developed this on macOS, so I could not run the graphical acceptance suite, and I have not seen the change in the running Quickshell UI —
agents/skills/visual-verification.mdasks for that and I can't provide it. The panel behaviour is exercised throughModel.jsunder node instead; the QML change is three call sites gaining a fourth argument.One behaviour I can't verify on hardware:
batteryInfostarts empty, so during the first refresh cycle after the panel opens a genuine hold reads as "Time to full" for a moment before the threshold arrives. Previously it read as a hold immediately. I think that's the right trade — it's the same data theCharge limitvalue was already waiting on — but a second opinion from someone with a limit set would be worth having.This was AI-assisted; the diagnosis in #7803 did the hard part.