From ed78bfd9461ce2328275d10493507711ff91ae8a Mon Sep 17 00:00:00 2001 From: mrT23 Date: Thu, 4 Jan 2024 10:27:07 +0200 Subject: [PATCH] use_collapsible_file_list --- docs/DESCRIBE.md | 3 ++- pr_agent/settings/configuration.toml | 6 +++--- pr_agent/tools/pr_description.py | 16 +++++++++++++--- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/docs/DESCRIBE.md b/docs/DESCRIBE.md index c4106008c..222d79d34 100644 --- a/docs/DESCRIBE.md +++ b/docs/DESCRIBE.md @@ -48,7 +48,8 @@ Under the section 'pr_description', the [configuration file](./../pr_agent/setti - `final_update_message`: if set to true, it will add a comment message [`PR Description updated to latest commit...`](https://github.com/Codium-ai/pr-agent/pull/499#issuecomment-1837412176) after finishing calling `/describe`. Default is true. -- `enable_semantic_files_types`: if set to true, "PR changes walkthrough" section will be generated. Default is true. +- `enable_semantic_files_types`: if set to true, "Changes walkthrough" section will be generated. Default is true. +- `collapsible_file_list`: if set to true, the file list in the "Changes walkthrough" section will be collapsible. If set to "adaptive", the file list will be collapsible only if there are more than 8 files. Default is "adaptive". ### Markers template diff --git a/pr_agent/settings/configuration.toml b/pr_agent/settings/configuration.toml index e5428feea..6b6cdc9b9 100644 --- a/pr_agent/settings/configuration.toml +++ b/pr_agent/settings/configuration.toml @@ -51,10 +51,10 @@ keep_original_user_title=false use_bullet_points=true extra_instructions = "" enable_pr_type=true -enable_semantic_files_types=true final_update_message = true - - +## changes walkthrough section +enable_semantic_files_types=true +collapsible_file_list='adaptive' # true, false, 'adaptive' # markers use_description_markers=false include_generated_by_header=true diff --git a/pr_agent/tools/pr_description.py b/pr_agent/tools/pr_description.py index 61b40eb8f..362849d51 100644 --- a/pr_agent/tools/pr_description.py +++ b/pr_agent/tools/pr_description.py @@ -293,7 +293,7 @@ def _prepare_pr_answer(self) -> Tuple[str, str]: for idx, (key, value) in enumerate(self.data.items()): if key == 'pr_files': value = self.file_label_dict - key_publish = "PR changes walkthrough" + key_publish = "Changes walkthrough" else: key_publish = key.rstrip(':').replace("_", " ").capitalize() pr_body += f"## {key_publish}\n" @@ -336,6 +336,9 @@ def _prepare_file_labels(self): pass def process_pr_files_prediction(self, pr_body, value): + use_collapsible_file_list = get_settings().pr_description.collapsible_file_list + if use_collapsible_file_list == "adaptive": + use_collapsible_file_list = len(value) > 8 if not self.git_provider.is_supported("gfm_markdown"): get_logger().info(f"Disabling semantic files types for {self.pr_id} since gfm_markdown is not supported") return pr_body @@ -350,7 +353,11 @@ def process_pr_files_prediction(self, pr_body, value): s_label = semantic_label.strip("'").strip('"') pr_body += f"""{s_label.capitalize()}""" list_tuples = value[semantic_label] - pr_body += f"""
{len(list_tuples)} files""" + + if use_collapsible_file_list: + pr_body += f"""""" + else: + pr_body += """
{len(list_tuples)} files""" + else: + pr_body += f"""""" + if use_collapsible_file_list: + pr_body += """
""" for filename, file_change_description in list_tuples: filename = filename.replace("'", "`") filename_publish = filename.split("/")[-1] @@ -389,7 +396,10 @@ def process_pr_files_prediction(self, pr_body, value): """ - pr_body += """
""" pr_body += """""" except Exception as e: