claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

[BUG] Claude Desktop Inhibits Sleep in Linux and Leaves Orphaned Processes When Quit

Open adellario opened this issue 3 months ago • 5 comments

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

Note: this report is about Claude Desktop for Linux, not the Claude Code CLI. Filing here since there is no public tracker for Claude Desktop and other Desktop issues live in this repo.

Related but distinct from #83573. That issue describes a held flags=8 (idle-inhibit) lock with reason Capturing that blocks screen blanking. This one is a cycling flags=4 (suspend) inhibitor that blocks automatic suspend by a different mechanism. Fixing the leaked Capturing lock would not fix this.

Claude Desktop repeatedly registers and releases a session-manager inhibitor (app='/usr/bin/claude-desktop', flags=4, reason='Electron') while sitting idle with no user interaction. GNOME resets Mutter's idle counter on each inhibition-state change, so the idle timer never accumulates enough uninterrupted time to reach the automatic-suspend threshold. The machine never suspends for as long as the app is running.

The flags value is worth stressing, because it makes the cause counterintuitive: the app never requests idle inhibition. flags=4 is the suspend bit, a request to be notified before suspend, not a request to prevent it. The damage comes from the register/release churn, not from the inhibit itself. A steadily-held inhibitor causes no problem; I observed the idle counter climbing normally for 20+ minutes while the same inhibitor stayed continuously registered.

What Should Happen?

Either:

  1. Register the inhibitor once at startup and hold it, rather than cycling it. A stable inhibitor does not reset the idle counter.
  2. Or take it only when there is actual work to protect (an in-flight Cowork task, a running Code session), and not at all when the app is idle in Chat.

Secondary: quitting the app from its own menu leaves numerous claude-desktop processes running, and the inhibitor cycling continues until pkill -f claude-desktop. Users who "quit" the app still cannot suspend.

Error Messages/Logs


Steps to Reproduce

Run Claude Desktop on a GNOME desktop with automatic suspend enabled (Settings → Power → Automatic Suspend). 2. Leave the machine completely untouched, past the suspend threshold. 3. Sample the idle counter periodically: gdbus call --session --dest org.gnome.Mutter.IdleMonitor --object-path /org/gnome/Mutter/IdleMonitor/Core --method org.gnome.Mutter.IdleMonitor.GetIdletime 4. Observe the counter resetting every few minutes and never reaching the threshold (2700000 ms for a 45-minute setting). The machine does not suspend. 5. Quit Claude Desktop and confirm with pkill -f claude-desktop. Repeat step 2. The counter climbs uninterrupted and the machine suspends normally.

idle-watch.log

Claude Model

No response

Is this a regression?

I don't know

Last Working Version

No response

Claude Code Version

Claude 1.34493.1 (255293) 2026-08-21T02:05:20.000Z (Desktop, not Code)

Platform

Other

Operating System

Ubuntu/Debian Linux

Terminal/Shell

Other

Additional Information

In reference to the idle-watch.log blob posted above: Single session, one variable toggled twice, everything else held constant. Idle time and registered inhibitors sampled once per minute.

Period        Claude Desktop   Max idle    Resets   Median gap   Suspended?
10:05-11:38   running           4.9 min      73      1.0 min     no
11:39-13:17   CLOSED           44.5 min      49      1.0 min     YES, at 13:17
14:18-14:42   CLOSED           23.4 min       2     24.3 min     (woken at 14:18)
14:43-18:31   relaunched       22.7 min      29      5.0 min     no

The claude-desktop inhibitor is absent from the log in exactly one continuous run, 11:38:48 to 14:42:32, which contains the only suspend of the day. The app was closed at 11:38; the machine reached 44.5 min idle and suspended at 13:17 (45-minute threshold). It was relaunched at 14:42; the reset pattern resumed immediately and the machine did not suspend again in the following four hours.

An earlier 7.5-hour session with the app running throughout: 68 resets, median gap 6.1 min, longest clean stretch 20.8 min, zero stretches over 45 min, zero suspends.

The inhibitor is present in only 17–23% of samples during periods when the app is running, which is the churn made visible; it is registering and releasing constantly rather than holding.

D-Bus trace correlating resets to the calls

Idle-counter resets line up to the second with Inhibit/Uninhibit calls:

13:10:38  Uninhibit from :1.124        -> idle counter reset at 13:10:38
13:16:49  Inhibit  '/usr/bin/claude-desktop' flags=4 reason='Electron'
                                       -> idle counter reset at 13:16:49

Captured with:

dbus-monitor --session "member='Inhibit'" "member='Uninhibit'" "member='SimulateUserActivity'"

adellario avatar Aug 24 '26 02:08 adellario

Same symptom on Ubuntu 26.04.1, GNOME Shell 50.1 (Wayland), Claude Desktop 2.7032.0, and I can name the source of the churn: the remote_tools keep-awake claim.

What takes the inhibitor. With nothing being used, each running instance takes a hold for exactly 300 s every 25–30 minutes, all day and night:

[keep-awake] started (id=28, claims=remote_tools)
[remote-tools-device] keep-awake held (pss=0)
... 5 minutes later ...
[keep-awake] stopped (id=28): last claim remote_tools released
[remote-tools-device] keep-awake released (quiet, held 300000ms)

Every hold start and every release registers or drops the /usr/bin/claude-desktop / Electron / flags 4 inhibitor, and GNOME's idle time (org.gnome.Mutter.IdleMonitor.GetIdletime) drops to 0 at that moment.

How I matched them. I recorded three things side by side: every evdev event with its device (libinput), every XTEST request with its client (X RECORD), and session-bus inhibitor calls with their callers (dbus-monitor). Over one unattended evening, every reset of GNOME's idle time that had no input device behind it landed within 2 ms of a Claude Desktop SessionManager.Inhibit/Uninhibit, and within the same second as a remote-tools-device log line:

Idle time reset to 0 Claude Desktop log line, same second
18:10:24.689 remote-tools-device keep-awake released (quiet, held 300000ms)
18:13:00.242 same, second instance
18:35:06.365 remote-tools-device keep-awake held (pss=0)
18:40:58.290 released (the Uninhibit call is at 18:40:58.2887)
19:02:37.194 held (the Inhibit call is at 19:02:37.1924)
19:10:10.662 released
19:30:09.079 held

There were no XTEST requests, no evdev events and no SimulateUserActivity/SimulateActivity calls anywhere near these times.

The idle counter therefore never climbs past about 25 minutes. Anything that waits for 30 idle minutes never fires. In my case that was GNOME's automatic suspend, a local idle-suspend script, and a script that closes an abandoned game stream.

The "Keep computer awake while Claude works" toggle does not stop it. It was off in both instances ("ccKeepAwakeWhileWorking": false in claude_desktop_config.json), and the remote_tools holds carried on unchanged overnight and the next morning. That matches the comment on #94420 from someone who saw the churn with the toggle off.

Running two instances makes it worse. With two profiles open (default and a second --user-data-dir), each runs its own cycle, offset from the other, so the gaps between resets shrink. A transition only resets the idle time when it changes the combined inhibited state. When one instance's hold overlaps the other's, the inner start and release cause no reset.

I also confirmed the point in the original report that a steadily held inhibitor is harmless. Taking and releasing a gnome-session-inhibit --inhibit suspend while Claude Desktop already held its inhibitor left the idle time climbing normally. Only a change in the combined state resets it.

Expected: no remote_tools claim while no remote-tools client is connected (pss=0 suggests none was), and the claim should respect the keep-awake toggle.

trouni avatar Sep 29 '26 04:09 trouni

I think this is also related to the problem on Mac https://github.com/anthropics/claude-code/issues/96015#issuecomment-5938597643

hbsmith avatar Oct 02 '26 00:10 hbsmith

Having the same issue on KDE Plasma 5 X11.

bdiddy12 avatar Oct 02 '26 13:10 bdiddy12

Same symptom here, but I traced a different (or additional) trigger — maybe it helps narrow it down.

Env: Ubuntu 26.04, GNOME 50 / Wayland, Claude Desktop 2.9939.4 (first broke with 1.40609.0)

Trigger: the remote-tools device bridge. Roughly every ~30 min it rotates its credential, serves get_device_info, and that takes a keep-awake hold that lingers exactly 5 min:

10:53:06 [remote-tools-device] rotation due — re-presenting credential in-band
10:53:06 [keep-awake] started (id=4, claims=remote_tools)
10:53:06 [remote-tools-device] served get_device_info
10:58:06 [keep-awake] stopped (id=4): last claim remote_tools released

The hold shows up as GNOME inhibitor app=/usr/bin/claude-desktop flags=4 reason=Electron (mirrored to logind as block-weak). Sampling org.gnome.Mutter.IdleMonitor.GetIdletime every 5 s while locked, the counter drops to 0 both when the inhibitor is added and when it is released:

13:23:45 idle=877s lock=true
13:23:50 idle=0s   lock=true   <- keep-awake started (remote_tools)
13:28:47 idle=297s lock=true
13:28:53 idle=2s   lock=true   <- keep-awake stopped

With a 30 min sleep timeout and a cycle every ~30 min, idle suspend never fires.

Not affected by any setting: keepAwakeEnabled=false, ccKeepAwakeWhileWorking=false, Remote Control off, "Only on your computer" on — after a full restart the bridge still comes up with [remote-tools-device] init: shrimp=on, so it looks server-gated.

Onset: auto-suspend worked reliably until the update 1.24012.11 → 1.40609.0 (2026-08-31). The first [keep-awake] line in my logs appears that same day; zero automatic suspends since.

Suggestion: don't take a sleep assertion for credential rotation / get_device_info (or for remote-tools at all unless the user enabled keep-awake).

fcaps avatar Oct 04 '26 20:10 fcaps

Same root cause on Debian 13 / MATE 1.28 (X11), claude-desktop .deb 4.29.0. "Keep computer awake while Claude works" is not set in claude_desktop_config.json (default).

MATE adds a more visible symptom: it honours the inhibitor for manual suspend too. Choosing Suspend shows mate-session's "A program is still running — /usr/bin/claude-desktop — Electron" dialog, which waits until the lock is released and only then suspends (or you click "Suspend Anyway").

Image

The holds are much more frequent here than the 25–30 min cadence reported above. Over ~30 min with the app idle in the tray, the lock was held about 80% of the time, always as remote_tools with pss=0:

19:28:35 [remote-tools-device] keep-awake held (pss=0)
19:37:09 [remote-tools-device] keep-awake released (quiet, held 514050ms)
19:37:34 [remote-tools-device] keep-awake held (pss=0)
19:42:46 [remote-tools-device] keep-awake released (quiet, held 311820ms)
19:48:06 [remote-tools-device] keep-awake held (pss=0)
19:58:50 [remote-tools-device] keep-awake released (quiet, held 644447ms).

— logind began the pending manual suspend in the same second ("The system will suspend now!" at 19:58:50)

Every hold starts within a second of connection housekeeping rather than any work:

19:20:06 [remote-tools-device] rotation due — re-presenting credential in-band
19:20:06 [keep-awake] started (id=2, claims=remote_tools)
...
19:48:05 [remote-tools-device] rotation due — re-presenting credential in-band
19:48:06 [keep-awake] started (id=5, claims=remote_tools)

and the other four holds (18:59:18, 19:06:46, 19:28:35, 19:37:34) each start within a second of [Chrome Extension MCP] Extension fcoeoabgfenejglbffodgkkbkcdhcgfn not found in any browser.

Expected: credential rotation and tool re-advertisement shouldn't take a suspend inhibitor when pss=0, and a remote_tools claim shouldn't block a user-initiated suspend.

bobdole4prez avatar Oct 30 '26 00:10 bobdole4prez