[bug] Linux idle sensing never reports idle on a seatless (SSH-only) session, disabling both deep-idle sleep arms
Linux idle sensing (v2.2.0) never reports idle on a seatless session, so both deep-idle sleep arms are permanently disabled on any SSH-only box.
Symptom
doctor reports L6 as unavailable:
[WARN] (l6) os idle sensing — available: none; L6 will fall back to heartbeat-idle only
Consequence: _deep_idle_override (daemon/__init__.py:314) and _window_deep_idle_arm (daemon/__init__.py:410) both open with if os_idle_sec is None: return False (lines 320, 417), so a sleep cycle can only ever start via fresh_count() == 0 — every Claude Code wrapper closed. On a box that's reached only over SSH, that's permanently true, and essential_variable_consecutive_breaches climbs without bound because the daemon never gets a legitimate excuse to sleep while anything is open.
Cause
_logind_session_paths() (idle_detector.py:139-171) filters on a non-empty seat:
target_uid = os.getuid()
paths: list[str] = []
for entry in entries:
try:
_session_id, uid, _user, seat, path = entry
except (ValueError, TypeError):
continue
if uid == target_uid and seat:
paths.append(path)
return paths
Every session on an SSH/pts-only box has Seat= empty — there's no physical seat to attach to. So this always returns [], _logind_aggregate_idle (line 195) short-circuits on if not session_paths: return None, and os_idle_sec is permanently None. The comment above the function (line 140) says the intent is picking "seat-attached (interactive, non-headless) sessions," but seat is the wrong proxy for interactive — it's the wrong proxy for headless too, since an SSH session is neither headless nor seat-attached.
Reproduction
Any Linux box reached only over SSH (a VM, an LXC container, a cloud box with no physical console):
$ loginctl list-sessions
SESSION UID USER SEAT TTY
3 1000 [user] pts/0
Seat is empty for every row. iai-mcp doctor then reports the L6 WARN above regardless of how idle the terminal actually is.
Fix, verified over 5 consecutive nights
logind maintains IdleHint/IdleSinceHint from tty atime whether or not a session has a seat, so the fix is to widen the filter to an interactive session that owns a TTY, rather than one that owns a seat:
target_uid = os.getuid()
paths: list[str] = []
for entry in entries:
try:
_session_id, uid, _user, seat, path = entry
except (ValueError, TypeError):
continue
if uid != target_uid:
continue
if seat:
paths.append(path)
continue
if self._logind_get_property(path, "Class") != "user":
continue
# A session whose leader has exited sits in State=closing indefinitely,
# and logind stops maintaining its IdleHint -- it stays "no" with
# IdleSinceHint=0 forever. _logind_aggregate_idle() returns None the
# moment any admitted session has no usable hint, so one stale closing
# session pins the aggregate to None permanently. Exclude it for the
# same reason a TTY-less session is excluded below: no usable hint
# should not poison the aggregate.
if self._logind_get_property(path, "State") == "closing":
continue
tty = self._logind_get_property(path, "TTY")
if isinstance(tty, str) and tty:
paths.append(path)
return paths
Two patches landed a day apart, both against the same box, because the first one alone surfaced a second failure mode: a closed terminal (leader process exited, session lingering in State=closing) has IdleHint=false/IdleSinceHint=0 forever, which re-pins the aggregate to None the same way the original bug did. Both exclusions are needed together.
doctor now reports L6 PASS with source logind, and the daemon's own breadcrumbs confirm the fix works end to end, not just that the doctor check went green: essential_variable_consecutive_breaches went from 16 to 0 and essential_variable_consecutive_clears reached 6, and SLEEP cycles have started inside the configured 02:00-06:00 window on five straight nights (2026-09-07 through 2026-09-11) with sessions left open, which was never possible before the patch.
Scope
This affects any headless or SSH-only Linux install — containers, VMs, cloud boxes, anything without a physical console attached to logind's seat concept. It's a gap in the v2.2.0 idle-sensing feature rather than a regression from a later change: that feature's own description ("mirroring the macOS HID-idle check... across X11 and Wayland") didn't have a seatless case in view.
Environment
Ubuntu LXC on Proxmox, Linux 6.14.11-9-bpo12-pve, Python 3.12, reached only over SSH. Confirmed the bug is still present through v3.2.1 (current latest) by reading idle_detector.py in that release — the seat-only filter is unchanged.
I'm glad to send a PR for this if the shape above looks right; it's a small, self-contained change to one method with no callers outside idle_detector.py.
Fixed in v3.2.2 (live on PyPI as iai-pme 3.2.2). Developed/tested on macOS; Linux/Windows paths welcome from contributors.