Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 20 additions & 6 deletions pr_agent/tools/pr_code_suggestions.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,12 +333,26 @@ def _extract_link(comment_text: str):
pr_comment_updated += f"{prev_suggestion_table}\n"

get_logger().info(f"Persistent mode - updating comment {comment_url} to latest {name} message")
if progress_response: # publish to 'progress_response' comment, because it refreshes immediately
git_provider.edit_comment(progress_response, pr_comment_updated)
git_provider.remove_comment(comment)
comment = progress_response
else:
git_provider.edit_comment(comment, pr_comment_updated)
# Edit the previously-found persistent comment in place and remove the throwaway
# progress note. Editing the persistent comment (rather than re-targeting to the
# progress note and deleting the original) keeps the stable thread stable across
# pushes on GitLab, where deleting a note with replies fails silently.
git_provider.edit_comment(comment, pr_comment_updated)
if progress_response:
# Cleanup is best-effort: isolate it from the outer try/except so a failure
# here does not trigger the "no previous comment" fallback below, which
# would publish a duplicate suggestions thread despite the persistent
# comment update having already succeeded.
try:
# Replace the WIP progress body with a benign final-state message
# before deletion so that if remove_comment fails for any reason, the
# leftover note does not keep displaying "Work in progress ...".
git_provider.edit_comment(progress_response, "Code suggestions published in the persistent thread above.")
git_provider.remove_comment(progress_response)
except Exception as cleanup_error:
get_logger().warning(
f"Failed to clean up progress note after persistent update, leaving it in place: {cleanup_error}"
)
return comment
except Exception as e:
get_logger().exception(f"Failed to update persistent review, error: {e}")
Expand Down
Loading