Stream ntfy notifications to app clients over /connect

Record every notification published to ntfy (run outbox, stage notify
hooks, chat question/approval/reply) in a persisted app_notifications
outbox and stream it to subscribe_notifications clients with an after
cursor; clear_notifications and ack_attention clear across devices, as do
runs leaving waiting, deleted runs and answered chat questions. Add the
notify.ntfy_enabled setting (default on) to stop only the ntfy publish.
This commit is contained in:
2026-11-01 02:03:58 +00:00
parent 6c7c32078c
commit d1846441cc
20 changed files with 1265 additions and 20 deletions
+13 -1
View File
@@ -120,8 +120,14 @@ func HandlerWithOptions(ctx context.Context, options Options, stores ...*pipelin
hub.settings = settingsStore
acks := newAttentionAckHub()
var ackStore attentionAckStore
var notes *appNotifier
if len(stores) > 0 {
ackStore = stores[0]
notes = newAppNotifier(stores[0])
hub.notes = notes
if runs != nil {
runs.notes = notes
}
}
mux.HandleFunc("GET /artifacts/{run}/{step}/{name...}", func(w http.ResponseWriter, r *http.Request) {
if runs == nil {
@@ -194,6 +200,9 @@ func HandlerWithOptions(ctx context.Context, options Options, stores ...*pipelin
// the welcome frame so a push never precedes it.
acks.attach(clientID, write)
defer acks.detach(clientID)
if notes != nil {
defer notes.detach(clientID)
}
for {
var request protocol.Message
if err := wsjson.Read(connCtx, conn, &request); err != nil {
@@ -210,7 +219,10 @@ func HandlerWithOptions(ctx context.Context, options Options, stores ...*pipelin
if handleNotificationSettings(ctx, request, settingsStore, write) {
continue
}
if handleAttentionAcks(ctx, request, ackStore, acks, clientID, write) {
if handleAttentionAcks(ctx, request, ackStore, acks, notes, clientID, write) {
continue
}
if handleAppNotifications(ctx, request, notes, ackStore, acks, clientID, write) {
continue
}
if handleRunEvents(request, events, runs, clientID, write) {