The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
feat(desktop): keep-awake follows the turn — a "while working" mode alongside off/always
John Paul Soliva3acd94921785
diff --git a/apps/desktop/electron/main.ts b/apps/desktop/electron/main.tsindex f3c6bc0b983..8873804cc81 100644--- a/apps/desktop/electron/main.ts+++ b/apps/desktop/electron/main.ts@@ -443,7 +443,7 @@ import {import { createPoolStopper } from './pool-stop'import { poolTouchKeys } from './pool-touch-scope'import { createPortalSession } from './portal-session'-import { createKeepAwake } from './power-save'+import { createKeepAwake, type KeepAwakeMode, keepAwakeWanted, parseKeepAwakeMode, readKeepAwakeMode } from './power-save'import { readPreUpdateBackupEnabled } from './pre-update-backup-config'import { capturePreviewContents } from './preview-capture'import { onPreviewWatchOwnerDestroyed, sendPreviewFileChangedToOwner } from './preview-file-watch'@@ -18140,8 +18140,17 @@ const streamThrottle = createStreamThrottle(undefined, undefined, {keepFullscreenPainting: process.platform === 'linux' && linuxOzoneBackend(process.env, process.argv) === 'wayland'})+function isAnyTurnInFlight() {+ return mergeActiveWork(activeWorkByWebContents.values()).count > 0+}+function updateStreamThrottleFromActiveWork() {- streamThrottle.update(mergeActiveWork(activeWorkByWebContents.values()).count > 0)+ const working = isAnyTurnInFlight()++ streamThrottle.update(working)+ // The 'while-working' keep-awake mode rides the same merged signal: no+ // listener or timer of its own (see the keep-awake block below).+ applyKeepAwake(working)}ipcMain.on('hermes:active-work', (event, payload) => {@@ -18302,27 +18311,45 @@ ipcMain.on('hermes:translucency', (_event, payload) => {})// Keep-awake: hold the machine awake for long/overnight runs. Main owns the one-// blocker and its persisted state so a cold launch restores it (applied on-// ready — powerSaveBlocker needs the app ready). The renderer toggles it from-// Settings → Advanced over IPC. See store/keep-awake.+// blocker and the persisted mode so a cold launch restores it (applied on+// ready — powerSaveBlocker needs the app ready). The renderer picks the mode+// from Settings → Advanced over IPC. In 'while-working' the blocker follows the+// merged active-work picture that already drives stream throttling, so it is+// held exactly while a turn is in flight and released at idle. See+// store/keep-awake + power-save.ts.const KEEP_AWAKE_CONFIG_PATH = path.join(app.getPath('userData'), 'keep-awake.json')const keepAwake = createKeepAwake(powerSaveBlocker)+let keepAwakeMode: KeepAwakeMode = 'off'-function readPersistedKeepAwake() {+function readPersistedKeepAwakeMode(): KeepAwakeMode {try {- return JSON.parse(fs.readFileSync(KEEP_AWAKE_CONFIG_PATH, 'utf8')).on === true+ return readKeepAwakeMode(JSON.parse(fs.readFileSync(KEEP_AWAKE_CONFIG_PATH, 'utf8')))} catch {- return false+ return 'off'}}-ipcMain.on('hermes:keep-awake', (_event, on) => {- const enabled = Boolean(on)- keepAwake.set(enabled)+// Reconcile the blocker with the mode and the live turn picture. Called from+// every mode change and every active-work report — both happen after app+// ready, when `keepAwake` and `keepAwakeMode` above are initialised.+function applyKeepAwake(working = isAnyTurnInFlight()) {+ keepAwake.set(keepAwakeWanted(keepAwakeMode, working))+}++ipcMain.on('hermes:keep-awake', (_event, value) => {+ // Accepts the mode string, or the boolean the pre-mode toggle sent.+ const mode = parseKeepAwakeMode(value)++ if (mode === null) {+ return+ }++ keepAwakeMode = mode+ applyKeepAwake()try {fs.mkdirSync(path.dirname(KEEP_AWAKE_CONFIG_PATH), { recursive: true })- fs.writeFileSync(KEEP_AWAKE_CONFIG_PATH, JSON.stringify({ on: enabled }, null, 2), 'utf8')+ fs.writeFileSync(KEEP_AWAKE_CONFIG_PATH, JSON.stringify({ mode }, null, 2), 'utf8')} catch (error) {rememberLog(`[keep-awake] write failed: ${error.message}`)}@@ -19398,7 +19425,8 @@ app.whenReady().then(() => {ensureWslWindowsFonts()configureSpellChecker()registerPowerResumeListeners()- keepAwake.set(readPersistedKeepAwake())+ keepAwakeMode = readPersistedKeepAwakeMode()+ applyKeepAwake()void minimizeToTray.start()mainProcessLagWatchdog.start()f12Blocked = readPersistedDisableF12()diff --git a/apps/desktop/electron/power-save.test.ts b/apps/desktop/electron/power-save.test.tsindex 52e797e0209..e818ab3258a 100644--- a/apps/desktop/electron/power-save.test.ts+++ b/apps/desktop/electron/power-save.test.ts@@ -1,6 +1,12 @@import { describe, expect, it, vi } from 'vitest'-import { createKeepAwake, type PowerSaveBlockerLike } from './power-save'+import {+ createKeepAwake,+ keepAwakeWanted,+ parseKeepAwakeMode,+ type PowerSaveBlockerLike,+ readKeepAwakeMode+} from './power-save'function fakeBlocker() {let next = 1@@ -49,3 +55,56 @@ describe('createKeepAwake', () => {expect(keepAwake.isActive()).toBe(true)})})++describe('keep-awake mode', () => {+ it('parses the three modes and the boolean the pre-mode toggle sent', () => {+ expect(parseKeepAwakeMode('off')).toBe('off')+ expect(parseKeepAwakeMode('while-working')).toBe('while-working')+ expect(parseKeepAwakeMode('always')).toBe('always')+ // The old Switch sent a boolean; on meant what 'always' means now.+ expect(parseKeepAwakeMode(true)).toBe('always')+ expect(parseKeepAwakeMode(false)).toBe('off')+ // Anything else is refused rather than guessed.+ expect(parseKeepAwakeMode('on')).toBeNull()+ expect(parseKeepAwakeMode(1)).toBeNull()+ expect(parseKeepAwakeMode(undefined)).toBeNull()+ })++ it('reads the persisted copy in the new and the legacy shape', () => {+ expect(readKeepAwakeMode({ mode: 'while-working' })).toBe('while-working')+ // keep-awake.json written before modes existed.+ expect(readKeepAwakeMode({ on: true })).toBe('always')+ expect(readKeepAwakeMode({ on: false })).toBe('off')+ // An explicit mode wins over a stale legacy flag beside it.+ expect(readKeepAwakeMode({ mode: 'off', on: true })).toBe('off')+ // Unreadable or absent -> off, the pre-existing default.+ expect(readKeepAwakeMode(null)).toBe('off')+ expect(readKeepAwakeMode('garbage')).toBe('off')+ expect(readKeepAwakeMode({ mode: 'sometimes' })).toBe('off')+ })++ it("holds the blocker only when the mode and the live turn picture agree", () => {+ expect(keepAwakeWanted('off', true)).toBe(false)+ expect(keepAwakeWanted('off', false)).toBe(false)+ expect(keepAwakeWanted('always', true)).toBe(true)+ expect(keepAwakeWanted('always', false)).toBe(true)+ // The point of the mode: follows the turn in and out.+ expect(keepAwakeWanted('while-working', true)).toBe(true)+ expect(keepAwakeWanted('while-working', false)).toBe(false)+ })++ it('drives the real blocker in and out of a turn under while-working', () => {+ const { blocker } = fakeBlocker()+ const keepAwake = createKeepAwake(blocker)+ const apply = (working: boolean) => keepAwake.set(keepAwakeWanted('while-working', working))++ apply(false)+ expect(blocker.start).not.toHaveBeenCalled()+ apply(true)+ apply(true) // a second active-work report mid-turn must not stack blockers+ expect(blocker.start).toHaveBeenCalledTimes(1)+ apply(false)+ expect(blocker.stop).toHaveBeenCalledTimes(1)+ expect(keepAwake.isActive()).toBe(false)+ })+})diff --git a/apps/desktop/electron/power-save.ts b/apps/desktop/electron/power-save.tsindex 0939de99d80..350a41cadf8 100644--- a/apps/desktop/electron/power-save.ts+++ b/apps/desktop/electron/power-save.ts@@ -48,3 +48,47 @@ export function createKeepAwake(}}}++/**+ * How the blocker follows the user: never, only while a turn is in flight, or+ * around the clock. 'while-working' is the mode the module doc-comment always+ * described — overnight runs survive without the user predicting, before they+ * start, that they will need it, and without a laptop pinned awake all week.+ */+export type KeepAwakeMode = 'always' | 'off' | 'while-working'++const KEEP_AWAKE_MODES: readonly KeepAwakeMode[] = ['off', 'while-working', 'always']++/**+ * Coerce a wire or persisted value to a mode. The pre-mode toggle sent and+ * stored a boolean; `true` meant what 'always' means now, `false` meant 'off'.+ */+export function parseKeepAwakeMode(value: unknown): KeepAwakeMode | null {+ if (value === true) {+ return 'always'+ }++ if (value === false) {+ return 'off'+ }++ return typeof value === 'string' && (KEEP_AWAKE_MODES as readonly string[]).includes(value)+ ? (value as KeepAwakeMode)+ : null+}++/** The main process's persisted copy: the `{ mode }` shape, or the legacy `{ on }`. */+export function readKeepAwakeMode(persisted: unknown): KeepAwakeMode {+ if (typeof persisted !== 'object' || persisted === null) {+ return 'off'+ }++ const record = persisted as Record<string, unknown>++ return parseKeepAwakeMode(record.mode) ?? parseKeepAwakeMode(record.on) ?? 'off'+}++/** Whether the blocker should be held right now, given the mode and the live turn picture. */+export function keepAwakeWanted(mode: KeepAwakeMode, working: boolean): boolean {+ return mode === 'always' || (mode === 'while-working' && working)+}diff --git a/apps/desktop/electron/preload.ts b/apps/desktop/electron/preload.tsindex 505df7af380..0a0b35ede0e 100644--- a/apps/desktop/electron/preload.ts+++ b/apps/desktop/electron/preload.ts@@ -387,7 +387,7 @@ contextBridge.exposeInMainWorld('hermesDesktop', {setTitleBarTheme: payload => ipcRenderer.send('hermes:titlebar-theme', payload),setNativeTheme: mode => ipcRenderer.send('hermes:native-theme', mode),setTranslucency: payload => ipcRenderer.send('hermes:translucency', payload),- setKeepAwake: on => ipcRenderer.send('hermes:keep-awake', on),+ setKeepAwake: mode => ipcRenderer.send('hermes:keep-awake', mode),minimizeToTray: {get: () => ipcRenderer.invoke('hermes:minimize-to-tray:get'),set: on => ipcRenderer.invoke('hermes:minimize-to-tray:set', on),diff --git a/apps/desktop/src/app/settings/config-settings.tsx b/apps/desktop/src/app/settings/config-settings.tsxindex 39f5e643061..a35a087650d 100644--- a/apps/desktop/src/app/settings/config-settings.tsx+++ b/apps/desktop/src/app/settings/config-settings.tsx@@ -6,6 +6,7 @@ import { useSearchParams } from 'react-router'import { Button } from '@/components/ui/button'import { Input } from '@/components/ui/input'+import { SegmentedControl } from '@/components/ui/segmented-control'import { getElevenLabsVoices, getHermesConfigSchema, saveHermesConfig } from '@/hermes'import { useI18n } from '@/i18n'import { triggerHaptic } from '@/lib/haptics'@@ -23,7 +24,7 @@ import {import { recordSettingsSaved } from '@/store/desktop-metrics'import { $disableF12, setDisableF12 } from '@/store/disable-f12'import { $alwaysExternalLinks, setAlwaysExternalLinks } from '@/store/external-links'-import { $keepAwake, setKeepAwake } from '@/store/keep-awake'+import { $keepAwakeMode, type KeepAwakeMode, setKeepAwakeMode } from '@/store/keep-awake'import { notify, notifyError } from '@/store/notifications'import { normalizeProfileKey } from '@/store/profile'import { repoDiscoveryPolicyFromConfig, repoDiscoveryPolicySignature, scanAndRecordRepos } from '@/store/projects'@@ -102,7 +103,14 @@ function ConfigSettingsInner({}: ConfigSettingsProps & { scopeProfile: string | undefined }) {const { t } = useI18n()const c = t.settings.config- const keepAwake = useStore($keepAwake)+ const keepAwakeMode = useStore($keepAwakeMode)++ const keepAwakeOptions = [+ { id: 'off', label: c.keepAwakeOff },+ { id: 'while-working', label: c.keepAwakeWhileWorking },+ { id: 'always', label: c.keepAwakeAlways }+ ] as const satisfies readonly { id: KeepAwakeMode; label: string }[]+const disableF12 = useStore($disableF12)const alwaysExternalLinks = useStore($alwaysExternalLinks)// The editable draft is local (debounced autosave watches it), but it's seeded@@ -447,12 +455,20 @@ function ConfigSettingsInner({power-user, this-computer-only knobs. */}{showDesktopSettings && (<>- <ToggleRow- checked={keepAwake}+ <ListRow+ action={+ <SegmentedControl+ onChange={mode => {+ triggerHaptic('selection')+ setKeepAwakeMode(mode)+ }}+ options={keepAwakeOptions}+ value={keepAwakeMode}+ />+ }description={c.keepAwakeDesc}id={settingElementId(SETTING_IDS.advanced.keepAwake)}- label={c.keepAwakeTitle}- onChange={setKeepAwake}+ title={c.keepAwakeTitle}/><ToggleRowchecked={disableF12}diff --git a/apps/desktop/src/global.d.ts b/apps/desktop/src/global.d.tsindex b39c87708d5..bb4694eb0f1 100644--- a/apps/desktop/src/global.d.ts+++ b/apps/desktop/src/global.d.ts@@ -387,7 +387,7 @@ declare global {/** Sanitized local `display.skin`, available before any gateway connects. */localSkin?: { profile: string; skin: HermesSkin } | nullsetTranslucency?: (payload: TranslucencyState) => void- setKeepAwake?: (on: boolean) => void+ setKeepAwake?: (mode: 'always' | 'off' | 'while-working') => voidminimizeToTray?: {get: () => Promise<{ enabled: boolean; available: boolean }>set: (on: boolean) => Promise<{ enabled: boolean; available: boolean }>diff --git a/apps/desktop/src/i18n/en.ts b/apps/desktop/src/i18n/en.tsindex a3e34fedc05..a421de462e9 100644--- a/apps/desktop/src/i18n/en.ts+++ b/apps/desktop/src/i18n/en.ts@@ -1379,7 +1379,11 @@ export const en: Translations = {toolsetsWipeConfirm:'Remove all enabled toolsets? This disables memory, terminal, web search, delegation, and most other tools until you re-enable them.',keepAwakeTitle: 'Keep computer awake',- keepAwakeDesc: 'Stop this machine from sleeping so long or overnight runs keep going. The display can still dim.',+ keepAwakeDesc:+ 'Stop this machine from sleeping. "While working" holds it only while a turn is in flight, so overnight runs survive without pinning the laptop awake all week. The display can still dim.',+ keepAwakeOff: 'Off',+ keepAwakeWhileWorking: 'While working',+ keepAwakeAlways: 'Always',disableF12Title: 'Disable F12 DevTools',disableF12Desc: 'Block F12 from opening Developer Tools. Ctrl+Shift+I (or Cmd+Opt+I on Mac) still works.',alwaysExternalLinksTitle: 'Always open links in external browser',diff --git a/apps/desktop/src/i18n/ja.ts b/apps/desktop/src/i18n/ja.tsindex c1b2b2a8b1e..7e348353f43 100644--- a/apps/desktop/src/i18n/ja.ts+++ b/apps/desktop/src/i18n/ja.ts@@ -1052,7 +1052,11 @@ export const ja = defineLocale({imported: '設定をインポートしました',invalidJson: '設定 JSON が無効です',keepAwakeTitle: 'コンピューターをスリープさせない',- keepAwakeDesc: '本体のスリープを防ぎ、長時間や夜通しの実行を継続します。画面は暗転できます。',+ keepAwakeDesc:+ '本体のスリープを防ぎます。「実行中のみ」はターンの実行中だけ有効になるため、夜通しの実行を継続しつつ、ノートPCを一週間つけたままにはしません。画面は暗転できます。',+ keepAwakeOff: 'オフ',+ keepAwakeWhileWorking: '実行中のみ',+ keepAwakeAlways: '常に',voiceShortcutHintTitle: '音声録音ショートカット',voiceShortcutHintDesc:'「設定 → キーボードショートカット」で音声録音ショートカット(「Start / stop voice conversation」)を設定します。voice.record_key は CLI と TUI 専用です。'diff --git a/apps/desktop/src/i18n/ru.ts b/apps/desktop/src/i18n/ru.tsindex d2537b52e17..9d5e7c1eaf3 100644--- a/apps/desktop/src/i18n/ru.ts+++ b/apps/desktop/src/i18n/ru.ts@@ -1106,7 +1106,10 @@ export const ru = defineLocale({'Удалить все включённые наборы инструментов? Это отключит память, терминал, веб-поиск, делегирование и большинство других инструментов, пока вы не включите их снова.',keepAwakeTitle: 'Не давать компьютеру засыпать',keepAwakeDesc:- 'Не даёт этой машине засыпать, чтобы долгие или ночные прогоны продолжались. Экран при этом может гаснуть.',+ 'Не давать этому компьютеру засыпать. «Во время работы» держит его только пока выполняется ход — ночные запуски переживут сон, а ноутбук не останется включённым всю неделю. Экран по‑прежнему может гаснуть.',+ keepAwakeOff: 'Выкл',+ keepAwakeWhileWorking: 'Во время работы',+ keepAwakeAlways: 'Всегда',disableF12Title: 'Отключить F12 DevTools',disableF12Desc:'Блокирует открытие Developer Tools по F12. Ctrl+Shift+I (на Mac — Cmd+Opt+I) продолжает работать.',diff --git a/apps/desktop/src/i18n/types.ts b/apps/desktop/src/i18n/types.tsindex 5e1bc504763..443eca85435 100644--- a/apps/desktop/src/i18n/types.ts+++ b/apps/desktop/src/i18n/types.ts@@ -1144,6 +1144,9 @@ export interface Translations {toolsetsWipeConfirm: stringkeepAwakeTitle: stringkeepAwakeDesc: string+ keepAwakeOff: string+ keepAwakeWhileWorking: string+ keepAwakeAlways: stringdisableF12Title: stringdisableF12Desc: stringalwaysExternalLinksTitle: stringdiff --git a/apps/desktop/src/i18n/zh-hant_settings.ts b/apps/desktop/src/i18n/zh-hant_settings.tsindex 2a9cc794224..e113d3bcb3c 100644--- a/apps/desktop/src/i18n/zh-hant_settings.ts+++ b/apps/desktop/src/i18n/zh-hant_settings.ts@@ -776,7 +776,10 @@ export const zhHantSettings = {imported: '設定已匯入',invalidJson: '設定 JSON 無效',keepAwakeTitle: '保持電腦喚醒',- keepAwakeDesc: '阻止本機睡眠,讓長時間或整夜執行持續進行。螢幕仍可變暗。',+ keepAwakeDesc: '阻止本機睡眠。「執行時」僅在有回合進行時生效,整夜執行得以持續,又不會讓筆電整週保持喚醒。螢幕仍可變暗。',+ keepAwakeOff: '關閉',+ keepAwakeWhileWorking: '執行時',+ keepAwakeAlways: '一律',voiceShortcutHintTitle: '語音錄製快捷鍵',voiceShortcutHintDesc:'請在「設定 → 鍵盤快捷鍵」中設定語音錄製快捷鍵(「Start / stop voice conversation」)。voice.record_key 設定僅適用於 CLI 和 TUI。',diff --git a/apps/desktop/src/i18n/zh.ts b/apps/desktop/src/i18n/zh.tsindex a54b7f56e94..db5ddc1dfdd 100644--- a/apps/desktop/src/i18n/zh.ts+++ b/apps/desktop/src/i18n/zh.ts@@ -1323,7 +1323,10 @@ export const zh = defineLocale({toolsetsWipeConfirm:'确定移除所有已启用的工具集吗?这将禁用记忆、终端、网络搜索、委派以及大多数其他工具,直到你重新启用它们。',keepAwakeTitle: '保持电脑唤醒',- keepAwakeDesc: '阻止本机休眠,让长时间或通宵运行继续进行。屏幕仍可变暗。',+ keepAwakeDesc: '阻止本机休眠。“运行时”仅在有回合进行时生效,通宵运行得以继续,又不会让笔记本整周保持唤醒。屏幕仍可变暗。',+ keepAwakeOff: '关闭',+ keepAwakeWhileWorking: '运行时',+ keepAwakeAlways: '始终',disableF12Title: '禁用 F12 开发者工具',disableF12Desc: '阻止 F12 打开开发者工具。Ctrl+Shift+I(Mac 上为 Cmd+Opt+I)仍然可用。',alwaysExternalLinksTitle: '始终在外部浏览器中打开链接',diff --git a/apps/desktop/src/store/keep-awake.test.ts b/apps/desktop/src/store/keep-awake.test.tsindex 4807e436ae4..a4b5ffc836a 100644--- a/apps/desktop/src/store/keep-awake.test.ts+++ b/apps/desktop/src/store/keep-awake.test.ts@@ -1,17 +1,24 @@import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'-import { storedBoolean } from '@/lib/storage'+import { storedString, writeKey } from '@/lib/storage'-import { $keepAwake, setKeepAwake } from './keep-awake'--const KEY = 'hermes.desktop.keepAwake.v1'+const KEY = 'hermes.desktop.keepAwakeMode.v1'+const LEGACY_KEY = 'hermes.desktop.keepAwake.v1'const desktopWindow = window as unknown as { hermesDesktop?: Window['hermesDesktop'] }const initialHermesDesktop = desktopWindow.hermesDesktopconst setKeepAwakeBridge = vi.fn()+/** The atom reads storage at import time, so migration tests need a fresh module. */+async function loadStore() {+ vi.resetModules()++ return import('./keep-awake')+}+beforeEach(() => {desktopWindow.hermesDesktop = { setKeepAwake: setKeepAwakeBridge } as unknown as Window['hermesDesktop']- setKeepAwake(false)+ writeKey(KEY, null)+ writeKey(LEGACY_KEY, null)setKeepAwakeBridge.mockClear()})@@ -20,14 +27,47 @@ afterEach(() => {})describe('keep-awake store', () => {- it('persists the pref and mirrors it to the main process', () => {- setKeepAwake(true)- expect($keepAwake.get()).toBe(true)- expect(storedBoolean(KEY, false)).toBe(true)- expect(setKeepAwakeBridge).toHaveBeenLastCalledWith(true)-- setKeepAwake(false)- expect(storedBoolean(KEY, true)).toBe(false)- expect(setKeepAwakeBridge).toHaveBeenLastCalledWith(false)+ it('persists the mode and mirrors it to the main process', async () => {+ const { $keepAwakeMode, setKeepAwakeMode } = await loadStore()++ setKeepAwakeMode('while-working')+ expect($keepAwakeMode.get()).toBe('while-working')+ expect(storedString(KEY)).toBe('while-working')+ expect(setKeepAwakeBridge).toHaveBeenLastCalledWith('while-working')++ setKeepAwakeMode('off')+ expect(storedString(KEY)).toBe('off')+ expect(setKeepAwakeBridge).toHaveBeenLastCalledWith('off')+ })++ it('defaults to off on a machine with no preference', async () => {+ const { $keepAwakeMode } = await loadStore()++ expect($keepAwakeMode.get()).toBe('off')+ })++ it('migrates the pre-mode toggle: on meant always, off meant off', async () => {+ writeKey(LEGACY_KEY, 'true')+ expect((await loadStore()).$keepAwakeMode.get()).toBe('always')+ // Loading persisted the migrated mode under the new key (the subscriber runs+ // on init) — that is the one-shot migration working. Clear it to test the+ // other legacy value from a clean slate.+ writeKey(KEY, null)++ writeKey(LEGACY_KEY, 'false')+ expect((await loadStore()).$keepAwakeMode.get()).toBe('off')+ })++ it('prefers a saved mode over a stale legacy flag beside it', async () => {+ writeKey(LEGACY_KEY, 'true')+ writeKey(KEY, 'while-working')++ expect((await loadStore()).$keepAwakeMode.get()).toBe('while-working')+ })++ it('ignores an unrecognised saved mode instead of trusting it', async () => {+ writeKey(KEY, 'sometimes')++ expect((await loadStore()).$keepAwakeMode.get()).toBe('off')})})diff --git a/apps/desktop/src/store/keep-awake.ts b/apps/desktop/src/store/keep-awake.tsindex f2d2022391f..535292fccd1 100644--- a/apps/desktop/src/store/keep-awake.ts+++ b/apps/desktop/src/store/keep-awake.ts@@ -2,28 +2,52 @@* Keep-awake — stop the machine sleeping during long, unattended runs.** A device-local preference (each computer keeps its own), off by default. This- * atom backs the Settings → Advanced toggle and mirrors changes to the main+ * atom backs the Settings → Advanced picker and mirrors changes to the main* process, which owns the real power-save blocker AND its own persisted copy —* so a cold launch restores the blocker without the renderer visiting Settings* (see electron/main.ts + electron/power-save.ts). Linux/web without the bridge* just no-op.+ *+ * Modes: 'off' never holds the blocker; 'while-working' holds it only while a+ * turn is in flight (main reads that from the same active-work reports that+ * drive stream throttling); 'always' holds it around the clock, which is what+ * the pre-mode boolean toggle meant when it was on.*/import { atom } from 'nanostores'-import { persistBoolean, storedBoolean } from '@/lib/storage'+import { persistString, storedBoolean, storedString } from '@/lib/storage'++export type KeepAwakeMode = 'always' | 'off' | 'while-working'++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 KEY = 'hermes.desktop.keepAwake.v1'+ if (isKeepAwakeMode(stored)) {+ return stored+ }++ // No mode saved yet: honour what the old toggle said. On meant "always".+ return storedBoolean(LEGACY_KEY, false) ? 'always' : 'off'+}-export const $keepAwake = atom<boolean>(typeof window === 'undefined' ? false : storedBoolean(KEY, false))+export const $keepAwakeMode = atom<KeepAwakeMode>(typeof window === 'undefined' ? 'off' : initialKeepAwakeMode())-export function setKeepAwake(on: boolean): void {- $keepAwake.set(on)+export function setKeepAwakeMode(mode: KeepAwakeMode): void {+ $keepAwakeMode.set(mode)}if (typeof window !== 'undefined') {- $keepAwake.subscribe(on => {- persistBoolean(KEY, on)- window.hermesDesktop?.setKeepAwake?.(on)+ $keepAwakeMode.subscribe(mode => {+ persistString(KEY, mode)+ window.hermesDesktop?.setKeepAwake?.(mode)})}diff --git a/website/docs/user-guide/desktop.md b/website/docs/user-guide/desktop.mdindex 3ac2bbe86a0..6b2c07b9e7c 100644--- a/website/docs/user-guide/desktop.md+++ b/website/docs/user-guide/desktop.md@@ -253,7 +253,7 @@ Manage providers, models, tools, and credentials from a real UI instead of editi- **Auxiliary-model warning** — if you switch the main model to a new provider while auxiliary tasks (titling, summarization, and similar helpers) are still pinned to another provider, the app warns you so you don't unknowingly split work across two providers.- **Per-task reasoning effort** — each row under **Settings → Model → Auxiliary models** has a reasoning selector next to its provider/model pick: a level, **Off**, or **inherit · main model effort** (the default, which removes the task's override). It is saved as `auxiliary.<task>.reasoning_effort` in `config.yaml`, the same key `hermes model` writes, and shows in the row's summary when set. Use it to run frequent helpers such as compression or titling at low or no reasoning while the main agent stays at high.- **VS Code Marketplace themes** — beyond the built-in theme presets, the appearance settings include a live VS Code Marketplace search: pick any color theme and the app downloads, converts, and installs it as a desktop theme. The same importer is available from the command palette (*Install theme*), and imported themes can be removed again from the appearance settings.-- **Keep computer awake** — **Settings → Advanced → Keep computer awake** stops the machine from sleeping so long or overnight agent runs keep going (the display can still dim). This is a per-computer setting.+- **Keep computer awake** — **Settings → Advanced → Keep computer awake** stops the machine from sleeping so long or overnight agent runs keep going (the display can still dim). **While working** holds the machine awake only while a turn is in flight and lets it sleep normally once the run finishes or fails; **Always** holds it whenever Hermes is open. This is a per-computer setting.First-run onboarding has been redesigned on a unified overlay design system, and you can pick **Choose provider later** to skip provider setup and get into the app first.