hotfix/workflow-duplication #21

Merged
Latte merged 5 commits from hotfix/workflow-duplication into main 2025-12-29 10:34:49 +00:00
Owner
No description provided.
Latte added 4 commits 2025-12-29 10:33:01 +00:00
feat: Add automatic PR summary generator
All checks were successful
Enterprise AI Code Review / ai-review (pull_request) Successful in 7s
e21ec5f57a
Implements automatic PR summary generation feature that analyzes pull
request diffs and generates comprehensive summaries.

Features:
- Auto-generates summaries for PRs with empty descriptions
- Manual trigger via @codebot summarize command in PR comments
- Structured output with change type, files affected, and impact assessment
- Configurable (enable/disable, comment vs description update)

Implementation:
- Added pr_summary.md prompt template for LLM
- Extended PRAgent with summary generation methods
- Added auto_summary configuration in config.yml
- Comprehensive test suite with 10 new tests
- Updated documentation in README.md and CLAUDE.md

Usage:
- Automatic: Opens PR with no description → auto-generates summary
- Manual: Comment '@codebot summarize' on any PR

Related: Issue #2 - Milestone 2 feature delivery
Merge branch 'dev' into feature/pr-summary-generator
All checks were successful
Enterprise AI Code Review / ai-review (pull_request) Successful in 30s
92840d820b
Reviewed-on: #20
fix: Prevent duplicate workflow runs on @codebot mentions
All checks were successful
Enterprise AI Code Review / ai-review (pull_request) Successful in 40s
21470c7a4a
Critical fix for workflow routing that was causing 3x duplication on every
@codebot mention. All three workflows (ai-chat, ai-comment-reply, ai-issue-triage)
were triggering simultaneously.

Changes:
- ai-issue-triage.yml: Only runs on '@codebot triage' (unchanged, already specific)
- ai-comment-reply.yml: Only runs on specific commands (help, explain, suggest, etc)
- ai-chat.yml: Only runs on free-form questions (excludes all specific commands)

Workflow routing logic:
1. '@codebot triage' → ai-issue-triage.yml ONLY
2. '@codebot <command>' → ai-comment-reply.yml ONLY
3. '@codebot <question>' → ai-chat.yml ONLY (fallback)

This prevents the massive duplication issue where every @codebot mention
triggered all three workflows simultaneously, causing 10+ redundant runs.

Updated documentation in CLAUDE.md with workflow routing architecture.
Latte added 1 commit 2025-12-29 10:33:06 +00:00
Merge branch 'main' into hotfix/workflow-duplication
All checks were successful
Enterprise AI Code Review / ai-review (pull_request) Successful in 1m3s
c6a801c781
Owner

📋 Pull Request Summary

This PR introduces an automated PR summary generation feature that creates comprehensive, structured summaries for pull requests with empty descriptions or upon manual request via the @codebot summarize command. It enhances workflow routing to prevent duplicate AI workflow triggers and updates documentation to reflect these new capabilities.

Type: Feature

Changes

Added:

  • Automated PR summary generation in PRAgent
  • Manual @codebot summarize command handling for PR summaries
  • New prompt template pr_summary.md for PR summary generation
  • Extensive tests for PR summary generation functionality
  • Workflow routing logic to separate free-form chat, specific commands, and triage commands

📝 Modified:

  • PRAgent to support summary generation and command handling
  • AI workflows (ai-chat.yml, ai-comment-reply.yml, ai-issue-triage.yml) to implement mutually exclusive routing
  • Documentation (CLAUDE.md, README.md) to describe PR summary feature and updated workflow routing
  • Test suite to include tests for PR summary generation and configuration

Files Affected

  • 📝 .gitea/workflows/ai-chat.yml - Refined workflow conditions to trigger only on free-form @codebot mentions excluding specific commands
  • 📝 .gitea/workflows/ai-comment-reply.yml - Updated workflow to trigger only on specific @codebot commands, excluding free-form chat and triage
  • 📝 .gitea/workflows/ai-issue-triage.yml - Clarified workflow routing to handle only the 'triage' command
  • 📝 CLAUDE.md - Added detailed documentation on PR summary generation feature and workflow routing logic
  • 📝 README.md - Updated feature list and command descriptions to include PR summary generation
  • 📝 tests/test_ai_review.py - Added comprehensive tests covering PR summary prompt, command handling, formatting, and config validation
  • 📝 tools/ai-review/agents/pr_agent.py - Implemented PR summary generation logic, command handling for summarize, and formatting of summary output

Impact

🟡 Scope: Medium
Introduces a new automated and manual PR summary feature that improves PR documentation and reviewer experience without disrupting existing review workflows. Workflow routing changes reduce duplicate AI workflow triggers, enhancing efficiency.

## 📋 Pull Request Summary This PR introduces an automated PR summary generation feature that creates comprehensive, structured summaries for pull requests with empty descriptions or upon manual request via the `@codebot summarize` command. It enhances workflow routing to prevent duplicate AI workflow triggers and updates documentation to reflect these new capabilities. **Type:** ✨ Feature ## Changes **✅ Added:** - Automated PR summary generation in PRAgent - Manual `@codebot summarize` command handling for PR summaries - New prompt template `pr_summary.md` for PR summary generation - Extensive tests for PR summary generation functionality - Workflow routing logic to separate free-form chat, specific commands, and triage commands **📝 Modified:** - PRAgent to support summary generation and command handling - AI workflows (`ai-chat.yml`, `ai-comment-reply.yml`, `ai-issue-triage.yml`) to implement mutually exclusive routing - Documentation (`CLAUDE.md`, `README.md`) to describe PR summary feature and updated workflow routing - Test suite to include tests for PR summary generation and configuration ## Files Affected - 📝 `.gitea/workflows/ai-chat.yml` - Refined workflow conditions to trigger only on free-form @codebot mentions excluding specific commands - 📝 `.gitea/workflows/ai-comment-reply.yml` - Updated workflow to trigger only on specific @codebot commands, excluding free-form chat and triage - 📝 `.gitea/workflows/ai-issue-triage.yml` - Clarified workflow routing to handle only the 'triage' command - 📝 `CLAUDE.md` - Added detailed documentation on PR summary generation feature and workflow routing logic - 📝 `README.md` - Updated feature list and command descriptions to include PR summary generation - 📝 `tests/test_ai_review.py` - Added comprehensive tests covering PR summary prompt, command handling, formatting, and config validation - 📝 `tools/ai-review/agents/pr_agent.py` - Implemented PR summary generation logic, command handling for summarize, and formatting of summary output ## Impact 🟡 **Scope:** Medium Introduces a new automated and manual PR summary feature that improves PR documentation and reviewer experience without disrupting existing review workflows. Workflow routing changes reduce duplicate AI workflow triggers, enhancing efficiency.
Bartender reviewed 2025-12-29 10:33:39 +00:00
Bartender left a comment
Owner

AI Code Review - Inline Comments

AI Code Review - Inline Comments
Owner

[LOW] Maintainability

The 'if' condition for filtering out specific commands in the ai-chat workflow is very long and repetitive, which could be error-prone and hard to maintain as commands grow.

Recommendation: Consider defining a reusable list of commands and using a function or expression to check for exclusion, or move this logic to a reusable script or action input to improve maintainability.

**[LOW] Maintainability** The 'if' condition for filtering out specific commands in the ai-chat workflow is very long and repetitive, which could be error-prone and hard to maintain as commands grow. **Recommendation:** Consider defining a reusable list of commands and using a function or expression to check for exclusion, or move this logic to a reusable script or action input to improve maintainability.
Owner

[LOW] Testing

The new PR summary generation tests cover prompt existence, formatting, command handling, and formatting output, but do not include tests for failure scenarios such as LLM call failures or empty diffs.

Recommendation: Add tests to cover error handling paths in _generate_pr_summary, including empty diffs and exceptions from LLM calls, to ensure robustness.

**[LOW] Testing** The new PR summary generation tests cover prompt existence, formatting, command handling, and formatting output, but do not include tests for failure scenarios such as LLM call failures or empty diffs. **Recommendation:** Add tests to cover error handling paths in _generate_pr_summary, including empty diffs and exceptions from LLM calls, to ensure robustness.
Owner

[LOW] Correctness

The PR summary generation on PR open event does not short-circuit after generating the summary, which is intentional to continue with the normal review. However, if the summary generation fails, no fallback or notification is provided.

Recommendation: Consider logging or notifying if summary generation fails during auto-summary to aid debugging and visibility.

