feat(chat): unread read-receipts with lobby/game dot and history-open ack
CI / changes (pull_request) Successful in 2s
CI / unit (pull_request) Successful in 9s
CI / integration (pull_request) Successful in 15s
CI / ui (pull_request) Successful in 49s
CI / gate (pull_request) Successful in 0s
CI / deploy (pull_request) Successful in 1m16s

Persist per-message read state as a chat_messages.unread_seats bitmask
(migration 00008): a text message seeds every recipient seat's bit, a nudge
only the awaited seat's. A seat's bit clears when the player opens the move
history or chat (POST /games/:id/chat/read, sent only when something is
unread), and a nudge additionally clears when its recipient answers by moving
(a wired game NudgeClearer, dependency-inverted so game keeps off social).

UI shows a per-viewer unread dot in the lobby (next to the opponent) and the
game score bar — the unread_chat game-view flag seeds it from authoritative
REST views, live chat/nudge events raise it. Opening the move history counts
as reading (even without entering chat): the 💬 fade-blinks twice and the
client acks. Admin Messages gains an unread-only filter, a read/unread column,
and a per-message card with the per-seat read breakdown. Observability:
chat_read_duration histogram + chat_unread_messages gauge + social tracing.
This commit is contained in:
Ilia Denisov
2026-06-17 11:12:38 +02:00
parent d53ff18a67
commit aaac816dc2
51 changed files with 1000 additions and 111 deletions
+3
View File
@@ -73,6 +73,9 @@ table GameView {
// vs_ai marks an honest-AI game: the opponent is shown as 🤖 and chat/nudge/add-friend
// are disabled in the client. A robot-filled random game keeps vs_ai=false.
vs_ai:bool;
// unread_chat is a per-viewer flag: the requesting player has at least one unread chat
// entry (message or nudge) in this game. It drives the lobby and in-game unread badge.
unread_chat:bool;
}
// MoveRecord is one decoded move (a committed play, or a hint preview).
+16 -1
View File
@@ -185,8 +185,20 @@ func (rcv *GameView) MutateVsAi(n bool) bool {
return rcv._tab.MutateBoolSlot(28, n)
}
func (rcv *GameView) UnreadChat() bool {
o := flatbuffers.UOffsetT(rcv._tab.Offset(30))
if o != 0 {
return rcv._tab.GetBool(o + rcv._tab.Pos)
}
return false
}
func (rcv *GameView) MutateUnreadChat(n bool) bool {
return rcv._tab.MutateBoolSlot(30, n)
}
func GameViewStart(builder *flatbuffers.Builder) {
builder.StartObject(13)
builder.StartObject(14)
}
func GameViewAddId(builder *flatbuffers.Builder, id flatbuffers.UOffsetT) {
builder.PrependUOffsetTSlot(0, flatbuffers.UOffsetT(id), 0)
@@ -230,6 +242,9 @@ func GameViewAddLastActivityUnix(builder *flatbuffers.Builder, lastActivityUnix
func GameViewAddVsAi(builder *flatbuffers.Builder, vsAi bool) {
builder.PrependBoolSlot(12, vsAi, false)
}
func GameViewAddUnreadChat(builder *flatbuffers.Builder, unreadChat bool) {
builder.PrependBoolSlot(13, unreadChat, false)
}
func GameViewEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT {
return builder.EndObject()
}
+3
View File
@@ -44,6 +44,8 @@ type GameView struct {
LastActivityUnix int64
// VsAI marks an honest-AI game (the opponent is shown as 🤖, chat/nudge/add-friend off).
VsAI bool
// UnreadChat is a per-viewer flag: the requesting player has unread chat in this game.
UnreadChat bool
}
// TileRecord is one tile in a decoded MoveRecord (the concrete letter, "?" for a blank
@@ -161,6 +163,7 @@ func BuildGameView(b *flatbuffers.Builder, g GameView) flatbuffers.UOffsetT {
fb.GameViewAddSeats(b, seats)
fb.GameViewAddLastActivityUnix(b, g.LastActivityUnix)
fb.GameViewAddVsAi(b, g.VsAI)
fb.GameViewAddUnreadChat(b, g.UnreadChat)
return fb.GameViewEnd(b)
}