Rebasely Beta: data may be purged

examples/live-notes Public

Markdown · 1.4 KiB · at 6e3dc76

id: 0003-presence-lives-on-the-sockets
type: decision
owner: justin
reviewed: 2026-10-15
status: accepted

0003 Presence lives on the sockets

Context

The page should show who else is editing. The room needs to know, for each open socket, which editor it belongs to, and it needs that after waking from hibernation, when its memory is gone.

We considered three places to keep it:

  1. A presence table in the note's SQLite database, a row per connection.
  2. A field on the NoteRoom instance, rebuilt as sockets send frames.
  3. The socket attachment, which the Hibernation API keeps with each accepted socket.

Decision

Each editor's id, name and color are the attachment of its socket. The list of who is here is read from ctx.getWebSockets() whenever it is needed, and is never written to storage.

Consequences

  • There is nothing to clean up. A socket that closes takes its editor with it, including after a crash or a deploy, where a stored row would have stayed behind.
  • After a wake the room knows everyone immediately; an in-memory field would have been empty until each editor sent something.
  • Reading the list touches every socket, which is fine at the size of a note's editors and would need another look for rooms with thousands of connections.
  • Presence is not history: nobody can ask who edited a note yesterday. If we want that, it belongs with the op log, not here. See [[presence]].