feat: Add @codebot review-again command for manual PR re-review #10
Reference in New Issue
Block a user
Delete Branch "feature/review-again-command"
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?
Key features:
Closes feature request for manual PR re-review capability
AI Code Review - Inline Comments
[LOW] Maintainability
The workflow script duplicates the 'actions/checkout@v4' step twice in a row, which is unnecessary and could be simplified.
Recommendation: Remove the redundant 'actions/checkout@v4' step to streamline the workflow and avoid confusion.
[LOW] Readability
The shell script in the 'Run AI Comment Response' step uses a multi-line if-else block with embedded GitHub Actions expressions, which can be hard to read and maintain.
Recommendation: Consider extracting the dispatch logic into a separate script file or a dedicated action to improve readability and maintainability.
[LOW] Readability
The logic to detect the 'review-again' command in PR comments uses a case-sensitive substring check on the comment body converted to lowercase, which may cause false negatives if the mention prefix case differs or if there is extra whitespace.
Recommendation: Normalize the mention prefix and command string to lowercase and trim whitespace before checking. Consider using regex to robustly detect the command in the comment body.
[LOW] Maintainability
The method '_parse_review_comment' uses a regex pattern to extract findings from the previous review comment, but it assumes a very specific markdown format which may break if the comment formatting changes.
Recommendation: Add error handling or fallback parsing logic. Consider storing findings in a structured format (e.g., JSON block) in the comment to improve robustness.
[LOW] Performance
The '_compare_reviews' method creates dictionaries keyed by a truncated description substring (first 50 chars) which may cause collisions or mismatches for similar issues with longer descriptions.
Recommendation: Consider using a more robust unique key for findings, such as a hash of the full description or including additional context fields to reduce false matches.
[LOW] Readability
The '_format_review_update' method generates a large markdown string with many repeated patterns and manual string concatenations, which can be error-prone and hard to maintain.
Recommendation: Refactor to use a templating engine or helper functions to build sections of the comment for better readability and easier updates.
[LOW] Testing
The new '_handle_review_again' method and its helper methods introduce complex logic for re-reviewing PRs, but there is no indication of added or updated unit or integration tests covering these new code paths.
Recommendation: Add comprehensive tests for the 'review-again' command handling, including cases with no previous review, with previous reviews, and with various diff and security scan results.
Note: This review was generated by an AI assistant. While it aims to be accurate and helpful, it may contain mistakes or miss important issues. Please verify all findings before taking action.
AI Code Review
This PR introduces a new '@codebot review-again' command to manually re-run AI code reviews on pull requests without new commits. It includes workflow updates to dispatch PR comment events, extensive logic in the PR agent to handle re-review requests, comparison of new and previous review results, and updates to comments and labels accordingly. The implementation is comprehensive and well integrated with existing systems, improving usability and iteration speed for PR reviews.
Summary
Review Findings
.gitea/workflows/ai-comment-reply.yml:38- The workflow script duplicates the 'actions/checkout@v4' step twice in a row, which is unnecessary and could be simplified..gitea/workflows/ai-comment-reply.yml:44- The shell script in the 'Run AI Comment Response' step uses a multi-line if-else block with embedded GitHub Actions expressions, which can be hard to read and maintain.tools/ai-review/agents/pr_agent.py:90- The logic to detect the 'review-again' command in PR comments uses a case-sensitive substring check on the comment body converted to lowercase, which may cause false negatives if the mention prefix case differs or if there is extra whitespace.tools/ai-review/agents/pr_agent.py:150- The method '_parse_review_comment' uses a regex pattern to extract findings from the previous review comment, but it assumes a very specific markdown format which may break if the comment formatting changes.tools/ai-review/agents/pr_agent.py:230- The '_compare_reviews' method creates dictionaries keyed by a truncated description substring (first 50 chars) which may cause collisions or mismatches for similar issues with longer descriptions.tools/ai-review/agents/pr_agent.py:270- The '_format_review_update' method generates a large markdown string with many repeated patterns and manual string concatenations, which can be error-prone and hard to maintain.tools/ai-review/agents/pr_agent.py:100- The new '_handle_review_again' method and its helper methods introduce complex logic for re-reviewing PRs, but there is no indication of added or updated unit or integration tests covering these new code paths.Overall Severity:
LOWAI Recommendation: Approve