From e18680544bdf5e47d1e12883d084ddf1cbef6d50 Mon Sep 17 00:00:00 2001 From: Kalle Bracht Date: Sat, 2 May 2026 10:56:53 +0200 Subject: [PATCH] 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 --- gitea_bot/poller.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/gitea_bot/poller.py b/gitea_bot/poller.py index 2286338..2ef15f9 100644 --- a/gitea_bot/poller.py +++ b/gitea_bot/poller.py @@ -212,7 +212,7 @@ def handle_assignment(owner: str, repo: str, pr: dict): # Analyze each file individually based on its diff. review_comments: List[dict] = [] - file_summaries: List[str] = [] + file_errors: List[str] = [] for file_dict in files: 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, "") if not patch.strip(): - file_summaries.append(f"**{filename}**: No textual diff available.") + file_errors.append(f"**{filename}**: No textual diff available.") continue file_for_prompt = dict(file_dict) @@ -236,7 +236,6 @@ def handle_assignment(owner: str, repo: str, pr: dict): try: ai_response = gemini.generate_review(prompt) parsed_review = parse_structured_review(ai_response) - file_summaries.append(f"**{filename}**: {parsed_review['summary']}") for finding in parsed_review["findings"]: severity = finding["severity"].upper() @@ -248,10 +247,18 @@ def handle_assignment(owner: str, repo: str, pr: dict): }) except Exception as 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. - 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: gitea.create_pull_request_review(