Skip to content

Commit bd9c32b

Browse files
m-de-graaffclaude
andcommitted
fix(web): stop pre-seeding the sidebar delete batch as already-deleted
`deletedThreadKeys` was seeded with every selected thread before the loop ran, so the first delete saw all its batch mates as gone and removed a worktree they still pointed at. Now that a failure no longer aborts the batch, a thread that fails to delete would keep a live reference to a worktree the loop already removed. Grow the set as deletions land, matching SidebarV2, and deselect only the threads that actually deleted. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
1 parent 2fb0ffc commit bd9c32b

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

‎apps/web/src/components/Sidebar.tsx‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1838,8 +1838,11 @@ const SidebarProjectItem = memo(function SidebarProjectItem(props: SidebarProjec
18381838
if (!confirmed) return;
18391839
}
18401840

1841-
const deletedThreadKeys = new Set(threadKeys);
1842-
const removedThreadKeys: string[] = [];
1841+
// Grown as deletions actually land, never seeded with the whole batch:
1842+
// orphaned-worktree detection must only discount threads that are
1843+
// really gone, or the first delete would treat still-alive batch mates
1844+
// as deleted and remove a worktree they still point at.
1845+
const deletedThreadKeys = new Set<string>();
18431846
let firstError: unknown = null;
18441847
for (const { threadKey, threadRef } of selectedThreadEntries) {
18451848
const result = await deleteThread(threadRef, {
@@ -1851,7 +1854,7 @@ const SidebarProjectItem = memo(function SidebarProjectItem(props: SidebarProjec
18511854
firstError ??= squashAtomCommandFailure(result);
18521855
continue;
18531856
}
1854-
removedThreadKeys.push(threadKey);
1857+
deletedThreadKeys.add(threadKey);
18551858
}
18561859
if (firstError !== null) {
18571860
toastManager.add(
@@ -1862,7 +1865,7 @@ const SidebarProjectItem = memo(function SidebarProjectItem(props: SidebarProjec
18621865
}),
18631866
);
18641867
}
1865-
removeFromSelection(removedThreadKeys);
1868+
removeFromSelection([...deletedThreadKeys]);
18661869
},
18671870
[
18681871
appSettingsConfirmThreadArchive,

0 commit comments

Comments
 (0)