Skip to content

Wait for a battery event after a failed charge-limit write - #20879

Open
Cynnamoroll wants to merge 2 commits into
omacom:quattrofrom
Cynnamoroll:contributions/power-wave3-5e635d50
Open

Cynnamoroll wants to merge 2 commits into
omacom:quattrofrom
Cynnamoroll:contributions/power-wave3-5e635d50

Conversation

@Cynnamoroll

Copy link
Copy Markdown
Contributor

What changes

When a “100% once” charge finishes, the battery service asks UPower to restore the charge limit. If UPower rejects the write, the request stays pending. The process-exit callback used to recheck the same full battery reading and immediately start the command again, with no new battery event.

Now exit only refreshes the saved state. A later battery event or explicit refresh can still retry, and a successful write still clears the pending request. This follows up on #20379; it does not claim to fix a hardware issue.

Verification

  • Ran the same fixture against the base and patch in a disposable Arch root. It uses Quickshell 0.3.2, the actual battery service and omarchy-battery-limit, and a private D-Bus that supplies UPower readings and controls whether writes succeed. The base sent 83 threshold-write calls in 1.2 seconds. The patch sent one, kept the marker, made no call on a subsequent below-full reading, then made exactly one successful retry and removed the marker when the battery returned to 100%.
  • All 24 checks in bash test/shell.d/battery-test.sh passed, including the private-bus regression. power-test.sh, powerprofiles-set-test.sh (nine checks in Arch), and git diff --check also passed. The profile suite fails identically on the Ubuntu host and unchanged base before the first assertion; the Arch run is the platform check.
  • Quickshell warned that it was built for Qt 6.12.0 while the scratch root ran 6.12.1. It loaded the configuration and exercised both paths without crashing. No physical charger, battery firmware, laptop, or graphical desktop was tested.

Screenshots

No visible change: the battery panel's controls and presentation are unchanged; the fix prevents repeat hardware calls after a write fails.

A rejected hardware write leaves the one-time top-up marker in place.
Refresh the state when the process exits without rechecking the same
charge reading. A new battery event can still restore the limit.

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
@greptile-apps

greptile-apps Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5 · The PR appears safe to merge, with the previous test-timing issue fixed.RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge, with the previous test-timing issue fixed.

Summary

Stops failed charge-limit writes from immediately retrying against the same battery reading.

  • Battery charge-limit failures wait for another battery event before retrying.

The previous test-timing finding is fixed. No new actionable issues were found. This review checked the code; tests were not run.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Battery event or explicit refresh] --> B{Top-up finished?}
  B -->|Yes| C[Try restoring charge limit]
  C --> D[Command exits]
  D --> E[Refresh saved state]
  E --> F[Wait for another event or refresh]
Loading

Reviews (2) · Last reviewed commit: "Wait for charge-limit events in the regr..." · Reviewed by Greptile

Wait for Quickshell to handle the failed write before watching for a
retry, and wait for the successful write to clear the marker. Bound both
waits so slow startup or D-Bus calls do not fail a working implementation.

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
@chessing234

Copy link
Copy Markdown
Contributor

both of your commits are in #21013. the charge-limit retry waits for a battery event, and that test section stayed next to the warning and charger checks. the Quickshell fixture did not run on this machine. @dhh @omarchybot if 21013 lands, this can close as superseded.

@omarchybot omarchybot added the bug Something isn't working label Dec 2, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Codex High and Opus 5.5 High traced the retry in Quickshell and found no blocking code defect. Muse Wonder High questioned whether the running guard prevented the old retry. I checked the packaged Quickshell revision and confirmed it clears the running flag before emitting the exit signal, so the old callback could start another write with the top-up marker still present. The fix leaves the request pending for another battery event or an explicit refresh. Review independence is not guaranteed.

The comparison found the same fix and regression fixture in the broader #21013 bundle. Worker reproduction and the suite are still pending after a worker preflight failure. The GitHub Tests workflow is waiting for maintainer approval. Tests workflow

@chessing234

Copy link
Copy Markdown
Contributor

thanks. a rejected charge-limit restore still waits for a later battery event instead of retrying the same full reading, in #21226. Please close this PR as superseded by #21226.

@omarchybot

Copy link
Copy Markdown
Collaborator

Codex High and Opus 5.5 High compared the source and agreed that #21226 includes the same charge-limit retry fix and byte-identical regression fixture alongside its charger and power-panel changes. The second reviewer can access the same session context.

Both PRs are open, so this one stays open for the maintainer to decide where the fix should land. Worker verification is still pending, and the GitHub Tests workflow still requires approval.

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