Skip to content

Messages: react to a message with an emoji - #2084

Closed
svaka2000 wants to merge 11 commits into
Open-Coding-Society:mainfrom
svaka2000:feat/messages-reactions
Closed

svaka2000 wants to merge 11 commits into
Open-Coding-Society:mainfrom
svaka2000:feat/messages-reactions

Conversation

@svaka2000

Copy link
Copy Markdown
Contributor

You can react to a message in a DM or a group chat with one of six emoji. Spring keeps the reactions, so this needs Open-Coding-Society/spring#302 deployed first.

  • Each message has a React button, the smiley at the front of its action bar. It opens a row of six emoji: 👍 ❤️ 😂 😮 😢 🎉. The ones that are already yours are tinted, and Left and Right move through the row.
  • Under the message, a chip shows each reaction and how many people left it. Hovering one shows who, like "Celebrate: You and Grace Hopper" on 🎉. Your chips are filled, and clicking yours, or picking the same emoji again, takes yours back.
  • Reactions load with the chat and show up live. After a dropped connection they load again, so ones added or taken back while you were offline still show.
  • A chip is yours if your user id (uid) matches, not your name, since two people in a group can have the same name. Deleted messages, and old group messages that don't have an id, can't get reactions.
  • The menu is the grammar's ocs__menu and the chips are ocs__btn small pill, with yours accent fill. I added a few .dm styles (the Messages page's own Sass) to lay the menu out as one row, open it above the action bar when it wouldn't fit below and there's more room above, and space the chips.
  • UI Builder's group chat block gets reactions too (its read-only announcements block doesn't). ui_builder.yml lists the new chat words because a test requires it to name every word the chat embed uses.

Other notes:

Picking a reaction on a laptop:

The row of reactions open under a message's action bar

A DM with two reactions, yours filled:

Two reaction chips under a DM

The row of emoji on a phone:

The reaction row on a phone

Chips in the Midnight theme on a phone:

Reaction chips in the Midnight theme

How to try it:

  1. Run Spring with spring#302, Flask and the site, and sign in.
  2. Go to /dm, open a group chat, hover a message and press the smiley. Pick 🎉.
  3. Open the same group as another user in a private window and react to the same message. The chip says 2 in both windows.
  4. Click your filled chip to take yours back.
  5. Run node --test _projects/systems/messages/tests/*.test.mjs tests/chat_reply.test.mjs tests/ui_builder.test.mjs.

A React button comes first in a message's action bar and opens a menu of
the six reactions (the composer's PopupMenu, ocs__menu). setReactions draws
a message's chips after what it shows and before the action bar; picking
your own reaction, or clicking your chip, takes it back. While a change is
saving, that message's reaction controls wait. A message without an id, a
deleted one and a pin note take none, and deleting a message or clearing
the log closes its menu. The new words are in the UI Builder's text.chat.
Once a conversation's history is drawn, the thread asks Spring for its
reactions and draws each message's chips, and asks again after the socket
reconnects, so reactions left or taken back while offline show. A
reactions frame redraws one message's chips, and a message a frame or your
own change redrew since the load began keeps that newer state. Picking a
reaction sends PUT, picking yours again sends DELETE, and a failure says
"Could not save your reaction. Try again." A read-only pane, or a host
whose API has no reaction calls, asks for none.
… the log's foot

As a column of six named items it was taller than a phone's log has room
for beside a message, so its first items were cut off. Now it is one row of
the six emoji, with each name kept as its button's name but not drawn.
Where there still isn't room under the action bar, it opens above.
The Messages README gets a Reactions section, the reaction routes and
frames under Endpoints, and reactions.js in its file list. AGENTS.md and
AGENTS_MD_DOCUMENTATION.md get the same Messages bullet: how reactions
look and load, that Spring keeps them (Open-Coding-Society/spring#302),
and that the reaction keys change together with Spring's Reaction enum.
…and Open-Coding-Society#2078 change

The calls page (Open-Coding-Society#2070) adds its frame case after the error case, and the
push-note PR (Open-Coding-Society#2078) edits the Shared panel bullet in both AGENTS files.
The reactions frame case now follows the delete case, and the reactions
bullet follows the GitHub cards bullet, so this merges cleanly with either
in any order.
The rows' fade kept itself in effect after it ended (fill mode both),
which made each row its own layer, and the action bar is its own layer
while it fades in. Either way the next message covered the open menu and
took its clicks, even on that message's Delete. The fade now fills only
backwards, and a row with focus in it (an open menu always has it) sits
above the rows after it. The menu's emoji stand upright in Chrome, and
your own reactions wear the grammar's hover tint.
A chip that had focus keeps it when its row is redrawn, and after a
reaction saves, focus that fell off the page goes back to that chip or
the React button. A click elsewhere closes a menu without taking focus
back to its button, which also scrolled the log up to it. The reaction
menu is a horizontal menu (Left and Right step through it) and marks
yours as checked items, and the chip row is left out of the log's live
announcements.
One set of messages changed since a load began was shared by every load,
so a catch-up for a chat you had left reset it and the open chat's older
answer could undo a newer frame. Each change now counts, and a load or
your own PUT's answer that started before a message's last change leaves
that message as it is; a load for a chat that's no longer open asks for
nothing. Read-only panes ignore reaction frames, and a saved reaction
clears only its own failure notice.
@svaka2000

Copy link
Copy Markdown
Contributor Author

Combined into #2091 with the same commits.

@svaka2000 svaka2000 closed this Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant