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
+10 -2
View File
@@ -23,6 +23,7 @@ const (
NotifyRunFinished = "run_finished"
NotifyChatNeedsYou = "chat_needs_you"
NotifyChatReplyFinished = "chat_reply_finished"
NotifyNtfyEnabled = "ntfy_enabled"
)
// NotificationSettings is the typed form of the global notification choices.
@@ -35,14 +36,18 @@ type NotificationSettings struct {
ChatNeedsYou bool
// ChatReplyFinished notifies when an assistant turn in a chat ends.
ChatReplyFinished bool
// NtfyEnabled publishes notifications to ntfy. On by default; when off the
// server still records and streams every notification to app clients
// (subscribe_notifications) but stops publishing to ntfy.
NtfyEnabled bool
}
// NotificationSettingKeys lists every setting key in a stable order.
var NotificationSettingKeys = []string{NotifyRunFinished, NotifyChatNeedsYou, NotifyChatReplyFinished}
var NotificationSettingKeys = []string{NotifyRunFinished, NotifyChatNeedsYou, NotifyChatReplyFinished, NotifyNtfyEnabled}
// DefaultNotificationSettings are the values before the operator changes any.
func DefaultNotificationSettings() NotificationSettings {
return NotificationSettings{RunFinished: false, ChatNeedsYou: true, ChatReplyFinished: false}
return NotificationSettings{RunFinished: false, ChatNeedsYou: true, ChatReplyFinished: false, NtfyEnabled: true}
}
// Map returns the wire form with every key present.
@@ -51,6 +56,7 @@ func (s NotificationSettings) Map() map[string]any {
NotifyRunFinished: s.RunFinished,
NotifyChatNeedsYou: s.ChatNeedsYou,
NotifyChatReplyFinished: s.ChatReplyFinished,
NotifyNtfyEnabled: s.NtfyEnabled,
}
}
@@ -63,6 +69,8 @@ func (s *NotificationSettings) Field(key string) *bool {
return &s.ChatNeedsYou
case NotifyChatReplyFinished:
return &s.ChatReplyFinished
case NotifyNtfyEnabled:
return &s.NtfyEnabled
}
return nil
}