**[LOW] Correctness** The PR summary generation on PR open event does not short-circuit after generating the summary, which is intentional to continue with the normal review. However, if the summary generation fails, no fallback or notification is provided. **Recommendation:** Consider logging or notifying if summary generation fails during auto-summary to aid debugging and visibility.
Owner

[LOW] Maintainability

The _format_pr_summary method uses hardcoded emoji mappings and markdown formatting inline, which could be extracted for easier updates and localization.

Recommendation: Extract emoji mappings and markdown templates to constants or configuration to improve maintainability and allow easier customization.

**[LOW] Maintainability** The _format_pr_summary method uses hardcoded emoji mappings and markdown formatting inline, which could be extracted for easier updates and localization. **Recommendation:** Extract emoji mappings and markdown templates to constants or configuration to improve maintainability and allow easier customization.
Owner

[LOW] Performance

The _format_pr_summary method limits files affected to the first 10 files but still processes all files in the list before slicing, which is acceptable but could be optimized if the list is very large.

Recommendation: If performance becomes an issue, consider slicing the list before iteration to avoid unnecessary processing.

**[LOW] Performance** The _format_pr_summary method limits files affected to the first 10 files but still processes all files in the list before slicing, which is acceptable but could be optimized if the list is very large. **Recommendation:** If performance becomes an issue, consider slicing the list before iteration to avoid unnecessary processing.
Owner

AI Code Review

This PR introduces a new feature for automatic and manual generation of comprehensive PR summaries, integrated into the existing AI review system. The workflows have been updated to prevent duplicate triggers, and extensive tests cover the new summary functionality. The implementation is well-structured, with clear separation of concerns and good documentation. No critical security or correctness issues were found. Minor improvements in error handling and documentation clarity are suggested.

Summary

Severity Count
HIGH 0
MEDIUM 0
LOW 5

Review Findings

  • [LOW] tools/ai-review/agents/pr_agent.py:847 - The method _generate_pr_summary attempts to update the PR description via Gitea API, but the comment notes that this may not be supported and falls back to posting a comment. This fallback is good, but the code does not explicitly verify API support or handle partial failures robustly.
  • [LOW] tools/ai-review/agents/pr_agent.py:823 - The _format_pr_summary method uses hardcoded emoji mappings and markdown formatting inline, which could be extracted for easier updates and localization.
  • [LOW] .gitea/workflows/ai-chat.yml:15 - The workflow condition for ai-chat.yml uses a long chain of negated contains() checks to exclude specific commands, which can be error-prone and hard to maintain as commands evolve.
  • [LOW] tools/ai-review/agents/pr_agent.py:805 - The _generate_pr_summary method concatenates the prompt template and diff with a simple newline, which may cause formatting issues if the prompt or diff contains trailing or leading whitespace.
  • [LOW] tools/ai-review/agents/pr_agent.py:92 - The can_handle method checks for both 'review-again' and 'summarize' commands in the same conditional, which could grow as more commands are added.

Overall Severity: LOW
AI Recommendation: Approve

<!-- AI_PR_REVIEW --> ## AI Code Review This PR introduces a new feature for automatic and manual generation of comprehensive PR summaries, integrated into the existing AI review system. The workflows have been updated to prevent duplicate triggers, and extensive tests cover the new summary functionality. The implementation is well-structured, with clear separation of concerns and good documentation. No critical security or correctness issues were found. Minor improvements in error handling and documentation clarity are suggested. ### Summary | Severity | Count | |----------|-------| | HIGH | 0 | | MEDIUM | 0 | | LOW | 5 | ### Review Findings - **[LOW]** `tools/ai-review/agents/pr_agent.py:847` - The method _generate_pr_summary attempts to update the PR description via Gitea API, but the comment notes that this may not be supported and falls back to posting a comment. This fallback is good, but the code does not explicitly verify API support or handle partial failures robustly. - **[LOW]** `tools/ai-review/agents/pr_agent.py:823` - The _format_pr_summary method uses hardcoded emoji mappings and markdown formatting inline, which could be extracted for easier updates and localization. - **[LOW]** `.gitea/workflows/ai-chat.yml:15` - The workflow condition for ai-chat.yml uses a long chain of negated contains() checks to exclude specific commands, which can be error-prone and hard to maintain as commands evolve. - **[LOW]** `tools/ai-review/agents/pr_agent.py:805` - The _generate_pr_summary method concatenates the prompt template and diff with a simple newline, which may cause formatting issues if the prompt or diff contains trailing or leading whitespace. - **[LOW]** `tools/ai-review/agents/pr_agent.py:92` - The can_handle method checks for both 'review-again' and 'summarize' commands in the same conditional, which could grow as more commands are added. --- **Overall Severity:** `LOW` **AI Recommendation:** Approve
Owner

