Skip to content

Commit cabbeac

Browse files
centdixclaude
andcommitted
fix: avoid reopening removing worktrees
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 671bf22 commit cabbeac

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

frontend/src/App.svelte

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,13 @@
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
@@ -111,14 +116,14 @@
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(() => {

0 commit comments

Comments
 (0)