Skip to content

feat(presence): buildLocalPresence — publish side of the payload contract#126

Merged
th3-br41n merged 1 commit into
mainfrom
feat/presence-publish-builder
Jul 8, 2026
Merged

feat(presence): buildLocalPresence — publish side of the payload contract#126
th3-br41n merged 1 commit into
mainfrom
feat/presence-publish-builder

Conversation

@th3-br41n

Copy link
Copy Markdown
Contributor

Completes the presence payload contract in both directions, as pure functions — pairs with the merged awarenessToPeers (read side).

buildLocalPresence(self, clientId) builds this device's payload to publish into awareness:

  • id = the sovereign member pubkey (stable across a member's tabs, so capPresence collapses them to one avatar).
  • name prefers the roster display name, falls back to the key fingerprint (mirrors useSelfDisplayName — never blank/"Anonymous").
  • color = peerColor(clientId) (distinct caret hue per tab; the avatar still dedups by id).

+4 tests, including a publish→read round-trip (buildLocalPresenceawarenessToPeers yields the same peer) so the two sides can't drift.

With this, the entire presence logic surface is pure + tested. The only remaining presence rung is plumbing: call buildLocalPresence on entity open, render <PresenceStack peers={awarenessToPeers(states, clientID)}> in the app header, and activate the dormant 10.6 awareness broadcaster over the relay (the dedicated live pass).

🤖 Generated with Claude Code

…contract

Completes the presence payload contract, both directions, as pure functions.
`buildLocalPresence(self, clientId)` builds THIS device's payload to publish
into awareness (`setLocalStateField(PRESENCE_STATE_KEY, …)`): id = sovereign
pubkey (stable across tabs); name prefers displayName, falls back to the key
fingerprint (mirrors useSelfDisplayName — never blank/"Anonymous"); color via
peerColor(clientId). awarenessToPeers reads the same shape back.

+4 tests incl. a publish→read round-trip (buildLocalPresence → awarenessToPeers
yields the same peer) — so publish/read symmetry is pinned. The remaining
presence rung is pure plumbing: call buildLocalPresence on open, mount
<PresenceStack peers={awarenessToPeers(states, clientID)}> in the header, and
activate the dormant 10.6 broadcaster over the relay.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@th3-br41n th3-br41n merged commit ac9965d into main Jul 8, 2026
3 checks passed
@th3-br41n th3-br41n deleted the feat/presence-publish-builder branch July 8, 2026 22:54
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