Repository navigation
Description
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
- On Windows, open the desktop app and turn on the WSL backend.
- Turn on "WSL only". Mixed mode fails in the same way (see below).
- Leave "Keep awake while agents work" on, which is the default.
- Start a long agent turn in a WSL project.
- 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.
- In
[KeepAwake.ts](https://github.com/pingdotgg/t3code/blob/main/apps/server/src/background/KeepAwake.ts),inhibitorCommandchooses a command fromHostProcess.Platform. Inside WSL the platform islinux, so the service runssystemd-inhibit. Windows ignores that blocker.- With systemd off in the distro,
systemd-inhibitexits at once. Theholdretry 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.
- With systemd off in the distro,
- In WSL-only mode no Windows server runs (see
describePrimaryin[DesktopBackendConfiguration.ts](https://github.com/pingdotgg/t3code/blob/main/apps/desktop/src/backend/DesktopBackendConfiguration.ts)). Thewin32branch withSetThreadExecutionStatetherefore never runs. - The desktop app does not block sleep itself.
apps/desktophas nopowerSaveBlockercall. - 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.
- The WSL server runs as a separate process in the backend pool (
[DesktopWslBackend.ts](https://github.com/pingdotgg/t3code/blob/main/apps/desktop/src/wsl/DesktopWslBackend.ts)). - The desktop strips
T3CODE_HOMEfrom the WSL launch env ([DesktopBackendConfiguration.ts](https://github.com/pingdotgg/t3code/blob/main/apps/desktop/src/backend/DesktopBackendConfiguration.ts)), so the WSL server keeps its own database inside the distro. - Each server's KeepAwake checks only its own runs table (the
hasActiveRunquery in[KeepAwake.ts](https://github.com/pingdotgg/t3code/blob/main/apps/server/src/background/KeepAwake.ts)). The Windows server never sees WSL runs, so it never starts its PowerShell blocker for them.
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
- 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. - The WSL server blocks Windows sleep through interop. On a WSL kernel, the server runs the existing
win32PowerShell 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 insideKeepAwake.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 launchPATHstarts with a fixed Linux path. The command needs a full path, and the service needs a fallback.
Related
- feat(server): keep the computer awake while agents work #34128 added this feature. Its description says the Linux and Windows inhibitor commands "have not been run on a real host".
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