@@ -205,6 +205,13 @@ def get_metrics(self) -> dict[str, Any]:
205205 )
206206 )
207207
208+ def get_sop_run_totals (self ) -> dict [str , int ]:
209+ """Return total execution counts grouped by SOP id."""
210+ totals : dict [str , int ] = {}
211+ for log in self .logs :
212+ totals [log .sop_id ] = totals .get (log .sop_id , 0 ) + 1
213+ return totals
214+
208215 def build_igor_assistant_brief (
209216 self ,
210217 * ,
@@ -273,12 +280,43 @@ def build_igor_assistant_brief(
273280 def dashboard_html (self ) -> str :
274281 """Return a basic dashboard HTML for quick product demo."""
275282 metrics = self .get_metrics ()
283+ sop_totals = self .get_sop_run_totals ()
284+ max_runs = max (sop_totals .values (), default = 1 )
285+ bars = "" .join (
286+ [
287+ (
288+ "<div class='bar-row'>"
289+ f"<span class='bar-label'>{ sop_id } </span>"
290+ f"<div class='bar-track'><div class='bar-fill' style='width:{ (count / max_runs ) * 100 :.1f} %'></div></div>"
291+ f"<span class='bar-value'>{ count } </span>"
292+ "</div>"
293+ )
294+ for sop_id , count in sorted (sop_totals .items ())
295+ ]
296+ ) or "<p class='empty-state'>No runs yet. Execute agents to populate chart metrics.</p>"
276297 return f"""
277298<!doctype html>
278299<html lang=\" en\" >
279- <head><meta charset=\" utf-8\" ><title>7ya Workflow Module</title></head>
300+ <head>
301+ <meta charset=\" utf-8\" >
302+ <title>7ya Workflow Module</title>
303+ <style>
304+ body {{ font-family: Arial, sans-serif; margin: 24px; line-height: 1.4; }}
305+ .chart-card {{ border: 1px solid #d9e2f2; border-radius: 10px; padding: 16px; margin-bottom: 20px; background: #f8fbff; }}
306+ .bar-row {{ display: grid; grid-template-columns: minmax(180px, 240px) 1fr 40px; gap: 10px; align-items: center; margin-bottom: 10px; }}
307+ .bar-track {{ background: #e9effa; border-radius: 8px; height: 18px; overflow: hidden; }}
308+ .bar-fill {{ background: linear-gradient(90deg, #2d6cdf, #41b0ff); height: 100%; }}
309+ .bar-label {{ font-size: 13px; color: #1c2a4a; word-break: break-word; }}
310+ .bar-value {{ text-align: right; color: #1c2a4a; font-weight: 700; }}
311+ .empty-state {{ color: #56607a; margin: 0; }}
312+ </style>
313+ </head>
280314 <body>
281315 <h1>7ya.io Workflow Product Module</h1>
316+ <div class=\" chart-card\" >
317+ <h2>SOP Activity (Bar Chart)</h2>
318+ { bars }
319+ </div>
282320 <h2>KPIs</h2>
283321 <ul>
284322 <li>Total tasks: { metrics ['total_tasks' ]} </li>
0 commit comments