← Lessons

quiz vs the machine

Silver1100

System Design

Presence and Cursors

Showing who is in a document and where their caret sits right now.

4 min read · intro · beat Silver to climb

What presence is

Presence is the live signal of who is currently viewing or editing a document and what they are doing, like the colored cursors and name tags you see in shared editors. It is ephemeral state, meaning it is never saved into the document itself.

Why it is separate from content

  • Presence updates are high frequency since a cursor moves on every keypress.
  • They are disposable, so dropping one update just means a slightly stale cursor.
  • They must expire when a user disconnects so ghosts do not linger.

How cursors are shared

Each client broadcasts its caret position and selection range as small messages. Because content can change underneath, positions are stored relative to the document model, not raw character offsets, so a remote edit shifts the cursor correctly.

Servers usually relay presence on a separate fast path from durable edits so a flood of cursor moves never blocks real content sync.

Key idea

Presence is ephemeral high frequency state that shows who is here and where, kept apart from the saved document.

Check yourself

Answer to earn rating on the learn ladder.

1. How should presence data be treated compared to document content?

2. Why store cursor positions relative to the document model?