Skip to content

Add persistent rooms: server-side session state with configurable TTL - #51

Open
fingolfin0 wants to merge 12 commits into
sahilatahar:mainfrom
fingolfin0:persistent-rooms
Open

Add persistent rooms: server-side session state with configurable TTL#51
fingolfin0 wants to merge 12 commits into
sahilatahar:mainfrom
fingolfin0:persistent-rooms

Conversation

@fingolfin0

Copy link
Copy Markdown

Protocol changes

  • JOIN_ACCEPTED payload now includes isNewRoom: boolean, signaling whether a saved session exists for the room.
  • New client-to-server event SEED_FILE_STRUCTURE allows the first client in a new room to provide the initial file tree.
  • When a saved session exists, the server sends SYNC_FILE_STRUCTURE to the joining client alongside JOIN_ACCEPTED.

How it works

  1. First client joins a new room and sends SEED_FILE_STRUCTURE with its file tree; the server stores it.
  2. Subsequent mutations are applied to the stored tree as they occur.
  3. When a room becomes empty, a cleanup timer (default 60 seconds) starts. If a user rejoins before it fires, the timer is cancelled and the saved tree is sent to the new client.
  4. If the timer expires, the session is discarded.

Note

This code has been tested in a live environment and works as expected.

@vercel

vercel Bot commented Jun 16, 2026

Copy link
Copy Markdown

Someone is attempting to deploy a commit to the Sahil Atahar's projects Team on Vercel.

A member of the Team first needs to authorize it.

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