-
Notifications
You must be signed in to change notification settings - Fork 956
Improvement: Enhance ask_line tool by adding PR review comment threads as context #1687
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
ofir-frd
merged 12 commits into
qodo-ai:main
from
benedict-lee:feat/add-conversation-history-on-line-question
Apr 24, 2025
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
b53d277
improve ask_line tool(add conversation history context)
benedict-lee 8952459
Update pr_agent/tools/pr_line_questions.py
benedict-lee 6bf093a
refactor: Add GitHub provider check for conversation history
benedict-lee c5165d9
refactor: Validate all required parameters before proceeding
benedict-lee 9c06b6b
Apply PR review feedback: Code style and functionality improvements
benedict-lee a434d0a
Improve comment thread retrieval by using in_reply_to_id instead of l…
benedict-lee e11c2e1
Reorganize imports according to Python conventions
benedict-lee 8b4bf49
Improve conversation history handling and prompts for line questions
benedict-lee 9906ec3
Improve conversation history formatting with numbered comments
benedict-lee 29d4fe5
Improve get_review_thread_comments method implementation
benedict-lee ddb94ec
mprove get_review_thread_comments method implementation
benedict-lee c35942c
mprove get_review_thread_comments method implementation
benedict-lee File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -427,7 +427,41 @@ def publish_inline_comments(self, comments: list[dict], disable_fallback: bool = | |
self._publish_inline_comments_fallback_with_verification(comments) | ||
except Exception as e: | ||
get_logger().error(f"Failed to publish inline code comments fallback, error: {e}") | ||
raise e | ||
raise e | ||
|
||
def get_review_thread_comments(self, comment_id: int) -> list[dict]: | ||
""" | ||
Retrieves all comments in the same thread as the given comment. | ||
|
||
Args: | ||
comment_id: Review comment ID | ||
|
||
Returns: | ||
List of comments in the same thread | ||
""" | ||
try: | ||
# Fetch all comments with a single API call | ||
all_comments = list(self.pr.get_comments()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here, you're collecting all PR comments. You can expect to find the given |
||
|
||
# Find the target comment by ID | ||
target_comment = next((c for c in all_comments if c.id == comment_id), None) | ||
if not target_comment: | ||
return [] | ||
|
||
# Get root comment id | ||
root_comment_id = target_comment.raw_data.get("in_reply_to_id", target_comment.id) | ||
# Build the thread - include the root comment and all replies to it | ||
thread_comments = [ | ||
c for c in all_comments if | ||
c.id == root_comment_id or c.raw_data.get("in_reply_to_id") == root_comment_id | ||
] | ||
|
||
|
||
return thread_comments | ||
|
||
except Exception as e: | ||
get_logger().exception(f"Failed to get review comments for an inline ask command", artifact={"comment_id": comment_id, "error": e}) | ||
return [] | ||
|
||
def _publish_inline_comments_fallback_with_verification(self, comments: list[dict]): | ||
""" | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.