Revert PR #2908: workspace deletion fix#2922
Conversation
📝 WalkthroughWalkthroughThis pull request refactors external worktree detection by removing the Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
apps/desktop/src/lib/trpc/routers/workspaces/procedures/delete.ts (1)
489-551:⚠️ Potential issue | 🟡 MinorPath comparison in
worktree/deleteis inconsistent withworkspace/delete.The
workspace/deletemutation (lines 277-280) usesnormalizePathfor both the worktree path and external worktree paths when checkingisActuallyExternal. However,worktree/deletecompares raw paths directly without normalization:const isActuallyExternal = externalWorktrees.some( (wt) => wt.path === worktree.path, // No normalization );Since
listExternalWorktreesreturns raw, unnormalized paths fromgit worktree list --porcelainoutput, this comparison could fail ifworktree.pathin the database was stored with symlinks resolved. This inconsistency means the same worktree could be handled differently depending on which deletion path is used.🔧 Suggested fix for consistency
+ const worktreePathNorm = normalizePath(worktree.path); const isActuallyExternal = externalWorktrees.some( - (wt) => wt.path === worktree.path, + (wt) => normalizePath(wt.path) === worktreePathNorm, );🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/desktop/src/lib/trpc/routers/workspaces/procedures/delete.ts` around lines 489 - 551, The path comparison in worktree/delete is brittle—change the isActuallyExternal check to compare normalized paths like workspace/delete does: call normalizePath on worktree.path and on each externalWorktrees[].path (the same function used elsewhere) before comparing; update the logic around listExternalWorktrees, externalWorktrees, and the isActuallyExternal predicate so normalization occurs consistently (refer to normalizePath, listExternalWorktrees, isActuallyExternal, and worktree.path to locate where to apply the fix).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@apps/desktop/src/lib/trpc/routers/workspaces/procedures/delete.ts`:
- Around line 489-551: The path comparison in worktree/delete is brittle—change
the isActuallyExternal check to compare normalized paths like workspace/delete
does: call normalizePath on worktree.path and on each externalWorktrees[].path
(the same function used elsewhere) before comparing; update the logic around
listExternalWorktrees, externalWorktrees, and the isActuallyExternal predicate
so normalization occurs consistently (refer to normalizePath,
listExternalWorktrees, isActuallyExternal, and worktree.path to locate where to
apply the fix).
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 10c9e5ee-2ba2-40d4-b59e-6c1a58da26e1
⛔ Files ignored due to path filters (1)
bun.lockis excluded by!**/*.lock
📒 Files selected for processing (6)
apps/desktop/src/lib/trpc/routers/workspaces/procedures/create.tsapps/desktop/src/lib/trpc/routers/workspaces/procedures/delete.tsapps/desktop/src/lib/trpc/routers/workspaces/procedures/external-worktree-import.test.tsapps/desktop/src/lib/trpc/routers/workspaces/procedures/git-status.tsapps/desktop/src/lib/trpc/routers/workspaces/utils/git.tsapps/desktop/src/lib/trpc/routers/workspaces/utils/workspace-creation.ts
💤 Files with no reviewable changes (1)
- apps/desktop/src/lib/trpc/routers/workspaces/procedures/create.ts
🧹 Preview Cleanup CompleteThe following preview resources have been cleaned up:
Thank you for your contribution! 🎉 |
Summary
Reverts PR #2908 which introduced changes to workspace deletion behavior.
Reason for Revert
This PR reverts the changes made in #2908 that modified how workspace deletion handles disk cleanup and external worktree detection.
Original PR
Changes Reverted
listExternalWorktrees→listAllGitWorktreeslistExternalWorktrees(mainRepoPath, projectId)implementationcreatedBySupersetflag gatingFiles Affected
apps/desktop/src/lib/trpc/routers/workspaces/procedures/create.tsapps/desktop/src/lib/trpc/routers/workspaces/procedures/delete.tsapps/desktop/src/lib/trpc/routers/workspaces/procedures/external-worktree-import.test.tsapps/desktop/src/lib/trpc/routers/workspaces/procedures/git-status.tsapps/desktop/src/lib/trpc/routers/workspaces/utils/git.tsapps/desktop/src/lib/trpc/routers/workspaces/utils/workspace-creation.tsbun.lockTesting
Summary by cubic
Reverts #2908 to restore the previous workspace deletion behavior and safety checks. Disk deletion now only happens for worktrees created by Superset; external worktrees are never removed from disk.
Bug Fixes
createdBySupersetgate for on-disk deletion; external worktrees only remove DB records.listExternalWorktreestolistExternalWorktrees(mainRepoPath)and move DB filtering to callers (updatedgit-status, creation/import, and tests).Dependencies
@superset/desktopversion inbun.lockto 1.3.2.Written for commit 35e3908. Summary will update on new commits.
Summary by CodeRabbit
Release Notes
Bug Fixes
Improvements