Add anchored awareness positions#720
Conversation
Co-authored-by: Codex <noreply@openai.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
2 Skipped Deployments
|
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Warning Testing pausedMonthly snapshot limit reached. Update your plan to get more snapshots and resume testing. |
Anchored cursor/selection resolution was only invoked inside usePeerCursors, so consumers rendering selections from useOthers/useOther saw raw, unresolved offsets. Extract the resolution into a shared applyResolver helper, apply it when deriving `others` in PresenceProvider, and apply it on demand in useOther and the includeSelf branch of usePeersInBlock. A resolver returning null now clears just the affected field instead of dropping the peer entirely, so the user stays in the roster. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The WebSocket and BroadcastChannel adapters carried byte-identical copies of isRecord / isCursorPosition / isSelectionRange / isPointerPosition. Lift them into src/types/guards.ts so the wire shape lives in one place and future fields cannot drift between adapters. The adapter-specific isPresenceUser and update-payload guards stay local since they validate different field sets. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The provider was constructing a throwaway PresenceState (with dummy activities and connectionStatus) just to invoke the state-shaped helper, and then mutating presenceRef.current inside the setPresence updater. Add a Map-level remapRemoteUsers helper next to remapRemotePositions, call that from the provider, and let the existing useEffect([presence]) keep presenceRef in sync — the mutation inside the updater was a side-effect that concurrent renders could replay. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Summary
Adds editor-agnostic anchored cursor and selection support to
@softmaple/awareness, plus a separate pointer presence field with explicit coordinate space. Consumers can now resolve opaque anchors at render time or locally remap offset-only remote positions after document changes without rebroadcasting.Changes
PositionAnchor,PointerPosition,PresenceResolver, andPositionMappertypes.remapRemotePositions, pointer state operations,useRemapRemotePositions, anduseUpdatePointer.PresenceProviderandusePeerCursors.Validation
pnpm --filter @softmaple/awareness typecheckpnpm --filter @softmaple/awareness checkpnpm --filter @softmaple/awareness testpnpm --filter @softmaple/awareness buildNote: the package-specific Storybook/Vitest project ran as part of the awareness test command. The
softmaple-awareness-storybook-mcptools referenced in package instructions were not exposed in this Codex session.