Repository navigation
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📥 CommitsReviewing files that changed from the base of the PR and between d8e9fa1 and 4810dc1fe3ef3e6fabcee618abd83b4eea937892. 📒 Files selected for processing (10)
🚧 Files skipped from review as they are similar to previous changes (9)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe change extends worktree sleep intent across shutdown, PTY startup, activation, and background wake flows. Shutdown marks all requested worktrees and clears intent for failed sleeps. PTY setup skips fresh spawning for hidden panes in inactive worktrees with sleep intent. Queued startup, visible panes, active worktrees, never-slept worktrees, and explicitly woken workspaces can still spawn. Activation and background wake clear sleep intent, including when no sleeping-agent records exist. Tests cover these paths. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Description checkExplanation The description is complete and relevant. It includes the required explanation, change scope, rationale, linked issue, visual proof, testing results, AI disclosure, review considerations, boundary confirmation, notes, and checklist status.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 4afafcd8-a90f-42ee-8023-566c81cb6343
📥 Commits
Reviewing files that changed from the base of the PR and between 34f2a62 and 471489a5e44a3ceb50a639f526eea9db941ba648.
📒 Files selected for processing (9)
src/renderer/src/components/sidebar/sleep-worktree-flow.test.tssrc/renderer/src/components/sidebar/sleep-worktree-flow.tssrc/renderer/src/components/terminal-pane/deliberate-sleep-cold-start.test.tssrc/renderer/src/components/terminal-pane/deliberate-sleep-cold-start.tssrc/renderer/src/components/terminal-pane/pty-connection.test.tssrc/renderer/src/components/terminal-pane/pty-connection.tssrc/renderer/src/lib/wake-sleeping-agents-in-background.tssrc/renderer/src/lib/worktree-activation.tssrc/renderer/src/lib/worktree-sleep-intent.ts
|
On the Docstring Coverage pre-merge warning (40% vs 80%): I have deliberately not raised it, and want to flag the reason rather than silently ignore the check. The functions it counts are
Adding What I did instead is put the non-obvious information where it earns its place:
Happy to add the missing docstrings if maintainers would rather have the threshold satisfied — just say so and I will, since it is a house-style call, not a technical one. |
c56fe93 to
4a78410
Compare
|
Conflict resolved and rebased onto current The conflict was modify/delete on Local check: the four suites that cover this change (49 tests) pass, including the two ported call-site cases. Nothing else from review is outstanding — CodeRabbit's wake-intent ordering catch is already in, and the docstring-coverage warning is the same house-style call noted earlier. The remaining GitHub banner is the first-time workflow approval, which needs a maintainer. |
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
|
Any further news on this? Still happens on latest version. I've rebased onto main to help with merging/review. Currently really annoying bug as it just wakes sleeping worktrees randomly. Happy to help with anything that can make the review faster/easier on your end! |
4a78410 to
e9b3446
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
e9b3446 to
4810dc1
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
…s PTY Sleeping a workspace kills its PTYs but leaves its panes mounted, and a pane's deferred connect still runs on later render passes — including one caused by activating an unrelated workspace. With no live handle to attach to, that connect fell straight through to a fresh spawn, re-creating the PTY and flipping the workspace the user just slept back to awake seconds later. Captured in a running build: activating one workspace spawned a PTY for a different, slept one ~50ms later, from runDeferredConnect -> pty-transport.connect. This matches the field trace in stablyai#10205, where daemon.log shows session-attached on the activated workspace immediately followed by session-created on a slept one. The sleep-intent marker already existed but was set only for the focused workspace and cleared as soon as teardown finished, so it could not describe a workspace that stays slept. It now covers every slept workspace, survives teardown, and is released by an explicit activation or background wake — the two gestures that mean the user wants the workspace back. A pane with nothing to attach to consults it and stays cold instead of spawning. Visible panes, queued startup commands (agent resume, background launches), and activation of the workspace itself are all unaffected. Fixes stablyai#10205 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01N3XFTKvDbdrkFXgzZw5xDZ
A workspace slept with only plain shells holds no sleeping-agent record, so the background wake returned before clearing its sleep intent. Its panes then stayed cold permanently and a client opening the workspace became a silent no-op. Clear the mark first: the client's open is the explicit wake regardless of whether there is any agent session to resume. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01N3XFTKvDbdrkFXgzZw5xDZ
4810dc1 to
df32e21
Compare
|
@nwparker Addressed the readiness review and pushed the corrected candidate rebased onto current
Fresh validation after rebase: changed-surface tests 50/50, |
…oken Sleeping a workspace kills its PTYs but keeps its panes mounted and keeps each tab's session id as a wake hint. Any later remount of those panes (recovery, parking, portals) reattached that dead id, and the daemon's create-or-attach spawned a fresh shell, so slept workspaces revived on their own (#10205). The existing sleep-intent marker now outlives teardown and gates the deferred connect itself, so both the reattach and fresh-spawn arms stay cold. It is released by activating the workspace, by any PTY binding to one of its tabs (CLI, automation, client wake), and by purge. A queued startup still connects. Reproduces the community root cause from gatsby74 in #13343; the regression e2e remounts a slept hidden pane and fails on main. Co-authored-by: gatsby74 <gatsby74@users.noreply.github.com>
|
Cross-review from #20039, which I opened tonight for the same bug before finding this PR and #18051. You identified the root cause first: the wake is the renderer pane-connect path, and manual sleep has no durable "stay dead until Wake" gate. I arrived at the same mechanism independently from field logs and then built a weaker fix (latching the terminal park on sleep so the panes never remount). Verifying it, I found the park gate leaks on exactly the paths a connect gate catches — Field evidence you may want, since neither this PR nor #18051 has a reproduced user journey attached — the dominant trigger in a long session is a background unpark sweep, not an activation. From a packaged build tonight, three self-wakes after three sleeps, each ~100ms behind another hidden workspace's pane remounting in the same pass: Irregular 16–28 min gaps matching park-verdict churn, no Credit for the design is yours; #18051 credits it too. Between the two, #18051 looks further along to me — it moves the gate to the connect entry so it covers both the reattach and fresh-spawn arms, adds clear-on-bind so non-activation wakes can't strand a workspace cold, and carries an e2e that fails on cc @Jinwoo-H @gatsby74 |
…oken (#20075) * fix(terminal): keep a deliberately slept workspace cold until it is woken Sleeping a workspace kills its PTYs but keeps its panes mounted and keeps each tab's session id as a wake hint. Any later remount of those panes (recovery, parking, portals) reattached that dead id, and the daemon's create-or-attach spawned a fresh shell, so slept workspaces revived on their own (#10205). The existing sleep-intent marker now outlives teardown and gates the deferred connect itself, so both the reattach and fresh-spawn arms stay cold. It is released by activating the workspace, by any PTY binding to one of its tabs (CLI, automation, client wake), and by purge. A queued startup still connects. Reproduces the community root cause from gatsby74 in #13343; the regression e2e remounts a slept hidden pane and fails on main. Co-authored-by: gatsby74 <gatsby74@users.noreply.github.com> Co-authored-by: mmarabel <mmarabel@users.noreply.github.com> * fix(terminal): let a slept pane wait for its wake instead of latching cold A pane whose connect ran while its workspace was slept used to mark itself connected and stop; nothing re-armed it, so a wake that produced a live PTY before the user clicked (CLI create, background agent resume, split panes) left panes stranded. The connect now waits on the sleep marker and resumes when the marker clears, and a torn-down pane drops its listener. Tabs created with a live PTY clear the marker too, the sleep flow marks each workspace only when its own teardown starts, and purge forgets the marker without waking anything. * fix(terminal): wake a waiting pane once, in its remounted generation Activation clears the sleep marker after the set() that bumps dead tabs' generations, and the waiting pane only resumes its connect when its tab generation is still current. Otherwise the stale pane and its remounted successor both reattached the same session id on a deliberate wake. * fix(terminal): resolve the waiting pane's tab by either id and re-arm after wake The wake listener looked the tab up by the pane's render id, which can be a unified id whose terminal tab lives under entityId, so the generation check declined forever for those panes. Mount, fresh spawn, and the wake listener now share one live resolver. The wait flag resets when the listener fires so a second sleep can hold the pane again, listener dispatch is guarded, folder activation clears after its own set(), and the sleep flow re-asserts the marker after each teardown while releasing a workspace the user activated meanwhile. * fix(terminal): ignore PTY binds that land inside the sleep teardown window A spawn resolving while shutdown was still awaiting the host bound a PTY and cleared the marker, waking every waiting pane mid-sleep; re-marking afterwards could not un-connect them. The sleep flow now scopes each teardown so binds in that window are not wakes. The e2e asserts a deliberate wake yields exactly one PTY, and the dispose test proves the listener is gone. --------- Co-authored-by: Jinwoo-H <jinwoo0825@gmail.com> Co-authored-by: mmarabel <mmarabel@users.noreply.github.com>
|
Landed as #20075, via @Jinwoo-H's #18051 which built directly on your design. You called the root cause first — the wake is the renderer pane-connect path, and manual sleep had no durable stay-dead-until-wake gate. You're credited as Closing as superseded rather than rejected. cc @Jinwoo-H @gatsby74 |



ELI5
Putting a workspace to sleep could briefly stop its terminals and then silently restart them during unrelated background work. Sleeping now sticks until the workspace is explicitly opened or woken, and explicit wakes reliably bring plain-shell workspaces back.
What Changed
Why
A slept workspace leaves mounted panes behind. Their deferred connect path could later run because another workspace changed, find no PTY to attach, and create a new one. The same race could complete a spawn after sleep teardown had begun. Both paths recreated terminals without an explicit wake.
The marker is intentionally in-memory: renderer restart also resets mounted workspace state, while persistence would reintroduce the stale-sleep-state approach previously reverted for #10205.
Linked Issue
Fixes #10205
Visual Proof
No styling change; these captures show the interaction behavior in the headed Electron regression test.
Testing
pnpm exec vitest run --config config/vitest.config.ts src/renderer/src/components/sidebar/sleep-worktree-flow.test.ts src/renderer/src/components/terminal-pane/deliberate-sleep-cold-start.test.ts src/renderer/src/components/terminal-pane/pty-connection-fresh-spawn-guards.test.ts src/renderer/src/lib/wake-sleeping-agents-in-background.test.ts— 4 files, 50/50 passed after rebasing onto currentmainpnpm typecheckpnpm lintpnpm buildpnpm testwas not rerun after the latest rebase; changed-surface tests are green and CI will cover the full suiteAI Disclosure
AI-assisted implementation and review were used. All changed-surface tests, typecheck, lint, and build were run after the final rebase.
Review
Set/store reads on the spawn path and one targeted tab mount on explicit plain-shell background wake.Agent skill upstream boundary
Notes
Checklist
pnpm lint,pnpm typecheck, targeted tests, andpnpm buildpass; CI will cover the full test suite