Skip to content

feat(keep-awake): a PC doesn't sleep while a chat is working - #393

Merged
vaakx-dev merged 1 commit into
mainfrom
sand/keep-system-awake
Nov 14, 2026
Merged

vaakx-dev merged 1 commit into
mainfrom
sand/keep-system-awake

Conversation

@vaakx-dev

Copy link
Copy Markdown
Owner

A new core feature, keep-awake, on by default like the out-of-memory guard and switchable off in Settings. It runs in the runtime and in sand -p.

  • Holds a system-sleep block while any turn is open (threads, bots and subagents all go through the engine's turnOpen/turnClose), and lets go 60 s after the last one closes. The display may still turn off and lock.
  • Windows: SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED) through bun:ffi; Windows drops it when the process exits.
  • macOS: caffeinate -i cat; Linux: systemd-inhibit --what=sleep --mode=block … cat. cat reads a pipe from sand, so letting go, sand exiting or sand crashing all close it and end the block.
  • Where it can't (no systemd-inhibit, the inhibitor fails, other OS) it does nothing and writes one line to the server log.

Reference: pingdotgg/t3code#34128.

Checked on Windows: in a sandbox, sand -p running a shell sleep 5 took the block (the thread's state read 0x80000001 while held, 0x80000000 after). The inhibitor's release and failure paths were exercised with stand-in commands. macOS and Linux weren't run.

@vaakx-dev
vaakx-dev merged commit 4a7cc5e into main Nov 14, 2026
4 checks passed
@vaakx-dev
vaakx-dev deleted the sand/keep-system-awake branch November 14, 2026 04:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant