feat(chat): hibernate idle sessions when their view closes - #6087
illegalcall wants to merge 26 commits into
Conversation
🏆 Review leaderboardSep 23–30, 2026 · UTC
Ranked by distinct external PRs reviewed, then review rounds, then PR comments. Self-activity and bot activity are excluded. Show 9 more reviewers
|
6d9a234 to
93c848d
Compare
93c848d to
7bd51ad
Compare
|
Full macOS dev-build demo (Developer Mode ON): Claude ACP (0:00) and Codex app-server (1:45) each show a fresh session, first reply, hibernation with host/provider PID exit, reopen and second reply, then PID exit again. The two continuous provider takes are joined; sending before wake completes is not covered. hibernate-full-journey-claude-codex.mp4 |
|
One lifecycle edge looks worth covering before merge: the view lease is only AO does not set Electron That permits:
So “view closed” can become “browser timer was suspended,” causing provider-process churn/native resume while the user never actually left Chat. I would avoid solving this by globally disabling Chromium throttling. A stronger contract would make view ownership come from a non-throttled Electron/main lifecycle signal, or otherwise make crash-expiry distinguishable from normal background throttling. At minimum the lease should tolerate the browser’s worst-case renewal cadence. A regression with the Chat component still mounted, renewal paused for >30s, and the hibernation sweep running would make this boundary explicit. Checked against head |
|
Hibernation came up as Dhruv Sharma's committed next work on the Oct 2 call: "as you move out of a session, if the session is idle, it will hibernate. Once you come back to your session, before even you start typing, you just click on the session, then the session wakes up" (30:36). prateek flagged the risk this PR should design against: "we show an agent to be idle even if it has subagents that are currently working... If our activity detection is wrong and there's actually work happening in the background, hibernation is going to kill that work" (31:08). Dhruv agreed: fix subagent activity detection first, hibernation proceeds after. Synced from the Oct 2 call: https://discord.com/channels/1476302178913357958/1555642689368891463 |
|
Claude Code before/after in the macOS Electron dev build (Developer Mode on). After an interrupted turn and leaving Chat, the old build kept host PID 66753 alive for over 50 seconds. The changed build stopped PID 62880; reopening started PID 64348, Claude recalled pr6087-claude-before-after.mp4 |
|
Local E2E after 5b58b84 (macOS, isolated Electron dev build, Developer Mode on):
Recording of the isolated dev app: |
5b58b84 to
6179f08
Compare
6179f08 to
1cdae0c
Compare

Code changes: +1459 -161
Tests: +2189 -53
Others: +398 -6
How it works
Evidence
zai-coding-plan/glm-5.3-flash: a fresh task replied; leaving Chat sethibernated_atand exited host/provider PIDs 41475/41480. Reopening and immediately messaging recalledIBIS-53using new PIDs 41768/41769; leaving Chat exited both again.PELICAN-42. A forced 500 remained visible after a 204 lease renewal; retry recovered.QA matrix
activereturns 400; unknown fields remain acceptedOther providers need live testing and native conversation resume support.