Updates AI comment

The review comment was just all files with the findings, wich is redundant to the actual comment and takes a lot of space.

Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
Kalle Bracht
2026-05-02 10:56:53 +02:00
parent 3b4dcabe66
commit e18680544b

View File

@@ -212,7 +212,7 @@ def handle_assignment(owner: str, repo: str, pr: dict):
# Analyze each file individually based on its diff. # Analyze each file individually based on its diff.
review_comments: List[dict] = [] review_comments: List[dict] = []
file_summaries: List[str] = [] file_errors: List[str] = []
for file_dict in files: for file_dict in files:
filename = file_dict.get("filename") or file_dict.get("path") filename = file_dict.get("filename") or file_dict.get("path")
@@ -224,7 +224,7 @@ def handle_assignment(owner: str, repo: str, pr: dict):
patch = fallback_patches.get(filename, "") patch = fallback_patches.get(filename, "")
if not patch.strip(): if not patch.strip():
file_summaries.append(f"**{filename}**: No textual diff available.") file_errors.append(f"**{filename}**: No textual diff available.")
continue continue
file_for_prompt = dict(file_dict) file_for_prompt = dict(file_dict)
@@ -236,7 +236,6 @@ def handle_assignment(owner: str, repo: str, pr: dict):
try: try:
ai_response = gemini.generate_review(prompt) ai_response = gemini.generate_review(prompt)
parsed_review = parse_structured_review(ai_response) parsed_review = parse_structured_review(ai_response)
file_summaries.append(f"**{filename}**: {parsed_review['summary']}")
for finding in parsed_review["findings"]: for finding in parsed_review["findings"]:
severity = finding["severity"].upper() severity = finding["severity"].upper()
@@ -248,10 +247,18 @@ def handle_assignment(owner: str, repo: str, pr: dict):
}) })
except Exception as e: except Exception as e:
print(f"failed to generate review for {filename}: {e}") print(f"failed to generate review for {filename}: {e}")
file_summaries.append(f"**{filename}**: Error analyzing file - {e}") file_errors.append(f"**{filename}**: Error analyzing file - {e}")
# Create one PR review containing summary + line-anchored comments. # Create one PR review containing summary + line-anchored comments.
review_body = "AI Code Review\n\n" + "\n".join(file_summaries) review_body = "### AI Code Review by [Karl der Computer](https://dev.skui.eu/SKUI/KARL)\n"
review_body += "There are three severity levels for comments: HIGH (red) indicates critical issues, MEDIUM (orange) suggests improvements, and LOW (blue) points out minor concerns or style suggestions.\n"
review_body += "Note: AI can make mistakes. Please review carefully.\n"
review_body += "If there are any mistakes, please report to the [issue tracker](https://dev.skui.eu/SKUI/KARL/issues) of Karl\n"
if file_errors:
review_body += "\n#### Issues with file analysis:\n"
review_body += "\n".join(file_errors)
try: try:
gitea.create_pull_request_review( gitea.create_pull_request_review(