From 29d4fe510e930fd04e6feeec546f4189da06420d Mon Sep 17 00:00:00 2001 From: Benedict Lee Date: Thu, 24 Apr 2025 11:21:49 +0900 Subject: [PATCH] Improve get_review_thread_comments method implementation Co-authored-by: ofir-frd <85901822+ofir-frd@users.noreply.github.com> --- pr_agent/git_providers/github_provider.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/pr_agent/git_providers/github_provider.py b/pr_agent/git_providers/github_provider.py index 2e3a8bf0..daa0c84b 100644 --- a/pr_agent/git_providers/github_provider.py +++ b/pr_agent/git_providers/github_provider.py @@ -448,19 +448,13 @@ class GithubProvider(GitProvider): if not target_comment: return [] - # First, identify if this is a reply to another comment + # Get root comment id root_comment_id = target_comment.raw_data.get("in_reply_to_id", target_comment.id) - if root_comment_id != target_comment.id: - # If this is a reply, find the root comment - root_comment = next((c for c in all_comments if c.id == root_comment_id), None) - if root_comment: - target_comment = root_comment - # Build the thread - include the root comment and all replies to it thread_comments = [ - c for c in all_comments if - c.id == target_comment.id or c.raw_data.get("in_reply_to_id") == target_comment.id - ] + c for c in all_comments if + c.id == root_comment_id or c.raw_data.get("in_reply_to_id") == root_comment_id +] # Sort chronologically thread_comments.sort(key=lambda c: c.created_at)