Chats: a shared highlight colour per chat, pushed live with star and rename
chat_color {session_id, color|null} stores a palette name (red, orange,
amber, green, teal, blue, purple, pink) on the operator-session row; rows
and replies carry it as color. Colour, star and rename changes are pushed
to every other connection as chat_session_changed.
This commit is contained in:
@@ -62,6 +62,14 @@ const (
|
||||
// device shows the same starred group. It takes a ChatQuery with SessionID
|
||||
// and Starred, and echoes the updated session like close/reopen.
|
||||
ChatStar = "chat_star"
|
||||
// ChatColor records the operator's shared highlight colour for one chat. It
|
||||
// takes a ChatQuery with SessionID and Color (a ChatColors name; null or ""
|
||||
// clears it) and echoes the updated session like chat_star.
|
||||
ChatColor = "chat_color"
|
||||
// ChatSessionChanged is pushed to every other open connection when a chat's
|
||||
// shared list metadata (colour, star, title) changes, carrying the updated
|
||||
// registry row in ChatSession, so each device's list updates live.
|
||||
ChatSessionChanged = "chat_session_changed"
|
||||
// ChatSubscribe attaches a connection to one session's shared live stream so
|
||||
// it receives every frame any client's turn produces (its own and the other
|
||||
// devices'), not only the frames of a turn it prompted itself. Any number of
|
||||
@@ -280,6 +288,22 @@ type ChatSession struct {
|
||||
// epoch-millisecond time it was set, 0 while unstarred.
|
||||
Starred bool `json:"starred,omitempty"`
|
||||
StarredAt int64 `json:"starred_at,omitempty"`
|
||||
// Color is the operator's shared highlight, a ChatColors name; omitted when
|
||||
// none is set. Clients map the name to their own theme-tuned shade.
|
||||
Color string `json:"color,omitempty"`
|
||||
}
|
||||
|
||||
// ChatColors is the fixed palette of chat highlight names, in picker order.
|
||||
var ChatColors = []string{"red", "orange", "amber", "green", "teal", "blue", "purple", "pink"}
|
||||
|
||||
// ValidChatColor reports whether name is one of ChatColors.
|
||||
func ValidChatColor(name string) bool {
|
||||
for _, color := range ChatColors {
|
||||
if color == name {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// ChatCloseResult reports the outcome of a chat_close: the session id, the
|
||||
@@ -339,7 +363,9 @@ type ChatQuery struct {
|
||||
SessionID string `json:"session_id"`
|
||||
// Starred is set by chat_star; nil means the command did not name a state.
|
||||
Starred *bool `json:"starred,omitempty"`
|
||||
Limit int `json:"limit,omitempty"`
|
||||
// Color is set by chat_color: a ChatColors name, or nil/"" to clear.
|
||||
Color *string `json:"color,omitempty"`
|
||||
Limit int `json:"limit,omitempty"`
|
||||
// Cursor is the opaque continuation returned by OpenCode's descending
|
||||
// message listing. It is deliberately not interpreted by the broker.
|
||||
Cursor string `json:"cursor,omitempty"`
|
||||
|
||||
Reference in New Issue
Block a user