Skip to content

fix(sidebar): closing a last tab and deleting a workspace leave the list at once with main's feed - #31306

Merged
Jinwoo-H merged 2 commits into
sidebar-flip-afrom
sidebar-flip-close-delete-timing
Oct 21, 2026
Merged

Jinwoo-H merged 2 commits into
sidebar-flip-afrom
sidebar-flip-close-delete-timing

Conversation

@Jinwoo-H

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

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​207 $\color{#cf222e}{\Huge{\mathbf{−}}}$​21 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​186
Prod 9 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​276 $\color{#cf222e}{\Huge{\mathbf{−}}}$​141 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​135

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:

  • With "Hide sleeping workspaces" on, closing a workspace's last terminal tab should make it leave the sidebar right away. It turned grey and stayed for about a third of a second.
  • Deleting a workspace should make the row go from "Deleting…" straight to gone. For a moment it flashed back as a normal row first.

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:

Action Switch off (today) Switch on, before Switch on, after
Close last terminal tab, Hide sleeping on (4-7 runs) 28-48 319-551, with the row grey in between 66-68
Delete a workspace (4-7 runs) 204-301 217-513, with a plain row for 21-74 ms before it leaves 155-253, no in-between row
Wake, Hide sleeping on (side effect, 3-4 runs) 107-216 217-229 169-181
Sleep, Hide sleeping on (unchanged, checks #31249) 658-867 733-805 545-646

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.ts so 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:

  • A window-side overlay for closed tabs. This would fix only the desktop and leave the phone slow.
  • Treating every stop request as "not running". This would also change panes that are only being replaced or hibernated, whose pane still shows the terminal. Requiring "no pane shows it" matches what the window's own list already decides on: a workspace with no terminal tab is asleep.

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

  • I manually tested these changes locally (hidden Electron, macOS, switch off and on, with the timings above)
  • Automated tests added/updated, or explained why not below
    • 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.ts also: 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 under src/main/runtime, src/main/ipc/pty, src/renderer/src/store, src/renderer/src/lib and src/renderer/src/components/sidebar, 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

  • SSH: SSH terminals take the same stop path, so they are covered. Only a terminal that reads running is dropped once it was asked to stop and no pane shows it; one whose host stopped answering stays "unverifiable" (docs/reference/ssh-execution-boundary.md). A stop that fails or is refused takes back its stop request, so a terminal that runs on is counted again.
  • Re-creating a just-removed workspace id on the same host drops that removal's hold, so the new row shows at once.
  • Paired servers: a paired server's terminals are that server's to count. The removal hold matches the server's rows by host.
  • Mobile: no mobile code change. The phone gets the close-tab fix through main's list.
  • Wire: no RPC or stream change.
  • Performance: one pass over the window's panes per graph update.
  • Cross-platform: no platform branches.

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)

…'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.
@Jinwoo-H
Jinwoo-H merged commit 8465608 into sidebar-flip-a Oct 21, 2026
31 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