fix(worktree): show closing state instead of "Starting terminal…" - #164
Closed
neumie wants to merge 1 commit into
Closed
fix(worktree): show closing state instead of "Starting terminal…"#164neumie wants to merge 1 commit into
neumie wants to merge 1 commit into
Conversation
neumie
force-pushed
the
fix/worktree-close-starting-terminal
branch
from
July 21, 2026 11:28
ae26ae4 to
46fd18f
Compare
Closing a worktree left every pane painting the "Starting terminal…" placeholder for the whole teardown window — seconds on a real checkout. `prepare_background_worktree_removal` nulls every layout leaf's `terminal_id` while keeping the project row and tree standing, so `ensure_terminal` can't resurrect a PTY inside the doomed checkout. The client mirrors that snapshot, rebuilds each pane with `terminal_id: None`, and `TerminalContent` falls into its uninitialized-slot placeholder. Give the project column an explicit `Closing` branch that wins over `Layout`, since a closing worktree keeps `layout: Some`. Gated on the terminals actually being gone rather than on the closing flag alone: the merge and `before_remove`-hook phases also set the flag while the terminals are still live and useful, and those keep painting. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Y4Aq3X2s6ftafXzmqaN3A8
neumie
force-pushed
the
fix/worktree-close-starting-terminal
branch
from
July 21, 2026 12:46
46fd18f to
9bcf816
Compare
neumie
changed the base branch from
fix/sync-terminal-size
to
refactorx/full-headless
July 21, 2026 12:46
Member
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.
Problem
Closing a worktree left every pane painting the "Starting terminal…" placeholder for the whole teardown window — seconds on a real checkout — even though the terminals were already dead and the project was on its way out.
Root cause
prepare_background_worktree_removal(crates/okena-workspace/src/actions/worktree.rs:721) runslayout.clear_terminal_ids_except(&HashSet::new()): it nulls every layout leaf'sterminal_idbut deliberately keeps the project row and the tree shape standing, soensure_terminalcan't resurrect a PTY inside the doomed checkout.The daemon then kills the PTYs (
command_loop.rs:144) and only afterwards runs the blockingremove_dir_all; the project row is deleted much later (command_loop.rs:190). The client mirrors that intermediate snapshot verbatim, rebuilds eachTerminalPanewithterminal_id: None,create_new_terminalonly logs a warning, andTerminalContent.terminalstaysNone→ the uninitialized-slot placeholder atcontent.rs:605.The id-nulling is correct and is not touched here.
Fix
okena-layout: new allocation-freeLayoutNode::has_terminal_ids()predicate.project_column.rs: the content branch becomes an explicitenum ColumnContent { Closing, Layout, Creating, Empty }picked by a purecolumn_content(), plus arender_closing_stateplaceholder mirroring the existingrender_creating_state.Closinghas to win overLayoutbecause a closing worktree keepslayout: Some— unlikeis_creating, which sits in theelsearm only because a mid-create project haslayout: None.Key call:
Closingis gated onclosing && !has_terminals, not on the closing flag alone. The merge andbefore_remove-hook phases also setis_closingwhile the terminals are still live and useful (and both are still abortable), so those keep painting the real pane tree. Only the id-less teardown window swaps to the placeholder.Tests
okena-layoutpinninghas_terminal_idsagainstclear_terminal_ids_except.cargo buildclean, clippy clean, 448 tests pass acrossokena-app/okena-layout/okena-workspace.Notes
Based directly on #157 (
refactorx/full-headless). This originally sat on top of #163; since that PR was closed unmerged, this branch was rebased with--ontoto drop its three commits, so nothing from the closed PR rides along here.Out of scope, spotted while tracing:
command_loop.rs:237(theJoinErrorarm of background removal) clearsis_closingwithout thespawn_uninitialized_terminalsrestore its sibling git-failure arm performs. Panic-only path and recoverable in one click, so left alone here.🤖 Generated with Claude Code
https://claude.ai/code/session_01Y4Aq3X2s6ftafXzmqaN3A8