Repository navigation
macOS 27: allow the DisplayServices calls and read Low Power Mode from powermode - #58
Conversation
CodingCossack
left a comment
There was a problem hiding this comment.
Same issue here, on a second Mac: MacBook Pro M1 Max (MacBookPro18,2), macOS 27.0 (26A428). pmset -g custom shows only powermode 1 under Battery Power, with no lowpowermode line. During an overnight lid-closed session on v0.1.0, every Low Power Mode read failed with "no lowpowermode line under Battery Power". sudo -n pmset -b lowpowermode 1 still works on this build.
The approach looks right to me. Keeping powermode 2 (High Power) as unknown is the important part. My local fix treated it as "off", which would have let a session end reset High Power to Automatic.
One thing needs fixing before merge. I ran swift test on this branch: 1222 tests, 3 failures.
RefusedDarkeningTests.testARefusalDoesNotHideAFailedWriteOnTheOtherDeviceandtestARefusalDoesNotHideAFailedAudioRestorestill expectmeasured on macOS 26 onlyatPrivateDisplayGuardTests.swift:1124and:1148. This is the failure Greptile reported. Changing both tomeasured on macOS 26, 27 onlymakes all 70RefusedDarkeningTestspass locally.UIStatusTests.testReopeningDuringAOneWriteCollapseDropsTheFoldAndBringsThePillsBackfailed once during the full run and passed 3 times out of 3 on its own. It looks like a timing flake under load and is unrelated to this PR.
A small follow-up, not a blocker: the refusal message measured on macOS 26, 27 only is spelled out in about seven test assertions. Every new macOS major will break all of them again. Asserting on this is macOS N, or building the expected text from measuredDisplayServicesMajors, would make the next version bump a one-line change.
LGTM once the two strings are updated.
Measured on macOS 27.0.1 (26A434, MacBook Pro M5 Pro): all three DisplayServices symbols resolve, GetBrightness returns 0 for the built-in display and CanChangeBrightness is true; in a supervised lid test the display was darkened to 0 and restored. Tests now use 28 as the unmeasured major. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016LRkYqs4KG6k4Dxe5aoCjw
macOS 27 pmset -g custom prints powermode (0 automatic, 1 Low Power, 2 High Power) and no lowpowermode line, so every read failed and Low Power Mode was never enabled on lid close. pmset -b lowpowermode 0|1 still sets the mode there, so the sudoers commands are unchanged; only the parser falls back to powermode. lowpowermode wins when both appear, and High Power reads as unknown so it is never taken over. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016LRkYqs4KG6k4Dxe5aoCjw
Probe, supervised lid test, the Low Power Mode read failure and what was not exercised. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016LRkYqs4KG6k4Dxe5aoCjw
… refusal text from the measured list Review on krishhgg#58: two RefusedDarkeningTests still expected "measured on macOS 26 only" (PrivateDisplayGuardTests.swift:1124, :1148). Every expected refusal message is now built from DisplayPower.measuredDisplayServicesMajors and an unmeasured major past the list, so measuring the next macOS is a one-line change. docs/spec.md and docs/lid-close.md say 26 and 27; the unmeasured-version row of the hardware table says 26 or 27, and a Not run row covers a macOS 27 session that reads powermode, enables Low Power Mode and leaves High Power alone. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01R72BAk5W5GvNnS2GR7qAFN
|
Thanks @CodingCossack for running the suite and confirming on a second Mac — good to have the High Power case backed by your near-miss. Pushed
CI on this exact head, run in my fork while the workflow here awaits approval: 1,226 tests, 0 failures (10 skipped), release build, ShellCheck and workflow lint all green — https://github.com/D4TBot/Insomnia/actions/runs/38142732115 If #66 lands first, I'll move the new row to |
|
Tested on a second macOS 27 Mac, including the High Power case listed as not run. Machine: MacBook Pro (Mac14,6), Apple M2 Max, 64 GB, macOS 27.0 (26A428), Xcode 27.1 (27A9269), Swift 6.4. Supervised, on a desk:
One wording issue: with High Power the log line is but the Not exercised: sessions longer than a few minutes, the battery floors (the battery was at 100%), the heat rules, and a restart with the mode claimed. Sources
|
krishhgg#66 moved the real-Mac checklist from docs/release-validation.md to docs/releasing.md. This PR's two checklist changes move there: the darkening-refused item now says a macOS major other than 26 or 27, and the macOS 27 Low Power Mode item goes under Sessions and recovery. The October 10 macOS 27.0.1 results stay in release-validation.md. Brings in krishhgg#85's macOS 27 CI job and krishhgg#89's test fix. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Brings in krishhgg#86, which runs ShellCheck over the scripts the tests write. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
A Battery Power `lowpowermode` line with no value was skipped, so a `powermode 0` below it read as "off" and Insomnia took over the mode. The lowpowermode line now wins even with no value, and reads as unknown. The read error also said "no lowpowermode or powermode line" for High Power (`powermode 2`) and for values like 3. It now names the line it read: missing, High Power left alone, or a value that is not 0 or 1. Tests add krishhgg#69's macOS 26.7.1 excerpt (Battery `powermode 0`, AC `powermode 2`), the reasons, and the error isLowPowerModeOn throws. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
I pushed c835d51 and 7c7eae9 to this branch with two small fixes from review:
I also added tests for both, plus the macOS 26.7.1 excerpt from #69 (Battery 🤖 Generated with Claude Code |
"a setting Insomnia leaves alone" was wrong in recovery, which logs the same error and then switches the mode off when the journal says it was ours. The reason now says only what pmset printed. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
docs/release-validation.md conflicted: main's October 10 macOS 27.0.1 section (krishhgg#58) and this branch's October 11 Comet section were added at the same place. Both are kept, oldest first. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
Thanks again for this fix. Before it ships in a release, I need test evidence from your Mac for the code as it is now on Checks for this change (on your macOS 27.0.1 MacBook Pro)
Build and what to post
Post the results as a comment on this PR. Put long logs in a gist and link it. Run everything while you're with the Mac, on a stable, ventilated surface, never in a bag, and not while you have unsaved work open. 🤖 Generated with Claude Code |
Summary
Two things stop Insomnia's lid-close actions on macOS 27:
measuredDisplayServicesMajorsis[26], so on 27 the display stays lit under the closed lid. I measured the calls on 27.0.1 (26A434) and opened the gate to[26, 27]. Tests now use 28 as the unmeasured major.pmset -g customno longer printslowpowermode; it printspowermode(0automatic,1Low Power,2High Power). Every read failed with "no lowpowermode line under Battery Power".pmset -b lowpowermode 0|1still sets the mode on 27 (it flipspowermodeunder Battery Power), so the sudoers commands are unchanged. Only the parser changes: it falls back topowermodewhenlowpowermodeis absent.lowpowermodewins when both appear, andpowermode 2reads as unknown so High Power is never taken over.Evidence (MacBook Pro, Apple M5 Pro, macOS 27.0.1 26A434)
GetBrightnessreturns 0 (brightness 1.0) for the built-in display;CanChangeBrightnessis true; all sixKeyboardBrightnessClienttype encodings match the macOS 26 measurements.pmset -g log; "display darkened (was brightness 1.0)", built-in brightness read 0.000 for the whole closed period and was restored to 1.0; keyboard backlight, mute and the freeze list were applied and undone; battery 34.0 → 35.4 °C while charging; thermal state nominal. The Low Power read failed on every power event in that run (before the parser change).sudo -n pmset -b lowpowermode 1setpowermode 1under Battery Power;lowpowermode 0set it back to0.pmset -g customoutput as off, and a standalone harness passed 8 cases.docs/release-validation.md.Not verified
-Xswiftc -warnings-as-errorspasses against the macOS 26.5 SDK.@Stateis now a macro whose plugin (SwiftUIMacros) ships with Xcode only.🤖 Generated with Claude Code

Confidence Score: 5/5
The PR appears safe to merge with no outstanding findings.Summary
The PR allows DisplayServices calls on macOS 27 and reads Low Power Mode from
powermodewhenlowpowermodeis absent. The latest changes clarify the High Power error message and update its tests.pmsetoutput.Reviews (4) · Last reviewed commit: "Low Power Mode: the High Power reason de..." · Reviewed by Greptile