@@ -143,12 +143,10 @@ async def run(self):
143143 initial_header = "## PR Code Suggestions ✨" ,
144144 update_header = True ,
145145 name = "suggestions" ,
146- final_update_message = final_update_message ,
147- max_previous_comments = get_settings ().pr_code_suggestions .max_history_len )
148- if self .progress_response :
149- self .progress_response .delete ()
146+ final_update_message = final_update_message ,
147+ max_previous_comments = get_settings ().pr_code_suggestions .max_history_len ,
148+ progress_response = self .progress_response )
150149 else :
151-
152150 if self .progress_response :
153151 self .git_provider .edit_comment (self .progress_response , body = pr_body )
154152 else :
@@ -174,7 +172,8 @@ def publish_persistent_comment_with_history(self, pr_comment: str,
174172 update_header : bool = True ,
175173 name = 'review' ,
176174 final_update_message = True ,
177- max_previous_comments = 4 ):
175+ max_previous_comments = 4 ,
176+ progress_response = None ):
178177 history_header = f"#### Previous suggestions\n "
179178 last_commit_num = self .git_provider .get_latest_commit_url ().split ('/' )[- 1 ][:7 ]
180179 latest_suggestion_header = f"Latest suggestions up to { last_commit_num } "
@@ -232,6 +231,7 @@ def publish_persistent_comment_with_history(self, pr_comment: str,
232231 # Add to the prev_suggestions section
233232 last_prev_table = f"\n <details><summary>{ tick } { name .capitalize ()} { up_to_commit_txt } </summary>\n <br>{ latest_table } \n \n </details>"
234233 prev_suggestion_table = last_prev_table + "\n " + prev_suggestion_table
234+
235235 new_suggestion_table = pr_comment .replace (initial_header , "" ).strip ()
236236
237237 pr_comment_updated = f"{ initial_header } \n "
@@ -242,17 +242,21 @@ def publish_persistent_comment_with_history(self, pr_comment: str,
242242 pr_comment_updated += f"{ prev_suggestion_table } \n "
243243
244244 get_logger ().info (f"Persistent mode - updating comment { comment_url } to latest { name } message" )
245-
246- self .git_provider .edit_comment (comment , pr_comment_updated )
245+ if progress_response : # publish to 'progress_response' comment, because it refreshes immediately
246+ self .git_provider .edit_comment (progress_response , pr_comment_updated )
247+ comment .delete ()
248+ else :
249+ self .git_provider .edit_comment (comment , pr_comment_updated )
247250 return
248251 except Exception as e :
249252 get_logger ().exception (f"Failed to update persistent review, error: { e } " )
250253 pass
251254
255+ # if we are here, we did not find a previous comment to update
252256 body = pr_comment .replace (initial_header , "" ).strip ()
253257 pr_comment = f"{ initial_header } \n \n { latest_commit_html_comment } \n \n { body } \n \n "
254- if found_comment is not None :
255- self .git_provider .edit_comment (found_comment , pr_comment )
258+ if progress_response :
259+ self .git_provider .edit_comment (progress_response , pr_comment )
256260 else :
257261 self .git_provider .publish_comment (pr_comment )
258262
0 commit comments