- {t(
- 'worktree.delete.nestedChildrenCannotBeKept',
- 'Child workspace folders inside this workspace must be moved outside it before they can be kept.'
- )}
+ {childWorkspaceCount === 0 || !parent
+ ? t(
+ 'worktree.delete.childrenChangedClearPreserve',
+ 'Child workspaces changed. Clear this option to review deletion.'
+ )
+ : t(
+ 'worktree.delete.nestedChildrenCannotBeKept',
+ 'Child workspace folders inside this workspace must be moved outside it before they can be kept.'
+ )}
)}
diff --git a/src/renderer/src/components/sidebar/workspace-actions/deletion/use-detach-worktree-delete-children.ts b/src/renderer/src/components/sidebar/workspace-actions/deletion/use-detach-worktree-delete-children.ts
index 82ed169f6fe..ff455f7449f 100644
--- a/src/renderer/src/components/sidebar/workspace-actions/deletion/use-detach-worktree-delete-children.ts
+++ b/src/renderer/src/components/sidebar/workspace-actions/deletion/use-detach-worktree-delete-children.ts
@@ -50,7 +50,9 @@ export function useDetachWorktreeDeleteChildren({
const [isDetachingChildren, setIsDetachingChildren] = useState(false)
const [detachError, setDetachError] = useState(null)
const canPreserveChildren =
- !!parent && canPreserveWorkspaceDeleteChildren(parent, lineage.descendants, isFolderWorkspace)
+ !!parent &&
+ lineage.descendants.length > 0 &&
+ canPreserveWorkspaceDeleteChildren(parent, lineage.descendants, isFolderWorkspace)
if (!isOpen && (preserveChildren || detachError)) {
setPreserve(false)
diff --git a/src/renderer/src/i18n/locales/en.json b/src/renderer/src/i18n/locales/en.json
index a7b7ea88434..4c47d6cb183 100644
--- a/src/renderer/src/i18n/locales/en.json
+++ b/src/renderer/src/i18n/locales/en.json
@@ -22633,10 +22633,12 @@
"delete": {
"detachingChildren": "Detaching children...",
"childrenPreservedTitle": "Child workspaces will be kept",
+ "childrenCannotBeKeptTitle": "Child workspaces cannot be kept",
"childrenPreservedDescription": "Direct children will become top-level workspaces. Their files, terminals, and nested children will be kept.",
"detachChildren": "Detach and keep child workspaces",
"nestedChildrenCannotBeKept": "Child workspace folders inside this workspace must be moved outside it before they can be kept.",
"childrenChanged": "Child workspaces changed. Review the workspace list and try again.",
+ "childrenChangedClearPreserve": "Child workspaces changed. Clear this option to review deletion.",
"detachFailed": "Could not detach all child workspaces. The parent was not deleted. {{error}}"
}
},
diff --git a/src/shared/plugins/languages/protected-copy-keys.json b/src/shared/plugins/languages/protected-copy-keys.json
index a638ccb9b06..4312ab3e4c9 100644
--- a/src/shared/plugins/languages/protected-copy-keys.json
+++ b/src/shared/plugins/languages/protected-copy-keys.json
@@ -1019,7 +1019,9 @@
"workspaceDeletion.moreActions",
"workspaceDeletion.moreDeleteOptions",
"workspaceDeletion.preferenceSaveFailed",
+ "worktree.delete.childrenCannotBeKeptTitle",
"worktree.delete.childrenChanged",
+ "worktree.delete.childrenChangedClearPreserve",
"worktree.delete.childrenPreservedDescription",
"worktree.delete.childrenPreservedTitle",
"worktree.delete.detachChildren",