fix(worktree): stop the PTY gate from permanently wedging workspace removal (#12153)

Destructive worktree removal proves every PTY is dead before touching the filesystem. When a stop
RPC failed, it re-listed the provider to check whether the PTY had already exited — but on the
same deadline the sweeps had just spent, so it timed out without ever asking and read "could not
verify" as "still live". The sweep spends that budget every run, making the refusal deterministic;
--force never reached the gate, so the workspace was unremovable forever.

- Verification gets its own budget instead of an exhausted remainder.
- Verdicts split into exited / live / unverifiable; the error names the blocking PTY ids and why.
- A reachable escape hatch: allowUnverifiedPtyStop, set only by genuine Force Delete affordances
  and the CLI's --force — never by the force the ordinary delete confirmation already sets — with
  an 'unstopped-pty' classifier reason so the desktop actually offers the button.
- Force also survives a sweep that cannot complete; the non-force path still fails fast.

Fixes #11960
This commit is contained in:
OrcaWin
2026-08-02 19:16:58 -07:00
committed by GitHub
parent 1e46121504
commit 525ffc5ae0
27 changed files with 995 additions and 119 deletions
+2
View File
@@ -280,6 +280,8 @@ export const WORKTREE_HANDLERS: Record<string, CommandHandler> = {
const result = await client.call<RuntimeWorktreeRemoveResult>('worktree.rm', {
worktree: await getRequiredWorktreeSelector(flags, 'worktree', cwd, client),
force: flags.get('force') === true,
// Why (#11960): --force is explicit here, so it may also waive PTY-stop proof.
allowUnverifiedPtyStop: flags.get('force') === true,
runHooks: flags.get('run-hooks') === true
})
printHookWarning(result.result, json)