Repository navigation
fix(sidebar): Hide sleeping keeps a live remote workspace row through a transient PTY gap - #29325
Merged
Merged
Conversation
…sient PTY gap A pane that rebinds its PTY clears the tab's live binding one commit before re-registering it. Under Hide sleeping an open-but-idle remote workspace hung on that binding alone, so its row was swept out and back for one frame. The sweep now treats a still-open tab with no binding as unverifiable and keeps a row that was live for a short settle window; a deliberate sleep or a closed last tab still sweeps immediately. Fixes #15996 Co-authored-by: mmarabel <[email protected]>
Contributor
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 7 minutes. View limit details
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 |
This was referenced Oct 16, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ELI5
With "Hide sleeping" on, a remote workspace that still has an open terminal could vanish from the sidebar for one frame when you clicked a different workspace, so every row below it jumped up and snapped back. The sidebar now waits a moment before deciding a workspace that was just awake has gone to sleep.
What Changed
Before: under "Hide sleeping", an idle remote workspace (open terminal, agent finished long ago) blinked out of the list for a single frame on some workspace switches. The reporter measured it on a paired
orca servehost: seven rows on every frame but one.After: the row stays put. A workspace you deliberately put to sleep, or whose last terminal tab you closed, still disappears straight away.
Mechanism: the "Hide sleeping" sweep keeps an idle workspace only while one of its tabs has a live terminal in
ptyIdsByTabId. Several paths that reconnect a pane to its terminal (SSH reconnect, remote-runtime reattach, deferred session reattach, codex restart) clear that entry and then write it back in a separate store update. During that one update the workspace looked asleep and was swept out.sidebar/sleeping-sweep-retention.ts: a small state machine. A workspace that was seen live and now reads inactive keeps its row for 1.5 s. A workspace that was never seen live gets no grace, so this cannot bring back a row that should have been hidden from the start. Appearing is still immediate.listing/use-sleeping-sweep-retention.ts: runs that state machine with the samehasActiveWorkspaceActivitycheck the sweep uses, so there is no second copy of the liveness rule. The grace only applies while the gap is unverifiable, meaning a terminal tab is still open and has no binding. An explicit sleep (hasWorktreeSleepIntent) or having no tabs left is definitive and sweeps right away. The state is written only after React commits, so abandoned renders can't change it, and one timer re-runs the sweep when the window expires.desktop-workspace-row-facts.ts/compute-visible-worktrees.ts: a newsleepingSweepExemptWorktreeIdsoption that only answers the "is sleeping" question. UnlikeforcedVisibleWorktreeIds, it does not bypass the repo, host or kind filters.Why
An empty binding on a tab that is still open doesn't prove the session is asleep or has exited. It is unverifiable for a moment, and the sweep was treating it as asleep. Fixing it where the sidebar reads the state covers every rebind path at once. The alternatives were weaker:
web-session-tabs-sync/terminal-build.tsalready cover the host graph and the mirrored snapshot. The client-side pane clear-then-rebind paths remain, and this change covers them.The one trade-off is that a row whose last live terminal exits while its tab stays open lingers for up to 1.5 s before it is swept.
This rebuilds contributor PR #16001 by @mmarabel on current main, with credit. Main had moved the sweep into the shared row filters, so the exemption is now a fact-reader input. I also added the immediate-sweep rules for a deliberate sleep and for a closed last tab.
Linked Issue
Fixes #15996
Visual Proof
N/A: the fix removes a one-frame reflow that does not reproduce on demand. The hook tests cover it by driving the real store through the gap.
Testing
use-visible-worktrees-retention.test.tsxdrivesuseVisibleSidebarWorktreesagainst the real store. It covers a one-commit PTY gap keeping the row, StrictMode and Suspense commit safety, the window expiring, and a deliberate sleep or closed last tab sweeping immediately. On the unpatched hook, 5 of these tests fail.sleeping-sweep-retention.test.tscovers the state machine.hide-sleeping-transient-pty-gap.test.tscovers the issue scenario throughcomputeVisibleWorktreeIds, including that the repo filter still wins over a grace window.pnpm tc,pnpm run check:code-quality:changed, and every sidebar test suite pass (368 files).I manually tested these changes locally
Automated tests added/updated, or explained why not below
Review
Agent skill upstream boundary
Notes
Renderer-only, with no wire, IPC or platform changes. It doesn't depend on the host type, so it applies the same way to SSH, paired
orca serve/orcad, and local. Folder workspaces go through the same sweep. Cost is one O(workspaces) pass inside memos that already recompute on the same inputs, plus at most one pending timer.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)