Repository navigation
fix(sidebar): closing a last tab and deleting a workspace leave the list at once with main's feed - #31306
Merged
Conversation
…'s list at once Closing a workspace's last terminal tab left main counting its PTY live until the exit arrived, so Hide sleeping kept the row ~300-500 ms longer than the window's own list. Main now stops counting a PTY it was asked to stop once no pane shows it, and re-reads activity on the graph change and on the stop request. A deleted row came back as a plain card until main's worktree re-scan landed. The window's pending layer now holds a removed row out until main drops it (the overlay moves to sidebar-pending-overlay.ts to keep the layer under the line limit).
…ct, and a failed stop reads running - An unverifiable verdict now wins over "closing": only a live terminal is dropped once it was asked to stop and no pane shows it. - A failed or refused stop (renderer close, stop-and-wait) takes back its stop request, so a terminal that runs on is counted again. - Re-creating a just-removed id on the same host drops that removal's hold, so the new row is listed at once.
9 tasks done
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
On the new sidebar (built from main's list, #30790), two actions finished later than they do today, or showed a wrong in-between picture:
Both now behave as they do today.
What Changed
Measured in hidden Electron runs (33 workspaces, 11-15 with live streaming terminals), in ms from the action until the sidebar stops changing:
After the fix, closing a last tab still shows the row's grey status for about 2-3 frames (~40 ms) before it leaves. Today's list removes it in one frame. That is under the 100 ms bar, so it is left alone.
Close last tab. The window closes a tab by asking main to stop its terminal, then publishing its tabs without that one. Main counted a terminal as running until the process had actually exited, roughly 300-500 ms later. So under Hide sleeping the row stayed. Main already records the stop request when it arrives (
markPtyStopRequested).Main now stops counting a terminal once both are true: it has been asked to stop, and no open pane shows it. It also re-reads the workspace's activity at two points: when that stop request lands, and when the window's tab and pane graph changes. Before, the re-read waited for the next session publication or the exit.
Delete. After the delete call returns, the window drops its own record and its "Deleting…" state. Main kept listing the row until its worktree re-scan landed, so for a moment the card was drawn from main's record as a plain row. The window's pending layer, which already covers its own writes and creations, now also holds a removed row out of the list until main stops listing it. This applies to worktrees and folder workspaces, and to one host's copy only. The pending layer's existing 10 s cap applies, after which main's list wins.
The overlay half of the pending layer moves to
sidebar-pending-overlay.tsso the layer stays under the file line limit.Why
Close last tab: main is the right place to fix it, because the phone reads the same list. Alternatives considered:
Delete: the window is the one that knows the delete finished. Main only learns the row is gone after a fresh git listing, which can take seconds over SSH. The pending layer exists for exactly this gap: it shows the window's own change until main's list catches up.
Linked Issue
Folds into #30790.
Visual Proof
N/A as images: the change is timing (a row leaves sooner, and one in-between frame state is gone). The table above comes from hidden Electron runs that sample the sidebar DOM every animation frame.
Testing
orca-runtime-window-sleep-retention.test.ts: closing the last tab hides the row before the terminal exits, in either order of stop request and graph update (both fail without the fix). A terminal that a pane still shows stays running when asked to stop.orca-runtime-window-sleep-retention.test.tsalso: a closed tab's terminal stays unverifiable when its host stops answering, and reads running again when its stop fails.kill-legacy-relay-bridged.test.ts: a refused reversible stop-and-wait and a failed tab-close stop take back their stop request.sidebar-pending-layer.test.ts: a removed row stays out of the list while main still lists it, and settles once main drops it. Only the removed host's copy of a same-id row is hidden, a removal with no host holds nothing, and a re-create of the same id and host is listed at once.pnpm tc, the unit suites undersrc/main/runtime,src/main/ipc/pty,src/renderer/src/store,src/renderer/src/libandsrc/renderer/src/components/sidebar, and every step of the static-analysis job ran locally.Agent skill upstream boundary
Notes
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)