Skip to content

Draft PR if copilot has findings#369

Draft
edenhaus wants to merge 2 commits into
mainfrom
edenhaus/co-pilot-drafting
Draft

Draft PR if copilot has findings#369
edenhaus wants to merge 2 commits into
mainfrom
edenhaus/co-pilot-drafting

Conversation

@edenhaus

@edenhaus edenhaus commented May 5, 2026

Copy link
Copy Markdown
Member

No description provided.

Copilot AI 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.

Pull request overview

Extends the GitHub webhook ReviewDrafter so Copilot review findings can influence PR draft/ready-for-review flow, alongside the existing human-review behavior.

Changes:

  • Add Copilot-specific review detection and unanswered-finding tracking in ReviewDrafter.
  • Add Copilot tracker/outdated issue comment handling when reviews are submitted or PRs are marked ready.
  • Add a new test suite covering Copilot review submission and ready-for-review scenarios.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
services/bots/src/github-webhook/handlers/review_drafter.ts Adds Copilot finding detection, tracker comment management, and draft/ready-for-review behavior.
tests/services/bots/github-webhook/handlers/review_drafter.spec.ts Adds unit tests for Copilot review handling and tracker comment flows.

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

Comment thread services/bots/src/github-webhook/handlers/review_drafter.ts Outdated
Comment thread services/bots/src/github-webhook/handlers/review_drafter.ts Outdated
Comment thread services/bots/src/github-webhook/handlers/review_drafter.ts Outdated
Comment thread services/bots/src/github-webhook/handlers/review_drafter.ts Outdated
Comment thread services/bots/src/github-webhook/handlers/review_drafter.ts Outdated
@joostlek

joostlek commented May 5, 2026

Copy link
Copy Markdown
Member

I think drafting a PR whenever Copilot has findings is different from forcing everyone to respond to every comment. As long as Copilot leaves the same comments over and over again and authors are required to respond to every one of them, I think this will only lead to more frustration rather than a better first PR.

image

@edenhaus

edenhaus commented May 5, 2026

Copy link
Copy Markdown
Member Author

@joostlek So what would you instead propose?

Many authors ignore comments totally because it's AI but most of the time they are valuable and AI is improving
Positive reactions are also considered as answered. I can include all of them if that helps
We decided that if the author is not agreeing with the comment, he should comment on it and tell why. So the reviewer can understand it

@edenhaus

This comment was marked as outdated.

@joostlek

This comment was marked as outdated.

@justanotherariel justanotherariel left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

So I think we need unanimous agreement tbh - I would discuss this on tuesday. Also, this webhook will fire for all home assistant repositories, as well as esphome. We might want to first try this out in home-assistant/core only for now - unless we know that other repos want this too.

Comment on lines +74 to +78
if (this.isCopilotReview(context)) {
await this.handleCopilotReviewSubmitted(context);
return;
}

@justanotherariel justanotherariel May 6, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't think this should be in here, but rather be branched of in handle(). Otherwise this gets a bit confusing.
To expand on this: This webhook does now four things:

  1. 'Changes requested' by member -> mark PR as draft
  2. PR is marked as ready -> request review from everyone who has requested changes
  3. Copilot reviews and has in-line comments ->write a comment listing how many inline comments are present
  4. Copilot in-line comment has been addressed by PR author -> update the comment (adjust the unaddressed reviews number or mark the comment as outdated)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looking at this more, I think this shouldn't be in this handler at all. Instead it should be a seperate handler IMO

Comment on lines +279 to +296
private async markCopilotCommentOutdated(
context: WebhookContext<PullRequestReviewSubmittedEvent | PullRequestReadyForReviewEvent>,
issueComments: Array<{ id: number; body?: string | null }>,
): Promise<void> {
const activeComment = issueComments.find((comment) =>
comment.body?.startsWith(COPILOT_MESSAGE_ID),
);
if (!activeComment) {
return;
}

// Drop the active marker so subsequent lookups don't rediscover this comment,
// and prepend an outdated banner.
const remainingBody = (activeComment.body ?? '').replace(COPILOT_MESSAGE_ID, '').trimStart();
const outdatedBody = `${COPILOT_OUTDATED_NOTICE}${remainingBody}`;

await context.github.issues.updateComment(
context.repo({ comment_id: activeComment.id, body: outdatedBody }),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think we should just remove the comment after everything is done tbh

@home-assistant home-assistant Bot marked this pull request as draft May 6, 2026 20:21
@home-assistant

home-assistant Bot commented May 6, 2026

Copy link
Copy Markdown

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍

Learn more about our pull request process.

@abmantis

Copy link
Copy Markdown
Member

I think we should just make the PR draft and a comment stating "Make sure to resolve all copilot comments and reply to those you don't agree with".
No need for extra enforcing, its mostly a nudge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants