From b70225294c0a178462c8b6b0004340524c498ec9 Mon Sep 17 00:00:00 2001 From: mrT23 Date: Wed, 20 Mar 2024 08:14:08 +0200 Subject: [PATCH] Update 'improve' tool documentation and functionality: Add persistent comment option, adjust default values, and enhance comment handling in pr_code_suggestions.py --- docs/docs/tools/improve.md | 7 ++++--- pr_agent/settings/configuration.toml | 1 + pr_agent/tools/pr_code_suggestions.py | 16 +++++++++++++--- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/docs/docs/tools/improve.md b/docs/docs/tools/improve.md index d642a1b12..f58081398 100644 --- a/docs/docs/tools/improve.md +++ b/docs/docs/tools/improve.md @@ -53,16 +53,17 @@ To edit [configurations](https://github.com/Codium-ai/pr-agent/blob/main/pr_agen !!! example "General options" - - `num_code_suggestions`: number of code suggestions provided by the 'improve' tool. Default is 4. + - `num_code_suggestions`: number of code suggestions provided by the 'improve' tool. Default is 4 for CLI, 0 for auto tools. - `extra_instructions`: Optional extra instructions to the tool. For example: "focus on the changes in the file X. Ignore change in ...". - `rank_suggestions`: if set to true, the tool will rank the suggestions, based on importance. Default is false. - - `summarize`: if set to true, the tool will display the suggestions in a single comment. Default is false. + - `summarize`: if set to true, the tool will display the suggestions in a single comment. Default is true. + - `persistent_comment`: if set to true, the improve comment will be persistent, meaning that every new improve request will edit the previous one. Default is false. - `enable_help_text`: if set to true, the tool will display a help text in the comment. Default is true. !!! example "params for '/improve --extended' mode" - `auto_extended_mode`: enable extended mode automatically (no need for the `--extended` option). Default is true. - - `num_code_suggestions_per_chunk`: number of code suggestions provided by the 'improve' tool, per chunk. Default is 8. + - `num_code_suggestions_per_chunk`: number of code suggestions provided by the 'improve' tool, per chunk. Default is 5. - `rank_extended_suggestions`: if set to true, the tool will rank the suggestions, based on importance. Default is true. - `max_number_of_calls`: maximum number of chunks. Default is 5. - `final_clip_factor`: factor to remove suggestions with low confidence. Default is 0.9. diff --git a/pr_agent/settings/configuration.toml b/pr_agent/settings/configuration.toml index 21ad264b4..886fad1a0 100644 --- a/pr_agent/settings/configuration.toml +++ b/pr_agent/settings/configuration.toml @@ -82,6 +82,7 @@ summarize = true extra_instructions = "" rank_suggestions = false enable_help_text=true +persistent_comment=false # params for '/improve --extended' mode auto_extended_mode=true num_code_suggestions_per_chunk=5 diff --git a/pr_agent/tools/pr_code_suggestions.py b/pr_agent/tools/pr_code_suggestions.py index 336281233..cb4dc8358 100644 --- a/pr_agent/tools/pr_code_suggestions.py +++ b/pr_agent/tools/pr_code_suggestions.py @@ -117,10 +117,20 @@ async def run(self): pr_body += HelpMessage.get_improve_usage_guide() pr_body += "\n\n" - if self.progress_response: - self.git_provider.edit_comment(self.progress_response, body=pr_body) + if get_settings().pr_code_suggestions.persistent_comment: + final_update_message = False + self.git_provider.publish_persistent_comment(pr_body, + initial_header="## PR Code Suggestions", + update_header=True, + final_update_message=final_update_message, ) + if self.progress_response: + self.progress_response.delete() else: - self.git_provider.publish_comment(pr_body) + + if self.progress_response: + self.git_provider.edit_comment(self.progress_response, body=pr_body) + else: + self.git_provider.publish_comment(pr_body) else: self.push_inline_code_suggestions(data)