feat: respond to comment mentions on PRs and issues #2
No reviewers
Labels
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
brooktrails/pr-reviewer!2
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/comment-mention-trigger"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
When the bot is @mentioned in a comment:
"I don't have a configured action for issues yet."
Requires "Issue Comment" events enabled on the webhook in addition
to "Pull Request" events.
Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com
Automated review by pr-reviewer v0.6.0 | Full Review | anthropic | tracking id
r-bcdf91-7e228eStatus: ✅ Completed
Code Review
This PR successfully adds support for responding to comment mentions on PRs and issues. The implementation is well-structured and handles the various edge cases appropriately. Here's my detailed review:
✅ Positive Aspects
Architecture & Design:
_handle_comment_eventand_handle_pr_eventcommentandissuefieldsError Handling:
Security & Robustness:
🔍 Areas for Improvement
Minor Code Quality:
forgejo_client.py:9 - Good cleanup moving the datetime import to the top level instead of inside the function.
main.py:102-107 - The event type detection logic is clean and readable.
main.py:153 - The comment author check properly prevents infinite loops, which is critical for this feature.
main.py:175 - Good use of the
pull_requestfield to distinguish PRs from regular issues, as this is the standard GitHub/Forgejo API pattern.🚨 Potential Issues
Logic Concern:
main.py:178-184 - There's a potential inconsistency in the event recording. For non-PR issues, you set
evt.status = "completed"but alsoevt.ignore_reason = "mentioned on issue, not PR". This is confusing because "completed" typically means a review was successfully done, but here nothing was actually reviewed. Consider using a status like "acknowledged" or keeping it as "ignored" since no review occurred.Performance Consideration:
main.py:192-194 - For comment-triggered reviews, you're always doing a "full" review regardless of whether a full review already exists. While this matches the stated behavior, it could be expensive for large PRs that get multiple comment mentions. Consider if this is the desired behavior or if you want some rate limiting.
🧪 Test Coverage Gaps
The changes don't include tests, which would be valuable for:
📝 Documentation
main.py:441-448 - Excellent user-facing messaging in the warning log when comment events aren't properly configured. This will help users troubleshoot webhook configuration issues.
🔧 Minor Suggestions
main.py:179 - Consider extracting the issue acknowledgment message to a constant or configuration, similar to how other user-facing messages are handled.
main.py:184 - The trailing comma in the background task arguments is unnecessary but not harmful.
📋 Summary
This is a solid implementation that adds the requested functionality cleanly. The code follows the existing patterns well and handles edge cases appropriately. The main concern is the semantic inconsistency in event status recording for non-PR acknowledgments, but this doesn't affect functionality. The feature will work as designed and provides good user experience with helpful error messages.
Recommendation: Approve with minor cleanup - Consider fixing the status/ignore_reason inconsistency, but the functionality is sound and ready for deployment.
Automated review by pr-reviewer v0.6.0 | Full Review | anthropic | tracking id
r-bce27f-51be1fStatus: ✅ Completed
Code Review
This is a well-implemented feature that adds comment mention handling to the PR review bot. The changes are substantial but well-structured and maintain good separation of concerns. Here's my detailed review:
✅ Overall Assessment
The implementation looks solid with good error handling, proper separation of webhook event types, and thoughtful user experience design. The code is readable and maintains consistency with the existing codebase.
🔍 Detailed Analysis
Architecture & Design
_handle_comment_eventand_handle_pr_eventinmain.py:169-174_parse_bot_commandfunctionSecurity & Input Validation
main.py:203-208)_parse_bot_commandis case-insensitive but doesn't handle Unicode normalization - this is probably fine for the use caseError Handling
Performance Considerations
_parse_bot_commandfunction does string operations on potentially long comments, but limiting to first 6 words mitigates thisLogic & Edge Cases
has_review_in_progresscheck (main.py:219-223)_parse_bot_command, the function looks for the mention anywhere in the comment but only parses commands after the first occurrence - this could be confusing if someone mentions the bot multiple times, but it's a reasonable design choiceUser Experience
main.py:109-127)Database & State Management
has_review_in_progressfunction prevents duplicate concurrent reviewsCode Quality
forgejo_client.py:2is a good cleanupTesting Gaps
The PR doesn't include tests, which is concerning for a feature this complex. Key areas that should be tested:
Documentation
Specific Issues Found
Potential Race Condition (
main.py:219): The concurrency checkhas_review_in_progresshappens after command parsing but there's still a window where two comment events could both pass this check. This is probably acceptable given the async nature and low likelihood.Missing Import Cleanup (
forgejo_client.py:86): The datetime import was moved to the top but there's a stale comment reference to the old location.Version Bump: The version was bumped from 0.6.0 to 0.8.0, which suggests this might be bundled with other changes not visible in this diff.
🎯 Minor Suggestions
🚀 Verdict
This is a high-quality implementation that's ready to merge. The code is well-structured, handles edge cases appropriately, and provides good user experience. The lack of tests is the main concern, but the code quality and error handling are solid enough that this could be deployed with confidence.
The feature adds significant value by enabling interactive review requests and providing helpful feedback to users who mention the bot in various contexts.