Improve try-fix comment parsing and summary#33794
Conversation
Refactor the Post-Try-Fix comment logic to more robustly parse and preserve existing attempts. Extract the inner attempts area (supporting both new and old headers), strip stray headers/HRs, and count existing attempts/pass/fail statuses. Update attempt insertion/replacement to operate on the inner content, adjust Approach newline handling, and build a single collapsible Try-Fix section with a concise summary (e.g. ✅ n passed, ❌ m failed). Misc: remove redundant header handling and ensure the section is wrapped consistently to avoid duplicated headers and formatting issues.
There was a problem hiding this comment.
Pull request overview
This PR refactors the try-fix comment logic in post-try-fix-comment.ps1 to more robustly parse and preserve existing attempts. The changes aim to improve handling of both new and old comment formats, provide better counting of attempt statuses, and create a cleaner collapsible summary section.
Changes:
- Enhanced extraction logic to support both new collapsible format and old header format
- Added counting logic to track passed/failed attempts for display in summary
- Modified attempt insertion/replacement to work on extracted inner content rather than full section
- Created a new collapsible wrapper with status summary (e.g., "✅ 2 passed, ❌ 1 failed")
.github/skills/ai-summary-comment/scripts/post-try-fix-comment.ps1
Outdated
Show resolved
Hide resolved
.github/skills/ai-summary-comment/scripts/post-try-fix-comment.ps1
Outdated
Show resolved
Hide resolved
.github/skills/ai-summary-comment/scripts/post-try-fix-comment.ps1
Outdated
Show resolved
Hide resolved
.github/skills/ai-summary-comment/scripts/post-try-fix-comment.ps1
Outdated
Show resolved
Hide resolved
.github/skills/ai-summary-comment/scripts/post-try-fix-comment.ps1
Outdated
Show resolved
Hide resolved
- Add ⚪ emoji to existingAttemptCount regex pattern (line 360) - Remove extra space in assignment (line 371) - Recalculate attempt statistics from final content for consistency - Fix counting logic to properly handle Compiles status - Use totalAttemptCount instead of existingAttemptCount for fallback
📋 PR Finalization ReviewTitle: ✅ GoodCurrent: Description: ❌ Needs RewriteDescription needs updates. See details below. ✨ Suggested PR Descriptionnote in for people that find this PR -->
Root CauseThe post-try-fix-comment script had several formatting issues:
Description of ChangeRefactored comment parsing to: 1. Robust Content Extraction
2. Accurate Attempt Counting
3. Clean Attempt Insertion
4. Single Collapsible Section
Key ChangesFile:
Issues FixedNone (internal improvement to pr agent infrastructure) Testing
|
> [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ### Root Cause The post-try-fix-comment script had several formatting issues: 1. **Duplicated headers** - Old "### 🔧 Try-Fix Analysis" headers accumulated when updating comments 2. **Stray formatting** - Horizontal rules and `<br>` tags accumulated between attempts 3. **No summary** - Users had to expand each attempt to see overall status 4. **Fragile parsing** - Didn't handle both old (header-based) and new (collapsible) formats ### Description of Change Refactored comment parsing to: **1. Robust Content Extraction** - Extract inner attempts area, supporting both: - **New format:** `<details><summary><b>🔧 Try-Fix Analysis...</summary>...[attempts]...</details>` - **Old format:** `### 🔧 Try-Fix Analysis\n\n...[attempts]...` - Strip stray headers (`### 🔧...`), horizontal rules (`---`), and `<br>` tags **2. Accurate Attempt Counting** - Count existing attempts by status emoji: `✅` (passed), `❌` (failed) - Recalculate after insertion/replacement to ensure consistency - Use counts to build summary line: `"✅ 2 passed, ❌ 1 failed"` **3. Clean Attempt Insertion** - Operate on inner content only (avoids wrapper duplication) - Replace existing attempt by number, or append new - Add newline before Approach text for proper spacing **4. Single Collapsible Section** - Wrap all attempts in one `<details>` with summary showing status counts - Example: `🔧 Try-Fix Analysis: ✅ 2 passed, ❌ 1 failed` - Eliminates duplicated wrappers and headers ### Key Changes **File:** `.github/skills/ai-summary-comment/scripts/post-try-fix-comment.ps1` | Change | Before | After | |--------|--------|-------| | **Header handling** | Added `### 🔧` header each time | Single collapsible with summary | | **Content extraction** | Used entire section as-is | Extract inner attempts, strip wrappers | | **Counting** | Not implemented | Count ✅/❌ and show in summary | | **Attempt matching** | Matched old "Attempt N:" format | Match new "Fix N" with emoji | | **Approach spacing** | `"$Approach\n\n"` | `"\n$Approach\n\n"` (blank line before) | ### Issues Fixed None (internal improvement to pr agent infrastructure) ### Testing - Tested with existing try-fix comments (both old and new formats) - Verified attempt counting and summary generation - Confirmed no header/wrapper duplication
Note
Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!
Root Cause
The post-try-fix-comment script had several formatting issues:
<br>tags accumulated between attemptsDescription of Change
Refactored comment parsing to:
1. Robust Content Extraction
<details><summary><b>🔧 Try-Fix Analysis...</summary>...[attempts]...</details>### 🔧 Try-Fix Analysis\n\n...[attempts]...### 🔧...), horizontal rules (---), and<br>tags2. Accurate Attempt Counting
✅(passed),❌(failed)"✅ 2 passed, ❌ 1 failed"3. Clean Attempt Insertion
4. Single Collapsible Section
<details>with summary showing status counts🔧 Try-Fix Analysis: ✅ 2 passed, ❌ 1 failedKey Changes
File:
.github/skills/ai-summary-comment/scripts/post-try-fix-comment.ps1### 🔧header each time"$Approach\n\n""\n$Approach\n\n"(blank line before)Issues Fixed
None (internal improvement to pr agent infrastructure)
Testing