diff --git a/apps/ui/templates/dashboard.html b/apps/ui/templates/dashboard.html
index 5d123fb..6948355 100644
--- a/apps/ui/templates/dashboard.html
+++ b/apps/ui/templates/dashboard.html
@@ -726,6 +726,15 @@
});
});
+ // Clean up SSE connection before page unload
+ window.addEventListener('beforeunload', () => {
+ if (eventSource) {
+ console.log('Closing SSE connection before unload');
+ eventSource.close();
+ eventSource = null;
+ }
+ });
+
// API_BASE injected from backend (supports Docker/K8s environments)
window.API_BASE = '{{ api_base }}';