From 88532c1feb2a8955364b840495fe5f2b4467faa8 Mon Sep 17 00:00:00 2001 From: Rohan Kumawat Date: Sat, 11 Apr 2026 06:50:13 +0100 Subject: [PATCH] fix(web): allow removing projects that still contain threads Previously, attempting to remove a project with existing threads showed a blocking warning toast ("Project is not empty") and refused to proceed, forcing users to manually delete every thread first. Now the confirmation dialog deletes all threads in the project automatically before removing it. The dialog also clarifies that files on disk are not affected. Co-Authored-By: Claude Opus 4.6 (1M context) --- apps/web/src/components/Sidebar.tsx | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/apps/web/src/components/Sidebar.tsx b/apps/web/src/components/Sidebar.tsx index c5725c6d0d..98f5061b6a 100644 --- a/apps/web/src/components/Sidebar.tsx +++ b/apps/web/src/components/Sidebar.tsx @@ -1318,19 +1318,25 @@ const SidebarProjectItem = memo(function SidebarProjectItem(props: SidebarProjec } if (clicked !== "delete") return; - if (projectThreads.length > 0) { - toastManager.add({ - type: "warning", - title: "Project is not empty", - description: "Delete all threads in this project before removing it.", - }); - return; - } - - const confirmed = await api.dialogs.confirm(`Remove project "${project.name}"?`); + const confirmed = await api.dialogs.confirm( + [ + `Remove project "${project.name}"?`, + projectThreads.length > 0 + ? `This will also delete ${projectThreads.length} thread${projectThreads.length === 1 ? "" : "s"} in this project.` + : null, + "Your files on disk will not be affected.", + ] + .filter(Boolean) + .join("\n"), + ); if (!confirmed) return; try { + // Delete all threads in the project first + for (const thread of projectThreads) { + await deleteThread(scopeThreadRef(thread.environmentId, thread.id)); + } + const projectDraftThread = getDraftThreadByProjectRef( scopeProjectRef(project.environmentId, project.id), ); @@ -1363,12 +1369,13 @@ const SidebarProjectItem = memo(function SidebarProjectItem(props: SidebarProjec clearComposerDraftForThread, clearProjectDraftThreadId, copyPathToClipboard, + deleteThread, getDraftThreadByProjectRef, project.cwd, project.environmentId, project.id, project.name, - projectThreads.length, + projectThreads, suppressProjectClickForContextMenuRef, ], );