fix(next): a program's tab back shows its pane again when a later close hid that pane (follow-up of #32898)
Follow-up of #32898 (its review receipt, finding 1). Leo, 2026-10-25: "closing the right pane seems be like... waiting for the right tab's closing animation to play before closing".
leo-named-fix
What was wrong
Two quick Cmd-Ws in one split pane with two terminals, the first running a program. The first close keeps a tab in the pane, so only its tab hides. The second close empties the pane, which hides too (#32898). If the first read then finds the program, its rollback put the tab back into a pane that was still hidden, and its question showed with no pane on screen.
Fix
TabCloseGuard: a rolled-back close that puts a tab back into its pane now withdraws whatever pane close is hiding that pane (LayoutModel.withdrawPaneClose), whichever close it came from. Its focus comes back with it. The idle terminal's close still goes through: its pane keeps the program's tab, so its own close shows no pane close. A pane close already sent to the daemon and then withdrawn settles as a no-op (settlePaneClose on a missing hold).
Risk
risk:normal. One condition in the close guard's rollback (emptied became "the strip has a tab again").
Tests
New CmdWEmptiedSplitPaneLeavesInItsTurnTests.aProgramsTabBackShowsThePaneALaterCloseHid: two Cmd-Ws with the read held, then released. The question shows with the pane and the program's tab, the idle terminal closes, and Cancel keeps the pane.
Results: TEST_PENDING
Performance
No change to the close timing. This only touches the rollback.
| metric | before | after | delta | harness or run link |
|---|---|---|---|---|
| Cmd-W on a split's last idle terminal -> pane gone, p50 | 1.96 ms | n/a (path unchanged) | 0 | #32898 |
Observed / Not run
Not run yet: the suite at this head (fleet run in flight).
Changelog
none
Agent session: agent session
🤖 Generated with Claude Code
![Autofix with [code]smith](https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-dark-3x.png)
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.
Summary by cubic
When a running program’s tab is restored after a close, its pane now reappears even if a later close hid it. This keeps the close question visible with the program’s tab while allowing the other terminal’s close to finish.
- Adds a regression test for two quick Cmd-W presses in a split pane.