feat(api): status ring buffer (last 100) + GET /status/recent endpoint

Bus.Publish now also appends each event to a per-topic ring buffer of
size 100. Bus.Recent(topic, n) returns the tail. New endpoint:

  GET /status/recent?n=N    → JSON array of last N status-diff events

This lets a fresh client (agents_dashboard launching cold) populate its
Status Feed panel with historical activity before subscribing to
/sse/status for live updates. Until now, new SSE subscribers only saw
events emitted AFTER they connected — making the panel useless for
recent history review.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-22 23:38:55 +02:00
parent e3b034e784
commit 71b3b2bca9
3 changed files with 57 additions and 9 deletions
+3
View File
@@ -95,6 +95,9 @@ func (s *Server) Run(ctx context.Context) error {
mux.Handle("GET /sse/status", s.auth(http.HandlerFunc(s.handleSSEStatus)))
mux.Handle("GET /sse/agents/{id}/logs", s.auth(http.HandlerFunc(s.handleSSEAgentLogs)))
// History endpoint: recent status-diff events from the in-memory ring buffer.
mux.Handle("GET /status/recent", s.auth(http.HandlerFunc(s.handleStatusRecent)))
addr := ":" + strconv.Itoa(s.port)
ln, err := net.Listen("tcp", addr)
if err != nil {