[Bug] Windows desktop 3.10.2: "Keep computer running" wake lock silently lost after sleep→resume; PC idle-sleeps despite toggle ON
Nobody has claimed this yet.
- Dominant language
- No language data
- Stars
- 22
- Forks
- 1
- PR merge metrics
- No merged PRs in 30d
Description
提交前确认 · Pre-submission checklist
- 我已搜索过现有 issue,确认这不是重复 / I searched existing issues and confirmed this isn't a duplicate.
- 我已阅读 CONTRIBUTING.md / I've read CONTRIBUTING.md.
问题类别 · Category
稳定性 / 崩溃 · Stability / Crash
涉及的 Agent 框架 · Agent framework
ZCode Agent(自研)
严重程度 · Severity
影响体验 · Major (功能可用但体验受损 / works but degraded)
复现频率 · Reproducibility
必现 · Always
问题描述 · Description
Windows desktop app: the wake lock behind Settings → "Keep computer running" (keepAwakeWhileRunning) is silently lost after any sleep→resume cycle. Windows discards power requests during a sleep transition; ZCode never re-asserts its powerSaveBlocker on resume, so the OS-level request is gone while the app still considers its blocker id active. Result: the PC idle-sleeps after the power-plan timeout even though the toggle is ON. Re-toggling the setting (or restarting the app) restores protection until the next sleep/wake.
Evidence (ZCode logs ~/.zcode/v2/logs + Windows Event Log Kernel-Power ID 42; one app process, pid 16104, alive throughout — not an app-restart scenario):
2026-09-04 19:23:02.146 [keep-awake] powerSaveBlocker started id=0 <- toggle enabled; protection works
2026-09-04 22:58:30 system sleeps (manual, reason "Application API" — allowed by design); Windows discards the power request
2026-09-05 13:07 system wakes; same pid keeps logging; NO [keep-awake] line — blocker was NOT re-asserted
2026-09-05 15:32:07 system sleeps (Kernel-Power 42, reason "System Idle") — 60-min idle timer fired although toggle was ON
2026-09-05 16:52:20.552 [keep-awake] powerSaveBlocker stopped id=0 <- user re-toggles OFF
2026-09-05 16:52:20.793 [keep-awake] powerSaveBlocker started id=1 <- protection restored (until the next sleep)
Root cause (resources/app.asar, minified — reconcileKeepAwakeBlocker() only acts on state transitions):
if (enabled && blockerId === null) { blockerId = powerSaveBlocker.start("prevent-app-suspension") }
else if (!enabled && blockerId !== null) { powerSaveBlocker.stop(blockerId) }
After resume the state is (enabled=true, blockerId=non-null) → the function no-ops, and the OS request cleared during sleep is never re-established. The module already imports electron.powerMonitor but does not re-assert the blocker on its resume event.
Suggested fix: on powerMonitor resume, if the setting is enabled, stop the stored blocker id and start a fresh one (or reset the id to null on suspend and re-run reconcile on resume). Optional hardening: also re-run reconcile on main-window restore; log a distinct line when re-asserting after resume.
复现步骤 · Steps to reproduce
- Windows desktop PC (classic S3 standby), power plan set to sleep after 60 min idle on AC.
- Open ZCode desktop and enable Settings → "Keep computer running" → log shows
[keep-awake] powerSaveBlocker started. - Sleep the PC manually, then wake it, keeping ZCode running (close-to-tray).
- Leave the PC idle for 60 minutes.
- PC sleeps: Windows Event Log shows Kernel-Power ID 42 with reason "System Idle". No new
[keep-awake]log line appears — the app still considers the pre-sleep blocker active while the OS request was cleared.
期望表现 · Expected behavior
While the toggle is ON, the system never sleeps from idle, regardless of previous sleep/resume cycles. (Manual sleep and lid close remain allowed, per the setting's own description.) Concretely: ZCode should re-acquire the powerSaveBlocker on powerMonitor resume after every wake.
实际表现 · Actual behavior
The wake lock dies at the first sleep→resume: Windows clears power requests as part of the sleep transition, and the app's reconcile function no-ops after resume because its stored blocker id is still non-null (it only starts a blocker when the id is null). The PC then idle-sleeps although the toggle is ON, until the user re-toggles the setting or restarts the app. No error is logged — the failure is fully silent.
ZCode 版本 · ZCode version
3.10.2 (Windows desktop app)
设备 / 系统 / 浏览器 · Device / OS / Browser
Windows 11 Pro, build 26200, x64. Desktop PC on AC power (chassis type 3, no battery), classic S3 standby — NOT Modern Standby (S0 Low Power Idle not supported by firmware). Power plan: sleep after 60 min idle on AC. Repro is independent of browser; this is the Electron desktop app.
截图 / 录屏 / 日志 · Screenshots / Recordings / Logs
ZCode desktop log (~/.zcode/v2/logs/2026-09-0{4,5}.log):
[2026-09-04 19:23:02.146] [info] [pid:16104] [main] [keep-awake] powerSaveBlocker started id=0
... (no [keep-awake] lines at all between the 22:58 sleep and the 15:32 idle sleep the next day, although the app logged continuously) ...
[2026-09-05 16:52:20.552] [info] [pid:16104] [main] [keep-awake] powerSaveBlocker stopped id=0
[2026-09-05 16:52:20.793] [info] [pid:16104] [main] [keep-awake] powerSaveBlocker started id=1
Windows Event Log (System, Microsoft-Windows-Kernel-Power, ID 42):
- 2026-09-05 15:32:07 — Sleep Reason: System Idle ← the bug (toggle was ON)
- 2026-09-04 22:58:30 — Sleep Reason: Application API (manual, allowed by design)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with resources/app.asar, locating reconcileKeepAwakeBlocker() and the existing electron.powerMonitor usage. Reproduce the Windows sleep→resume sequence with Keep computer running enabled, then verify that the setting continues preventing idle sleep after resume while manual sleep remains allowed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- electron
- Domain
- desktop, operating-systems
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 72/100