Repository navigation
Count the battery's time to full to the charge limit sysfs enforces - #16685
ThatRetiredDude wants to merge 2 commits into
Conversation
Confidence Score: 5/5
[Medium impact] The PR appears safe to merge; no new actionable issues were found. SummaryMakes the reported charge limit and time to full follow the selected battery’s sysfs settings.
Both earlier, unnumbered findings are addressed: known-unlimited batteries skip the fallback, and tests cover UPower-only limits with the feature on and off. Reviews (6) · Last reviewed commit: "Handle unreadable sysfs reads and avoid ..." · Reviewed by Greptile |
|
updated. Both findings are addressed in 8689541: Unlimited batteries inheriting another limit (P1): a battery that reports its own threshold, or reports having none, no longer falls back to the BAT* scan. Only a battery that says nothing about its limit borrows one. Added a regression test with an unlimited BAT1 next to a BAT0 limited to 60%, and it fails on the previous commit. test/shell.d/battery-status-test.sh passes. |
|
This fixes the cause: the script now takes the battery's own sysfs limit over UPower's hwdb 75/80, trusts UPower's pair only when it says the limit is on, and treats an end of 0 or 100 as no limit. I pushed one commit on top, ending at 053864c. On a ThinkPad with only an end limit, sysfs reads 0/80, and with sysfs now winning that showed "Holding at 0-80%". A start of 0 now counts as no start, so it shows "Holding at 80%". The commit also makes the disabled-UPower test delete the What was checked. Everything ran on a disposable Omarchy worker with UPower 1.91.5, testing this branch both as it is and merged onto current
Codex Medium and muse-wonder (pi, thinking high) reviewed it. Before the push, I asked both, without giving them my answer, to compare this branch with #9612, #17138 and #17202. Both picked this one:
Neither reviewer found anything in the others worth folding in here. Their second round, on this head, found nothing. Independence is not guaranteed, since both read the same workspace. Still open, none of it for this branch. The power panel's This is verified and waits on the maintainer: choosing among the four competing pull requests is their call. |
|
Reviewed P2 — Custom configuration is not always the active Dell limit. At The reporting logic needs to establish mode applicability for drivers whose numeric thresholds only apply in Custom mode, and the “sysfs enforces” claim needs to match that distinction. A blanket rule that Standard disables thresholds for every vendor would be wrong. I have not pushed a speculative cross-vendor guard: the available DX13260's mode and threshold reads fail, so it cannot validate a functioning Dell mode transition. The author and maintainer need to settle that guard and confirm it on a Dell whose interface works, with Custom and Standard/Adaptive coverage in the existing battery-status test. The #17137 fix itself holds: replaying its UPower metadata against the DX13260's actual ENXIO threshold files makes the base print 75–80% and this head omit it. That remains reporting proof, not working firmware charge control. For failed sysfs reads with an enabled UPower flag, restoring the cached pair is not a demonstrated fix: it can also restore an unverified limit. Whether a real ceiling remains active during such a failure needs hardware evidence, so I have left that precedence policy unchanged. The other findings are pre-existing: the BAT* fallback can borrow another pack's limit when the selected battery has no data, and the panel's Model.js can infer Holding independently of the script's threshold. Neither is introduced by this PR. The UPower-only enabled/disabled coverage mentioned in the inline bot comment is already present at lines 169–183; no duplicate test is needed. Battery-status, power-model, system-power and CLI checks passed at this unchanged head and its clean integration onto 🤖 Generated by GPT-6.1 Sol High in T3 Code through the Codex harness. Reviewed by Codex XHigh (GPT-6.1 Sol). |
|
Thanks @spencerbull, good catch on Dell. Pushed a fix: when the battery exposes Agreed that #17137 is reporting only. This PR doesn't try to fix the firmware refusing the write. |
|
Re-reviewed On a disposable Omarchy worker, thirteen reporting cases passed on the submitted head and its clean integration with The captures show the actual power panel opened through its normal IPC, using controlled UPower and sysfs inputs: 40%, 20Wh stored, 50Wh full, 20W charging, Dell Standard selected, stored Custom thresholds 50/90 and cached UPower thresholds 75/80. The base displays 1h; this head displays 1h 30m. Custom mode separately displayed 1h 15m. This verifies reporting; it does not verify a physical charge cutoff or repair #17137's firmware refusal. Codex High (GPT-6) performed this review and found no additional defect to change. The configured Opus 5.5 High review terminated without returning a report, although its availability probe answered. There is no completed second opinion on this head, so |
|
Ran the branch against a real limit on a pre-T2 Mac, because this board is an edge case the tests don't cover: Two things that checks: a One caveat about what this machine can and cannot show: UPower on this board reports Worth noting for the same reasons: this unit is why the |
|
Rechecked unchanged head The branch integrates cleanly with Codex High (GPT-6) performed this pass and found no additional defect to change. The configured Opus 5.5 High returned a weekly usage-limit message instead of a second review; its availability probe also failed. The panel's muse-wonder availability probe answered, but the panel cannot replace the required primary reviewer. There is still no completed second opinion on this head, so |
|
Physical-hardware confirmation of the "sysfs 100 + UPower 75/80" case, on a stock kernel (no DKMS Machine: MacBookPro12,1 (13-inch, Early 2015, pre-T2), Omarchy 4.5.0-3, Live, on battery, same moment:
Then on AC, charging at 68% (UPower:
At 35.4 W, Above 80% the time disappears entirely. On a later replug at ~79%, UPower's reading jumped to 82% within seconds. The installed panel, which reads The estimates in both versions are jumpy on this Mac (29m to 2h 12m within seconds at 78%). That is because the script prefers the instantaneous sysfs
The #10193 case, live. I charged to 100%, unplugged for about 7 minutes, and plugged back in at about 91–93% (UPower's reading moved around in that range). The SMC did not resume charging, which is normal Apple hysteresis:
So on this Mac, Measurements were taken on my machine with Claude Code's help. Filed by Claude Opus 5.5 via Claude Code. |
|
Rechecked Twenty reporting cases pass on the submitted head and that integration. The new Mac inputs reproduce the base's missing time estimate above 80% and false “holding” state during fully-charged hysteresis; this head reports the remaining charge time and preserves Codex High (GPT-6), Opus 5.5 High and muse-wonder via pi (thinking high) reviewed this pass and found no actionable defect. Both additional reviewers completed their reviews this time. Their agreement is based on shared source and supplied evidence, so independence is not guaranteed. Comparison with #9612 and #17202 still finds their unrestricted/disabled-UPower and source-mixing cases unresolved; neither contributes an improvement missing here. Both old Greptile findings have been answered with the commits that fixed them. This addresses #17137's phantom reporting; firmware charge control and the panel's separate holding inference remain separate work.
|
Ignore Dell charge_control thresholds when charge_types is outside Custom mode, require UPower's charge-threshold-enabled to be explicitly yes when falling back without sysfs (since UPower 1.91+ omits the line when disabled), keep batteries with their own limit/no-limit from borrowing another BAT* limit, and omit a start threshold of 0.
3a43d46 to
67c9976
Compare
|
Codex (GPT-6.2 Sol, high effort) and Opus 5.5 High and muse-wonder via pi, thinking high reviewed the rebased head Two cases from the source review still need runtime checks. An existing sysfs attribute that fails to read can hide an enabled UPower limit, and the fallback to another battery can show that battery’s threshold while calculating the selected battery’s time to 100%. Please update the description for the current base and reference #17137 without closing it. Suppressing its phantom threshold addresses the reporting symptom, and the panel can still offer the control that the firmware rejects. The worker isolation check failed, so the current head still needs runtime and panel verification. GitHub is waiting for approval to run Tests and Check translation structure. |
…hreshold Fall back to an explicitly enabled UPower limit when an existing sysfs threshold attribute fails to read (while still suppressing omitted/disabled UPower defaults), and restrict the BAT* fallback to unresolved battery paths so a selected battery never displays another battery's threshold while timing to 100%.
|
Recommend: Hold — the current head needs worker verification and maintainer approval for the two CI workflows. At GPT-6 High in Codex, Opus 5.5 High and muse-wonder via pi, thinking high checked the source and fixtures. The reviewers shared the source and brief, which limits independence. The worker isolation check blocked runtime and panel verification. Tests and Check translation structure are awaiting approval. |


Current
quattroalready prefers numeric sysfs thresholds over UPower's hwdb defaults (since #20379), but several threshold-selection bugs remain when Dell exposes storedCustomsettings outside Custom mode, when UPower 1.91+ omitscharge-threshold-enabledfor disabled limits, or when a dual-battery system falls back to another battery'sBAT*threshold.Fixes #16653. Addresses the threshold half of #7374 and the phantom threshold reporting in #17137 (firmware charge control and panel toggle availability remain separate).
Problem
Customnumbers incharge_control_{start,end}_thresholdwhilecharge_typeshasStandard,Adaptive, or another mode active, causingomarchy-battery-statusto display an inactive limit and shorten "Time to full".ENXIO/ENODEV),quattrochecksupower_threshold_enabled != "no". UPower 1.91+ omitscharge-threshold-enabledentirely when disabled, so emptyupower_threshold_enabledstill matches and lets the hwdb75-80%defaults leak through.BAT*glob when the selected battery has its own sysfs directory can display another battery's threshold while computing the selected battery's time to 100%, andupower_threshold_startof0wasn't stripped on the UPower fallback path.Change
quattro'sread_sysfs_numberhelper andupower_threshold_*/limit_*metadata intact.charge_control_*_thresholdvalues whencharge_typeslistsCustomand another mode is active ([Custom]is not selected).upower_threshold_enabled == "yes"before falling back to UPower's thresholds, and fall back when sysfs has no readable numeric value (whether the file is missing or fails to read) so a failed sysfs read doesn't hide an explicitly enabled UPower limit while still suppressing disabled/omitted UPower defaults.end <= 0or>= 100,start <= 0or>= end) consistently across sysfs, UPower, andBAT*fallback.BAT*fallback to cases where UPower did not resolve an existing sysfs battery directory (-z $native_path || ! -d $battery_path) and computecharge_limitafterward sothresholdandtimealways agree.Tests
Extended
test/shell.d/battery-status-test.shto cover:75-80%default.charge_typesignoring thresholds inStandardmode and reporting them inCustommode.0start threshold and treating an end threshold of100as no limit.100) neither shortening its time to full nor borrowing another battery'sBAT*threshold.The change was written with AI models under my direction. I reviewed it myself, and the battery-status tests pass with the change.