Repository navigation
Description
What happened
On Windows, I delete a thread and choose to delete its worktree too. T3 shows:
Could not remove t3-xxxxxxxx. Git command failed in GitVcsDriver.removeWorktree (<project root>): fatal: failed to delete '<t3 worktrees>\<project>\t3-xxxxxxxx'
The thread is deleted, but the worktree stays on disk, with part of its files deleted. If I retry a few minutes later, the remove works.
Diagnosis
useThreadActions.ts waits for stopThreadSession, then calls vcs.removeWorktree at once. The stop only signals the provider. The Claude adapter's closeClaudeQuery calls queryRuntime.close() and does not wait for the process tree to exit. On Windows, a folder that is a process's working directory, or that has open files, cannot be deleted. So removeLinkedWorktree (fileSystem.remove(worktreePath, { recursive: true })) fails partway and puts .git back.
The processes that kept the folder open:
- Claude thread:
claude.exe, and a project stdio MCP server thatpnpmstarted (noderunningtsx, a childnode, andesbuild.exe). - Codex thread:
codex.exe app-server, started by T3 with its working directory in the worktree, with child processesnode_repl.exe,node.exe(cua-repl) and an MCPnode.exe.
handle.exe showed these processes holding the worktree folder at the time of the failure. A few minutes later, it showed no handles and the remove worked. Automatic cleanup after settle runs much later, so it probably does not hit this.
Steps to reproduce
- On Windows, open a project whose agent config starts a stdio MCP server, or use a Codex thread.
- Start a new thread in a new worktree. Send one message and let the turn complete.
- Delete the thread and confirm "Delete the worktree too?".
- T3 shows "failed to delete". The folder stays, with part of its files deleted.
Version
0.1.5-nightly.20261029.3877 (desktop, local server)
Environment
Windows 11 x64 (10.0.26100), Node v24.22.1, Git 2.56.0.windows.3, Claude Code 2.1.312, codex-cli 0.165.0
Evidence
15:46:42.860 provider (claudeAgent): session stop for the thread
15:46:42.957 vcs.removeWorktree start
15:46:42.998 GitWorkflowService.removeWorktree Failure: GitCommandError: fatal: failed to delete '<t3 worktrees>\<project>\t3-18261db2'
Related issues
- [Bug]: Codex subagent child threads and stuck-active root threads are never unsubscribed, so their MCP servers live until the app-server exits #21354: Codex MCP servers live until the
app-serverexits. Related, but that issue is about process leaks, not removal order. - [Bug]: MCP plugin processes (bun server.ts) are never killed when closing conversations #3089 (closed): MCP processes not killed on conversation close.
- [Bug]: Windows: hardcoded 15s timeout in removeWorktree is unreachable for large monorepos, stranding worktree directories #5614, Storage cleanup cannot remove worktrees that have initialized git submodules #20355, [Bug]: Removing a worktree on Windows follows directory junctions and deletes the files they point to #14990 (closed): other worktree-remove failures on Windows. None of them is about running processes.
Fix applied or workaround
Retry the delete after the provider processes exit, or stop them first (for example, taskkill /PID <pid> /T /F), then run git worktree remove --force.
Possible fix: before the remove, wait for the thread's provider process tree to exit, and kill the tree on Windows. Or retry the remove with a backoff.
Filed by
Claude Code (Claude Opus 5.5), from t3 triage.
Activity
christopher-buss commentedon Oct 29, 2026
Filed via
t3 triage. Thevia-triagelabel could not be applied because the filing account has no triage access. Could a maintainer add it?