feat(desktop): keep the machine awake while local agents work #5535
Closedleo-mathurin(GitHub profile, opens in a new tab)wants to merge 2 commits into
main fromrefs/pull/5535/headopened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
- @@ -0,0 +123,21 @@123+124+/**125+ * Drives the desktop shell's keep-awake assertion from the renderer, the only126+ * layer that sees every environment. Each state is sent over IPC at most once127+ * per flip; the initial send also resets main-process state after a renderer128+ * reload. The assertion is released on unmount and on `pagehide`, because129+ * React cleanups do not run when the renderer reloads.130+ */131+export function useDesktopCaffeination(): void {132+ const enabled = useClientSettings((settings) => settings.caffeinateWhileAgentsRunning);133+ const anyLocalAgentWorking = useAtomValue(anyLocalAgentWorkingAtom);134+ const battery = useBatteryState();135+ const keepAwake = computeKeepAwake({ enabled, anyLocalAgentWorking, battery });136+ const lastSentRef = useRef<boolean | null>(null);137+138+ useEffect(() => {139+ const setKeepAwake = window.desktopBridge?.setKeepAwake;140+ if (typeof setKeepAwake !== "function") {141+ return;142+ }143+ const send = (value: boolean) => {
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
t3dotgg(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.
Important
Review skipped#
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID:
28abbe2e-2a90-4bd9-a880-5f0b379ed8f2You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share