feat: F5.4 presence: who else is in the project

Over Yjs awareness each editor tells who it is (F names the person in
the access message), the device it has chosen and the windows it has
open, and nothing else: no pointer, nothing that changes without a
cause, sent only when it changed. Others' states are read with care.
A frame in their colour round a device they chose, a dot on a window
they have open too, a circle with initials each beside the mode
buttons; the bridge tells the dashboard who is there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-04 16:09:34 +00:00
co-authored by Claude Opus 5.5
parent f52852493a
commit 47beda6b85
22 changed files with 600 additions and 33 deletions
+5 -4
View File
@@ -73,9 +73,9 @@ export function cookieValue(header: string | undefined, name: string): string |
return undefined;
}
/** What a connection is told when its access changes. */
export function accessMessage(readOnly: boolean, frozen: boolean): string {
const message: AccessMessage = { v: 1, kind: 'access', readOnly, frozen };
/** What a connection is told when it comes (with who it is) and when its access changes. */
export function accessMessage(readOnly: boolean, frozen: boolean, person?: SessionPerson): string {
const message: AccessMessage = { v: 1, kind: 'access', readOnly, frozen, ...(person === undefined ? {} : { you: { user: person.user, name: person.name, color: person.color } }) };
return JSON.stringify(message);
}
@@ -121,7 +121,8 @@ export function createSync({ store, sessions, log, compactAfterIdleMilliseconds
},
// Told at once, so that the editor knows from the start whether it reads, and why.
async connected({ connection, context }) {
connection.sendStateless(accessMessage(connection.readOnly, (context as ConnectionContext).frozen));
const { frozen, person } = context as ConnectionContext;
connection.sendStateless(accessMessage(connection.readOnly, frozen, person));
},
async onLoadDocument({ documentName, document }) {
const persistence = new DocumentPersistence(store, documentName, log);