feat(sleep): prevent system sleep during runs#17
Merged
kunchenguid merged 4 commits intomainfrom Apr 3, 2026
Merged
Conversation
09607ca to
40762c7
Compare
40762c7 to
3b62bc8
Compare
45fd1e2 to
1a66f25
Compare
1a66f25 to
864fcec
Compare
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.
Summary
Adds built-in sleep prevention for long-running
gnhfruns and hardens the surrounding lifecycle so it works across macOS, Linux, and Windows. The change is not just a new flag: it also fixes shutdown, subprocess cleanup, stdin handoff, and cross-platform verification so overnight runs do not leave helper processes behind.Risk Assessment: 🟡 Medium — Well-covered cross-platform lifecycle changes look mergeable, but default-on sleep prevention and two unresolved re-exec edge cases keep the risk at medium.
Architecture
Key changes made
preventSleepto config with a default oftrue, plus a--prevent-sleep on|offruntime override and README/docs updates.caffeinateon macOS,systemd-inhibitre-exec plus readiness/stdin handoff on Linux, and a PowerShellSetThreadExecutionStatehelper on Windows.opencode, androvodevshutdown paths so signals, timeouts, and late agent results are handled cleanly.opencodefixtures and Windows-friendly wrappers.How was this tested
Critique Comments
src/cli.ts:145 - ValidateGNHF_REEXEC_STDIN_PROMPT_FILEwithisTrustedReexecPromptPath()beforereadFileSync(). As written, any inherited env value can make gnhf read an arbitrary local file and use its contents as the agent prompt.src/core/sleep.ts:384 - If SIGINT/SIGTERM arrives while waiting forsystemd-inhibitreadiness and the helper never exits, this timeout branch falls back to an unprotected normal run instead of honoring the interrupt. Record the received signal and return its exit code here so startup cannot continue after the user tried to stop it.