diff --git a/src/browser/components/ProjectSidebar.tsx b/src/browser/components/ProjectSidebar.tsx index 4f73c31d66..94c4f2680b 100644 --- a/src/browser/components/ProjectSidebar.tsx +++ b/src/browser/components/ProjectSidebar.tsx @@ -200,6 +200,7 @@ const ProjectSidebarInner: React.FC = ({ archiveWorkspace: onArchiveWorkspace, renameWorkspace: onRenameWorkspace, beginWorkspaceCreation: onAddWorkspace, + archivedCountByProject, } = useWorkspaceContext(); // Get project state and operations from context @@ -518,34 +519,71 @@ const ProjectSidebarInner: React.FC = ({ Manage secrets - - - - - Remove project - + {(() => { + // Compute workspace counts for removal eligibility + const activeCount = + sortedWorkspacesByProject.get(projectPath)?.length ?? 0; + const archivedCount = archivedCountByProject.get(projectPath) ?? 0; + const canDelete = activeCount === 0 && archivedCount === 0; + + // Build tooltip based on what's blocking deletion + let tooltip: string; + if (canDelete) { + tooltip = "Remove project"; + } else if (archivedCount === 0) { + // Only active workspaces + tooltip = + activeCount === 1 + ? "Delete workspace first" + : `Delete all ${activeCount} workspaces first`; + } else if (activeCount === 0) { + // Only archived workspaces + tooltip = + archivedCount === 1 + ? "Delete archived workspace first" + : `Delete ${archivedCount} archived workspaces first`; + } else { + // Both active and archived + tooltip = `Delete ${activeCount} active + ${archivedCount} archived workspaces first`; + } + + return ( + + + + + {tooltip} + + ); + })()}