// script.js -- renders the Leaderboard and Episode replay tabs from // data.json (built ahead of time by generate_data.py from a real // milo_benchmark results JSON -- see that file's docstring for why // this is a build step rather than a live server call). No network // calls beyond fetching this Space's own data.json/screenshots. function escapeHtml(s) { if (s === null || s === undefined) return ""; return String(s) .replaceAll("&", "&") .replaceAll("<", "<") .replaceAll(">", ">"); } function setupTabs() { const buttons = document.querySelectorAll(".tab-btn"); buttons.forEach((btn) => { btn.addEventListener("click", () => { buttons.forEach((b) => { b.classList.remove("active"); b.setAttribute("aria-selected", "false"); }); btn.classList.add("active"); btn.setAttribute("aria-selected", "true"); document.querySelectorAll(".tab-panel").forEach((p) => p.classList.remove("active")); document.getElementById(`tab-${btn.dataset.tab}`).classList.add("active"); }); }); } function renderLeaderboard(data) { const wrap = document.getElementById("leaderboard-table-wrap"); const cols = data.leaderboard_columns; const headers = data.leaderboard_headers; let html = "
| ${escapeHtml(headers[c] || c)} | `; } html += "
|---|
| ${escapeHtml(row[c] ?? "—")} | `; } html += "
No episode selected.
"; return; } const outcomeBadge = ep.goal_success ? 'SUCCESS' : 'FAILED'; let html = `Why this episode was picked: ${escapeHtml(ep.reason_picked)}
`; html += '${escapeHtml(ep.goal)}, object=${escapeHtml(ep.object)}, target=${escapeHtml(ep.target)}${escapeHtml(ep.task_id)}${ep.goal_success}, execution_success=${ep.execution_success}, plan_success=${ep.plan_success}The source results JSON records aggregate counts per episode (action_count, plan_step_count), not a literal per-step action log. The steps below are reconstructed from this task's goal/object/target and this project's documented, deterministic planner behavior (see the Space README and phase_e_milo_benchmark_report.md in the origin repository) — they illustrate the shape of what ran, not a captured trace.
`; html += `${escapeHtml(ep.plan_trace.join("\n"))}`;
if (ep.screenshots && ep.screenshots.length > 0) {
html += `Screenshots below are generic, illustrative product UI captures from docs/screenshots/demo/ in the origin repository — a single walkthrough, not per-episode captures. They are shown alongside this episode as an example of what the live UI looks like during an instruction/task-in-progress/task-complete flow, not a screenshot of this literal episode's run.
`; html += 'Failed to load data.json: ${escapeHtml(err.message)}
`; } } main();