Skip to content

feat: enhanced PR rescue — resolve threads, request reviews, handle conflicts#121

Closed
microsasa wants to merge 8 commits intomainfrom
feat/enhanced-rescue
Closed

feat: enhanced PR rescue — resolve threads, request reviews, handle conflicts#121
microsasa wants to merge 8 commits intomainfrom
feat/enhanced-rescue

Conversation

@microsasa
Copy link
Owner

Enhanced PR Rescue Workflow

Three rescue modes for stuck agent PRs, sorted by progress (approved first):

1. No Copilot review

  • Rebases first if behind main (so Copilot reviews fresh code)
  • Requests Copilot review
  • Stops — lets pipeline run, next cycle picks up

2. Unresolved threads

3. Behind main

  • Approved + threads clear + BEHIND: rebases
  • Removes review-response-attempted label BEFORE push so responder can run on new comments
  • Merge conflicts: adds aw-conflict label, posts comment, skips in future runs

Other changes

  • 15-min cron schedule (catches stuck PRs between merges)
  • PRs sorted by approval status (approved first = closest to done)
  • aw-conflict PRs excluded from processing
  • Re-queries merge state after thread resolution
  • Updated docs and changelog

Review feedback incorporated (from closed PR #118)

Closes #116. Refs #114.

…onflicts

Three rescue modes, sorted by progress (approved PRs first):
1. No Copilot review: rebase if behind main, then request review
2. Unresolved threads: resolve if bot reply is last comment (real
   GraphQL thread IDs, not hallucinated)
3. Behind main: rebase, remove review-response-attempted label
   BEFORE push so responder can run on new comments

Plus: 15-min cron schedule, aw-conflict label on merge conflicts,
skip conflicted PRs in future runs.

Incorporates review feedback from Gemini 3 Pro and GPT-5 Codex:
- Rebase before requesting review (not after)
- Remove label before push (not after)
- Label merge conflicts instead of silent retry loop
- Explicit sort by approval status
- Check last comment author (not just any reply exists)

Closes #116

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 16, 2026 02:51
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Changelog: PR #119 label gate fix, pull_request_review ref finding
- Agentic workflows: updated activation section with if: condition,
  corrected pitfall #6 (head branch, not default branch),
  added history entry for 2026-03-16

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Enhances the repository’s PR Rescue automation to unstick agent-created PRs across multiple failure modes (missing Copilot review, unresolved review threads, behind-main rebases, and merge conflicts), and updates documentation/changelog to reflect the new behavior.

Changes:

  • Expand .github/workflows/pr-rescue.yml to: run on a 15-min cron, prioritize approved PRs, request Copilot reviews when missing, resolve addressed threads via GraphQL, and label/comment conflicted PRs (aw-conflict).
  • Update docs/agentic-workflows.md to document the new PR Rescue stages and the thread-ID limitation background.
  • Add an append-only changelog entry describing the enhanced rescue workflow.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.

File Description
.github/workflows/pr-rescue.yml Implements the enhanced rescue logic (cron, sorting, review request, thread resolution, conflict labeling).
docs/agentic-workflows.md Updates pipeline documentation to match the new rescue behavior and known limitations.
docs/changelog.md Records the new PR Rescue capability in the repo-level changelog.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sasa Junuzovic and others added 2 commits March 15, 2026 20:01
…ad limit to 100

Address Copilot review comments on PR #121:
- Guard GraphQL calls for unresolved_threads and remaining count
- Guard re-queries of mergeStateStatus/reviewDecision
- Use git checkout -B to handle fresh runners deterministically
- Bump reviewThreads pagination from 50 to 100, add totalCount field

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Add -- separator to git fetch/checkout/push to prevent branch names
  starting with - from being interpreted as flags
- Add totalCount check to warn when threads exceed pagination cap

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 16, 2026 03:05
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the PR Rescue automation to handle multiple “stuck PR” scenarios (missing Copilot review, unresolved threads, behind main, conflicts), and documents these workflow behaviors in the repo docs/changelog.

Changes:

  • Expanded .github/workflows/pr-rescue.yml to add a 15-minute cron, thread resolution via GraphQL, Copilot review requests, and conflict labeling/comments.
  • Updated workflow documentation in docs/agentic-workflows.md to reflect the new rescue behavior and label-gating rationale.
  • Added changelog entries describing the label-gate fix and the enhanced PR rescue workflow.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
.github/workflows/pr-rescue.yml Implements the enhanced rescue modes (review request, thread resolution, rebase, conflict handling) plus cron scheduling and sorting.
docs/agentic-workflows.md Documents the updated PR rescue behavior and related workflow activation details.
docs/changelog.md Records the new rescue workflow behavior and recent workflow gating changes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sasa Junuzovic and others added 2 commits March 15, 2026 20:08
- git checkout -B doesn't use -- separator (not a path operation)
- GitHub GraphQL may reject first:0; use first:1 for totalCount only

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Review-responder posts replies using GH_AW_WRITE_TOKEN (a PAT),
so replies appear as 'microsasa', not 'github-actions[bot]'.
Without this fix, rescue would never resolve any thread.

Found by OpenAI Codex review.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 16, 2026 03:19
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Enhances the repo’s “PR Rescue” automation to unstick agent-created PRs across multiple failure modes (missing Copilot review, unresolved threads, behind main, conflicts) and updates repo documentation/changelog to reflect the new behavior.

Changes:

  • Expand PR Rescue workflow to (1) request Copilot review, (2) resolve review threads via GraphQL, (3) rebase approved PRs that are behind main, plus conflict labeling and 15-min cron.
  • Update agentic workflow docs to describe the new PR Rescue behavior and related operational findings.
  • Add changelog entries documenting the workflow enhancements and label-gating discovery/fix history.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
.github/workflows/pr-rescue.yml Implements multi-mode rescue logic (review request, thread resolution, rebase, conflict labeling) and adds cron scheduling.
docs/agentic-workflows.md Updates the pipeline documentation to match the enhanced PR Rescue behavior and recent workflow gating learnings.
docs/changelog.md Records the new PR Rescue behavior and related workflow gating findings in the repo-level changelog.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

- Resolve PAT owner login at runtime via gh api user
- Remove hardcoded 'microsasa' from thread-resolution check
- Fix log message: 'bot' → 'responder (login)'

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@microsasa
Copy link
Owner Author

Abandoning bash-based approach. Rewriting as gh-aw agent workflow for better maintainability and error handling.

@microsasa microsasa closed this Mar 16, 2026
@microsasa microsasa deleted the feat/enhanced-rescue branch March 16, 2026 07:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enhanced PR Rescue: resolve threads + request reviews + rebase behind-main

2 participants