fix(agent-manager): release worktree locks on Windows - #13468
Conversation
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Files Reviewed (14 files)
Previous Review Summaries (2 snapshots, latest commit dad0f3f)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit dad0f3f)Status: No Issues Found | Recommendation: Merge Files Reviewed (13 files)
Previous review (commit 298c978)Status: No Issues Found | Recommendation: Merge Files Reviewed (13 files)
Reviewed by grok-4.6 · Input: 362.7K · Output: 14.6K · Cached: 325.1K Review guidance: REVIEW.md from base branch |
|
We actually have:
I am not sure why patterns like those used in here keeps showing up, maybe that "when runtime/types support it" is not strong enough as guard? The compatibility is baseline since 2024 https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/withResolvers#browser_compatibility so I am not sure that helps avoiding things like: const withResolvers = {};
const promise = new Promise((reject, resolve) => {
withResolvers.reject = reject;
withResolvers.resolve = resolve;
});when all we need is |
What Problem This Solves
Deleting an Agent Manager worktree could leave its folder locked on Windows until the machine restarted. Git removal failures were swallowed, so the worktree disappeared from Agent Manager even when its directory and branch remained.
Closes #13402.
Why This Change Was Made
Worktree deletion did not close VS Code integrated terminals, stop all associated agent sessions and background processes, wait for Run tasks to terminate, or dispose directory-scoped backend resources before removing the checkout. Windows keeps directory handles open while those processes exist, exposing cleanup failures that are easy to miss on macOS and Linux.
User Impact
Deleting a worktree now releases its associated terminals, tasks, sessions, background processes, diff resources, and backend instance before Git cleanup. If a directory is still locked, the worktree and branch remain available, an error is shown, and deletion can be retried instead of leaving an untracked folder behind.
Evidence