feat(presence): PRES-3b — usePresence primitive + Notes header stack#141
Merged
Conversation
The reusable fleet primitive + first consumer, building on PRES-2b/PRES-3a. - `@brainstorm/sdk/presence-stack` `usePresence(entityId, type, self)` — publishes THIS device's presence and returns live remote peers for `<PresenceStack>`. Cross-device in the shell (over the PRES-2b transport, keyed on the entity id), single-device standalone. Rebinds on entity change, clears on unmount. Couples the transport (react-yjs createSyncedAwareness/createPresenceTransport/ useAwareness) to the read-side (awarenessToPeers/buildLocalPresence); reads the runtime off window.brainstorm like useVaultEntities. + `useSelf()` (sources PresenceSelf from roster.self — structurally identical) + `presenceAwarenessFor`. SDK now deps @brainstorm/react-yjs (acyclic — react-yjs only deps sdk-types). - **Notes** mounts `<PresenceStack>` at the leading edge of the header-right group, driven by `usePresence(note.id, NOTE_TYPE, useSelf())` — the reference consumer. Consumers need no presence typing (the hook reads window.brainstorm internally). 3 use-presence tests (shell publish / inbound peer → rendered / untrack on unmount / standalone → local); 26 presence-stack tests green; full typecheck (12 apps) + Notes build + lint (biome/reactivity/control-faces/css-tokens/i18n) clean. Also biome-formats two presence test files that landed on main via #138 with drift. Remaining PRES-3: roll `usePresence`+`<PresenceStack>` across the other React shared-entity headers (Database/Tasks/…) + dedup the whiteboard's local presenceAwarenessFor onto the SDK one. Then PRES-4 /pentester two-shell. Co-Authored-By: Claude Opus 4.8 <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.
Builds on PRES-2b (merged). The reusable fleet primitive for who's-here avatar stacks, plus the first consumer.
The primitive —
@brainstorm/sdk/presence-stackusePresence(entityId, type, self)→ live remotePresencePeer[]for<PresenceStack>, and publishes THIS device's presence. Cross-device in the shell (over the PRES-2b transport, keyed on the entity id); single-device standalone / preview. Rebinds on entity change, clears on unmount.useSelf()— sourcesPresenceSelffromroster.self(structurally identical).presenceAwarenessFor(entityId, type)— the transport glue (shared shape with PRES-3a's whiteboard-local one; dedup follow-up noted).window.brainstorminternally, so consumers need no presence typing. SDK now deps@brainstorm/react-yjs(acyclic — react-yjs only deps sdk-types).First consumer — Notes
<PresenceStack peers={usePresence(note.id, NOTE_TYPE, useSelf())} />at the leading edge of the header-right group. Two other users on the same note now show as avatars.Verification
3
usePresencetests (shell publish · inbound peer → rendered · untrack on unmount · standalone → local) · 26 presence-stack tests · full typecheck (12 apps) · Notes build · full lint (biome/reactivity/control-faces/css-tokens/i18n). Also biome-formats two presence test files that landed onmainvia #138 with minor drift.Behavioural (avatars actually appear across two shells) is the PRES-4
/pentestertwo-shell dogfood.Remaining PRES-3
Roll
usePresence+<PresenceStack>across the other React shared-entity headers (Database/Tasks/…) + dedup the whiteboard's localpresenceAwarenessForonto the SDK one.🤖 Generated with Claude Code