fix(review): remove stale progress comments - #2788
Conversation
PR Summary by QodoFix /review: reliably delete stale “Preparing review…” progress comments
AI Description
Diagram
High-Level Assessment
Files changed (4)
|
Code Review by Qodo🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)
Great, no issues found!Qodo reviewed your code and found no material issues that require review
Tip of the day💡 Did you know, you can switch off images and animations for a plain-text comment |
IsmaelMartinez
left a comment
There was a problem hiding this comment.
Thanks for carrying #2648's fix through to /review, and for going with a targeted handle instead of a blanket sweep. Three notes inline, no blockers.
| finally: | ||
| if progress_response is not None: | ||
| try: | ||
| self.git_provider.remove_comment(progress_response) | ||
| except Exception as e: | ||
| get_logger().exception(f"Failed to remove review progress comment, error: {e}") |
There was a problem hiding this comment.
Right shape, and I prefer it to the /improve version it follows, which repeats remove_comment at each exit and so has to be rechecked every time an early return is added.
One thing worth confirming as deliberate: a failed /review now leaves nothing on the PR at all. /improve posts a "Failed to generate code suggestions" notice only on the branch where there was no progress comment to remove, so it does not really settle it either way.
There was a problem hiding this comment.
I agree that a visible failure result could be better for manual runs.
I kept this change smaller and focused, but the additional fix does not look too large. I can add it to this PR with the relevant cross-provider behavior and tests if it fits project approach, or handle it in a follow-up PR.
What do you suggest?
|
|
||
| if get_settings().config.publish_output and not get_settings().config.get('is_auto_command', False): | ||
| self.git_provider.publish_comment("Preparing review...", is_temporary=True) | ||
| progress_response = self.git_provider.publish_comment("Preparing review...", is_temporary=True) |
There was a problem hiding this comment.
Checked what every provider returns here against its remove_comment: GitHub and GitLab hand back a comment object that deletes, Azure a Comment carrying thread_id, Gitea a dict its remove_comment already unpacks, and Bitbucket Server, Gerrit, CodeCommit and local all return None for a temporary comment, so the new finally is a no-op there. Bitbucket Cloud was the only one that needed the fix.
There was a problem hiding this comment.
That matches what I had in mind:
- keep the cleanup generic
- skip it when a provider returns None
- handle the Bitbucket Cloud difference inside its provider.
In the future, we could standardize the comment handle across providers, but that feels separate from this PR.
| def remove_comment(self, comment): | ||
| try: | ||
| self.pr.delete(f"comments/{comment}") | ||
| comment_id = comment["id"] if isinstance(comment, dict) else comment |
There was a problem hiding this comment.
Both shapes are genuinely live, so this needs to stay tolerant: remove_initial_comment still feeds it the bare id out of temp_comments, while the new caller passes the whole dict.
There was a problem hiding this comment.
Yep, I kept it compatible with both forms. We could normalize the handle later, but I think changing the provider boundary belongs in a separate PR.
IsmaelMartinez
left a comment
There was a problem hiding this comment.
Approving, and keep the failure result separate.
Open it as a follow-up: it changes behaviour on every provider, so it wants its own test matrix, and bundling it would put a small safe fix behind a larger argument. Your instinct on the provider boundary is the same one, and I agree with it.
Summary
/reviewprogress comment when quiet output suppresses the review or review generation fails.Related to #2648, which applied exact-handle cleanup to
/improve.Result
When
/reviewpostsPreparing review..., quiet no-findings exits and errors no longer leave that placeholder behind. Runs that do not publish a progress comment do not delete existing comments.Testing
PYTHONPATH=. pytest tests/unittest/test_pr_reviewer_core.py tests/unittest/test_bitbucket_provider.py -q(73 passed)PYTHONPATH=. pytest tests/unittest -q(2,039 passed, 1 skipped, 1 expected failure)git diff --check(passed)