feat(desktop): add prevent-sleep settings toggle - #93
Merged
deepagent-ai merged 2 commits intoJul 26, 2026
Merged
Conversation
The desktop app unconditionally started a powerSaveBlocker at launch with no user-facing way to opt out. Add a "Prevent system sleep" switch under a new Power section in General settings (desktop only). - main: persist preventSleep in the settings store; default stays enabled (only explicit false opts out) so existing installs keep the historical always-on behavior; set-prevent-sleep IPC starts/stops the blocker live and broadcasts to all windows - preload/renderer/app: bridge get/setPreventSleepEnabled through the platform context, mirroring the pinchZoom pattern - i18n: translate the new section and row across all 18 locales - tests: unit-cover the persisted-setting resolution (Electron-free, same split as close-to-tray); add prevent-sleep-smoke, a Playwright-driven dynamic test that clicks the real Settings switch and asserts macOS pmset NoIdleSleepAssertion across default-on, disable, relaunch persistence, and re-enable - ci: run the smoke in a new desktop-smoke (macos) job in test.yml Signed-off-by: thomas-yanga <odie_majere@outlook.com>
The generic store-set/store-delete/store-clear IPCs could write the preventSleep key in the settings store without starting/stopping the powerSaveBlocker, desyncing the persisted setting from the running blocker (a string "false" even resolved back to enabled on next launch). - store-set: reject writes to the preventSleep key; the dedicated set-prevent-sleep IPC is now the single write path - store-delete/store-clear: after touching the settings store, re-sync the blocker via syncPowerSaveBlocker() so the reset to the default-on behavior takes effect immediately Verified with the macOS prevent-sleep smoke (4/4) plus a Playwright guard check: rejected store-set leaves the assertion running, and store-delete/store-clear restore the NoIdleSleepAssertion. Signed-off-by: thomas-yanga <odie_majere@outlook.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Issue for this PR
Closes #
Type of change
What does this PR do?
The desktop app calls
powerSaveBlocker.start("prevent-app-suspension")unconditionally at launch, so the system never idle-sleeps while the app is running,and there is no user-facing way to opt out.
This PR adds a "Prevent system sleep" switch under a new Power section in General settings (desktop only):
preventSleepvalue is persisted in the settings store. The default stays enabled (only an explicitfalseopts out), so existing installskeep the historical always-on behavior. A
set-prevent-sleepIPC handler starts/stops the blocker live and broadcasts the change to all windows; startup readsthe stored value instead of always starting the blocker.
get/setPreventSleepEnabledthrough the platform context, mirroring the existingpinchZoomwiring, and adds theswitch to the settings UI.
prevent-sleep.ts, an Electron-free module (same split asclose-to-tray.ts), so the default-on semantics areunit-testable.
The toggle takes effect immediately; no restart is required.
How did you verify your code works?
falsevalue → on, explicitfalse→ off); all 87 desktop package tests pass.test:prevent-sleep-smoke, a Playwright-driven dynamic test that launches the real built app, clicks the actual Settings switch, and asserts againstmacOS
pmset -g assertions:NoIdleSleepAssertiondesktop-smoke (macos)job intest.yml(kept out of the unit matrix since it needs a window server and a prior desktopbuild).
Screenshots / recordings
Recorded locally during development; can attach a recording of the toggle flipping
pmsetassertions on/off if helpful.Checklist