Skip to content

feat: Autofix CI failures and merge conflicts#137

Open
JuliusWallblom wants to merge 6 commits into
mainfrom
fix/autofix-ci-and-merge-conflicts
Open

feat: Autofix CI failures and merge conflicts#137
JuliusWallblom wants to merge 6 commits into
mainfrom
fix/autofix-ci-and-merge-conflicts

Conversation

@JuliusWallblom

Copy link
Copy Markdown
Contributor

Summary

  • Adds failed CI webhook handling for check_run and status events so autofix can respond to failing jobs on PR heads.
  • Adds merge-conflict detection before review by attempting a base-branch merge in the PR checkout and resolving conflicts through autofix.
  • Adds dedicated CI and merge-conflict prompts, PR summary comments, review accounting, and GitHub client helpers for CI context.

Validation

  • bun run typecheck (apps/review-agent)
  • bun test (apps/review-agent)
  • bun test (packages/prompts)
  • bunx biome check on touched TypeScript files
  • git diff --check origin/main...HEAD

@opendiff-agent

opendiff-agent Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

OpenDiff Summary

What This PR Changes

This PR extends apps/review-agent/src/index.ts and apps/review-agent/src/webhook/triage-handler.ts so the review agent can enqueue autofix jobs from failing check_run and status webhooks, gather CI context via new GitHub client helpers, and attempt a synthetic base-branch merge before normal PR review. It also adds prompt plumbing and accounting for CI-failure and merge-conflict autofix flows, plus summary comments and tests around the new queueing and triage behavior. The main effect is that CI failures and merge conflicts can now trigger dedicated remediation paths before or alongside the existing review flow.

Review Judgement

OpenDiff completed the review and found 2 warnings to consider before merging.

Open Issues Across Reviews

  • ⚠️ 2 warnings

New Issues

  • apps/review-agent/src/index.ts:755 review still runs after unresolved merge conflict
  • apps/review-agent/src/index.ts:388 one bad associated PR aborts CI autofix resolution

Addressed Since Earlier Reviews

  • apps/review-agent/src/index.ts:383 check_run only considers the first associated PR
  • apps/review-agent/src/index.ts:720 merge-conflict detection is disabled with autofix

Rating: 80/100
Confidence: 82/100

Reviewed by opendiff

@opendiff-agent opendiff-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

## Status Update

This PR expands the review agent to react to failing CI signals and merge conflicts, adding new webhook handling in apps/review-agent/src/index.ts, GitHub client helpers for associated PRs and check annotations, and new triage flows in apps/review-agent/src/webhook/triage-handler.ts. It also adds prompt plumbing for CI-failure and merge-conflict autofix paths, records those runs in review accounting, and surfaces queue stats and summary comments for the new workflows. The main behavior change is that failed check_run/status events can now enqueue autofix jobs, while pull-request review jobs can try a synthetic base-branch merge before running the normal review flow.

### Overview

- ⚠️ 2 warnings

### Highlighted In This Review

- apps/review-agent/src/index.ts:383 check_run only considers the first associated PR
- apps/review-agent/src/index.ts:720 merge-conflict detection is disabled with autofix


Resolved in a later revision. See the living OpenDiff Summary comment for the current state of this PR.

@opendiff-agent

opendiff-agent Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Remediation Summary

2 issues fixed automatically

✅ Fixed

  • bug-risk in apps/review-agent/src/index.ts:755acb8083

    Updated apps/review-agent/src/index.ts so any detected merge conflict now stops the normal review flow unless conflicts were actually resolved, while preserving existing review accounting for autofix runs.

  • bug-risk in apps/review-agent/src/index.ts:38874a7881

    Updated resolvePullRequestForCiFailure in apps/review-agent/src/index.ts to treat associated PR hydration as best-effort by using Promise.allSettled, ignoring failed PR lookups while still selecting from successfully loaded associated PRs before falling back to commit-based PR lookup.

@opendiff-agent opendiff-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Status Update

This PR extends apps/review-agent/src/index.ts and apps/review-agent/src/webhook/triage-handler.ts so the review agent can enqueue autofix jobs from failing check_run and status webhooks, gather CI context via new GitHub client helpers, and attempt a synthetic base-branch merge before normal PR review. It also adds prompt plumbing and accounting for CI-failure and merge-conflict autofix flows, plus summary comments and tests around the new queueing and triage behavior. The main effect is that CI failures and merge conflicts can now trigger dedicated remediation paths before or alongside the existing review flow.

Overview

  • ⚠️ 2 warnings

Highlighted In This Review

  • apps/review-agent/src/index.ts:755 review still runs after unresolved merge conflict
  • apps/review-agent/src/index.ts:388 one bad associated PR aborts CI autofix resolution

Comment thread apps/review-agent/src/index.ts Outdated
Comment thread apps/review-agent/src/index.ts Outdated
@github-actions

Copy link
Copy Markdown

Preview Deployment

Service URL
Website https://pr-137.opendiff.dev
App https://pr-137-app.opendiff.dev
API https://pr-137-api.opendiff.dev
Agent https://pr-137-agent.opendiff.dev

Updated: 2026-06-24 21:22:09 UTC

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.

1 participant