feat: Improve thread resolution with referenced commit context#230
feat: Improve thread resolution with referenced commit context#230finxo wants to merge 2 commits into
Conversation
…ext in PR review threads
| return Skip("No thread_review_candidates in context") | ||
|
|
||
| contexts = build_thread_review_contexts_operation(candidates, threads, diff) | ||
| commit_contexts_by_thread = _load_referenced_commit_contexts(ctx, threads) |
There was a problem hiding this comment.
_load_referenced_commit_contexts is passed the full threads list (all PR threads), but the result is only applied to contexts, which was built from candidates. Any SHA reference inside a resolved or foreign-reviewer thread will trigger a real API call whose result is immediately discarded.
Filter to only the threads that correspond to candidates before fetching:
candidate_ids = {c.thread_id for c in candidates}
candidate_threads = [t for t in threads if t.thread_id in candidate_ids]
commit_contexts_by_thread = _load_referenced_commit_contexts(ctx, candidate_threads)| return Skip("No thread_review_candidates in context") | ||
|
|
||
| contexts = build_thread_review_contexts_operation(candidates, threads, diff) | ||
| commit_contexts_by_thread = _load_referenced_commit_contexts(ctx, threads) |
There was a problem hiding this comment.
_load_referenced_commit_contexts is called with all review_threads (every thread on the PR), but only candidate threads are ever enriched. Any non-candidate thread (resolved, from a different reviewer, etc.) whose replies mention a hex SHA will trigger a get_commit_review_context API call whose result is immediately discarded.
The call should filter to candidate threads only:
candidate_thread_ids = {c.thread_id for c in candidates}
candidate_threads = [t for t in threads if t.thread_id in candidate_thread_ids]
commit_contexts_by_thread = _load_referenced_commit_contexts(ctx, candidate_threads)| result = pr_service.get_commit_review_context("343e2e9") | ||
|
|
||
| assert isinstance(result, ClientError) | ||
| assert result.error_code == "PARSE_ERROR" |
There was a problem hiding this comment.
The new get_commit_review_context tests cover success and PARSE_ERROR but skip the API_ERROR branch. The implementation explicitly catches GitHubAPIError and returns ClientError(error_code="API_ERROR"), and test_merge_pr_failure shows this pattern is expected to be tested. Please add:
def test_get_commit_review_context_returns_api_error_on_network_failure(pr_service, mock_gh_network):
mock_gh_network.run_command.side_effect = GitHubAPIError("Not Found")
result = pr_service.get_commit_review_context("343e2e9")
assert isinstance(result, ClientError)
assert result.error_code == "API_ERROR"
Pull Request
📝 Summary
This PR improves the pull request thread resolution workflow in the GitHub plugin. It filters thread review candidates to only include those started by the current user (where the PR author has replied), and adds support for extracting and embedding context from referenced commit SHAs mentioned in the discussion threads to improve AI-driven resolution analysis.
🔧 Changes Made
get_commit_review_contextto the GitHub client API to retrieve compact file changes and patch excerpts for referenced SHAs.review_threads,review_pr,review_current_user) and documented the new client API.🧪 Testing
poetry run pytest)make test)titan-devUnit tests were added to cover:
📊 Logs
✅ Checklist
Plugins > Git Plugin,GitHub Plugin,Jira Plugin)