@@ -34,6 +34,32 @@ Presence entries are structured objects with fields like:
3434- ` reason ` : free-form client-supplied string; the Gateway itself only emits ` self ` , ` connect ` , and ` disconnect `
3535- ` deviceId ` , ` roles ` , ` scopes ` : device identity and role/scope hints from the connect handshake
3636- ` ts ` : last update timestamp (ms since epoch)
37+ - ` watchedSessions ` : session keys the client explicitly declares it is viewing, filtered for the recipient
38+
39+ ### Watched session references
40+
41+ Hello snapshots, ` system-presence ` , and ` presence ` events include only watched
42+ session references that the recipient can see under the current session-list
43+ visibility rules. Drafts, incognito sessions, and operator role restrictions
44+ follow those same rules. Missing or deleted sessions are omitted, including for
45+ admins. Keys retain their agent scope, including agent-qualified ` global ` and
46+ ` unknown ` references.
47+
48+ Session references require an operator connection with read access
49+ (` operator.read ` , ` operator.write ` , or ` operator.admin ` ). Nodes, pairing-only
50+ clients, and non-admin clients awaiting authenticated profile verification still
51+ receive the non-session presence roster in hello snapshots and events, without
52+ watched references. An established admin grant does not depend on profile
53+ verification. ` system-presence ` itself requires operator read access.
54+
55+ Filtering preserves the connection and person metadata and the presence timestamp.
56+ When no references are visible, ` watchedSessions ` is omitted, just as when the
57+ client declares no watches; there are no hidden-session counts or markers.
58+ Message subscriptions alone do not declare viewer presence.
59+
60+ These are coordination features within a shared agent, not isolation between
61+ mutually untrusted users. Everyone operating an agent shares that agent's
62+ capabilities. See [ Multi-user trust boundary] ( /concepts/multi-user#trust-boundary ) .
3763
3864## Producers (where presence comes from)
3965
@@ -73,16 +99,17 @@ is sampled for this compatibility value.
7399When a node connects over the Gateway WebSocket with ` role: node ` , the Gateway
74100upserts a presence entry for that node (same flow as other WS clients).
75101
76- ## Merge + dedupe rules (why ` instanceId ` matters)
102+ ## Connection rows and beacon deduplication
77103
78- Presence entries are stored in a single in-memory map, keyed case-insensitively
79- by the first available of, in order: a paired device id, ` connect.client.instanceId ` ,
80- or the per-connection id as a last resort.
104+ Presence entries are stored in a single in-memory map with case-insensitive keys.
105+ User WebSocket clients have one row per connection, so two tabs watching different
106+ sessions cannot overwrite each other. Node connections use their device id,
107+ then ` connect.client.instanceId ` , then the connection id.
81108
82- Ephemeral control-plane clients are excluded from tracking entirely (see
83- above), so their connection ids never become keys. For every other client, the
84- connection id fallback means a client that reconnects without a stable
85- ` instanceId ` shows up as a ** duplicate ** row .
109+ ` system-event ` beacons merge by device id or instance id when supplied, otherwise
110+ by parsed host or other beacon metadata. A stable ` instanceId ` helps consumers
111+ associate rows with the same client; it does not merge separate user WebSocket
112+ connections. Ephemeral control-plane clients are excluded from tracking entirely .
86113
87114## TTL and bounded size
88115
@@ -116,11 +143,11 @@ indicator (Active/Idle/Stale) based on the age of the last update.
116143
117144## Debugging tips
118145
119- - To see the raw list, call ` system-presence ` against the Gateway.
146+ - To see the list projected for your connection , call ` system-presence ` against the Gateway.
120147- If you see duplicates:
121148 - confirm clients send a stable ` client.instanceId ` in the handshake
122149 - confirm periodic beacons use the same ` instanceId `
123- - check whether the connection-derived entry is missing ` instanceId ` (duplicates are expected)
150+ - check for multiple tabs or reconnects; separate user connections have separate rows, and old rows expire after the TTL
124151
125152## Related
126153
0 commit comments