"""
ARF UI Components
Gradio-first, Hugging Face Spaces safe
Compatible with app.py v3.8.0
"""
from __future__ import annotations
import gradio as gr
import plotly.graph_objects as go
from typing import Dict, Any, List
# ============================================================
# HEADER / FOOTER
# ============================================================
def create_header(version: str, enterprise: bool = False):
badge = "ENTERPRISE EDITION" if enterprise else "OSS EDITION"
return gr.HTML(
f"""
🚀 Agentic Reliability Framework
Version: {version} · {badge}
"""
)
def create_footer():
return gr.HTML(
"""
ARF © 2025 · Self-Healing Agentic Systems
"""
)
def create_status_bar():
return gr.HTML(
"""
✅ System Online · 🧠Agentic Core Active · 📦 OSS Mode
"""
)
# ============================================================
# TAB 1 — INCIDENT DEMO
# ============================================================
def create_tab1_incident_demo(scenarios: Dict[str, Any], default: str):
scenario_dropdown = gr.Dropdown(
choices=list(scenarios.keys()),
value=default,
label="Incident Scenario"
)
scenario_description = gr.Markdown("Select a scenario to begin analysis.")
metrics_display = gr.JSON(label="Live Metrics")
impact_display = gr.Markdown("### Estimated Business Impact")
timeline_output = gr.Markdown("Timeline will render here")
oss_btn = gr.Button("Run OSS Analysis")
enterprise_btn = gr.Button("Execute Enterprise Healing", variant="primary")
approval_toggle = gr.Checkbox(label="Require Human Approval", value=True)
demo_btn = gr.Button("Run Demo")
approval_display = gr.HTML()
oss_results_display = gr.JSON(label="OSS Results")
enterprise_results_display = gr.JSON(label="Enterprise Results")
return (
scenario_dropdown,
scenario_description,
metrics_display,
impact_display,
timeline_output,
oss_btn,
enterprise_btn,
approval_toggle,
demo_btn,
approval_display,
oss_results_display,
enterprise_results_display,
)
# ============================================================
# TAB 2 — ROI / BUSINESS IMPACT
# ============================================================
def create_tab2_business_roi(scenarios: Dict[str, Any]):
dashboard_output = gr.Plot(label="Executive ROI Dashboard")
roi_scenario_dropdown = gr.Dropdown(
choices=list(scenarios.keys()),
label="Scenario"
)
monthly_slider = gr.Slider(
1, 100, value=15, step=1, label="Monthly Incidents"
)
team_slider = gr.Slider(
1, 50, value=5, step=1, label="On-call Team Size"
)
calculate_btn = gr.Button("Calculate ROI", variant="primary")
roi_output = gr.JSON(label="ROI Breakdown")
roi_chart = gr.Plot(label="ROI Multiplier")
return (
dashboard_output,
roi_scenario_dropdown,
monthly_slider,
team_slider,
calculate_btn,
roi_output,
roi_chart,
)
# ============================================================
# TAB 3 — ENTERPRISE FEATURES
# ============================================================
def create_tab3_enterprise_features():
license_display = gr.JSON(label="License Status")
validate_btn = gr.Button("Validate License")
trial_btn = gr.Button("Start Trial")
upgrade_btn = gr.Button("Upgrade")
mcp_mode = gr.Radio(
["advisory", "approval", "autonomous"],
value="advisory",
label="MCP Execution Mode"
)
mcp_mode_info = gr.JSON(label="Mode Details")
features_table = gr.Dataframe(
headers=["Feature", "Available"],
value=[
["Autonomous Healing", "Enterprise"],
["Audit Trail", "Enterprise"],
["Compliance", "Enterprise"],
],
interactive=False
)
integrations_table = gr.Dataframe(
headers=["Integration", "Status"],
value=[
["Kubernetes", "Ready"],
["AWS", "Ready"],
["GCP", "Ready"],
],
interactive=False
)
return (
license_display,
validate_btn,
trial_btn,
upgrade_btn,
mcp_mode,
mcp_mode_info,
features_table,
integrations_table,
)
# ============================================================
# TAB 4 — AUDIT TRAIL
# ============================================================
def create_tab4_audit_trail():
refresh_btn = gr.Button("Refresh")
clear_btn = gr.Button("Clear")
export_btn = gr.Button("Export")
execution_table = gr.Dataframe(
headers=["Time", "Scenario", "Mode", "Status", "Savings", "Details"],
interactive=False
)
incident_table = gr.Dataframe(
headers=["Time", "Component", "Scenario", "Severity", "Status"],
interactive=False
)
export_text = gr.Textbox(
label="Exported Audit JSON",
lines=15
)
return (
refresh_btn,
clear_btn,
export_btn,
execution_table,
incident_table,
export_text,
)
# ============================================================
# TAB 5 — LEARNING ENGINE
# ============================================================
def create_tab5_learning_engine():
learning_graph = gr.Plot(label="Learning Graph")
graph_type = gr.Dropdown(
["patterns", "performance", "confidence"],
value="patterns",
label="Graph Type"
)
show_labels = gr.Checkbox(value=True, label="Show Labels")
search_query = gr.Textbox(label="Search Incidents")
search_btn = gr.Button("Search")
clear_btn_search = gr.Button("Clear")
search_results = gr.JSON(label="Search Results")
stats_display = gr.JSON(label="Learning Stats")
patterns_display = gr.JSON(label="Detected Patterns")
performance_display = gr.JSON(label="Performance Metrics")
return (
learning_graph,
graph_type,
show_labels,
search_query,
search_btn,
clear_btn_search,
search_results,
stats_display,
patterns_display,
performance_display,
)