-
Notifications
You must be signed in to change notification settings - Fork 2
feat: Improve thread resolution with referenced commit context #230
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
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
8598598
feat: Add support for extracting and including referenced commit contβ¦
finxo ba89f0d
feat: Filter thread review candidates to only include the current useβ¦
finxo e2b1bb9
Fix: code_review_steps.py
finxo 3e40ab8
Fix: test_pr_service.py
finxo 71ababe
Fix: pr_service.py
finxo a02cd3e
Fix: thread_resolution_operations.py
finxo 26c6751
Fix: code_review_steps.py
finxo 86205a1
Fix: pr_service.py
finxo e7b0a72
Fix: thread_resolution_operations.py
finxo 626169b
Fix: code_review_steps.py
finxo 2664a81
Fix: pr_service.py
finxo 4c32b76
Fix: test_code_review_steps.py
finxo 4647873
Merge branch 'master' into feat/improve_thread_resolution_with_sha
finxo 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
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
87 changes: 87 additions & 0 deletions
87
plugins/titan-plugin-github/tests/operations/test_thread_resolution_operations.py
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 |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| from titan_plugin_github.models.review_models import ReferencedCommitContext, ThreadReviewContext | ||
| from titan_plugin_github.models.view import UIComment, UICommentThread | ||
| from titan_plugin_github.operations.thread_resolution_operations import ( | ||
| build_thread_resolution_prompt, | ||
| build_thread_review_candidates, | ||
| ) | ||
|
|
||
|
|
||
| def _make_thread(*, main_author: str, reply_author: str) -> UICommentThread: | ||
| return UICommentThread( | ||
| thread_id=f"thread_{main_author}_{reply_author}", | ||
| main_comment=UIComment( | ||
| id=10, | ||
| body="Please fix this", | ||
| author_login=main_author, | ||
| author_name=main_author, | ||
| formatted_date="", | ||
| path="src/main.py", | ||
| line=42, | ||
| ), | ||
| replies=[ | ||
| UIComment( | ||
| id=11, | ||
| body="Fixed", | ||
| author_login=reply_author, | ||
| author_name=reply_author, | ||
| formatted_date="", | ||
| path="src/main.py", | ||
| line=42, | ||
| ) | ||
| ], | ||
| is_resolved=False, | ||
| is_outdated=False, | ||
| ) | ||
|
|
||
|
|
||
| def test_build_thread_review_candidates_only_includes_current_users_threads(): | ||
| candidates = build_thread_review_candidates( | ||
| [ | ||
| _make_thread(main_author="current-reviewer", reply_author="pr-author"), | ||
| _make_thread(main_author="other-reviewer", reply_author="pr-author"), | ||
| ], | ||
| pr_author="pr-author", | ||
| reviewer_login="current-reviewer", | ||
| ) | ||
|
|
||
| assert len(candidates) == 1 | ||
| assert candidates[0].main_comment_author == "current-reviewer" | ||
|
|
||
|
|
||
| def test_build_thread_review_candidates_excludes_threads_without_pr_author_last_reply(): | ||
| candidates = build_thread_review_candidates( | ||
| [_make_thread(main_author="current-reviewer", reply_author="other-reviewer")], | ||
| pr_author="pr-author", | ||
| reviewer_login="current-reviewer", | ||
| ) | ||
|
|
||
| assert candidates == [] | ||
|
|
||
|
|
||
| def test_build_thread_resolution_prompt_includes_referenced_commit_context(): | ||
| context = ThreadReviewContext( | ||
| thread_id="thread_123", | ||
| comment_id=10, | ||
| path="src/buttons.kt", | ||
| line=543, | ||
| main_comment_body="Please remove the default dialog state.", | ||
| main_comment_author="reviewer", | ||
| all_replies=[{"author": "author", "body": "Fixed in 343e2e9"}], | ||
| current_code_hunk="@@ -1,2 +1,2 @@\n-old\n+new\n", | ||
| referenced_commits=[ | ||
| ReferencedCommitContext( | ||
| sha="343e2e9d7402d0afccfd35a9ecc8e6ea341031c6", | ||
| abbreviated_sha="343e2e9", | ||
| message="remove default state value", | ||
| changed_files=["src/BaseDialog.kt"], | ||
| patch_excerpt="diff --git a/src/BaseDialog.kt b/src/BaseDialog.kt\n@@ -1 +1 @@\n-old\n+new\n", | ||
| ) | ||
| ], | ||
| ) | ||
|
|
||
| prompt = build_thread_resolution_prompt([context]) | ||
|
|
||
| assert "Referenced commits from replies" in prompt | ||
| assert "343e2e9" in prompt | ||
| assert "src/BaseDialog.kt" in prompt | ||
| assert "remove default state value" in prompt |
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
Oops, something went wrong.
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.