feat: consolidate PR comments into single comment per PR#30
Conversation
Instead of posting one comment per conflict pair, group all conflicts for a given PR into a single consolidated comment with a table format. Existing bot comments are updated in place rather than creating new ones. This significantly reduces notification noise for PRs involved in multiple conflicts. Closes #29 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…mments Combine filename and its line ranges together (e.g. `auth.py` (L10-L20)) instead of listing them in separate columns where the association was ambiguous for multi-file conflicts. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
jmeridth
left a comment
There was a problem hiding this comment.
Review
The consolidation logic is well-structured and test coverage is thorough. A few items to consider:
1. Stale comment cleanup on migration (main concern)
When this deploys on repos that already have old-format per-conflict comments, _find_existing_comment returns the first comment matching COMMENT_SIGNATURE. On a PR that currently has 3 separate bot comments (old format), this will:
Suggestion: delete extra bot comments when consolidating, or at minimum document this as a known limitation.
2. Missing return type annotation on _find_existing_comment
def _find_existing_comment(repo, pr_number: int):The rest of the codebase consistently uses type hints. This should have a return type (Optional[Any] or the github3 comment type).
3. Untyped inner data structure
_group_conflicts_by_pr returns dict[int, list[dict[str, Any]]] — the inner dicts use string keys "other_pr" and "files" which are easy to typo silently. A TypedDict or small dataclass would make this safer:
@dataclass
class ConflictEntry:
other_pr: PRInfo
files: list[FileOverlap]Style preference, not a blocker.
4. Dry run doesn't distinguish new vs. update
The dry run path continues before reaching _find_existing_comment, so it always reports everything as "new" comments. The log message will say "Posted X new comment(s), updated 0 existing comment(s)" even if some would have been updates. Minor inaccuracy for a debug mode.
Item #1 is the only one I'd consider blocking. The rest could be addressed here or as follow-ups.
|
I'm also good with this merging and #1 (in previous comment) being handled in a follow-up PR? I'll approve and let you decide. |
Fix #1 - Stale comment cleanup: _find_existing_comments now returns ALL bot comments. The first is updated to the consolidated format, and any extras (left over from the old per-conflict format) are deleted. Fix #2 - Type annotations: Added proper return type and parameter types to _find_existing_comments, _update_comment, and _delete_comment. Fix #3 - Typed data structure: Replaced dict[str, Any] inner dicts with a ConflictEntry dataclass for type-safe access to other_pr and files. Fix #4 - Dry run accuracy: Dry run now calls _find_existing_comments first and correctly reports whether each PR would get a new comment or an update, including how many stale comments would be cleaned up. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Thanks for the thorough review! All four items addressed in 44e8299.
|
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
Closes #29
Changes
Instead of posting one comment per conflict pair, this groups all conflicts for a given PR into a single consolidated comment with a table format. Existing bot comments are updated in place.
Before (3 conflicts = 3 separate comments on one PR)
After (3 conflicts = 1 consolidated comment)
Key changes
_build_consolidated_comment()groups conflicts per PR_has_existing_comment()replaced by_find_existing_comment()(returns comment object for updates)_group_conflicts_by_pr()restructures conflict data by PR number_update_comment()edits existing comments in placeTesting
make lint- all 5 linters pass (flake8, isort, pylint 10.00/10, mypy, black)make test- 210 tests pass, 99% coverage (required: 80%)DRY_RUN=trueagainstgithub/new-user-experience- scanned 6 open PRs, found 1 potential conflict, consolidated PR comment posting triggered successfully with no errors