Skip to content

High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.

fix: add 30s keepalive to dashboard SSE connections

Mariob9020eb43ec2
diff --git a/TODO.md b/TODO.md
index ee4bccbb..8206dcbf 100644
--- a/TODO.md
+++ b/TODO.md
@@ -39,7 +39,7 @@ P2 (K11 file path, blockImages on CreateTab) — all resolved.
- [ ] **installStableBinary streaming** — Use `io.Copy` with file streams instead of reading entire binary into memory.
- [ ] **Interfaces for ProfileManager/Orchestrator** — Add interfaces for unit testability (like `BridgeAPI`).
- [ ] **proxy_ws.go proper HTTP** — Replace raw `backend.Write` of HTTP headers with proper request construction.
-- [ ] **Dashboard SSE keepalive** — Add heartbeat/ping to SSE connections to detect silent disconnects.
+- [x] **Dashboard SSE keepalive** — 30s keepalive comments on SSE connections.
### Minor
- [ ] **humanType global rand** — Accept `*rand.Rand` for reproducible tests.
diff --git a/dashboard.go b/dashboard.go
index 3902b42b..7883a776 100644
--- a/dashboard.go
+++ b/dashboard.go
@@ -199,12 +199,18 @@ func (d *Dashboard) handleSSE(w http.ResponseWriter, r *http.Request) {
_, _ = fmt.Fprintf(w, "event: init\ndata: %s\n\n", data)
flusher.Flush()
+ keepalive := time.NewTicker(30 * time.Second)
+ defer keepalive.Stop()
+
for {
select {
case evt := <-ch:
data, _ := json.Marshal(evt)
_, _ = fmt.Fprintf(w, "event: action\ndata: %s\n\n", data)
flusher.Flush()
+ case <-keepalive.C:
+ _, _ = fmt.Fprintf(w, ": keepalive\n\n")
+ flusher.Flush()
case <-r.Context().Done():
return
}