From 172ed2dd74af7b4c78315424b10edfb3b2e8591a Mon Sep 17 00:00:00 2001 From: NagyVikt Date: Tue, 28 Apr 2026 02:55:02 +0200 Subject: [PATCH] fix(branch-finish): rephrase pending-PR cleanup message so claude doesn't claim the worktree is on disk MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The old message read "Branch cleanup skipped for now." That sounded like a present-tense fact ("worktree still here"), but in practice the autofinish watcher (or `gx worktree prune --include-pr-merged`) prunes the worktree shortly after the PR merges — so the worktree may be *gone* by the time the agent reads the line. The new message: PR pending review/check policy. Worktree retained for now; the autofinish watcher (or 'gx worktree prune --include-pr-merged --delete-branches') will prune it after merge. Verify with 'git worktree list' before claiming the worktree is still on disk. Why: agents (Claude in particular) were reading "skipped for now" as proof of presence and recommending a follow-up `gx branch finish ... --cleanup` to users whose worktree had already been pruned — confusing output and wasted turns. Updates the matching regex in `src/doctor/index.js#doctorFinishFlowIsPending` to anchor on "PR pending review/check policy." so doctor still recognises this state. The same string lives in `templates/scripts/agent-branch-finish.sh` (the canonical script templated into managed repos) and is updated alongside. --- scripts/agent-branch-finish.sh | 2 +- src/doctor/index.js | 2 +- templates/scripts/agent-branch-finish.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/agent-branch-finish.sh b/scripts/agent-branch-finish.sh index 933e21a..9b2abf4 100755 --- a/scripts/agent-branch-finish.sh +++ b/scripts/agent-branch-finish.sh @@ -831,7 +831,7 @@ if [[ "$PUSH_ENABLED" -eq 1 ]]; then echo "[agent-branch-finish] Merge did not complete within wait window; keeping branch open." >&2 exit 1 fi - echo "[agent-branch-finish] Merge pending review/check policy. Branch cleanup skipped for now." >&2 + echo "[agent-branch-finish] PR pending review/check policy. Worktree retained for now; the autofinish watcher (or 'gx worktree prune --include-pr-merged --delete-branches') will prune it after merge. Verify with 'git worktree list' before claiming the worktree is still on disk." >&2 exit 0 fi echo "[agent-branch-finish] PR flow failed." >&2 diff --git a/src/doctor/index.js b/src/doctor/index.js index 334b934..4240aa9 100644 --- a/src/doctor/index.js +++ b/src/doctor/index.js @@ -310,7 +310,7 @@ function extractAgentBranchFinishPrUrl(output) { function doctorFinishFlowIsPending(output) { return ( /\[agent-branch-finish\] PR merge not completed yet; leaving PR open\./.test(output) || - /\[agent-branch-finish\] Merge pending review\/check policy\. Branch cleanup skipped for now\./.test(output) || + /\[agent-branch-finish\] PR pending review\/check policy\./.test(output) || /\[agent-branch-finish\] PR auto-merge enabled; waiting for required checks\/reviews\./.test(output) ); } diff --git a/templates/scripts/agent-branch-finish.sh b/templates/scripts/agent-branch-finish.sh index 933e21a..9b2abf4 100755 --- a/templates/scripts/agent-branch-finish.sh +++ b/templates/scripts/agent-branch-finish.sh @@ -831,7 +831,7 @@ if [[ "$PUSH_ENABLED" -eq 1 ]]; then echo "[agent-branch-finish] Merge did not complete within wait window; keeping branch open." >&2 exit 1 fi - echo "[agent-branch-finish] Merge pending review/check policy. Branch cleanup skipped for now." >&2 + echo "[agent-branch-finish] PR pending review/check policy. Worktree retained for now; the autofinish watcher (or 'gx worktree prune --include-pr-merged --delete-branches') will prune it after merge. Verify with 'git worktree list' before claiming the worktree is still on disk." >&2 exit 0 fi echo "[agent-branch-finish] PR flow failed." >&2