File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 101101
102102 let openingBranches = $state <Set <string >>(new Set ());
103103 let visibleWorktrees = $derived (worktrees );
104+ let selectableWorktrees = $derived (
105+ visibleWorktrees .filter ((w ) => ! removingBranches .has (w .branch )),
106+ );
104107 let selectedWorktree = $derived (
105- visibleWorktrees .find ((w ) => w .branch === selectedBranch ),
108+ selectedBranch && ! removingBranches .has (selectedBranch )
109+ ? visibleWorktrees .find ((w ) => w .branch === selectedBranch )
110+ : undefined ,
106111 );
107112 let canConnect = $derived (!! selectedBranch && selectedWorktree ?.mux === " ✓" );
108113
111116 return ;
112117 }
113118
114- if (visibleWorktrees .length === 0 ) {
119+ if (selectableWorktrees .length === 0 ) {
115120 selectedBranch = null ;
116121 return ;
117122 }
118123
119124 // Prefer an open worktree, fall back to the first one.
120- const open = visibleWorktrees .find ((w ) => w .mux === " ✓" );
121- selectedBranch = (open ?? visibleWorktrees [0 ]).branch ;
125+ const open = selectableWorktrees .find ((w ) => w .mux === " ✓" );
126+ selectedBranch = (open ?? selectableWorktrees [0 ]).branch ;
122127 });
123128
124129 $effect (() => {
You can’t perform that action at this time.
0 commit comments