Back to Spacetimedb

Chat App - Threading

tools/llm-oneshot/apps/chat-app/prompts/composed/08_threading.md

2.1.02.8 KB
Original Source

Chat App - Threading

Create a real-time chat app.

See language/*.md for language-specific setup, architecture, and constraints.

UI Requirements

Use SpacetimeDB brand styling (dark theme).

Features

Basic Chat Features

  • Users can set a display name
  • Users can create chat rooms and join/leave them
  • Users can send messages to rooms they've joined
  • Show who's online
  • Include reasonable validation (e.g., don't let users spam, enforce sensible limits)

Typing Indicators

  • Show when other users are currently typing in a room
  • Typing indicator should automatically expire after a few seconds of inactivity
  • Display "User is typing..." or "Multiple users are typing..." in the UI

Read Receipts

  • Track which users have seen which messages
  • Display "Seen by X, Y, Z" under messages (or a seen indicator)
  • Update read status in real-time as users view messages

Unread Message Counts

  • Show unread message count badges on the room list
  • Track last-read position per user per room
  • Update counts in real-time as new messages arrive or are read

Scheduled Messages

  • Users can compose a message and schedule it to send at a future time
  • Show pending scheduled messages to the author (with option to cancel)
  • Message appears in the room at the scheduled time

Ephemeral/Disappearing Messages

  • Users can send messages that auto-delete after a set duration (e.g., 1 minute, 5 minutes)
  • Show a countdown or indicator that the message will disappear
  • Message is permanently deleted from the database when time expires

Message Reactions

  • Users can react to messages with emoji (e.g., 👍 ❤️ 😂 😮 😢)
  • Show reaction counts on messages that update in real-time
  • Users can toggle their own reactions on/off
  • Display who reacted when hovering over reaction counts

Message Editing with History

  • Users can edit their own messages after sending
  • Show "(edited)" indicator on edited messages
  • Other users can view the edit history of a message
  • Edits sync in real-time to all viewers

Real-Time Permissions

  • Room creators are admins and can kick/ban users from their rooms
  • Kicked users immediately lose access and stop receiving room updates
  • Admins can promote other users to admin
  • Permission changes apply instantly without requiring reconnection

Rich User Presence

  • Users can set their status: online, away, do-not-disturb, invisible
  • Show "Last active X minutes ago" for users who aren't online
  • Status changes sync to all viewers in real-time
  • Auto-set to "away" after period of inactivity

Message Threading

  • Users can reply to specific messages, creating a thread
  • Show reply count and preview on parent messages
  • Threaded view to see all replies to a message
  • New replies sync in real-time to thread viewers