Skip to content

Require a real charge threshold before reporting a held charge - #10196

Open
gabamnml wants to merge 5 commits into
omacom:quattrofrom
gabamnml:power-panel-require-real-charge-threshold
Open

gabamnml wants to merge 5 commits into
omacom:quattrofrom
gabamnml:power-panel-require-real-charge-threshold

Conversation

@gabamnml

@gabamnml gabamnml commented Sep 4, 2026 •

Copy link
Copy Markdown

Fixes #10193.

The problem

Model.chargeThresholdActive() mirrors the three states omarchy-battery-status uses to decide a charge is being held, but not its outer guard. The script requires a threshold to actually exist:

if [[ $ac_online == "true" && -n $threshold_end ]]; then

and omits the threshold field entirely when the battery exposes no charge_control_* attribute. Model.js only checked that we are on AC, so state === FullyCharged && fraction < 0.99 was enough to claim a limit.

Firmware that merely stops topping the pack up then reads as a charge limit the machine has no way to set. Apple's SMC does exactly this — it will not recharge until the pack falls to roughly 93–95%, the behaviour macOS surfaces as "Battery is charged". On a MacBookPro12,1 with no charge_control_* sysfs at all, the panel claimed a limit while the CLI correctly reported fully-charged.

The change

Thread the threshold through chargeThresholdActive(), batteryIcon() and modeLabel(), and bail out when it is empty — the same condition the shell script already applies. Panel.qml derives it from batteryInfo.threshold, which is exactly the field the script omits when there is no threshold, so the two implementations now agree by construction.

The charge-limit row's || "-" fallback goes away with it: chargeThresholdActive now implies a non-empty threshold, so the row can no longer render a label with no value.

Machines that genuinely have a threshold are unaffected — they report one, so the guard passes.

Verified

Automated:

  • test/shell.d/power-test.sh extended with the no-charge-control case, its positive counterpart, and modeLabel coverage for both. Existing threshold assertions now pass a threshold, which is what the hardware they model would report.
  • Two assertions against Panel.qml source pin the wiring: the chargeThreshold property must exist, and no threshold-aware Model.* call may end at upowerStates(). Both fail against the pre-fix file, so the guard cannot be silently orphaned again.
  • ./test/all: the shell and CLI suites pass. Three files fail identically before and after this change on a clean checkout (config-test, snapper-test, unowned-system-paths-test) — all three need a sibling omarchy-pkgs checkout that isn't present here.
  • qmllint on Panel.qml: no syntax errors, and no warnings beyond the import-resolution noise the unmodified file already produces.

Visually, on the MacBookPro12,1 that reproduces this, with the patched files overlaid on the package install and the shell restarted:

Before After
Hero label THRESHOLD FULLY CHARGED
Left row Charge limit / - Time to full / -
Right row Battery state / Holding Charging / -
Icon plain battery charged battery

Layout, spacing and the power-profile row are unchanged. A before/after capture is attached below.

omarchy-pr-charge-threshold

The power panel's chargeThresholdActive() mirrors the three states
omarchy-battery-status uses, but not its outer guard: the script only
treats a charge as held when the battery actually reports a threshold,
and omits the field entirely when no charge_control_* attribute exists.

Without that guard, firmware that merely stops topping the pack up reads
as a limit the machine has no way to set. Apple's SMC does exactly this,
so a MacBookPro12,1 on AC at 94% showed "Charge limit -" / "Battery
state Holding" and a "THRESHOLD" hero label, while the CLI correctly
reported fully-charged.

Thread the threshold through chargeThresholdActive(), batteryIcon() and
modeLabel(), and drop the charge-limit row's now-unreachable "-"
fallback.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BYs2Jy3APLhJpQxeC5qLrx
omarchybot and others added 2 commits October 2, 2026 05:39
The bar icon now asks for the threshold too, but batteryInfo was only filled when the panel opened. Until then a machine that does hold at a limit read as having none, so a pack parked at 80% on pending-charge showed the charging icon in the bar.

Load it when the bar comes up and when a battery appears, and retry every 30 seconds while closed until one lookup lands, since an empty answer is discarded and would otherwise wait for the panel to open.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Codex Medium <noreply@openai.com>
The existing assertion only rejects one spelling of the old call, so dropping the argument with a space before the paren still passed. Check each of the three calls passes root.chargeThreshold.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Codex Medium <noreply@openai.com>
@omarchybot omarchybot added the verified Omarchy Triage has verified that this issue is ready for final review label Oct 2, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed at f230612, run on a disposable Omarchy worker VM. Reviewed by Claude Opus 5.5 and, as a second opinion, Codex Medium over two rounds; the second round found nothing open.

The reported bug is real and this fixes it. With the inputs from #10193 (on AC, FullyCharged at 94.7%, no threshold reported), Model.chargeThresholdActive() returns true and modeLabel() returns Threshold on quattro; on this branch it returns false, and fails again with Model.js reverted. The same state with a 95% threshold still reads as a hold, so machines that really do limit charging are unaffected in the model. The Apple SMC behaviour itself rests on the report; what the panel does with that UPower state does not need the hardware to show.

One regression, fixed on your branch. The bar icon now takes the threshold too, but batteryInfo was only filled when the panel opened. Until then, a machine that does hold at a limit (a ThinkPad parked at 80% on pending-charge, say) read as having no threshold and showed the charging icon in the bar after every login. Two commits pushed:

  • e25591f loads battery status when the bar comes up and when a battery appears, and retries every 30 seconds while the panel is closed until one lookup lands, since an empty answer is discarded. Codex raised the retry.
  • f230612 checks that each of the three Model calls passes root.chargeThreshold. The existing assertion only rejected one spelling of the old call, so dropping the argument with a space before the paren still passed.

Each new assertion was checked by breaking the code it covers and watching it fail.

Tests. ./test/cli passes. test/shell.d/power-test.sh passes, 36 assertions, also with the branch merged onto current quattro. The full shell suite has two failures, ascii-test.sh and branding-about-animation-test.sh, which fail the same way on quattro itself; they are not from this change, but they keep the suite from being green. The changed panel loads in a live Quickshell on the worker without errors. No CI ran on this pull request.

Related. #7915 also adds a fourth argument to chargeThresholdActive (a {start, end} object, for #7803's dead-pack pending-charge case) and already loads battery status while the panel is closed. It does not fix this bug, since it leaves the FullyCharged branch ungated, but the two will conflict and whichever lands second needs reworking onto the other.

Waiting on the maintainer.

@greptile-apps

greptile-apps Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 4/5

[Low impact] The changes affect battery status shown in the power panel and bar.

The PR needs changes before merging: idle batteries still appear to be charging, and the retry must meet the shared-polling requirement.

Findings

  1. P1 Idle battery appears charging ▶
  2. P2 Each monitor repeats failed lookups ▶

Summary

The PR requires a reported charge threshold before showing a held charge.

  • The power panel reports a held charge only when a threshold exists.

Reviews (2) · Last reviewed commit: "Merge branch 'quattro' into power-panel-..." · Reviewed by Greptile

// firmware that merely stops topping the pack up: Apple's SMC parks at
// FullyCharged around 94% by design, and that read as a limit the machine
// has no way to set.
if (!threshold) return false

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.

P1 Idle battery appears charging

When a battery has no charge-control threshold, this guard correctly rules out a held charge, but the panel then treats AC-connected states below 100% as actively charging. A battery reported as FullyCharged at 94% gets a “Charging” stats row beneath a “Fully charged” heading. A PendingCharge battery gets charging phrases, a charging icon, and a pulsing bar even though it is not charging. These idle states need a display path distinct from threshold holding and active charging.

Knowledge Base Used: Hardware, devices, and power


Timer { interval: 5000; running: root.opened; repeat: true; onTriggered: root.refresh() }
// A startup lookup that came back empty would leave the bar without the threshold until the panel opens.
Timer { interval: 30000; running: root.batteryPresent && !root.opened && root.batteryInfo.percentage === undefined; repeat: true; onTriggered: root.refreshBattery() }

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.

P2 Threshold display can stay stale

The new retry stops once battery status returns a percentage, even if that result omits the threshold. It also does not refresh after a charge limit changes while the panel stays closed. Because the bar icon now uses the cached threshold, it can keep showing the wrong charging or holding indication until the panel is opened. Refresh the threshold-dependent bar state independently of whether a percentage has arrived.

Knowledge Base Used: Shell UI and desktop interactions

quattro translated the power panel, giving modeLabel a fourth argument for the translator. The threshold goes before it, so modeLabel takes (device, onBattery, states, threshold, tr), and the charge-limit row shows the threshold through the panel's localized reading. The wiring assertion accepts the call with the translator after the threshold.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@omarchybot omarchybot added the verified Omarchy Triage has verified that this issue is ready for final review label Oct 14, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

