Skip to content

[Bug]: Keep awake does not stop Windows from sleeping when agents run on the WSL server #38059

Closed

Description

@khubaibeh

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/desktop

Steps to reproduce

Undecided whether to call this bug or a feature request but with Keep Awake settings turned on, an agent running in WSL on the same machine as desktop does not keep the machine awake. It would make sense if WSL is treated as extension if both desktop and wsl are running on same machine.

Note

Exploration by Opus 5.5 High

Area: apps/server (apps/desktop is also involved)

Steps to reproduce

  1. On Windows, open the desktop app and turn on the WSL backend.
  2. Turn on "WSL only". Mixed mode fails in the same way (see below).
  3. Leave "Keep awake while agents work" on, which is the default.
  4. Start a long agent turn in a WSL project.
  5. Leave the machine idle past the Windows sleep timeout.

Expected behavior

Windows stays awake while the agent works. It sleeps again once the agent finishes.

Actual behavior

Windows sleeps, the WSL VM pauses, and the agent turn stalls. The setting still shows as on.

Impact: Cosmetic Issue

Version or commit: main @ 25da86c

Environment: Windows desktop app with the server in WSL (wslOnly and wslBackendEnabled on)

Root cause (from reading the code, not yet confirmed at runtime)

The keep-awake service picks its sleep blocker from the platform the server runs on, not from the machine that sleeps.

  1. In [KeepAwake.ts](https://github.com/pingdotgg/t3code/blob/main/apps/server/src/background/KeepAwake.ts), inhibitorCommand chooses a command from HostProcess.Platform. Inside WSL the platform is linux, so the service runs systemd-inhibit. Windows ignores that blocker.
    • With systemd off in the distro, systemd-inhibit exits at once. The hold retry loop then retries with backoff and logs warnings.
    • With systemd on, the blocker holds and logs "keep-awake holding sleep inhibitor". It only reaches logind inside the VM, so Windows still sleeps.
  2. In WSL-only mode no Windows server runs (see describePrimary in [DesktopBackendConfiguration.ts](https://github.com/pingdotgg/t3code/blob/main/apps/desktop/src/backend/DesktopBackendConfiguration.ts)). The win32 branch with SetThreadExecutionState therefore never runs.
  3. The desktop app does not block sleep itself. apps/desktop has no powerSaveBlocker call.
  4. The server can already detect WSL, in [ServerEnvironmentLabel.ts](https://github.com/pingdotgg/t3code/blob/main/apps/server/src/environment/ServerEnvironmentLabel.ts) and [automaticPort.ts](https://github.com/pingdotgg/t3code/blob/main/apps/server/src/cli/automaticPort.ts). KeepAwake does not use that check.

Mixed mode (Windows and WSL servers both on)

This mode fails too.

Windows stays awake only when the Windows server has its own active run at the same time.

The setting text in [SettingsPanels.tsx](https://github.com/pingdotgg/t3code/blob/main/apps/web/src/components/settings/SettingsPanels.tsx) promises to "Stop the computer from going to sleep". In this setup the switch does nothing, and nothing tells the user.

Possible fixes

  1. Desktop holds the blocker. Electron calls powerSaveBlocker.start("prevent-app-suspension") while any server it started has an active run. This covers WSL-only and mixed mode in one place, but the desktop needs a run signal from each server.
  2. The WSL server blocks Windows sleep through interop. On a WSL kernel, the server runs the existing win32 PowerShell command through /mnt/c/Windows/System32/WindowsPowerShell/v1.0/[powershell.exe](https://github.com/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe). This change stays inside KeepAwake.ts, but two points need care:
    • Wait-Process -Id <pid> would get a Linux pid. The command must exit when its stdin closes instead.
    • Interop can be off ([interop] enabled=false), and the launch PATH starts with a fixed Linux path. The command needs a full path, and the service needs a fallback.

Related

Expected behavior

Machine should be kept awake if the agent is running on wsl on same machine.

Actual behavior

Machine goes to sleep even if an agent is running in WSL on same machine

Impact

Cosmetic issue

Version or commit

main @ 25da86c

Environment

Windows 11, T3 Code desktop 0.1.10, WSL 2 Ubuntu-26.04 systemd on, server in WSL with wslOnly on,

Logs or stack traces

Screenshots, recordings, or supporting files

No response

Workaround

No response

Activity

  1. added
    bugSomething is broken or behaving incorrectly.
    needs-triageIssue needs maintainer review and initial categorization.
    on Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething is broken or behaving incorrectly.needs-triageIssue needs maintainer review and initial categorization.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions