package gateway // wsMessageEdited / wsMessageDeleted are the downstream event types of the D3 // history writes: a message's content was edited, or a message was removed. Both // reuse the wsEvent envelope and the same all-connections fan-out as // `message_persisted` — the hub has no per-session subscription, so the frame // carries SessionID and a client filters it by its active session, exactly as it // does for message_persisted. const ( wsMessageEdited = "message_edited" wsMessageDeleted = "message_deleted" ) // broadcastMessageEdited fans a content edit out to every client as a // `message_edited` frame whose data is the updated message DTO. The frame is a // render-only sync: the edited content's single source of truth stays the history // store, so a client that missed the frame converges again on its next read. The // caller strips Thinking to match the message_persisted/replay contract. func (h *hub) broadcastMessageEdited(msg historyMessage) { h.broadcast(wsEvent{Type: wsMessageEdited, SessionID: msg.SessionID, Data: msg}) } // broadcastMessageDeleted fans a removal out to every client as a // `message_deleted` frame carrying the removed id (plus the owning sessionId for // client-side session filtering), so every browser of the account drops the row // without a refresh. sessionID may be empty when the store could not report it; // clients then fall back to the globally unique id. func (h *hub) broadcastMessageDeleted(sessionID, id string) { h.broadcast(wsEvent{Type: wsMessageDeleted, SessionID: sessionID, Data: map[string]any{"id": id}}) }