Repository navigation
fix(battery): clamp health in the bar tooltip to 100% - #4192
Merged
ItsLemmy merged 2 commits intoSep 1, 2026
Merged
Conversation
maciej-rosiek
force-pushed
the
fix/battery-tooltip-health-clamp
branch
from
September 1, 2026 11:25
662c581 to
0086c47
Compare
The bar tooltip printed the raw EnergyFull / EnergyFullDesign ratio, so a battery whose learned full-charge capacity is above its design capacity showed values like 103%. The control center Power tab clamped the same ratio, so the two views disagreed about the same battery. Move the calculation onto UPowerDeviceInfo as hasHealth() and healthPercent() so both views share one definition, and cover it with battery_health_test. Assisted-by: Opus 5 (1M context), claude-code v2.1.250
maciej-rosiek
force-pushed
the
fix/battery-tooltip-health-clamp
branch
from
September 1, 2026 11:30
0086c47 to
52e2518
Compare
Member
|
Thanks! |
10 of 22 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
UPowerDeviceInfoashasHealth()andhealthPercent(), clamped to[0, 100].battery_health_test, covering a worn battery, a battery reporting above its design capacity, and the missing-data guards.Motivation
BatteryWidget::syncState()printed the rawEnergyFull / EnergyFullDesignratio, whilePowerTab::syncBatteryHealth()clamped the same ratio. The two views therefore disagreed about the same battery.A battery whose learned full-charge capacity exceeds its design capacity reports health above 100%.
EnergyFullDesignis written once by the vendor;EnergyFullis re-learned by the fuel gauge and can be higher on a healthy pack.On a Framework 13:
At the same moment, the bar tooltip read
Health 103%and the Power tab readHealth 100%.docs/user/control-center/index.mdxdescribes the figure as "current full-charge capacity as a percentage of the original design capacity", so the clamped value is the documented one. Sharing one definition keeps the two views from drifting apart again.Type of Change
Related Issue
None.
Testing
just formatwith clang-format 22.1.8 — no diff.just build— clean, no new warnings.just test— 99 passed, 1 failed. The failure isnoctalia:process(completion-only async command stdout was wrong). It fails identically on unmodifiedmainon my NixOS host, so it is pre-existing and unrelated to this change.-warnings-as-errors=*on the four changed files — clean. I ran it on those files rather than throughjust lint, which hardcodes-j $(nproc).upower -i /org/freedesktop/UPower/devices/battery_BAT1.Manual Coverage
Screenshots / Videos
Checklist
CONTRIBUTING.md.just formatwith clang-format v22+ installed, or this PR has no code changes.docs/user/when this PR changes documented behavior or configuration, or this PR does not require documentation changes.assets/translations/en.json, or this PR adds no new user-facing strings.Additional Notes
Reuses the existing
power.battery.tooltip.healthstring, so there is no translation impact.I used Claude Code to write this change, and reviewed it myself. The commit carries an
Assisted-by:trailer.