From ffb0e90ff3e41370c930ee3d5999f1c6d159e276 Mon Sep 17 00:00:00 2001 From: catlog22 Date: Sat, 3 Jan 2026 11:48:14 +0800 Subject: [PATCH] feat(issue): Add user choice for worktree completion (merge/PR/keep) - Replace auto-delete cleanup with AskUserQuestion - Options: Merge to main, Create PR, Keep branch - Prevents accidental loss of worktree commits --- .codex/prompts/issue-execute.md | 54 ++++++++++++++++++++++++++++++--- 1 file changed, 49 insertions(+), 5 deletions(-) diff --git a/.codex/prompts/issue-execute.md b/.codex/prompts/issue-execute.md index 9ccd514c..f329e72d 100644 --- a/.codex/prompts/issue-execute.md +++ b/.codex/prompts/issue-execute.md @@ -32,14 +32,56 @@ cd "${WORKTREE_PATH}" - Main working directory stays clean - Easy cleanup after execution -**Cleanup after completion:** -```bash -# Return to main repo -cd - +**Completion - User Choice:** -# Remove worktree +When all solutions are complete, ask user what to do with the worktree branch: + +```javascript +AskUserQuestion({ + questions: [{ + question: "All solutions completed in worktree. What would you like to do with the changes?", + header: "Merge", + multiSelect: false, + options: [ + { + label: "Merge to main", + description: "Merge worktree branch into main branch and cleanup" + }, + { + label: "Create PR", + description: "Push branch and create a pull request for review" + }, + { + label: "Keep branch", + description: "Keep the branch for manual handling, cleanup worktree only" + } + ] + }] +}) +``` + +**Based on user selection:** + +```bash +# Return to main repo first +MAIN_REPO=$(git worktree list | head -1 | awk '{print $1}') +cd "${MAIN_REPO}" + +# Option 1: Merge to main +git merge "${WORKTREE_NAME}" --no-ff -m "Merge issue queue execution: ${WORKTREE_NAME}" git worktree remove "${WORKTREE_PATH}" git branch -d "${WORKTREE_NAME}" + +# Option 2: Create PR +git push -u origin "${WORKTREE_NAME}" +gh pr create --title "Issue Queue: ${WORKTREE_NAME}" --body "Automated issue queue execution" +git worktree remove "${WORKTREE_PATH}" +# Branch kept on remote + +# Option 3: Keep branch +git worktree remove "${WORKTREE_PATH}" +# Branch kept locally for manual handling +echo "Branch '${WORKTREE_NAME}' kept. Merge manually when ready." ``` ## Execution Flow @@ -326,6 +368,8 @@ ccw issue next When `ccw issue next` returns `{ "status": "empty" }`: +**If running in worktree mode**: Prompt user for merge/PR/keep choice (see "Completion - User Choice" above) before outputting summary. + ```markdown ## Issue Queue Execution Complete