Show connected clients and their last human action in Status

This commit is contained in:
Ian Gulliver
2026-10-17 23:24:26 -07:00
parent 28c4549151
commit 8d9ba10849
8 changed files with 332 additions and 246 deletions
+24
View File
@@ -134,10 +134,34 @@ func (s *Server) identify(next http.Handler) http.Handler {
return
}
if (r.Method != http.MethodGet && !automaticRequests[r.Pattern]) || humanGets[r.Pattern] {
s.acted(login, r)
}
next.ServeHTTP(w, r.WithContext(context.WithValue(r.Context(), ctxKey{}, login)))
})
}
func (s *Server) acted(login string, r *http.Request) {
if s.hub.acted(login, r.Header.Get("Byre-Host"), r.Header.Get("Byre-Commit")) {
s.clientsChanged()
}
}
func (s *Server) clientsChanged() {
s.store.Broadcast(api.Event{Kind: "admin.clients", Actor: "byre", Payload: map[string]any{}})
}
var automaticRequests = map[string]bool{
"PUT /api/me/pane-focus": true,
"PUT /api/tasks/{taskId}/summary-read": true,
"POST /api/inbox/{itemId}/runs": true,
}
var humanGets = map[string]bool{
"GET /api/inbox/{itemId}/bundle": true,
}
func (s *Server) ensureUser(ctx context.Context, login, name string) error {
s.usersMu.Lock()
defer s.usersMu.Unlock()