Repository navigation
Derive power panel charge direction from settled battery state - #13016
jaderfeijo wants to merge 5 commits into
Conversation
The panel treated "charger plugged in" as "charging". When a charger can't cover the machine's draw, UPower reports on-battery: no while the battery reports Discharging, and the panel showed a draining battery as "Charging" / "Time to full" with the bolt icon. Keep trusting plug status for 30s after a plug change, since the battery state lags behind it, then follow the battery's own state. Fixes omacom#13015 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Automated AI review
Verified: in source, the charge-direction fix matches how UPower defines its signals. UPower sets One side effect was found: the change moves where profile choices are saved. Profile choices made in the panel on a weak charger are saved as the battery preset
// shell/plugins/panels/power/Panel.qml:170 (unchanged by this PR)
actionProc.command = ["omarchy-powerprofiles-set", root.discharging ? "battery" : "ac", profile]
Impact: on a weak charger, choosing a profile in the panel applies it right away, but the choice overwrites the battery preset and leaves the AC preset untouched. After unplugging, the battery service applies that profile (for example Performance) on battery. Choosing the same profile from the menu in the same state saves it to Suggested change: keep the storage key on the power source, Related, pre-existing: the low-battery warning in Review informationTest scope: Source review of head AI process: Opus 5.5 Medium coordination and synthesis, independent Opus 5.5 Xhigh and GPT 6 Sol Xhigh technical assessments, Opus 5.5 Medium editorial check. Opt out: To stop receiving these reviews, reply to this comment saying so. |
setProfile picked the ac/battery state key from root.discharging, which now follows the battery's own state. On a charger too weak to cover the load it saved the choice as the battery preset, so the battery service applied it after unplugging, and the menu's autodetect path saved the same choice under ac. omarchy-powerprofiles-set documents UPower.onBattery as the key every entry point uses, so the panel uses it too and root.discharging stays presentation only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Reviewed by Claude Opus 5.5, with Codex Medium as a second opinion. The fix is right, and I pushed one follow-up commit to your branch (5b3c6b4). Pushed: profile choices are saved under the power source again. What ran, on a disposable Omarchy worker VM:
Second opinion: Codex Medium agreed the change is proportionate and correct across unplugged, just-plugged, just-unplugged, settled weak charger, charging, full, threshold-held and no-battery states. It also agreed with the profile-key fix (it read this review, so independence isn't guaranteed). It noted that the new QML assertions match source text, so they would not catch a broken timer or handler. The existing power tests use the same convention, so I didn't change that. Next: this waits on the maintainer. No CI checks ran on this pull request, so it is marked verified but not ready. |
[Medium impact] The PR appears safe to merge; the earlier brief status error after a widget reload remains non-blocking. Findings
SummaryThe power panel now uses the battery’s reported direction after a 30-second plug settle window.
No new actionable issues were found.
|
| return device && device.isPresent && device.state === UPowerDeviceState.FullyCharged && !root.chargeThresholdActive | ||
| } | ||
| // True while a plug change settles; see Model.drawingFromBattery. | ||
| property bool plugSettling: false |
There was a problem hiding this comment.
Reload loses the settle window
plugSettling resets to false whenever the widget is rebuilt. If plugins reload just after a charger is connected, the new widget misses the earlier onBattery change. While the battery still reports Discharging, the panel briefly shows “Discharging” and “Time left” instead of preserving the remaining settle window.
Keep the last plug-change time outside the widget and use it when the widget loads.
Knowledge Base Used: Shell UI and desktop interactions
Resolves the conflict in test/shell.d/power-test.sh by taking quattro's side of the source-text assertions, which omacom#16334 removed on purpose, including the three this branch added. The drawingFromBattery model tests stay. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The merge. The only conflict was in What ran, on a disposable Omarchy worker VM serving the merged tree:
The bar icon and the hero label follow the fix too. Competing fixes. #12259 (older) and #16265 (newer) fix the same symptom in other ways. #15539 and #16855 change the same files for different bugs: the charge limit misread while the rate is re-measured, and noisy gauge readings. Both reviewers, asked without my answer, chose this one:
Both reviewers found no defects in the merge or in the change. They read this review's context, so their agreement isn't guaranteed to be independent. Next: this waits on the maintainer. One choice is theirs: for the first 30 seconds after any plug change the panel trusts the plug state, so a charger too weak for the load still reads "Charging" until the window ends. |
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>
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>
|
The merge (e55e739). #19046 added a One fix on top (6c539e8). Both reviewers found that the merge changed what #19046's reset does. It ran from What ran, on a disposable Omarchy worker VM serving 6c539e8:
Second opinion. Both reviewers found the grace-period problem above, and neither found anything else. Their second round on 6c539e8 was clean. They could read this review's context, so their agreement isn't guaranteed to be independent. Linked #12005. It is the same state, reached a different way: on an M2 MacBook Air, a stale USB-C source keeps Competing fixes. #17881 opened since the last review and also targets #13015. Like #12259, it trusts the battery state from the moment of plug-in. That means "On battery" for the first seconds after plugging into a working charger, and "Charging" after unplugging while the state lags. For you, if you want: the description's test plan still lists source checks for the settle window. #16334 removed those, and the six Next: this waits on the maintainer, who has one choice to make: for 30 seconds after any plug change, the panel trusts the plug state, so a charger too weak for the load reads "Charging" until the window ends. |
Summary
Fixes #13015.
UPower.onBattery == false) as "charging". When a charger can't cover the machine's draw, UPower reportson-battery: nowhile the battery reportsDischarging, and the panel showed a draining battery as Charging / Time to full with the bolt icon.Model.drawingFromBattery(device, onBattery, states, plugSettling): plug status still wins for 30 s after anyonBatterychange (the battery's state lags behind a plug/unplug, which the existing tests cover), then the battery's own state decides.dischargingandcharginginPanel.qmlare built from it; theonBatteryargument passed intobatteryIcon/modeLabel/chargeThresholdActiveis unchanged in meaning, so those stay as they are.Observed on a MacBook Pro 15" 2018 (T2) on a weak USB-C source:
Stock panel in that state: "Time to full 3h" (the value is actually time-to-empty from
omarchy-battery-status) and "Charging 19.1W".Test plan
bash test/shell.d/power-test.sh— newdrawingFromBatterycases (unplugged, settling after plug/unplug, settled draining on external power, charging, no battery) plus source checks for the settle window; the existing "external power is newer than stale discharging state" assertions still pass./test/all— only pre-existing failures that need anomarchy-pkgscheckout (config, snapper, unowned-system-paths), thelocatePython traceback, and the live-sessionruntime-smoketest; identical on a cleanquattrotree🤖 Generated with Claude Code
Fixes #12005