fix(web): improve batch thread deletion UX, ask for worktrees deletion confirmation once instead of going one by one #6594
Closedartieeg(GitHub profile, opens in a new tab)wants to merge 6 commits into
main fromrefs/pull/6594/headopened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
- apps/web/src/components/Sidebar.tsx line 2912OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -2875,10 +2896,17 @@2896+ : `There are ${orphanedWorktreeCount} worktrees linked only to the threads you're deleting.`,2897+ ].join("\n"),2898+ { variant: "destructive" },2899+ ),2900+ );2901+ if (confirmedWorktrees._tag === "Failure") return;2902+ worktreeDecision = confirmedWorktrees.value ? "delete" : "keep";2903+ }28752904 // Grown as deletions actually land, never seeded with the whole batch:28762905 // orphaned-worktree detection must only discount threads that are28772906 // really gone, or the first delete would treat still-alive batch mates28782907 // as deleted and remove a worktree they still point at.28792908 const deletedThreadKeys = new Set<string>();2880- for (const threadKey of threadKeys) {2881- const thread = threadByKeyRef.current.get(threadKey);2882- if (!thread) continue;2883- const result = await deleteThread(scopeThreadRef(thread.environmentId, thread.id), {2909+ for (const { threadKey, threadRef } of deleteTargets) {2910+ const result = await deleteThread(threadRef, {28842911 deletedThreadKeys,2912+ worktreeDecision,
artieeg(GitHub profile, opens in a new tab) changed the title
artieeg(GitHub profile, opens in a new tab) changed the title
artieeg(GitHub profile, opens in a new tab) changed the title
- apps/web/src/hooks/useThreadActions.ts line 311OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -271,0 +291,21 @@291+ const paths = new Set<string>();292+ for (const [environmentId, threadIds] of threadIdsByEnvironment) {293+ const threads = readEnvironmentThreadRefs(environmentId).flatMap((ref) => {294+ const shell = readThreadShell(ref);295+ return shell === null ? [] : [shell];296+ });297+ // Removal needs the owning project to resolve, so threads without one298+ // must not inflate the count the confirmation prompt quotes.299+ const removableThreadIds = new Set(300+ threads.flatMap((shell) =>301+ threadIds.has(shell.id) &&302+ readProject({ environmentId, projectId: shell.projectId }) !== null303+ ? [shell.id]304+ : [],305+ ),306+ );307+ for (const path of getOrphanedWorktreePathsForThreads(threads, removableThreadIds)) {308+ paths.add(path);309+ }310+ }311+ return paths;
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes
t3dotgg(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.


Important
Review skipped#
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID:
9140dbbb-49d1-4b02-b906-0c19b9cc13cfYou can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share