import pandas as pd def get_verdict_badge(verdict, status, github_state): v = str(verdict).lower() # Badges use solid colors and white text, work well in both modes if status == 'executed' or github_state == 'closed': return 'CLOSED' elif "possibly_resolved" in v: return 'POSSIBLY RESOLVED' elif "unresolved" in v: return 'OPEN BUG' elif "resolved" in v: return 'RESOLVED' elif "duplicate" in v: return 'DUPLICATE' elif "pending" in v or "new" in v: # Adjusted for dark mode: darker background if needed, but light gray usually works return 'WAITING AGENT' else: return f'{verdict}' def get_priority_badge(priority): p = str(priority).lower() if priority else "" # Using text colors, they should contrast well on gradio's dark/light background if "critical" in p: return '🔥 Critical' if "high" in p: return 'High' if "medium" in p: return 'Medium' if "low" in p: return 'Low' return "-" def generate_issues_html(df: pd.DataFrame, sort_col: str = "updated_at", sort_asc: bool = False) -> str: if df.empty: # Using a white container even when empty to maintain consistency return """
No issues found for this view.
""" headers_map = { "Issue": "issue_number", "Title / Repo": "title", "Verdict": "verdict", #"Priority": "priority", "Model": "llm_model", #"Confidence": "confidence", "Updated": "updated_at" } html = """
""" # Loop Headers for display, col_name in headers_map.items(): width = 'style="width: 70px;"' if display == "Issue" else "" icon = "" if col_name == sort_col: icon = "â–²" if sort_asc else "â–¼" icon_class = "tm-sort-icon tm-sort-active" else: icon = "â–¼" # Default hint icon_class = "tm-sort-icon" html += f""" """ html += """ """ for _, row in df.iterrows(): issue_num = row['issue_number'] repo_full = str(row['repo_url']) repo_short = repo_full.split('github.com/')[-1] if 'github.com' in repo_full else repo_full title = str(row.get('title') or "No Title") verdict_html = get_verdict_badge(row['verdict'], row['status'], row.get('github_state')) #priority_html = get_priority_badge(row.get('priority')) raw_model = str(row.get('llm_model') or "") model = raw_model.split('/')[-1] if raw_model else "-" #conf = f"{float(row.get('confidence', 0))*100:.0f}%" if row.get('confidence') else "-" # Define border class based on status status_code = row.get('status', 'new') status_class = f"status-{status_code}" if status_code in ['pending_approval', 'executed'] else "status-new" data_attrs = f'data-issue-number="{issue_num}" data-repo-url="{row["repo_url"]}" data-verdict="{row["verdict"]}"' target_url = f"{repo_full.rstrip('/')}/issues/{issue_num}" html += f""" """ html += "
{display} {icon} Actions
#{issue_num}
{title[:65]}{'...' if len(title)>65 else ''}
{repo_short}
{verdict_html} {model} {str(row["updated_at"])[:10]} GitHub ↗
" return html