Repository navigation
Add Keep Mac Awake control on Mac and iOS #7564
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 5 commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
ec732ed
Prevent Mac sleep while agents run or iPhone is connected
lawrencecchen e033dc0
Address review: fix stale-tab reconcile, gate agent census behind set…
lawrencecchen 3f3757e
Make power assertion logger nonisolated, align subsystem with app con…
lawrencecchen 026e6e4
Gate mobile keep-awake on authenticated connections; bound agent-even…
lawrencecchen fa7bfc5
Only record client IDs for verbs that required authorization; lean mo…
lawrencecchen 67bb288
Count authenticated connections at the authorization gate, not the cl…
lawrencecchen 3fba9f1
Refuse stale authenticated-connection inserts after mid-authorization…
lawrencecchen 820a696
Make PreventSleepDecision a value type instead of a top-level function
lawrencecchen 5b3c05b
Replace new debug seams with internal members reached via @testable i…
lawrencecchen a66aadc
Merge current main into feat-mac-awake
azooz2003-bit 0d46df4
Add Keep Mac Awake control on Mac and iOS
azooz2003-bit 7fba71d
Tolerate headless app activation in caffeine UI test
azooz2003-bit b1130ac
Fix iOS caffeine settings compilation
azooz2003-bit 4dd1bd7
Use mobile localization support in caffeine settings
azooz2003-bit 02963d7
Remove reintroduced disabled toast setting
azooz2003-bit 03d680c
Initialize task composer setting on iOS
azooz2003-bit b13d84a
Test iOS Keep Mac Awake control
azooz2003-bit 1c647d8
Capture Keep Mac Awake menu evidence
azooz2003-bit 37897fc
Fix iOS test Foundation import
azooz2003-bit 6085862
Revert "Fix iOS test Foundation import"
azooz2003-bit 5406c44
Merge origin/main into feat-mac-awake
azooz2003-bit bf54ebe
Harden mobile caffeine status handling
azooz2003-bit 384fc10
Annotate caffeine RPC handlers on main actor
azooz2003-bit eb1bb4d
Harden ambiguous mobile caffeine mutations
azooz2003-bit 8b5bb25
Report failed caffeine mutations accurately
azooz2003-bit 60f17cc
Keep caffeine retry available after unknown failure
azooz2003-bit a94b910
Isolate caffeine controller injection on main actor
azooz2003-bit fbe790e
Fence caffeine snapshots by state revision
azooz2003-bit File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
21 changes: 21 additions & 0 deletions
21
Packages/macOS/CmuxSettings/Sources/CmuxSettings/Keys/PowerCatalogSection.swift
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| import Foundation | ||
|
|
||
| /// Power management settings for keeping the Mac reachable during work. | ||
| public struct PowerCatalogSection: SettingCatalogSection { | ||
| /// Keeps the Mac from idle system sleep while cmux observes running agent sessions. | ||
| public let preventSleepWhileAgentsRunning = DefaultsKey<Bool>( | ||
| id: "power.preventSleepWhileAgentsRunning.enabled", | ||
| defaultValue: false, | ||
| userDefaultsKey: "power.preventSleepWhileAgentsRunning.enabled" | ||
| ) | ||
|
|
||
| /// Keeps the Mac from idle system sleep while an iPhone or iPad is connected. | ||
| public let preventSleepWhileMobileConnected = DefaultsKey<Bool>( | ||
| id: "power.preventSleepWhileMobileConnected.enabled", | ||
| defaultValue: true, | ||
| userDefaultsKey: "power.preventSleepWhileMobileConnected.enabled" | ||
| ) | ||
|
|
||
| /// Creates the Power settings catalog section. | ||
| public init() {} | ||
| } | ||
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
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
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
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
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These new
power.*settings areDefaultsKeys, but the config store only readsJSONKeys fromcmux.jsonandPreventSleepManagerreadsUserDefaults.standarddirectly. When a user or managed setup puts the advertisedpower.preventSleepWhileAgentsRunning.enabledorpower.preventSleepWhileMobileConnected.enabledkey incmux.json, the runtime never sees it, so the keep-awake behavior stays at the UserDefaults/default value.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no cmux.json path for these keys to be ignored on: DefaultsKey settings are UserDefaults-only by type (JSONConfigStore only accepts JSONKey), and no boolean setting in the catalog is cmux.json-backed today, so power.* follows the same pattern as every other toggle (e.g. mobile.iOSPairingHost.enabled). The PR description advertised cmux.json support incorrectly; it has been corrected instead of introducing a first-of-its-kind JSONKey.
— Claude Code