Skip to content

feat(presence): PRES-3b — usePresence primitive + Notes header stack#141

Merged
th3-br41n merged 1 commit into
mainfrom
feat/pres-3b-presence-stack
Jul 12, 2026
Merged

feat(presence): PRES-3b — usePresence primitive + Notes header stack#141
th3-br41n merged 1 commit into
mainfrom
feat/pres-3b-presence-stack

Conversation

@th3-br41n

Copy link
Copy Markdown
Contributor

Builds on PRES-2b (merged). The reusable fleet primitive for who's-here avatar stacks, plus the first consumer.

The primitive — @brainstorm/sdk/presence-stack

  • usePresence(entityId, type, self) → live remote PresencePeer[] 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() — sources PresenceSelf from roster.self (structurally identical).
  • presenceAwarenessFor(entityId, type) — the transport glue (shared shape with PRES-3a's whiteboard-local one; dedup follow-up noted).
  • Couples the transport (react-yjs) to the read-side (awarenessToPeers/buildLocalPresence); reads window.brainstorm internally, 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 usePresence tests (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 on main via #138 with minor drift.

Behavioural (avatars actually appear across two shells) is the PRES-4 /pentester two-shell dogfood.

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.

🤖 Generated with Claude Code

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>
@th3-br41n th3-br41n merged commit 6c7f2e4 into main Jul 12, 2026
2 of 3 checks passed
@th3-br41n th3-br41n deleted the feat/pres-3b-presence-stack branch July 12, 2026 06:59
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