Skip to content

feature: edit or delete your own chat messages for 10 minutes - #622

Merged
lukepolo merged 5 commits into
mainfrom
feature/chat-self-edit
Sep 29, 2026
Merged

lukepolo merged 5 commits into
mainfrom
feature/chat-self-edit

Conversation

@lukepolo

@lukepolo lukepolo commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Players can edit or delete their own chat messages for 10 minutes after sending them.

  • Edit and Delete in the message menu for your own web lines under 10 minutes old, DMs included; a gagged player keeps Delete but loses Edit in group rooms.
  • An inline editor (Enter saves, Esc cancels, same cap and countdown as the composer) and an "(edited)" marker with the edit time.
  • Socket.editMessage shares the delete request plumbing; the ack and the :edited broadcast can land in either order, and an older edit never replaces a newer one.
  • A trigger left over from before the window closed goes away with a toast, and a window_closed answer re-checks the row.
  • DM badges now know which messages they count, so a deleted DM comes off the badge; a conversation emptied by a delete closes its tab.
  • 9 new keys in all 16 locales.

Merge/deploy: pairs with 5stackgg/api#442; stacked on #618, merge that first.

Tests: Edit offered to a gagged player, the empty DM tab, a stale ack or older edit winning, DM badge ids, the editor staying open on a refusal, Esc/Cancel mid-save, focus return, the window-closed recheck and a stray hub-lock release each fail with their fix reverted. Based on DEAFCS d4bd9f46e
Not covered: a self-edit refused as window_closed closes the editor and loses the typed text.

@lukepolo

Copy link
Copy Markdown
Contributor Author

df80de9 follows api#442's edit ack, which now carries the server's stored message and edited_at:

  • The ack applies the server's text and time instead of this browser's clock. An api that leaves both fields out still gets the old browser-clock fallback. A stamp from that fallback is flagged, so the next server stamp always replaces it.
  • An edit whose edited_at is older than the one the message already has is never applied. This covers the ack, the :edited broadcast and the history snapshot, which all use the same rule. It fixes two tabs overwriting each other when an older edit's ack lands after a newer edit's broadcast, or the other way round.
  • Tests cover the ack with and without the server fields, both two-tab orderings, and the snapshot cases. The full vitest suite passes (468).

@lukepolo
lukepolo force-pushed the feature/chat-moderation branch from d1da735 to f056cf5 Compare September 29, 2026 01:11
Base automatically changed from feature/chat-moderation to main September 29, 2026 01:12
The message menu offers the author Edit Message and Delete Message on a
line they sent from the website in the last ten minutes, in every room
including direct conversations. Moderators keep their delete in group
rooms, and nobody edits someone else's words. The window is checked
when the menu opens rather than on a timer; a trigger left over from
before the window closed goes away with a toast saying why.

Editing happens in place: Enter saves, Esc cancels, Shift+Enter breaks
the line, and the box counts down near the 2000 character cap like the
composer. Only one editor is open across a list. An unchanged edit just
closes, a failure keeps the editor open with a toast, and a closed
window or a message that is gone closes it.

The socket sends lobby:edit through the same request plumbing as a
delete, applies the text on the ack, and listens for the room's
`edited` event, which never creates a message and never revives a
deleted one. A stale history snapshot keeps an edit it predates.
Edited lines carry an "(edited)" marker with the edit time in a
tooltip. Conversation badges now know which messages they counted, so
a deleted direct message comes off the badge.
A gagged player no longer gets Edit in a group room, which the api
refuses, and an edit refused as gagged or not allowed closes the editor
since no retry can succeed. Esc and Cancel wait for a save in flight.
Closing the editor hands focus back to the message's trigger, and a
closed window seen by an edit or a self-delete re-checks the row so the
trigger stops offering it.

The edit ack no longer overwrites the server's edited_at when the room
broadcast got there first; the two race, since the ack waits on the
notification update. A conversation emptied by a delete closes its tab
when it isn't on screen, matching the api dropping the conversation.
The edited marker is keyboard-focusable so its time can be reached.
An edit or self-delete answered window_closed now takes the row's
trigger away, and a stale trigger unmounting before its watcher runs no
longer releases a hub lock someone else holds. Each test fails with its
fix reverted.
@lukepolo
lukepolo force-pushed the feature/chat-self-edit branch from 85b4715 to ea4fce8 Compare September 29, 2026 01:17
@lukepolo
lukepolo merged commit 91a97d5 into main Sep 29, 2026
2 checks passed
@lukepolo
lukepolo deleted the feature/chat-self-edit branch September 29, 2026 01:18
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