Skip to content

Add message actions

Use this when each chat message needs useful controls beyond passive display. The common pattern is one compact action row for frequent actions and a “more” menu for destructive or lower-frequency actions.

ControlShow it whenOperationUI result
ReplyThe room uses side threadsThreaded replyOpen a thread panel and increment its reply count
QuoteReplies should stay in the main flowQuote a messageComposer shows a compact original-message preview
ReactReactions are enabledReact to a messageUpdate the count and current-user state
EditThe current user can edit the eventUpdate message contentReplace the visible body after confirmation
DeleteThe current user can delete the eventDelete eventRemove or tombstone the row
ReportThe message is visible and reportableReport messageConfirm receipt; do not immediately imply removal

These are current sportstalk-sdk methods. event.id is the TalkLabs-assigned event ID returned in the room stream.

message-actions.js
export function actionsFor(client, event) {
return {
send: (text) => client.executeChatCommand(text),
quote: (text) => client.sendQuotedReply(text, event.id),
thread: (text) => client.sendThreadedReply(text, event.id),
like: () => client.reactToEvent('like', event.id),
};
}

Normal sends belong to the room composer. Quote and thread handlers should open the composer with the target message stored separately from the draft text.

Use the same state transition for every message action:

flowchart LR
    A[User activates control] --> B[Disable that control]
    B --> C[Send operation]
    C -->|Success| D[Merge result by event ID]
    C -->|Failure| E[Restore previous state]
    D --> F[Reconcile with updates stream]
    E --> G[Show action-level error]
  • Replies: keep the draft if the request fails.
  • Reactions: an optimistic count is appropriate when you can roll it back.
  • Edits: do not replace the rendered body until the operation succeeds, or retain the previous body for rollback.
  • Deletes: require confirmation when deletion is permanent.
  • Reports: prevent repeated submissions while the first request is pending.

The action response gives immediate confirmation. The room updates stream is the shared state all participants receive.

  1. Apply the action response immediately.
  2. Key local messages by event id.
  3. When the matching update arrives, merge it instead of appending a duplicate.
  4. Handle replace, remove, reaction, and purge event types in the same reducer as new messages.

Keep permissions out of presentation logic

Section titled “Keep permissions out of presentation logic”

Your UI can hide controls that are irrelevant—for example, edit on someone else’s message—but the API remains the authority. Handle 403 as a normal action failure and refresh the affected event or room state.