Skip to content

The agent that grows with you

refactor(desktop): one keep-awake mode list for main and the renderer

kshitijk4poorf1b902e66a15
diff --git a/apps/desktop/src/global.d.ts b/apps/desktop/src/global.d.ts
index bb4694eb0f1..739fdf43c51 100644
--- a/apps/desktop/src/global.d.ts
+++ b/apps/desktop/src/global.d.ts
@@ -7,6 +7,7 @@ import type { HudModifierApi } from '../electron/hud-modifier-types'
import type { MachineProfile } from '../electron/machine-profile'
import type { HermesNotification } from '../electron/notification-types'
import type { PoolLimits } from '../electron/pool-limits'
+import type { KeepAwakeMode } from '../electron/power-save'
import type { UpdateRunReport } from '../electron/updater/update-metrics'
import type { GrowRequest } from '../electron/window-growth'
@@ -387,7 +388,7 @@ declare global {
/** Sanitized local `display.skin`, available before any gateway connects. */
localSkin?: { profile: string; skin: HermesSkin } | null
setTranslucency?: (payload: TranslucencyState) => void
- setKeepAwake?: (mode: 'always' | 'off' | 'while-working') => void
+ setKeepAwake?: (mode: KeepAwakeMode) => void
minimizeToTray?: {
get: () => Promise<{ enabled: boolean; available: boolean }>
set: (on: boolean) => Promise<{ enabled: boolean; available: boolean }>
diff --git a/apps/desktop/src/store/keep-awake.ts b/apps/desktop/src/store/keep-awake.ts
index 535292fccd1..68e60e7bd69 100644
--- a/apps/desktop/src/store/keep-awake.ts
+++ b/apps/desktop/src/store/keep-awake.ts
@@ -18,20 +18,18 @@ import { atom } from 'nanostores'
import { persistString, storedBoolean, storedString } from '@/lib/storage'
-export type KeepAwakeMode = 'always' | 'off' | 'while-working'
+import { type KeepAwakeMode, parseKeepAwakeMode } from '../../electron/power-save'
+
+export type { KeepAwakeMode }
const KEY = 'hermes.desktop.keepAwakeMode.v1'
/** The boolean the toggle persisted before modes existed; read once to migrate. */
const LEGACY_KEY = 'hermes.desktop.keepAwake.v1'
-function isKeepAwakeMode(value: unknown): value is KeepAwakeMode {
- return value === 'off' || value === 'while-working' || value === 'always'
-}
-
function initialKeepAwakeMode(): KeepAwakeMode {
- const stored = storedString(KEY)
+ const stored = parseKeepAwakeMode(storedString(KEY))
- if (isKeepAwakeMode(stored)) {
+ if (stored) {
return stored
}