Files
pipelines/internal/protocol/chat_shown.go
T
alan b91ef04ab0 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>
2026-12-02 19:49:31 +00:00

80 lines
3.3 KiB
Go

package protocol
// ChatShown is the pushed frame type for an item a chat's model showed the
// operator through the Pipelines tools (show_file, show_image, show_html,
// show_diff, notify). The chat_subscribe reply carries the retained list in the same
// ChatShown field.
const ChatShown = "chat_shown"
// The ChatShownItem kinds.
const (
ChatShownFile = "file"
ChatShownImage = "image"
ChatShownHTML = "html"
ChatShownDiff = "diff"
ChatShownNotify = "notify"
)
// ChatShownLimit bounds the items retained per chat, and ChatShownHTMLBudget
// the HTML and diff bytes kept across them: older documents and diffs beyond
// it keep their entry but drop the body (Expired).
const (
ChatShownLimit = 100
ChatShownHTMLBudget = 2 << 20
)
// ChatShownFrame is one chat's shown items, oldest first.
type ChatShownFrame struct {
SessionID string `json:"session_id"`
Items []ChatShownItem `json:"items"`
}
// ChatShownItem is one entry. A file or image Path is an absolute path on the
// chat's own machine, served by that machine's /files endpoint; URL is an
// https image address the client loads without credentials.
type ChatShownItem struct {
ID string `json:"id"`
Kind string `json:"kind"`
CreatedAt int64 `json:"created_at"`
Title string `json:"title,omitempty"`
Path string `json:"path,omitempty"`
Name string `json:"name,omitempty"`
Size int64 `json:"size,omitempty"`
Mime string `json:"mime,omitempty"`
URL string `json:"url,omitempty"`
Alt string `json:"alt,omitempty"`
HTML string `json:"html,omitempty"`
HTMLBytes int `json:"html_bytes,omitempty"`
// Diff is a show_diff item's repository comparison; DiffBytes is the size
// of its patches, counted against ChatShownHTMLBudget.
Diff *ChatShownDiffBody `json:"diff,omitempty"`
DiffBytes int `json:"diff_bytes,omitempty"`
// HeightHint is the model's preferred inline height in logical pixels.
HeightHint int `json:"height_hint,omitempty"`
Expired bool `json:"expired,omitempty"`
Message string `json:"message,omitempty"`
Priority string `json:"priority,omitempty"`
Delivered bool `json:"delivered,omitempty"`
// Detail says why a notification was not delivered (or not to the phone).
Detail string `json:"detail,omitempty"`
// Channels says where a delivered notification went: "apps" (the
// operator's signed-in Pipelines apps) and/or "phone" (ntfy).
Channels []string `json:"channels,omitempty"`
}
// ChatShownDiffBody is one Git comparison a chat's model showed: the work tree
// (or HEAD when CommittedOnly) of Repo against BaseCommit, which is HEAD when
// Base is empty and the merge base with Base otherwise. Changes uses the same
// per-file shape as a run's recorded changes; it is nil once Expired.
type ChatShownDiffBody struct {
Repo string `json:"repo"`
Base string `json:"base,omitempty"`
BaseCommit string `json:"base_commit,omitempty"`
Head string `json:"head,omitempty"`
CommittedOnly bool `json:"committed_only,omitempty"`
Files int `json:"files"`
Additions int `json:"additions"`
Deletions int `json:"deletions"`
Changes *StageFileChanges `json:"changes,omitempty"`
}