""" Evolva Operator Dashboard Fetches CURRENT_STATE.md from GitHub and displays: - Current sprint/phase - Test pass/fail counts - Recent session count - Status indicator (GREEN/YELLOW/RED) """ import gradio as gr import requests import re import json from datetime import datetime, timezone # ─── GitHub Configuration ───────────────────────────────────────────────────── GITHUB_RAW_URLS = [ "https://raw.githubusercontent.com/Gudmundur76/manus-persistent-drive/main/CURRENT_STATE.md", "https://raw.githubusercontent.com/Gudmundur76/ttruthdesk-platform/main/CURRENT_STATE.md", "https://raw.githubusercontent.com/Gudmundur76/manus-persistent-drive/main/docs/CURRENT_STATE.md", ] # ─── Fetch & Parse CURRENT_STATE.md ────────────────────────────────────────── def fetch_current_state(): """Fetch CURRENT_STATE.md from GitHub, trying multiple known paths.""" content = None source_url = None for url in GITHUB_RAW_URLS: try: resp = requests.get(url, timeout=10) if resp.status_code == 200: content = resp.text source_url = url break except Exception: continue return content, source_url def parse_state(content: str) -> dict: """Parse key metrics from CURRENT_STATE.md markdown.""" state = { "sprint": "Unknown", "phase": "Unknown", "tests_pass": 0, "tests_fail": 0, "tests_total": 0, "sessions": 0, "status": "YELLOW", "last_updated": "Unknown", "raw_content": content } if not content: return state # Sprint/phase detection sprint_match = re.search(r'[Ss]print[\s#:]*(\d+)', content) if sprint_match: state["sprint"] = f"Sprint {sprint_match.group(1)}" phase_match = re.search(r'[Pp]hase[\s#:]*(\d+|[A-Za-z]+)', content) if phase_match: state["phase"] = f"Phase {phase_match.group(1)}" # Test counts pass_match = re.search(r'[Pp]ass(?:ing|ed)?[\s:]*(\d+)', content) fail_match = re.search(r'[Ff]ail(?:ing|ed)?[\s:]*(\d+)', content) total_match = re.search(r'[Tt]otal[\s:]*(\d+)\s*[Tt]ests?', content) if pass_match: state["tests_pass"] = int(pass_match.group(1)) if fail_match: state["tests_fail"] = int(fail_match.group(1)) if total_match: state["tests_total"] = int(total_match.group(1)) elif state["tests_pass"] or state["tests_fail"]: state["tests_total"] = state["tests_pass"] + state["tests_fail"] # Session count session_match = re.search(r'[Ss]ession(?:s)?[\s:]*(\d+)', content) if session_match: state["sessions"] = int(session_match.group(1)) # Status detection if re.search(r'\bGREEN\b', content): state["status"] = "GREEN" elif re.search(r'\bRED\b', content): state["status"] = "RED" elif re.search(r'\bYELLOW\b', content): state["status"] = "YELLOW" # Last updated date_match = re.search(r'(?:[Ll]ast [Uu]pdated|[Dd]ate)[\s:]*([0-9]{4}-[0-9]{2}-[0-9]{2})', content) if date_match: state["last_updated"] = date_match.group(1) return state def get_status_html(status: str) -> str: colors = { "GREEN": ("#28a745", "🟢", "All systems operational"), "YELLOW": ("#ffc107", "🟡", "In progress / attention needed"), "RED": ("#dc3545", "🔴", "Blocked / critical issues"), } color, emoji, label = colors.get(status, ("#6c757d", "⚪", "Unknown")) return f"""
Last fetched: {fetch_time} | {source_info}