feat(desktop): add keep awake while agents are active setting#484
Merged
wesbillman merged 1 commit intomainfrom May 5, 2026
Merged
feat(desktop): add keep awake while agents are active setting#484wesbillman merged 1 commit intomainfrom
wesbillman merged 1 commit intomainfrom
Conversation
Prevents macOS idle sleep while local managed agents are running via an IOKit PreventUserIdleSystemSleep power assertion. Safety rails: auto-release when agents stop, 4-hour hard cap with frontend notification, and cleanup on app exit. Toggle defaults to OFF. No-op on non-macOS. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
wesbillman
added a commit
that referenced
this pull request
May 5, 2026
…ter expiry Two fixes from Codex adversarial review of #484: 1. Replace tokio::spawn with tauri::async_runtime::spawn for the 4-hour cap timer. Follows the codebase convention for spawning from non-async contexts (see huddle/models.rs:381 rationale). 2. Include !expired in the active derivation so the status badge shows "Inactive" after the 4-hour cap fires, matching the actual backend state where the IOKit assertion has been released. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
4 tasks
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
PreventUserIdleSystemSleepIOKit power assertion while local managed agents are runningImplementation
Rust backend (
prevent_sleep.rs): Raw IOKit FFI —IOPMAssertionCreateWithName/IOPMAssertionReleasebehind#[cfg(target_os = "macos")]. State managed viaArc<Mutex<PreventSleepState>>. 4-hour timer auto-releases and emits a Tauri event.Frontend (
usePreventSleep.ts): React context provider (single source of truth) watches managed agent status and syncs to backend. Settings card consumes context — no dual-hook race.Safety design:
PreventUserIdleSystemSleep(not display sleep) — only prevents idle sleep, lid-close/critical-battery/manual sleep still workstatus === "running"agents only (not"deployed"remote agents)release()then emits frontend notificationRunEvent::Exithandler releases beforeshutdown_managed_agentsFiles changed (11)
prevent_sleep.rs,commands/prevent_sleep.rs,usePreventSleep.ts,PreventSleepSettingsCard.tsxapp_state.rs,commands/mod.rs,lib.rs,AppShell.tsx,SettingsPanels.tsx,tauri.ts,check-file-sizes.mjsTest plan
pmset -g assertionsshows no Sprout assertionpmset -g assertionsshowsPreventUserIdleSystemSleepby SproutCAP_SECONDSfor testing) → assertion releases, expiry banner appearspmset -g assertions)🤖 Generated with Claude Code