This had stopped merging cleanly after quattro translated the power panel (#15326), so I merged quattro into your branch as 6aee12a. The two conflicted on the same lines: modeLabel gained a translator argument, so it now takes (device, onBattery, states, threshold, tr), and the charge-limit row shows the threshold through the panel's localized reading(). The wiring test accepts the threshold followed by the translator. Nothing else in your change moved. Reviewed by Claude Opus 5.5, and by Codex Medium as a second opinion. Codex found nothing open and agreed the merge passes every argument in the right place. Independence is not guaranteed, because it can read this session's notes.

Still fixes #10193 on current quattro. I ran this on a disposable Omarchy worker VM, with the shell linked to this branch. With the report's inputs (on AC, FullyCharged at 94.7%, no threshold), chargeThresholdActive() returns true and modeLabel() returns Threshold on quattro 84cfb93. On 6aee12a they return false and Charging, and with Model.js reverted they fail again. With a 95% threshold the battery reads as held on all three. The panel loads in the live shell without errors.

Tests. ./test/cli passes, and so does test/shell.d/power-test.sh (40 assertions). The full shell suite has five failing files: ascii-test.sh, background-instant-reload-test.sh, background-intro-clone-test.sh, branding-about-animation-test.sh and hyprland-startup-cursor-cold-test.sh. They fail the same way on quattro itself, so this change didn't cause them, but they still keep the suite from being green. background-intro-lifecycle-test.sh failed once and then passed three times in a row. It is a standalone fixture that never loads the power panel. No CI ran on this pull request.

Greptile's two comments. Neither is a defect this change introduces.

  • A battery at FullyCharged below 100% with no threshold now gets the "Fully charged" heading. The "Charging / -" row under it is how quattro already labels every full battery on AC.
  • A pending-charge battery with no threshold now falls back to the charging presentation instead of "Holding". That presentation is imperfect, but the old one was wrong for this hardware. Telling idle apart from charging is Treat pending-charge as a hold only inside a real charge limit #7915's ground.
  • The closed-panel retry stops once a lookup lands, and that's correct: a missing threshold field means the hardware has none, so polling for one would never end. Changing the limit's value while the panel is closed doesn't change whether a threshold exists, and opening the panel refreshes it.

Related. #7915 (for #7803) also threads limits through chargeThresholdActive and conflicts with this branch. It leaves the FullyCharged branch ungated, so it doesn't fix #10193. Whichever lands second needs to be reworked onto the other.

Waiting on the maintainer.

Comment thread shell/plugins/panels/power/Panel.qml Resolved
@omarchybot omarchybot removed the verified Omarchy Triage has verified that this issue is ready for final review label Oct 29, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Re-reviewed at 0ad3859, your merge of quattro into the branch. The merge applied without any hand resolution, and the fix itself is unchanged: Model.chargeThresholdActive() still returns false when no threshold is reported, and Panel.qml still loads the battery status at startup. The two Panel.qml source-text assertions are gone because quattro removed every test that only reads source text (#16334), not because of anything in this branch. Nothing was run on a worker this time, for the reason below.

A competing fix. #9763 was opened two days before this one, and it fixes #10193's case the same way. Its chargeHoldBand() returns no band when no threshold is reported, and chargeThresholdActive() then returns false before it reaches the FullyCharged branch. It also treats a 100% end threshold as no limit, and labels a battery FullyCharged below 100% as "Fully charged" instead of "Charging". Like this branch, it loads battery status at startup, so the bar icon is right before the panel is first opened. I found nothing in it that this one handles better. When two fixes are this similar, the older one takes precedence, so #9763 is the one to carry forward. Your 94.7% FullyCharged assertions, with and without a threshold, are the one thing this branch adds for the bug, and they are marked to be folded into #9763 with credit to you. #9763 also bundles a redesigned bar icon and power-profile modifiers, and it currently conflicts with quattro. #7915 also gates on a charge limit, but only for PendingCharge, so it does not fix #10193.

Codex Medium and muse-wonder (pi, thinking high) each compared the three pull requests from their diffs, and both reached the same conclusion: #9763 fixes the bug, #10196 fixes it too, and #7915 does not. They had no concrete defect in #9763 that would let the newer fix take precedence. Both may have read this session's notes, so their agreement is not independent. The one point they added was the 100% end threshold handling above, which I then checked against #9763's diff.

Choosing between #9763 and this pull request is the maintainer's call. Waiting on the maintainer.

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

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Power panel invents a "Charge limit / Holding" state on hardware with no charge-control support

2 participants