Repository navigation
Description
Before submitting
- I searched existing issues, discussions, and PRs and did not find a duplicate.
Area
apps/server
What happened
With Keep awake while agents work enabled (the default), closing the laptop lid does not suspend the machine on Linux/KDE. The desktop power manager's lid action is set to Sleep, but its suspend request is refused by logind because the T3 server holds a block inhibitor on sleep.
The setting's own description says:
Closing a laptop lid still puts it to sleep.
That is true on the other platforms by construction. macOS uses caffeinate -i and Windows uses SetThreadExecutionState(ES_SYSTEM_REQUIRED), which only prevent idle system sleep, so a user-initiated lid close still sleeps. On Linux the server instead runs:
systemd-inhibit --what=sleep --who="T3 Code" --why="Agents are working" --mode=block sh -c 'echo && exec tail --pid=<serverPid> -f /dev/null'
A block inhibitor on sleep makes logind refuse every suspend request, including the one issued by the desktop's power manager when the lid closes. So on Linux the setting silently disables lid-close suspend, which is stricter than both its description and the macOS/Windows behaviour.
Steps to reproduce
- Linux with a lid switch; KDE Plasma (Wayland) desktop power management.
- In System Settings → Power Management, set "When laptop lid closed" to Sleep (confirm
lidAction = 1andtriggersLidAction = trueonorg.kde.Solid.PowerManagement.Actions.HandleButtonEvents). - Leave Keep awake while agents work enabled and start a local agent turn on this server.
- Close the lid and wait. Nothing suspends: no
PM: suspend entryin the kernel log, and logind only recordsLid closed..
Confirm the blocker while the turn is running:
$ systemd-inhibit --list --what=sleep
WHO UID USER PID COMM WHAT WHY MODE
...
T3 Code 1000 deathpie 4428 systemd-inhibit sleep Agents are working block
$ busctl call org.freedesktop.login1 /org/freedesktop/login1 org.freedesktop.login1.Manager CanSuspend
s "inhibited"
Quit the app (or let the 60 s release grace elapse) and the identical lid close works:
Lid closed 14:18:04
PM: suspend entry (deep) 14:18:05
PM: suspend exit 14:18:12
Lid opened 14:18:12
Why LidSwitchIgnoreInhibited does not save it
logind's lid handling ignores inhibitors by default, but on KDE it never runs: PowerDevil takes a block inhibitor on handle-lid-switch ("KDE handles power events") so that logind stays out of lid handling, then asks logind to suspend when the lid closes. That request is a normal suspend request, so it is subject to the sleep block inhibitor. Any desktop that routes lid close through the logind Suspend() method behaves the same way.
Expected behavior
Closing the lid suspends the machine while agents work, matching the setting's description and the macOS/Windows behaviour. At minimum, the Linux limitation should be documented in the setting text, since on Linux the toggle currently also disables lid-close suspend.
Version
t3code-nightly-bin 0.1.12_nightly.20261122.5098-1. This build already includes #39490 — the live argv is --what=sleep with no idle, so this is not the idle-lock issue from #39486.
Environment
CachyOS (Arch-based), KDE Plasma 6.8.3 on Wayland, systemd 262 (262.2-1-arch), kernel 7.3.5-2-cachyos, laptop with an ACPI lid switch (LID0).
Evidence gathered
systemd-inhibit --list --what=sleepshowsT3 Code … systemd-inhibit sleep "Agents are working" blockfor the whole duration of a turn plus ~60 s.CanSuspendreturnsinhibitedwhile it is held, andyesonce it is released.- The lock is re-acquired within seconds if the helper is killed while a run is active.
- Lid close with T3 not running: deep suspend entry and clean exit (log above).
- Lid close with T3 running: logind logs
Lid closed.and nothing else.
Related issues and PRs
- Linux keep-awake takes a logind idle lock, which stops swayidle from locking the screen or turning off displays #39486 / fix(server): Linux keep-awake no longer blocks screen lock and display-off #39490 fixed the
idlehalf of the lock, which stopped screen locking and display-off. This report is about the remainingsleephalf and lid close, so it is not a duplicate of that fix. - [Bug]: Linux keep-awake reports a held inhibitor before acquisition and hides permission errors #38495 / fix(server): keep-awake logs a hold only once acquired and reports why the inhibitor failed #38505 covered Linux keep-awake diagnostics (logging a hold before acquisition, hiding polkit denials).
- [Bug]: Keep awake does not stop Windows from sleeping when agents run on the WSL server #38059 / fix(server): keep awake blocks Windows sleep when the server runs in WSL #38072 covered keep-awake not reaching Windows when the server runs in WSL.
- Linux AppImage: backend blocks system suspend (stuck in D state on FUSE page fault, freeze timeout after 20 s) #39682 is a different mechanism for suspend being blocked on Linux (stuck D-state on a FUSE page fault).
- Prevent sleep while running for increased reliability #663 asked for the feature and explicitly asked that auto-locking after inactivity not be affected.
Disclosure
Investigated and written with an AI agent operating the affected machine; every command output quoted above was observed on the real host, not inferred from source.
Activity