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:
@@ -53,6 +53,9 @@ type runner struct {
|
||||
// events pushes run state deltas to subscribed clients. When nil (tests that
|
||||
// build a runner directly) emits are dropped, so nothing else changes.
|
||||
events *runEventHub
|
||||
// notes records and streams app notifications beside every ntfy
|
||||
// publication. Nil (a runner built directly in a test) records nothing.
|
||||
notes *appNotifier
|
||||
// identMu guards idents: the pipeline identity and stored title (see
|
||||
// runIdentity) that every emitted frame of a run carries, so a client with no
|
||||
// cached row renders a brand-new run without re-reading the list. Populated
|
||||
@@ -1335,6 +1338,13 @@ func (r *runner) stampRunIdentity(frame *protocol.RunEventFrame) {
|
||||
// and does nothing otherwise (a runner built directly in a test has no hub).
|
||||
// terminal marks a final transition, which the hub flushes without coalescing.
|
||||
func (r *runner) emitRun(frame protocol.RunEventFrame, terminal bool) {
|
||||
// A run that is no longer waiting has no decision pending: its waiting
|
||||
// notifications are cleared on every device.
|
||||
if r.notes != nil && frame.Status != "" && frame.Status != protocol.RunStatusWaiting {
|
||||
c, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||
r.notes.clearFor(c, pipeline.AppNotificationFilter{RunID: frame.RunID, Kinds: []string{protocol.NotificationRunWaiting}})
|
||||
cancel()
|
||||
}
|
||||
if r.events == nil {
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user