From 48222083067ea7496e4deebac22357f4c8fa7cbc Mon Sep 17 00:00:00 2001 From: Egutierrez Date: Fri, 22 May 2026 22:32:06 +0200 Subject: [PATCH] fix(api): statusWriter implements http.Flusher for SSE handlers The logMiddleware wrapper (statusWriter) didn't forward Flush, so `w.(http.Flusher)` in SSE handlers failed and returned the plain text "streaming unsupported" with 500. SSE clients (agents_dashboard C++ app) saw a closed connection with no events. Add Flush() that delegates to the embedded ResponseWriter when it implements Flusher. Required for /sse/status and /sse/agents/{id}/logs. Co-Authored-By: Claude Opus 4.7 (1M context) --- internal/api/server.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/internal/api/server.go b/internal/api/server.go index a170bb2..12f48b2 100644 --- a/internal/api/server.go +++ b/internal/api/server.go @@ -147,6 +147,16 @@ func (sw *statusWriter) WriteHeader(code int) { sw.ResponseWriter.WriteHeader(code) } +// Flush forwards to the underlying ResponseWriter when it implements Flusher. +// Without this method, the type assertion `w.(http.Flusher)` in the SSE handlers +// fails (the wrapper hides the inner Flusher), and the handler aborts with +// "streaming unsupported". +func (sw *statusWriter) Flush() { + if f, ok := sw.ResponseWriter.(http.Flusher); ok { + f.Flush() + } +} + // --- Helpers --- func writeJSON(w http.ResponseWriter, status int, v any) {