Repository navigation
fix(sidebar): a slept workspace leaves the list at once under Hide sleeping with main's feed - #31249
Merged
Merged
Conversation
…eeping with main's feed The window stops its own PTYs when it sleeps a workspace, so main never saw the sleep and read the exits as a reconnect gap: its retention kept the row for the 1.5 s settle window. The window now tells main which workspaces it holds asleep, before any kill, and main treats their inactivity as definitive.
Review: a phone or paired desktop could otherwise send a slept set and skip the reconnect grace for any id. Also states that the report is fire-and-forget.
This was referenced Oct 21, 2026
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 workspaces" on, putting a workspace to sleep should make it leave the sidebar right away. On the new sidebar (the one built from main's list, #30790) it lingered as a grey row for about a second and a half. Now it leaves as soon as its terminals stop, as it does today.
What Changed
Before (switch on): sleep a workspace → its terminals stop and its dot turns grey → the grey row stays ~1.5 s longer → it disappears.
After: the row disappears with the terminals, one list update later.
Mechanism: the sidebar keeps a just-idled row on screen for 1.5 s when the idleness might be a terminal briefly reconnecting (an SSH reconnect clears a terminal's binding before re-binding it). A deliberate sleep is not a reconnect, so it should skip that grace. Main skipped it only for sleeps it ran itself; the desktop window runs its own sleep (it stops the terminals directly), so main saw terminals exit with their tabs still open and took it for a reconnect.
Now the window tells main which workspaces it is holding asleep, as it starts the sleep (fire-and-forget; it normally lands before the terminals exit, and a later one still ends the grace because main re-checks on every report) (
sidebarSession.sleptWorkspaces, the whole set each time it changes; tied to the window's connection, so a reload or closed window drops it). Main counts those workspaces' idleness as definitive, the same rule the window itself uses today (its sleep marker).Timings (hidden Electron runs, ms from clicking "Sleep" to the row leaving the DOM; "terminals stopped" is when the window's terminal binding clears):
A per-step trace in main (temporary) showed nothing else on this path grows with the list: the list update reads take 0-4 ms at 62 workspaces, and the hide decision reruns on the activity change itself, not after a worktree re-scan. The only switch-on-only delay was the 1.5 s grace. The time before "terminals stopped" is the terminal shutdown itself, the same in both modes.
Why
Alternatives considered:
Reporting the window's existing sleep marker gives main the same fact the window already decides on, so phone and desktop stay identical.
Scope: this host's own rows (local, SSH, folder workspaces) — those are the rows main's grace covers. A paired server's workspace is slept by that server, which already counts its own sleeps as definitive. A paired web client window never reports (it builds its own list). Headless hosts have no window and sleep through main's own path, already definitive. No change between separately-updated peers: the new call is only between a desktop window and its own main process.
Linked Issue
Folds into #30790.
Visual Proof
N/A as images: the change is a timing (row leaves ~1.5 s sooner); the before/after timings above are from hidden Electron runs measuring the row's removal from the DOM.
Testing
orca-runtime-window-sleep-retention.test.ts: a window sleep drops the row in the same pass (fails without the fix), a sleep reported after the exit ends a grace already open, an unexplained gap still keeps the grace, and a closed connection forgets its sleeps.worktree-sleep-intent-report.test.ts: the window reports the whole set synchronously on every change.pnpm tc, full root unit suite, mobile typecheck, and every step of the static-analysis job ran locally.Agent skill upstream boundary
Notes
Security: the new call refuses any caller but this host's own desktop window (a phone or paired desktop gets
forbidden, tested), and its params are bounded. Cross-platform: no platform branches. SSH: covered (SSH rows are this host's rows). Mobile: no mobile code change; the phone gets the fix through main's list. Performance: one small IPC per sleep or wake.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)