fix: Better comment formatting with plain text and line separators

This commit is contained in:
Ricel Leite 2026-02-18 18:03:13 -03:00
parent 5c8ceadb77
commit b8e38870e3
2 changed files with 49 additions and 9 deletions

37
api/comment_fix.py Normal file
View File

@ -0,0 +1,37 @@
# Nova função post_analysis_comment com formatação melhor
async def post_analysis_comment(ticket: dict, result: dict):
"""Post analysis result back to TicketHub as a comment"""
ticket_id = ticket.get("id")
if not ticket_id:
return
confidence_pct = int(result.get("confidence", 0) * 100)
files = ", ".join(result.get("affected_files", ["Unknown"]))
# Formatação texto plano com quebras de linha claras
comment = f"""🤖 AI ANALYSIS COMPLETE
📋 ROOT CAUSE:
{result.get('analysis', 'Unable to determine')}
📁 AFFECTED FILES: {files}
🔧 SUGGESTED FIX:
{result.get('suggested_fix', 'No fix suggested')}
📊 CONFIDENCE: {confidence_pct}%
Analyzed by JIRA AI Fixer"""
async with httpx.AsyncClient(timeout=10.0) as client:
try:
await client.post(
f"https://tickethub.startdata.com.br/api/tickets/{ticket_id}/comments",
json={"author": "AI Fixer", "content": comment}
)
except:
pass

View File

@ -290,21 +290,24 @@ async def post_analysis_comment(ticket: dict, result: dict):
confidence_pct = int(result.get("confidence", 0) * 100)
files = ", ".join(result.get("affected_files", ["Unknown"]))
comment = f"""🤖 **AI Analysis Complete**
# Formatação texto plano com quebras de linha claras
comment = f"""🤖 AI ANALYSIS COMPLETE
**Root Cause:** {result.get('analysis', 'Unable to determine')}
📋 ROOT CAUSE:
{result.get('analysis', 'Unable to determine')}
**Affected Files:** {files}
📁 AFFECTED FILES: {files}
**Suggested Fix:**
```cobol
🔧 SUGGESTED FIX:
{result.get('suggested_fix', 'No fix suggested')}
```
**Confidence:** {confidence_pct}%
📊 CONFIDENCE: {confidence_pct}%
---
_Analyzed by JIRA AI Fixer_"""
Analyzed by JIRA AI Fixer"""
async with httpx.AsyncClient(timeout=10.0) as client:
try: