Persist and broadcast shared attention acknowledgements

This commit is contained in:
2026-10-31 12:23:51 +00:00
parent 480f8843eb
commit f4b3ef17cc
9 changed files with 684 additions and 0 deletions
+12
View File
@@ -113,6 +113,11 @@ func HandlerWithOptions(ctx context.Context, options Options, stores ...*pipelin
settingsStore = stores[0]
}
hub.settings = settingsStore
acks := newAttentionAckHub()
var ackStore attentionAckStore
if len(stores) > 0 {
ackStore = stores[0]
}
mux.HandleFunc("GET /artifacts/{run}/{step}/{name...}", func(w http.ResponseWriter, r *http.Request) {
if runs == nil {
http.NotFound(w, r)
@@ -180,6 +185,10 @@ func HandlerWithOptions(ctx context.Context, options Options, stores ...*pipelin
return
}
}
// Shared attention acknowledgements reach every open connection, after
// the welcome frame so a push never precedes it.
acks.attach(clientID, write)
defer acks.detach(clientID)
for {
var request protocol.Message
if err := wsjson.Read(connCtx, conn, &request); err != nil {
@@ -196,6 +205,9 @@ func HandlerWithOptions(ctx context.Context, options Options, stores ...*pipelin
if handleNotificationSettings(ctx, request, settingsStore, write) {
continue
}
if handleAttentionAcks(ctx, request, ackStore, acks, clientID, write) {
continue
}
if handleRunEvents(request, events, runs, clientID, write) {
continue
}