Notifications: agent notify reaches every device and clears everywhere
- Server: chat ntfy messages carry a sequence id derived from their app id; clearing a chat app notification also clears it in ntfy (PUT /<topic>/<seq>/clear, verified on ntfy v2.38.1). - Server: a turn that sent an agent notify does not also send chat_reply. - notify tool and MCP instructions: Pipelines already notifies at reply end and for questions/approvals; notify is for mid-turn or background news. - Shown notify items carry channels (apps/phone); the transcript row says where it went. - App: NotificationBridge.close(tag); web closes tracked Notifications and tells other tabs over a BroadcastChannel; native bridge cancels by tag and now supports macOS. AgentNotices closes on notifications_cleared and on resubscribe cleared ids, and a tap sends clear_notifications. - Docs: skill, chat reference, ntfy/notifications docs, app note. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -16,6 +16,7 @@ import (
|
||||
|
||||
"git.a-wan.net/alan/pipelines/internal/pipeline"
|
||||
"git.a-wan.net/alan/pipelines/internal/protocol"
|
||||
"git.a-wan.net/alan/pipelines/internal/stage"
|
||||
)
|
||||
|
||||
// shownFile is a resolved file inside the operator's home.
|
||||
@@ -172,10 +173,11 @@ func (h *chatHub) publishToolNotification(ctx context.Context, sessionID string,
|
||||
digest := sha256.Sum256([]byte(title + "\x00" + message))
|
||||
id = hex.EncodeToString(digest[:8])
|
||||
}
|
||||
appID := chatNotificationID(sessionID, "notify", id)
|
||||
var delivery chatToolDelivery
|
||||
if h.notes != nil {
|
||||
delivery.App = h.notes.record(ctx, pipeline.AppNotificationRecord{
|
||||
AppNotification: protocol.AppNotification{ID: "chat:" + sessionID + ":notify:" + id, Kind: protocol.NotificationChatNotify, Title: title, Message: message, Click: click, Priority: chatNotifyPriority(notice.Priority), Tags: []string{}, Group: "chat:" + sessionID},
|
||||
AppNotification: protocol.AppNotification{ID: appID, Kind: protocol.NotificationChatNotify, Title: title, Message: message, Click: click, Priority: chatNotifyPriority(notice.Priority), Tags: []string{}, Group: "chat:" + sessionID},
|
||||
SessionID: sessionID,
|
||||
})
|
||||
}
|
||||
@@ -185,12 +187,16 @@ func (h *chatHub) publishToolNotification(ctx context.Context, sessionID string,
|
||||
case !chatNotificationSettings(ctx, h.settings).NtfyEnabled:
|
||||
delivery.Detail = "phone notifications (ntfy) are turned off"
|
||||
default:
|
||||
if _, err := chatAttentionPublish(ctx, "system", title, message, "", nil, click, views...); err != nil {
|
||||
if _, err := chatAttentionPublish(stage.WithNtfySequenceID(ctx, chatNtfySequence(appID)), "system", title, message, "", nil, click, views...); err != nil {
|
||||
log.Printf("chat tool notification session=%s: %v", sessionID, err)
|
||||
delivery.Detail = "the phone notification service refused it: " + err.Error()
|
||||
} else {
|
||||
delivery.Phone = true
|
||||
}
|
||||
}
|
||||
if delivery.App || delivery.Phone {
|
||||
// This turn has pinged the operator; its end is not announced again.
|
||||
h.markTurnNotified(sessionID)
|
||||
}
|
||||
return delivery
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user