feat(presence): buildLocalPresence — publish side of the payload contract#126
Merged
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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, socapPresencecollapses them to one avatar).nameprefers the roster display name, falls back to the key fingerprint (mirrorsuseSelfDisplayName— never blank/"Anonymous").color=peerColor(clientId)(distinct caret hue per tab; the avatar still dedups byid).+4 tests, including a publish→read round-trip (
buildLocalPresence→awarenessToPeersyields 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
buildLocalPresenceon entity open, render<PresenceStack peers={awarenessToPeers(states, clientID)}>in the app header, and activate the dormant10.6awareness broadcaster over the relay (the dedicated live pass).🤖 Generated with Claude Code