Update existing review comment instead of posting a new one#6
Conversation
Uses a hidden HTML marker to find and update the previous review comment on each PR push, preventing comment spam. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Z.ai Code ReviewThis is a valuable improvement that prevents the bot from spamming the pull request with multiple comments. However, there are two potential bugs regarding API pagination and permission errors. Here are the specific issues and recommendations: 1. Handle API PaginationIssue: Recommendation: Use // Use paginate to ensure you check all comments
const comments = await octokit.paginate(octokit.rest.issues.listComments, {
owner,
repo,
issue_number: pullNumber,
});
const existing = comments.find(c => c.body.includes(COMMENT_MARKER));2. Verify Comment Author/OwnershipIssue: The code currently updates any comment containing the Recommendation: Ensure the comment belongs to the bot (or the user associated with the const existing = comments.find(c =>
c.body.includes(COMMENT_MARKER) &&
c.user.type === 'Bot' // Or check specifically for your bot's name
);3. Robustness of the MarkerIssue: If the AI generated by Recommendation: While unlikely, consider using a more unique marker or HTML encoding the review content before appending the marker. Alternatively, placing the marker at the start of the body makes it easier to find and avoids parsing issues if the AI generates HTML-like content. |
Uses a hidden HTML marker to find and update the previous review comment on each PR push, preventing comment spam.