Skip to content

fix(sidebar): a slept workspace leaves the list at once under Hide sleeping with main's feed - #31249

Merged
Jinwoo-H merged 2 commits into
sidebar-flip-afrom
sidebar-sleep-hide-now
Oct 20, 2026
Merged

Jinwoo-H merged 2 commits into
sidebar-flip-afrom
sidebar-sleep-hide-now

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

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):

Setup Switch off (today) Switch on, before Switch on, after
2 workspaces, background sleep, 5 runs 298-688 (= terminals stopped) 1654-1719 (terminals stopped at 157-217) 136-303 (0-10 after terminals stopped)
32 workspaces, terminals streaming + agent "working", background, 4 runs 391-629 (= terminals stopped; measured sleeping the active one, no agent) 1928-2045 (+~1500) 368-799 (24-53 after)
62 workspaces, terminals streaming + agent "working", sleeping the active one, 4 runs 464-813 (= terminals stopped) 1879-2742 (+~1500) 408-563 (29-50 after)

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:

  • Treat any "stop and keep history" kill as a sleep in main. Main already marks those, but hibernating a single pane (a finished agent) also uses it, and the window keeps the grace there today; it would change behaviour beyond this bug.
  • Patch only the window (keep its own hide decision for slept rows). The phone reads the same list from main, so it would keep the delay and the two would drift apart.
  • Route desktop sleeps through main's own sleep. Larger change to the sleep flow for a one-signal problem.

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

  • I manually tested these changes locally (hidden Electron, macOS: the three setups in the table, switch on and off)
  • Automated tests added/updated, or explained why not below
    • 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

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

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

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

…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.
@Jinwoo-H
Jinwoo-H merged commit a0e6cd8 into sidebar-flip-a Oct 20, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant