Location
router/main.py (Dashboard HTML template script tag, lines 2818-2823)
Problem Description
Telemetry updates on the dashboard are forced via setInterval(() => { window.location.reload(); }, 3000);. This destructive full-page reload breaks layout persistence, impacts browser rendering performance, and demands full server-side DOM reconstruction and DB queries every 3 seconds.
Fix Overview
Strip the global page-reloader and replace it with a focused asynchronous script that targets specific metadata fields from a JSON status endpoint.
Proposed Implementation Steps
- Define a new JSON API endpoint (e.g.,
@app.get("/api/dashboard-stats")) that returns the metrics dictionary.
- In the dashboard HTML script tag, replace the
window.location.reload() with a fetch request to the new endpoint.
- Update specific DOM node elements dynamically inside the callback.
Code Example / Diff
Before:
<script>
// Auto refresh metrics every 3 seconds
setInterval(() => {
window.location.reload();
}, 3000);
</script>
After:
<script>
async function refreshStats() {
try {
const res = await fetch("/api/dashboard-stats");
const data = await res.json();
document.getElementById("litellm-status").className = data.litellm ? "status-ok" : "status-error";
// ... update other elements ...
} catch (e) {
console.error("Failed to fetch stats:", e);
}
}
setInterval(refreshStats, 3000);
window.addEventListener("DOMContentLoaded", refreshStats);
</script>
Location
router/main.py(Dashboard HTML template script tag, lines 2818-2823)Problem Description
Telemetry updates on the dashboard are forced via
setInterval(() => { window.location.reload(); }, 3000);. This destructive full-page reload breaks layout persistence, impacts browser rendering performance, and demands full server-side DOM reconstruction and DB queries every 3 seconds.Fix Overview
Strip the global page-reloader and replace it with a focused asynchronous script that targets specific metadata fields from a JSON status endpoint.
Proposed Implementation Steps
@app.get("/api/dashboard-stats")) that returns the metrics dictionary.window.location.reload()with a fetch request to the new endpoint.Code Example / Diff
Before:
After: