Skip to content

Only show a held charge inside a real charge limit - #17616

Open
selfcrypto wants to merge 10 commits into
omacom:quattrofrom
selfcrypto:fix-power-holding-needs-real-limit
Open

selfcrypto wants to merge 10 commits into
omacom:quattrofrom
selfcrypto:fix-power-holding-needs-real-limit

Conversation

@selfcrypto

@selfcrypto selfcrypto commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

What changes

The power panel reports a held charge ("Threshold"/"Holding" and the plain battery icon) whenever the battery is in pending-charge, charging at ≤ 0.2 W, or estimates ≥ 8 h to full, without checking that the battery has a charge limit at all. That shows a fake hold right after plug-in (#14474), on hardware where no charge limit is applied (#10193), and on a failed battery at 0% (#7803).

This reads each laptop battery's real limit from the kernel (charge_control_{start,end}_threshold) and only reports a hold when the end is below 99% and the battery's own level has reached the start (or the end, when there is no start or it is 0). No charge-control files, or an end of 100 as applesmc reports on the MacBook from #10193 → never held. With several batteries, each is checked against its own limit, and the hold shows only when every battery is inside its limit or full. One gate in chargeThresholdActive() covers all three heuristics.

UPower's ChargeStartThreshold/ChargeEndThreshold can't be used for this: they report hwdb defaults (75/80) even with ChargeThresholdEnabled = false, and Quickshell doesn't expose ChargeThresholdEnabled. sysfs attributes don't emit inotify events, so the limits are re-read on every onBatteryChanged, battery state change and panel refresh.

Builds on #19046, which holds off the stalled-rate check for 90 s after plug-in. That covers the 0 W reading, but not the pending-charge step or batteries without a limit; this keeps its rateFresh argument and adds the limit check alongside it. Overlaps with #10196, which gates on omarchy-battery-status's threshold; that falls back to UPower's 75/80 defaults, so on a machine like this one it treats a limit as present when none is applied. Also overlaps #7915 (gates only pending-charge).

Verification

  • test/shell.d/power-test.sh: 42/42 pass. New cases: pending-charge and the unmeasured rate with no limit and below the limit start, no limit files, end-only limits and a start of 0, two batteries (both held, one still charging, one full, one without a limit), firmware stopping short of full, the charging icon right after plug-in. The active-charging case now passes a real limit so it still exercises the rate check. The new no-limit cases fail against the current Model.js.
  • All shell tests that don't need a live compositor: same results on this branch and on quattro (327 pass; 5 unrelated failures on both on this machine).
  • qmllint on Panel.qml: no new warnings beyond the existing unqualified Commons ones and objectAt() returning QObject (same pattern as the agents plugin).
  • On a ThinkPad T490 (single BAT0), Omarchy 4.5.0 with this branch's Model.js and Panel.qml installed, kernel limit 75/80, battery at ~26% (upower --monitor-detail):
Time Event UPower Bar
19:44:58.0 Plugged in pending-charge, 0 W; on-battery: no at 58.2 Charging icon immediately
19:44:59.0 charging, still 0 W Charging icon
19:45:08.6 40 W measured Charging icon
19:45:16.7 Unplugged on-battery: yes at 16.9 Plain icon immediately
19:45:20.5 Plugged in again pending-charge, on-battery: no Charging icon immediately

With 4.5.0's own panel (before #19046) the bar kept the plain icon until the 40 W reading, about 10 s; with #19046 alone it would still show it for the ~1 s of pending-charge. The shell log shows no errors from the power panel.

Screenshots

screenrecording-2026-11-18_20-09-48.mp4

@greptile-apps

greptile-apps Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5 · The PR appears safe to merge.RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge.

Summary

The power panel now shows a held charge only when real kernel limits support it.

  • The power panel shows a held charge only inside a real limit.

The latest change preserves the limitsRevision read. No new actionable issues were found, and the earlier findings are addressed.

Reviews (11) · Last reviewed commit: "Name the charge limit revision read so q..." · Reviewed by Greptile

Comment thread shell/plugins/panels/power/Model.js Resolved
Comment thread shell/plugins/panels/power/Panel.qml Resolved
Comment thread shell/plugins/panels/power/Model.js Resolved
@omarchybot

Copy link
Copy Markdown
Collaborator

I read the diff, the existing review comments, #14474, and the power-panel code on current quattro. My assessment is that this fixes a bug, but the configured classification model, deepseek-v4p1-flash, returned no usable classification, so the required two-model classification remains unsettled. The branch also conflicts with current quattro.

This was a source review by GPT-6 in Codex (reasoning effort not exposed); no second code review or worker tests ran. The separate reviewer availability check passed, but that did not classify or review this PR. It waits for classification to be resolved before verification can proceed.

@selfcrypto
selfcrypto force-pushed the fix-power-holding-needs-real-limit branch from ba7145d to 0211279 Compare November 18, 2026 18:22
Comment thread shell/plugins/panels/power/Panel.qml Resolved
@omarchybot

Copy link
Copy Markdown
Collaborator

I read head 7ebf2d6c14628b9fa71ae81963a6515fa0501aba against current quattro, including the power-panel callers, tests, #14474, and the existing review threads. The revised code uses the end limit when the start is missing or zero, reloads limits on power-source and display-device state changes and panel refresh, and checks each battery against its own level and limits.

My assessment remains bug, but the configured classification model, deepseek-v4p1-flash, returned no usable class for this head, so the required classification remains unsettled. This was a source review by GPT-6 in Codex (reasoning effort not exposed); no second code review or worker tests ran. The reviewer availability probe passed, but it did not classify or review this PR. Verification waits for classification to be resolved.

@selfcrypto

Copy link
Copy Markdown
Contributor Author

Tested on real hardware: ThinkPad T490 (single BAT0), Omarchy 4.5.0 with this branch's Model.js and Panel.qml (7ebf2d6) installed, kernel charge limit 75/80, battery at about 26%.

upower --monitor-detail during plug / unplug / plug:

Time Event UPower Bar
19:44:58.0 Plugged in pending-charge, 0 W; on-battery: no at 58.2 Charging icon immediately
19:44:59.0 charging, still 0 W Charging icon
19:45:08.6 40 W measured Charging icon
19:45:16.7 Unplugged on-battery: yes at 16.9 Plain icon immediately
19:45:20.5 Plugged in again pending-charge, on-battery: no Charging icon immediately

Before this change the bar kept the plain icon through the pending-charge step and the 0 W readings, about 10 s here (19:44:58 to 19:45:08). The shell log shows no errors from the power panel.

The power panel treated pending-charge and a near-zero charge rate as a
charge-limit hold even when the battery has no limit, so right after
plug-in it showed the plain icon and "Threshold" instead of charging.

Read the kernel's charge_control_{start,end}_threshold and only report a
hold when the end is below 99% and the level has reached the start (or
the end, when there is no start). Re-read the limits on power-source and
battery-state changes and on every panel refresh.
The combined UPower device averages all laptop batteries, so comparing
its level with the first battery's limits misjudges a hold on laptops
with two batteries. Read the limits of every laptop battery and report
a hold only when each one is inside its own limit or already full.
@selfcrypto
selfcrypto force-pushed the fix-power-holding-needs-real-limit branch from 7ebf2d6 to 9d8128b Compare November 18, 2026 19:21
@selfcrypto

selfcrypto commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor Author

@birkskyum since you merged #19046 in the same code: this builds on it rather than replacing it. #19046 covers the stale 0 W rate after plug-in; this adds the missing check that the battery has a charge limit at all, which also covers the pending-charge step and batteries without charge control (#14474, #10193, #7803).

It overlaps #10196, which reads the limit through omarchy-battery-status. That falls back to UPower's hwdb 75/80 defaults, which UPower reports even with ChargeThresholdEnabled = false, so it can't tell "no limit" from "limit at 80%". This one reads the kernel's charge_control_*_threshold per battery instead.

Tested on a ThinkPad T490; timeline and recording are in the description.

Update (Nov 22): the missing classification was a failure of the bot's second classifier that hit many PRs from Nov 18 and has since cleared. On the current head (5f249d3, quattro merged in, checks green) omarchybot agreed the bug classification and its worker tests passed. It now waits on a test of this exact head on the hardware from #14474 or #10193.

@greptile-apps

greptile-apps Bot commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

Want your agent to iterate on Greptile's feedback? Try greploops.

@omarchybot

Copy link
Copy Markdown
Collaborator

I read head b696eac78891720759fffa3d011f0ad54c8e4f21, the power-panel callers and tests, #14474, and the existing review threads. This head includes quattro at d54cde78f174761803e4caa96c38006a3461d0d2; its GitHub checks pass. The power-panel code is unchanged from the previously reviewed 7ebf2d6c1 revision.

My assessment remains bug, but deepseek-v4p1-flash again returned no usable classification for this head, so the required two-model classification remains unsettled. This was a source review by GPT-6 in Codex (reasoning effort not exposed). No second code review or worker tests ran; the reviewer availability probe passed, but it did not classify or review this PR. Verification waits for the classification blocker to be resolved.

@ancientastronauttheorist

ancientastronauttheorist commented Nov 21, 2026 •

Copy link
Copy Markdown

Tested on the machine #10193 was reported on, in the exact state that issue describes.

Machine: MacBookPro12,1 (Early 2015, pre-T2), Omarchy 4.5.0-3, stock linux-omarchy 7.2.15-1, UPower 1.91.5. On this kernel the in-tree applesmc now exposes charge_control_end_threshold = 100 and no start file. UPower meanwhile reports its hwdb 75/80 with charge-threshold-supported: yes. So this board takes the "end ≥ 99 → no limit" path in limitInBand, not the "no files" path described in the PR.

State: charged to 100%, unplugged for a few minutes, plugged back in. The SMC did not resume charging (normal Apple hysteresis):

upower:  state fully-charged, percentage 92.9963%, energy-rate 0 W
sysfs:   status Full, current_now 0, charge_control_end_threshold 100, ADP1 online 1

Real power panel, same state, screenshotted one after another. For the PR runs I stopped the installed shell and ran quickshell -n -p <checkout>/shell at b696eac:

installed shell (4.5.0) this PR this PR + #16685's omarchy-battery-status on PATH
mode THRESHOLD FULLY CHARGED FULLY CHARGED
detail rows Charge limit 75-80%, Battery state Holding Time to full -, Charging - same as this PR
icon plain battery charging charging

Installed power panel at 92% on AC: header reads THRESHOLD, rows show Charge limit 75-80% and Battery state Holding

Same moment with this PR's shell: header reads FULLY CHARGED, rows show Time to full and Charging, no charge limit

The plug-in case on this Mac. Below the SMC's resume point (plugged in at ~79%), charging does resume, and UPower reports charging at energy-rate: 0 W for about 8 s until its first rate sample. I logged UPower and screenshotted the installed panel once a second across a replug (19:01:56 CST):

frames UPower sysfs current installed panel bar icon
00–02 discharging (AC already online) 2.08 A → 65 mA AMASSING WATTS (charging) charging
03–12 (~8 s) charging, 0 W 65 mA → 2.02 A THRESHOLD plain battery
13–20 charging, 23.06 W 0.9–2.0 A AMASSING WATTS (charging) charging

Six frames of the installed power panel across a plug-in: frame 01 charging, frames 03, 06 and 10 THRESHOLD with Charge limit 75-80% and Holding while UPower reports 0 W, frames 13 and 16 charging at 23 W

The false "THRESHOLD" lasts exactly as long as UPower's 0 W charging window. This PR's gate covers this case too: with { end: 100 }, limitInBand returns false before the rate check is reached.

So this PR on its own clears the false hold in the panel on this Mac, both when the SMC holds the charge and right after plug-in. #16685 is not needed for the panel, though it still fixes the CLI line and time to full. test/shell.d/power-test.sh passes here.

This also confirms the concern about #10196 on this hardware: its gate reads omarchy-battery-status's threshold, which on quattro is 75-80% here, so on its own it would still show the false hold.

Measurements and screenshots were taken on my machine with Claude Code's help. Filed by Claude Opus 5.5 via Claude Code.

On a MacBookPro12,1 the kernel exposes charge_control_end_threshold = 100
with no start file while UPower reports its 75/80 defaults (omacom#10193). Cover
that shape: the SMC holding the charge below full, and the unmeasured rate
right after plug-in, must not read as a threshold.
@omarchybot

Copy link
Copy Markdown
Collaborator

I read head 4f8e520cb90d9a3b8cd88dc4ff33cf7071ad11ef, the power-panel callers and tests, the existing review threads, and the reports in #14474, #10193 and #7803. Since the last reviewed head, the power-panel implementation is unchanged; the added tests cover an end-only limit of 100, matching the new MacBook report. GitHub checks pass on this head.

My assessment remains bug, but the configured classifier, deepseek-v4p1-flash, again returned no usable class for this head. The required two-model classification remains unsettled, so verification stops at that gate. This was a source review by GPT-6 in Codex (reasoning effort not exposed); no second code review or worker tests ran. It waits for classification to be resolved before verification can proceed.

@omarchybot omarchybot added the bug Something isn't working label Nov 22, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed head 5f249d327752e01013ca6ca7c2240e5f102726d5 after the merge of current quattro. Classification is now agreed as bug. On a fresh disposable Omarchy worker linked to this head, ./test/cli, power-test.sh (45 assertions), power-no-battery-test.sh, battery-status-test.sh and battery-test.sh all passed. My separate six-case model probe catches four false holds on base, passes on this head, and catches them again with Model.js reverted. Those are synthetic inputs: the worker has no laptop battery, so this does not establish the hardware behaviour or provide before/after captures of it.

GPT-6 in Codex (reasoning effort not exposed) reviewed the code. Opus 5.5 High and muse-wonder via pi (thinking high) reviewed this head too and found no confirmed, contained defect to patch. They agreed with the source comparison; independence is not guaranteed. #7915 still leaves the non-PendingCharge hold paths ungated, and #10196 accepts a threshold string even when it comes from UPower defaults. #14141 addresses the separate long-estimate case, which this PR leaves unchanged. The CLI part of #7803 is also unchanged here.

The reviewers also identified a coverage boundary for the maintainer: the new gate recognises numeric charge_control_*_threshold files only. Linux also documents an IdeaPad conservation-mode interface, now exposed by its driver through charge_types; this panel does not read those interfaces. I checked that boundary in the code and kernel sources, but did not test an IdeaPad. Supporting those modes or choosing a neutral “not charging” display needs a defined behaviour rather than restoring the unconditional hold inference.

@sarniva or @gabamnml, please test the full head 5f249d327752e01013ca6ca7c2240e5f102726d5 on the hardware from #14474 or #10193. To run that revision from a separate checkout:

git clone --single-branch --branch fix-power-holding-needs-real-limit https://github.com/selfcrypto/omarchy.git ~/omarchy-pr-17616
git -C ~/omarchy-pr-17616 checkout --detach 5f249d327752e01013ca6ca7c2240e5f102726d5
omarchy dev link ~/omarchy-pr-17616

Reboot when prompted. Compare the same plug-in or firmware-held state on quattro at 1c0d9b557b22ebde85d58ef28af5cd9fdd6c83c3 and this head (switch the checkout with git checkout --detach <SHA> and reboot between them), and report the bar/panel result, upower -i readings, kernel thresholds and any charge_types value. Include the full SHA in your confirmation. omarchy dev unlink followed by a reboot restores the packaged tree. The earlier hardware reports cover other revisions; exact-head confirmation from an original reporter or a maintainer is still needed. This is waiting on that confirmation, with the firmware-interface coverage boundary left for maintainer review. No verified or ready label was added.

@selfcrypto

selfcrypto commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor Author

Merged current quattro (33c2f660f) into the branch. New head: 9f1cc05806e21fd87cccd1e89efbb6b6856e9c4a.

#20379 added a limitState argument to chargeThresholdActive, batteryIcon and modeLabel, in the position where this PR passed limits. They now take limitState, limits and keep both checks. refresh() is the one from quattro plus reloadLimits().

In power-test.sh the #20379 assertions about a limit that is on, off or topping up now pass a 75-80 band, so they still reach the limitState line. No assertion was removed.

The gate is still needed after #20379: the pending-charge and fully-charged-below-99 branches return a hold before limitState is read. With the gate removed, "power does not flag pending charge as threshold without a limit" fails.

power-test.sh (67 assertions), power-present-test.sh, battery-status-test.sh, battery-test.sh and battery-present-test.sh pass locally. CI fails only on lock-appear-budget-test.sh ("lock preview appears and hides cleanly"), which this PR does not touch and which fails the same way on #12585. I can't rerun the job.

@sarniva @gabamnml the head to test is now 9f1cc05806e21fd87cccd1e89efbb6b6856e9c4a. The steps above are the same with that SHA.

Update: omarchybot pushed 8588bbd575bb53f1c4542b08d76d3b16b69b86f6 on top of this merge. Test that head.

The battery service signals after a charge-limit command applies the new setting. When the panel is closed, re-read the kernel limits as well as the battery details so the bar can update even if UPower leaves the battery in the same state.

Co-Authored-By: GPT-6.2 Sol High <noreply@openai.com>
Co-Authored-By: Opus 5.5 High <noreply@anthropic.com>
@omarchybot

Copy link
Copy Markdown
Collaborator

I pushed 8588bbd575bb53f1c4542b08d76d3b16b69b86f6 so the bar reloads the kernel charge limits when a charge-limit command finishes with the panel closed. GPT-6.2 Sol High in Codex traced the notification path. Opus 5.5 High found the missed refresh and reviewed the patch with no further findings. muse-wonder via pi, thinking high, also identified the missed refresh. The reviewers may have seen this session’s reasoning.

On a disposable Omarchy worker, the CLI and five focused power and battery test files passed on the pushed commit. A probe of the panel's signal handler left the cached end threshold at 100% on the previous head and updated it to 80% with the patch. The earlier model probe also reproduced the false holds on the base and passed with the PR's limit check. The worker had no laptop battery.

GitHub's exclusive job passed. The noncomp-1 job failed in the agent-account cancellation test when its mock login PID file was missing. That test and the agent-account code are unchanged by this PR. The test passed all 47 assertions on a worker using the exact merge GitHub tested. GitHub Actions failure

Could the original reporter for #14474 or #10193, or a maintainer with the affected hardware, test 8588bbd575bb53f1c4542b08d76d3b16b69b86f6? Follow the checkout steps in the earlier comment with this SHA and compare against quattro at 33c2f660f93f12d45b147658ccea6a678038a738. Please report what the bar and panel show after plugging in AC or when the MacBook firmware stops charging below 100%. Install and rollback steps

@selfcrypto

Copy link
Copy Markdown
Contributor Author

Merged current quattro (885482ad0) into the branch. New head: 6cf27fe9f.

The one conflict was in shell/plugins/panels/power/Panel.qml, where #20881 renamed glyphPaintedWidth to paintedContentWidth beside this PR's limit readers. Both are kept. The second commit names the limitsRevision read so the panel passes the qmllint check from #20549.

power-test.sh, the battery tests, qmllint-test.sh and ./test/cli pass locally, and CI is green on this head.

The hardware-test request above still stands, now for 6cf27fe9f: the steps are the same with that SHA.

@omarchybot

Copy link
Copy Markdown
Collaborator

I checked 6cf27fe9ffee600d4ec50890f5e09bfcd7e3c8d7 against current quattro. On a disposable Omarchy worker linked to this head, the CLI suite, the focused power and battery tests, QML lint, and the charge-limit refresh probe passed. The model probe showed five false holds on quattro, passed all eight cases at this head, and showed the same false holds when the new limit check was removed. GitHub CI passed, including the job that failed on the previous head. GitHub Actions

GPT-6.2 Sol High in Codex traced the limit check and refresh paths. Opus 5.5 High and muse-wonder via pi, thinking high, agreed on the fix for numeric limits and may have seen this session’s reasoning. Opus flagged that a firmware-only conservation mode can now lose a genuine “Holding” indication. Muse-wonder agreed on the behavior and treated it as a display choice. The enabled flag alone cannot establish that a battery has reached its cap, so using it as a fallback could restore false holds below the cap.

The per-battery check covers more false holds than the approaches in #7915, #9763, and #10196. It also rejects persistent false holds after the debounce windows used in #16855 and #17380. #14141 covers the separate case of a long estimate while the battery really is charging inside its limit.

The worker has no laptop battery. @sarniva or @gabamnml, please use the linked install and rollback steps with the full SHA 6cf27fe9ffee600d4ec50890f5e09bfcd7e3c8d7 in the checkout command. Compare with quattro at 80d88d53c86af26582562923fc387c9be05fe257. Please include that full PR SHA, the laptop model, and what the bar and panel show right after plugging in or when the MacBook stops charging below 100%. Install and rollback steps

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.

3 participants