Back to Spacetimedb

Chat App - Draft Sync

tools/llm-oneshot/apps/chat-app/prompts/composed/11_drafts.md

2.1.03.7 KB
Original Source

Chat App - Draft Sync

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

Private Rooms and Direct Messages

  • Users can create private/invite-only rooms that don't appear in the public room list
  • Room creators can invite specific users by username
  • Direct messages (DMs) between two users as a special type of private room
  • Invited users receive notifications and can accept/decline invitations
  • Only members can see private room content and member lists

Room Activity Indicators

  • Show activity badges on rooms with recent message activity (e.g., "Active now", "Hot")
  • Display real-time message velocity or activity level per room
  • Activity indicators update live as conversation pace changes
  • Help users quickly identify where active conversations are happening

Draft Sync

  • Message drafts are saved and synced across user's devices in real-time
  • Users can resume typing where they left off on any device
  • Each room maintains its own draft per user
  • Drafts persist across sessions until sent or cleared