Skip to content
Source
Sign inSign up
pingdotgg/t3code

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 intomain fromrefs/pull/6594/headopened View on GitHub

Showing 4 changed files with 113 additions and 7 deletions (loading 2).

x
0 of 4 viewed, 4 left
41 additions and 4 deletionsapps/web/src/components/Sidebar.tsxModified
View file
@@ -1700,6 +1700,7 @@
reorderPinnedThread,
archiveThread,
deleteThread,
+ collectOrphanedWorktreePathsForThreads,
} = useThreadActions();
const updateThreadMetadata = useAtomCommand(threadEnvironment.updateMetadata, {
reportFailure: false,
@@ -2951,16 +2952,51 @@
if (confirmed._tag === "Failure" || !confirmed.value) return;
+ const deleteTargets = threadKeys.flatMap((threadKey) => {
+ const thread = threadByKeyRef.current.get(threadKey);
+ return thread
+ ? [{ threadKey, threadRef: scopeThreadRef(thread.environmentId, thread.id) }]
+ : [];
+ });
+ // Asked once for the whole batch. Left to itself each deleteThread call
+ // opens its own worktree confirmation, so a ten-row selection meant ten
+ // prompts with a round trip of deletion work between them.
+ const orphanedWorktreePathKeys = collectOrphanedWorktreePathsForThreads(
+ deleteTargets.map(({ threadRef }) => threadRef),
+ );
+ // The answer travels with the exact paths it was given for, so a worktree
+ // that only becomes orphaned mid-batch still gets its own prompt.
+ let worktreeBatch: { decision: "delete" | "keep"; pathKeys: ReadonlySet<string> } = {
+ decision: "keep",
+ pathKeys: orphanedWorktreePathKeys,