📋 Pull Request Summary

This PR introduces an automated PR summary generation feature that creates comprehensive, structured summaries for pull requests with empty descriptions or upon manual request via the @codebot summarize command. It enhances workflow routing to prevent duplicate AI workflow triggers and updates documentation and tests to support and describe this new functionality.

Type: Feature

Changes

Added:

  • Automated PR summary generation in PRAgent
  • Manual @codebot summarize command handling in PRAgent
  • New prompt template pr_summary.md for PR summary generation
  • Extensive tests for PR summary generation functionality
  • Workflow routing logic to separate free-form chat, specific commands, and triage commands

📝 Modified:

  • AI workflows (ai-chat.yml, ai-comment-reply.yml, ai-issue-triage.yml) to implement mutually exclusive routing based on comment content
  • PRAgent to support summary generation, including new methods _generate_pr_summary and _format_pr_summary
  • Documentation (CLAUDE.md, README.md) to describe the PR summary feature and updated workflow routing
  • Test suite (test_ai_review.py) to add coverage for PR summary feature and configuration

Files Affected

  • 📝 .gitea/workflows/ai-chat.yml - Refined workflow conditions to trigger only on free-form @codebot mentions excluding specific commands
  • 📝 .gitea/workflows/ai-comment-reply.yml - Updated workflow to trigger only on specific @codebot commands, excluding free-form chat and triage
  • 📝 .gitea/workflows/ai-issue-triage.yml - Clarified workflow routing to handle only the 'triage' command
  • 📝 CLAUDE.md - Added detailed documentation on PR summary generation feature and workflow routing logic
  • 📝 README.md - Updated feature list and command descriptions to include PR summary generation
  • 📝 tests/test_ai_review.py - Added comprehensive tests covering PR summary prompt, command handling, formatting, and config validation
  • 📝 tools/ai-review/agents/pr_agent.py - Implemented PR summary generation logic, command handling, and formatting in PRAgent

Impact

🟡 Scope: Medium
Introduces a new automated and manual PR summary feature that improves PR documentation and reviewer experience without affecting existing review or triage functionality. Workflow routing changes prevent duplicate AI workflow triggers, enhancing efficiency.

## 📋 Pull Request Summary This PR introduces an automated PR summary generation feature that creates comprehensive, structured summaries for pull requests with empty descriptions or upon manual request via the `@codebot summarize` command. It enhances workflow routing to prevent duplicate AI workflow triggers and updates documentation and tests to support and describe this new functionality. **Type:** ✨ Feature ## Changes **✅ Added:** - Automated PR summary generation in PRAgent - Manual `@codebot summarize` command handling in PRAgent - New prompt template `pr_summary.md` for PR summary generation - Extensive tests for PR summary generation functionality - Workflow routing logic to separate free-form chat, specific commands, and triage commands **📝 Modified:** - AI workflows (`ai-chat.yml`, `ai-comment-reply.yml`, `ai-issue-triage.yml`) to implement mutually exclusive routing based on comment content - PRAgent to support summary generation, including new methods `_generate_pr_summary` and `_format_pr_summary` - Documentation (`CLAUDE.md`, `README.md`) to describe the PR summary feature and updated workflow routing - Test suite (`test_ai_review.py`) to add coverage for PR summary feature and configuration ## Files Affected - 📝 `.gitea/workflows/ai-chat.yml` - Refined workflow conditions to trigger only on free-form @codebot mentions excluding specific commands - 📝 `.gitea/workflows/ai-comment-reply.yml` - Updated workflow to trigger only on specific @codebot commands, excluding free-form chat and triage - 📝 `.gitea/workflows/ai-issue-triage.yml` - Clarified workflow routing to handle only the 'triage' command - 📝 `CLAUDE.md` - Added detailed documentation on PR summary generation feature and workflow routing logic - 📝 `README.md` - Updated feature list and command descriptions to include PR summary generation - 📝 `tests/test_ai_review.py` - Added comprehensive tests covering PR summary prompt, command handling, formatting, and config validation - 📝 `tools/ai-review/agents/pr_agent.py` - Implemented PR summary generation logic, command handling, and formatting in PRAgent ## Impact 🟡 **Scope:** Medium Introduces a new automated and manual PR summary feature that improves PR documentation and reviewer experience without affecting existing review or triage functionality. Workflow routing changes prevent duplicate AI workflow triggers, enhancing efficiency.
Bartender reviewed 2025-12-29 10:34:43 +00:00
Bartender left a comment
Owner

AI Code Review - Inline Comments

AI Code Review - Inline Comments
Owner

[LOW] Maintainability

The workflow condition for ai-chat.yml uses a long chain of negated contains() checks to exclude specific commands, which can be error-prone and hard to maintain as commands evolve.

Recommendation: Consider defining a reusable list or variable of known commands and use a more maintainable expression or a script step to determine if the comment is a free-form chat. Alternatively, centralize command definitions to avoid duplication across workflows.

**[LOW] Maintainability** The workflow condition for ai-chat.yml uses a long chain of negated contains() checks to exclude specific commands, which can be error-prone and hard to maintain as commands evolve. **Recommendation:** Consider defining a reusable list or variable of known commands and use a more maintainable expression or a script step to determine if the comment is a free-form chat. Alternatively, centralize command definitions to avoid duplication across workflows.
Owner

[LOW] Correctness

The method _generate_pr_summary attempts to update the PR description via Gitea API, but the comment notes that this may not be supported and falls back to posting a comment. This fallback is good, but the code does not explicitly verify API support or handle partial failures robustly.

Recommendation: Add explicit detection or configuration for whether PR description updates are supported by the Gitea instance. Consider logging more detailed errors or warnings if the update fails, and document this behavior clearly for maintainers.

**[LOW] Correctness** The method _generate_pr_summary attempts to update the PR description via Gitea API, but the comment notes that this may not be supported and falls back to posting a comment. This fallback is good, but the code does not explicitly verify API support or handle partial failures robustly. **Recommendation:** Add explicit detection or configuration for whether PR description updates are supported by the Gitea instance. Consider logging more detailed errors or warnings if the update fails, and document this behavior clearly for maintainers.
Owner

[LOW] Maintainability

The _format_pr_summary method uses hardcoded emoji mappings and markdown formatting inline, which could be extracted for easier updates and localization.

Recommendation: Extract emoji mappings and markdown templates into class-level constants or configuration to improve maintainability and allow easier future changes or internationalization.

**[LOW] Maintainability** The _format_pr_summary method uses hardcoded emoji mappings and markdown formatting inline, which could be extracted for easier updates and localization. **Recommendation:** Extract emoji mappings and markdown templates into class-level constants or configuration to improve maintainability and allow easier future changes or internationalization.
Owner

[LOW] Readability

The _generate_pr_summary method concatenates the prompt template and diff with a simple newline, which may cause formatting issues if the prompt or diff contains trailing or leading whitespace.

Recommendation: Strip or sanitize the prompt template and diff before concatenation to ensure consistent formatting. Consider using a more explicit template rendering approach.

**[LOW] Readability** The _generate_pr_summary method concatenates the prompt template and diff with a simple newline, which may cause formatting issues if the prompt or diff contains trailing or leading whitespace. **Recommendation:** Strip or sanitize the prompt template and diff before concatenation to ensure consistent formatting. Consider using a more explicit template rendering approach.
Owner

[LOW] Maintainability

The can_handle method checks for both 'review-again' and 'summarize' commands in the same conditional, which could grow as more commands are added.

Recommendation: Refactor command detection into a helper method or use a set of supported commands to improve extensibility and reduce duplication.

**[LOW] Maintainability** The can_handle method checks for both 'review-again' and 'summarize' commands in the same conditional, which could grow as more commands are added. **Recommendation:** Refactor command detection into a helper method or use a set of supported commands to improve extensibility and reduce duplication.
Latte merged commit f5ef66b43d into main 2025-12-29 10:34:49 +00:00
Latte deleted branch hotfix/workflow-duplication 2025-12-29 10:34:49 +00:00
Owner

@None

Summary:
Please provide the title and body of the issue you would like summarized.

@None **Summary:** Please provide the title and body of the issue you would like summarized.
Owner

@None

Summary:
Please provide the issue details you would like summarized.

@None **Summary:** Please provide the issue details you would like summarized.
Sign in to join this conversation.
No Reviewers
No Label
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Hiddenden/openrabbit#21