Skip to content

Improve try-fix comment parsing and summary#33794

Merged
PureWeen merged 2 commits intodotnet:mainfrom
kubaflo:post-try-fix-comment-improvements
Jan 31, 2026
Merged

Improve try-fix comment parsing and summary#33794
PureWeen merged 2 commits intodotnet:mainfrom
kubaflo:post-try-fix-comment-improvements

Conversation

@kubaflo
Copy link
Contributor

@kubaflo kubaflo commented Jan 30, 2026

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:

  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

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.
Copilot AI review requested due to automatic review settings January 30, 2026 13:40
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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")

- 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
@rmarinho
Copy link
Member

📋 PR Finalization Review

Title: ✅ Good

Current: Improve try-fix comment parsing and summary

Description: ❌ Needs Rewrite

Description needs updates. See details below.

✨ Suggested PR Description

note in for people that find this PR -->

[!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:

  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

@kubaflo kubaflo added the area-ai-agents Copilot CLI agents, agent skills, AI-assisted development label Jan 30, 2026
@PureWeen PureWeen merged commit add9f44 into dotnet:main Jan 31, 2026
2 of 3 checks passed
kubaflo added a commit to kubaflo/maui that referenced this pull request Feb 2, 2026
> [!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
@kubaflo kubaflo added the copilot label Feb 6, 2026
This was referenced Feb 12, 2026
This was referenced Feb 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-ai-agents Copilot CLI agents, agent skills, AI-assisted development copilot

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Comments