feat(settings): warn that keep-awake cannot survive a closed laptop lid#3148
Conversation
The "Keep awake while agents work" power-save blocker only prevents idle system sleep; closing a laptop lid forces sleep on macOS and Windows regardless. Detect a built-in battery (macOS ioreg, Windows Win32_Battery, Linux /sys/class/power_supply) and append a lid-close caveat to the setting description on laptops. Generated-By: PostHog Code Task-Id: 6b1cbbfe-903b-400d-a76f-45e614c6d0f8
|
Merging to
After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here |
|
React Doctor found no issues in the changed files. 🎉 Reviewed by React Doctor for commit |
|
| description={ | ||
| hasBuiltInBattery | ||
| ? "Prevent your computer from going to sleep on its own while the agent is running a task. Closing the lid will still put it to sleep." | ||
| : "Prevent your computer from going to sleep on its own while the agent is running a task" | ||
| } |
There was a problem hiding this comment.
The base description text is duplicated across both branches of the ternary — the only difference is the extra sentence appended for laptops. Extracting the shared portion satisfies the OnceAndOnlyOnce simplicity rule and makes future copy changes a single-site edit.
| description={ | |
| hasBuiltInBattery | |
| ? "Prevent your computer from going to sleep on its own while the agent is running a task. Closing the lid will still put it to sleep." | |
| : "Prevent your computer from going to sleep on its own while the agent is running a task" | |
| } | |
| description={`Prevent your computer from going to sleep on its own while the agent is running a task.${hasBuiltInBattery ? " Closing the lid will still put it to sleep." : ""}`} |
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
There was a problem hiding this comment.
I prefer it the original way
Generated-By: PostHog Code Task-Id: 6b1cbbfe-903b-400d-a76f-45e614c6d0f8
There was a problem hiding this comment.
Gates denied this PR: it's classified as a feature spanning two areas (platform interface change + UI + host adapter + router), which requires human review. The deny-list also flagged "auth" due to a touched test file. A human reviewer needs to approve before this can be auto-merged.
Problem
The "Keep awake while agents work" setting uses Electron's
powerSaveBlocker("prevent-app-suspension"), which only prevents idle system sleep. Closing a laptop lid forces sleep on macOS (and by default on Windows) — no user-space API can block that. Users reasonably expect the toggle to keep an agent running with the lid closed, and it can't.Change
hasBuiltInBattery()to theIPowerManagerplatform interface, implemented in the Electron adapter:ioreg -rc AppleSmartBatteryGet-CimInstance Win32_Battery(covers Windows laptops, which also sleep on lid close by default)/sys/class/power_supply/BAT*false(no caveat shown).SleepServiceand a newsleep.hasBuiltInBatteryhost-router query.Testing
pnpm --filtertypecheck green for platform, core, host-router, ui, workspace-server, code.IPowerManagertest fakes updated.ioreg -rc AppleSmartBatterydetection on a MacBook.Related: recovery of turns interrupted by sleep is addressed separately.
Created with PostHog Code