fix(workspaces): allow removing projects when repo folder was deleted on disk#1
Closed
bilalbayram wants to merge 1 commit intofeat/settings-shortcuts-searchfrom
Closed
Conversation
When a main workspace directory is deleted outside CodexMonitor, removal still attempted `git worktree remove` using the missing parent repo as current_dir. That produced `Failed to run git: No such file or directory (os error 2)`, caused child failures to accumulate, and blocked parent workspace removal. This patch updates shared workspaces core removal paths to treat missing parent repo folders as a filesystem-only cleanup flow: - In `remove_workspace_core`, skip git worktree remove/prune when parent path is not an existing directory, and remove child worktree folders directly. - In `remove_worktree_core`, skip git worktree remove/prune when parent path is missing and remove the worktree folder directly. - Added regression tests covering both parent-project removal and single-worktree removal when the parent repo folder no longer exists; tests assert the operation succeeds and git is not invoked. Validation run: - cargo test --manifest-path src-tauri/Cargo.toml remove_workspace_succeeds_when_parent_repo_folder_is_missing - cargo test --manifest-path src-tauri/Cargo.toml remove_worktree_succeeds_when_parent_repo_folder_is_missing - cargo check --manifest-path src-tauri/Cargo.toml - npm run typecheck
Owner
Author
|
Superseded by upstream PR: Dimillian#421 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix workspace/worktree removal when repositories are deleted directly from disk (outside the app), so stale entries can still be removed from
Projects.User-visible Problem
If a parent repository folder is deleted from the filesystem and the user then tries to remove that project in CodexMonitor, removal can fail with errors like:
Failed to remove one or more worktrees; parent workspace was not removed.Failed to run git: No such file or directory (os error 2)This leaves stale project/worktree entries in the app.
Root Cause
remove_workspace_coreandremove_worktree_coreattempted git worktree commands unconditionally when the child worktree path existed.Those commands run with
current_dirset to the parent repo path. When the parent directory has already been deleted, process spawn fails at the OS level (os error 2) before git can return a normal semantic worktree error.Because that OS error does not match
is_missing_worktree_error, the removal flow treated it as a hard failure (or accumulated child failures), and parent workspace deletion could be blocked.What Changed
remove_workspace_corenow checks whether the parent repo path exists as a directory.worktree removecalls.worktree prune.remove_worktree_corenow applies the same missing-parent-path behavior for single worktree removal.Why This Is Safe
Regression Tests Added
Added tests in
src-tauri/src/workspaces/tests.rs:remove_workspace_succeeds_when_parent_repo_folder_is_missingremove_worktree_succeeds_when_parent_repo_folder_is_missingBoth tests assert:
Validation
Executed:
cargo test --manifest-path src-tauri/Cargo.toml remove_workspace_succeeds_when_parent_repo_folder_is_missingcargo test --manifest-path src-tauri/Cargo.toml remove_worktree_succeeds_when_parent_repo_folder_is_missingcargo check --manifest-path src-tauri/Cargo.tomlnpm run typecheckAll passed.
Files Changed
src-tauri/src/shared/workspaces_core/crud_persistence.rssrc-tauri/src/shared/workspaces_core/worktree.rssrc-tauri/src/workspaces/tests.rs