feature: chat message reactions - #445
Merged
Merged
Conversation
This was referenced Sep 28, 2026
lukepolo
force-pushed
the
feature/chat-self-edit
branch
from
September 29, 2026 00:51
aa3e4cb to
5715f46
Compare
Players can react to a chat message with one of six reactions (thumbsup,
heart, laugh, fire, wow, sad) and take it back by sending it again.
- lobby:react { type, id, messageId, reaction, requestId? } toggles the
sender's reaction. The room gets lobby:<type>:<id>:reaction { id,
reactions } with the message's whole reaction state, never a delta.
chat:ack / chat:error carry action "react".
- Held to the same rules as sending: room access (canPostIn), and a gag
blocks reacting in group rooms. Never a notification, never relayed to
the game. At most 8 toggles a second per player (rate_limited), since
every toggle is a broadcast to the room.
- Rooms: a separate chat_reactions_<type>_<id> hash, field per message, so
reactions never contend with an edit's compare-and-set. One Lua script
toggles, refuses a message that is gone, and gives the reactions the
message's own expiry. Deleting a message clears its reactions, and the
draft-to-match move carries them in the same step.
- DMs: direct_message_reactions, toggled in one statement scoped to the
conversation; cascades with the message, the player and retention.
- History (room and DM) and live messages carry reactions per message.
…erialized DM toggles - The room toggle script takes a receipt key per toggle: ioredis resends a command whose reply was lost to a reconnect, and a toggle run twice undid itself. A resend now answers with the current state instead. - A gagged player can still take back a reaction they gave, the way #442 lets them delete their own message; only adding one is refused. - DM toggles lock the message row first (FOR NO KEY UPDATE) and toggle in a fresh statement, so racing toggles on an absent row cancel out as they do in rooms instead of both inserting, and a delete can no longer land between finding the message and writing the reaction. - Reactions are always handed out in ChatService.REACTIONS order; the Lua table and jsonb each had their own. - Index direct_message_reactions (steam_id) for the players cascade.
One round of the race lost it without the row lock only about three runs in four, so the regression could pass. Eight rounds fail every time without the lock.
lukepolo
force-pushed
the
feature/chat-reactions
branch
from
September 29, 2026 00:52
4580a4e to
8754dee
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Players can react to any chat message with one of six reactions, and take a reaction back by sending it again.
lobby:reacttoggles the sender's reaction; the room gets the message's whole reaction state, always inChatService.REACTIONSorderchat_reactions_<type>_<id>hash toggled by one Lua script with a per-toggle receipt, so a resent command can't undo itselfdirect_message_reactionstable; toggles lock the message row, so racing toggles cancel out in pairslobby:react {type, id, messageId, reaction, requestId?}in,lobby:<type>:<id>:reaction {id, reactions}out; newrate_limitederrorMerge/deploy: stacked on #442; run
yarn hasura:metadataafter merge. Pairs with 5stackgg/web#624.Tests: a test fails without each fix: the toggle resend receipt, gagged un-react, reaction order, and serialized DM toggles (that race test now runs 8 rounds; one round missed the bug about 1 run in 4). Based on DEAFCS f2c907512 b12c1c32a