diff --git a/docs/IMPROVE.md b/docs/IMPROVE.md index 60a01de3..dc7f9d6f 100644 --- a/docs/IMPROVE.md +++ b/docs/IMPROVE.md @@ -51,7 +51,6 @@ To edit [configurations](./../pr_agent/settings/configuration.toml#L66) related - `num_code_suggestions`: number of code suggestions provided by the 'improve' tool. Default is 4. - `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. -- `include_improved_code`: if set to true, the tool will include an improved code implementation in the suggestion. Default is true. - `summarize`: if set to true, the tool will display the suggestions in a single comment. Default is false. - `enable_help_text`: if set to true, the tool will display a help text in the comment. Default is true. #### params for '/improve --extended' mode diff --git a/pr_agent/settings/configuration.toml b/pr_agent/settings/configuration.toml index 66cd48bc..8c37ac8e 100644 --- a/pr_agent/settings/configuration.toml +++ b/pr_agent/settings/configuration.toml @@ -69,8 +69,7 @@ enable_help_text=true [pr_code_suggestions] # /improve # num_code_suggestions=4 -summarize = false -include_improved_code = true +summarize = true extra_instructions = "" rank_suggestions = false enable_help_text=true diff --git a/pr_agent/tools/pr_code_suggestions.py b/pr_agent/tools/pr_code_suggestions.py index 2070a621..97c183f2 100644 --- a/pr_agent/tools/pr_code_suggestions.py +++ b/pr_agent/tools/pr_code_suggestions.py @@ -169,35 +169,19 @@ class PRCodeSuggestions: if new_code_snippet: new_code_snippet = self.dedent_code(relevant_file, relevant_lines_start, new_code_snippet) - if get_settings().pr_code_suggestions.include_improved_code: - body = f"**Suggestion:** {content} [{label}]\n```suggestion\n" + new_code_snippet + "\n```" - code_suggestions.append({'body': body, 'relevant_file': relevant_file, + body = f"**Suggestion:** {content} [{label}]\n```suggestion\n" + new_code_snippet + "\n```" + code_suggestions.append({'body': body, 'relevant_file': relevant_file, 'relevant_lines_start': relevant_lines_start, 'relevant_lines_end': relevant_lines_end}) - else: - if self.git_provider.is_supported("create_inline_comment"): - body = f"**Suggestion:** {content} [{label}]" - comment = self.git_provider.create_inline_comment(body, relevant_file, "", - absolute_position=relevant_lines_end) - if comment: - code_suggestions.append(comment) - else: - get_logger().error("Inline comments are not supported by the git provider") except Exception: if get_settings().config.verbosity_level >= 2: get_logger().info(f"Could not parse suggestion: {d}") - if get_settings().pr_code_suggestions.include_improved_code: - is_successful = self.git_provider.publish_code_suggestions(code_suggestions) - else: - is_successful = self.git_provider.publish_inline_comments(code_suggestions) + is_successful = self.git_provider.publish_code_suggestions(code_suggestions) if not is_successful: get_logger().info("Failed to publish code suggestions, trying to publish each suggestion separately") for code_suggestion in code_suggestions: - if get_settings().pr_code_suggestions.include_improved_code: - self.git_provider.publish_code_suggestions([code_suggestion]) - else: - self.git_provider.publish_inline_comments([code_suggestion]) + self.git_provider.publish_code_suggestions([code_suggestion]) def dedent_code(self, relevant_file, relevant_lines_start, new_code_snippet): try: # dedent code snippet