You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Browse filesBrowse the repository at this point in the historyBrowse files
authored
refactor: node geometry reads from the store, delete useLayoutSync (#14133)
## Summary
Make `layoutStore` authoritative for node geometry and remove the Layout
→ LiteGraph writeback loop. `LGraphNode.pos` / `size` remain stable
compatibility views backed by a lazily refreshed `Rectangle` projection.
## Why a projection
At 1000 nodes, a `Rectangle` read measured ~6 ns versus ~63.5 ns for
`ynodes.get(id)` → rect. The legacy canvas reads node geometry ~44 times
per frame, making direct Yjs reads cost roughly 2.5 ms/frame. A
geometry-version check keeps the common path local and refreshes each
accessed projection once after invalidation.
## Changes
- Project `pos` / `size` from the store while preserving indexed
mutation compatibility and command-based writes.
- Register and unregister projection lifetime with node layout lifetime.
- Delete `useLayoutSync`, including its RAF/microtask batching and
writeback machinery.
- Observe layout changes through a Vue-scoped effect: invalidate the
canvas for node changes and forward actual non-Canvas size changes to
legacy `onResize` callbacks. Canvas resizes retain synchronous callback
ownership through `setSize()`.
- Share the stored `[x, y, width, height]` tuple type between Yjs
mappers and validation.
## Review Focus
- The projection stays inert until the node's own layout entry exists,
preventing accidental adoption of geometry from an ID collision during
attach.
- Two `test.fails` cases pin known whole-value setter cache gaps in this
PR alone. Child PR [#14480](../pull/14480) fixes both; rebasing it
should produce unexpected passes, after which the `.fails` markers must
be removed.
- Projection lifecycle extraction and node-scoped invalidation are
deferred until after #14480 and documented in the ECS migration plan.
## Tests
- Stable-view refresh and indexed mutation behavior
- Removal/re-addition and graph-scoped layout state
- Exact-once Canvas resize callbacks and store-originated resize
callbacks
- Layout notification graph filtering and cleanup
---------
Co-authored-by: Amp <amp@ampcode.com>
Co-authored-by: GitHub Action <action@github.com>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
0 commit comments