From 829417ce6e0be0cf5d5fc0fc21091a7dca9be197 Mon Sep 17 00:00:00 2001 From: dst03106 Date: Fri, 6 Jun 2025 20:12:58 +0900 Subject: [PATCH 1/5] feat: toggle open or closed based on line count for todo section --- pr_agent/algo/utils.py | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/pr_agent/algo/utils.py b/pr_agent/algo/utils.py index b967a0be..a106a7f3 100644 --- a/pr_agent/algo/utils.py +++ b/pr_agent/algo/utils.py @@ -260,12 +260,9 @@ def convert_to_markdown_v2(output_data: dict, else: return file_ref - if gfm_supported: - markdown_text += f"" - if is_value_no(value): - markdown_text += f"{emoji} No TODO sections" - else: - markdown_text += f"{emoji} TODO sections ({len(value)} items)\n
{todos_summary}\n\n" + def format_todo_items(value: list[TodoItem] | TodoItem) -> str: + markdown_text = "" + if gfm_supported: if isinstance(value, list): markdown_text += "\n" else: markdown_text += f"

{format_todo_item(value)}

\n" - markdown_text += "\n
\n" - markdown_text += f"\n" - else: - if is_value_no(value): - markdown_text += f"### {emoji} No TODO sections\n\n" else: - markdown_text += f"### {emoji} TODO sections ({len(value)} items)\n
{todos_summary}\n\n" if isinstance(value, list): for todo_item in value: markdown_text += f"- {format_todo_item(todo_item)}\n" else: markdown_text += f"- {format_todo_item(value)}\n" + return markdown_text + + markdown_todo_items = format_todo_items(value) + EXPAND_LINE_THRESHOLD = 10 + details_open_attr = " open" if markdown_todo_items.count("\n") + 1 <= EXPAND_LINE_THRESHOLD else "" + if gfm_supported: + markdown_text += "" + if is_value_no(value): + markdown_text += f"{emoji} No TODO sections" + else: + markdown_text += f"{emoji} TODO sections ({len(value)} items)\n" + markdown_text += f"{todos_summary}\n\n" + markdown_text += markdown_todo_items + markdown_text += "\n
\n" + markdown_text += "\n" + else: + if is_value_no(value): + markdown_text += f"### {emoji} No TODO sections\n\n" + else: + markdown_text += f"### {emoji} TODO sections ({len(value)} items)\n{todos_summary}\n\n" + markdown_text += markdown_todo_items markdown_text += "\n\n\n" elif 'can be split' in key_nice.lower(): if gfm_supported: From 277c6abf0f2c7df4a6d8e8c88d669d4c77903105 Mon Sep 17 00:00:00 2001 From: dst03106 Date: Fri, 6 Jun 2025 20:13:32 +0900 Subject: [PATCH 2/5] refactor: standardizes todo_sections and todos_summary formatting --- pr_agent/settings/pr_reviewer_prompts.toml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pr_agent/settings/pr_reviewer_prompts.toml b/pr_agent/settings/pr_reviewer_prompts.toml index 6d94acd6..417099b7 100644 --- a/pr_agent/settings/pr_reviewer_prompts.toml +++ b/pr_agent/settings/pr_reviewer_prompts.toml @@ -168,9 +168,9 @@ review: - ... security_concerns: | No - todo_sections: + todo_sections: | No - todos_summary: + todos_summary: | No {%- if require_can_be_split_review %} can_be_split: @@ -290,9 +290,9 @@ review: - ... security_concerns: | No - todo_sections: + todo_sections: | No - todos_summary: + todos_summary: | No {%- if require_can_be_split_review %} can_be_split: From 6c05c6685e1a5ec06ab060683661a63fa0a3eb87 Mon Sep 17 00:00:00 2001 From: dst03106 Date: Fri, 6 Jun 2025 22:51:24 +0900 Subject: [PATCH 3/5] fix: use | for multiline in YAML instead of \n for todo content prompts --- pr_agent/settings/pr_reviewer_prompts.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pr_agent/settings/pr_reviewer_prompts.toml b/pr_agent/settings/pr_reviewer_prompts.toml index 417099b7..918cff00 100644 --- a/pr_agent/settings/pr_reviewer_prompts.toml +++ b/pr_agent/settings/pr_reviewer_prompts.toml @@ -75,7 +75,7 @@ class KeyIssuesComponentLink(BaseModel): class TodoSection(BaseModel): relevant_file: str = Field(description="The file containing the TODO comment") line_range: Tuple[int, int] = Field(description="Start and end line numbers of the TODO comment (inclusive). Must be a tuple of two integers, e.g., (7, 7) for a single line or (7, 10) for a range. Do not use list format [7, 7].") - content: str = Field(description="The content of the TODO comment. Only include actual TODO comments within code comments (e.g., lines starting with '#', '//', '/*', '