[Bug] "Remove this worktree" button silently fails after commits; exit prompt sometimes missing

Resolved 💬 3 comments Opened Apr 15, 2026 by asportnoy Closed May 25, 2026

Bug Description

The end-of-session "Remove this worktree" button fails silently any time HEAD has moved from the original commit recorded at worktree creation. The internal check
compares current HEAD against originalHeadCommit and returns errorCode:4 before git worktree remove is ever attempted — the user sees nothing happen.

This makes the feature nearly useless in practice: the entire point of a worktree is to do work in it, and doing work means committing. Once you've committed (even
if pushed and merged), the only path to remove the worktree is to shell out to git worktree remove --force manually.

Separate issue: the exit prompt sometimes doesn't appear at all at session end, even when the session is clearly in a worktree (created via EnterWorktree earlier in
the session). The prompt-gating logic checks currentSessionWorktree !== null, but this flag appears to get cleared or lost under some conditions — after long
sessions, after compaction, or after background agents run. When this happens there's no way to reach the Remove/Keep choice at all; the session just prints a
farewell and exits, leaving the worktree behind silently.

Expected behavior:

  1. The Remove button should succeed when the branch is clean and pushed to its upstream (even with commits ahead of the original HEAD). It's safe — nothing is lost.
  2. git checkout <otherbranch> inside the worktree should also not block removal.
  3. If there are genuinely uncommitted/unpushed changes, either (a) surface the error inline with a "Remove anyway" option, or (b) gate on working-tree cleanliness +

upstream-tracking state rather than originalHeadCommit equality.

  1. The exit prompt should appear reliably whenever the session was created in or entered a worktree, regardless of conversation length or background agent activity.

At minimum: surface the error instead of silently no-oping. Silent failures plus missing prompts are the worst UX combination.

Repro (no-op): create a worktree with EnterWorktree, commit any change, push, click "Remove this worktree" at session end — nothing happens.

Repro (missing prompt): less reproducible; happens intermittently on long worktree sessions.

Environment Info

  • Platform: darwin
  • Terminal: iTerm.app
  • Version: 2.1.109
  • Feedback ID: cab63afa-b597-45f2-91dd-7624d128c298

Errors

[{"error":"Error: NON-FATAL: Lock acquisition failed for /Users/albert/.local/share/claude/versions/2.1.109 (expected in multi-process scenarios)\n    at yU_ (/$bunfs/root/src/entrypoints/cli.js:2342:2153)\n    at Vs6 (/$bunfs/root/src/entrypoints/cli.js:2342:1233)\n    at processTicksAndRejections (native:7:39)","timestamp":"2026-04-15T19:07:59.564Z"},{"error":"Error: ECONNREFUSED\n    at from (/$bunfs/root/src/entrypoints/cli.js:107:7862)\n    at <anonymous> (/$bunfs/root/src/entrypoints/cli.js:115:12925)\n    at emitError (node:events:43:23)\n    at <anonymous> (/$bunfs/root/src/entrypoints/cli.js:114:1149)\n    at emitError (node:events:43:23)\n    at <anonymous> (node:_http_client:253:22)\n    at processTicksAndRejections (native:7:39)","timestamp":"2026-04-15T19:08:14.583Z"},{"error":"Error: ECONNREFUSED\n    at from (/$bunfs/root/src/entrypoints/cli.js:107:7862)\n    at <anonymous> (/$bunfs/root/src/entrypoints/cli.js:115:12925)\n    at emitError (node:events:43:23)\n    at <anonymous> (/$bunfs/root/src/entrypoints/cli.js:114:1149)\n    at emitError (node:events:43:23)\n    at <anonymous> (node:_http_client:253:22)\n    at processTicksAndRejections (native:7:39)\n    at request (/$bunfs/root/src/entrypoints/cli.js:117:2467)\n    at processTicksAndRejections (native:7:39)","timestamp":"2026-04-15T19:08:55.600Z"},{"error":"Error: ECONNREFUSED\n    at from (/$bunfs/root/src/entrypoints/cli.js:107:7862)\n    at <anonymous> (/$bunfs/root/src/entrypoints/cli.js:115:12925)\n    at emitError (node:events:43:23)\n    at <anonymous> (/$bunfs/root/src/entrypoints/cli.js:114:1149)\n    at emitError (node:events:43:23)\n    at <anonymous> (node:_http_client:253:22)\n    at processTicksAndRejections (native:7:39)\n    at request (/$bunfs/root/src/entrypoints/cli.js:117:2467)\n    at processTicksAndRejections (native:7:39)","timestamp":"2026-04-15T19:09:18.518Z"},{"error":"Error: ECONNREFUSED\n    at from (/$bunfs/root/src/entrypoints/cli.js:107:7862)\n    at <anonymous> (/$bunfs/root/src/entrypoints/cli.js:115:12925)\n    at emitError (node:events:43:23)\n    at <anonymous> (/$bunfs/root/src/entrypoints/cli.js:114:1149)\n    at emitError (node:events:43:23)\n    at <anonymous> (node:_http_client:253:22)\n    at processTicksAndRejections (native:7:39)\n    at request (/$bunfs/root/src/entrypoints…

Note: Content was truncated.

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