Repository navigation
Conversation
lavrton
marked this pull request as ready for review
October 21, 2026 18:56
This branch has not been deployed
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.
What does this PR do and why?
Keeps a node's snapshot object the same across lazy instantiation.
Before a node is read, its snapshot computed returns the cached initial snapshot, and parents embed that object in their own snapshots.
createObservableInstancethen callstrackAndCompute(), which replaces it with a fresh, structurally identical object without notifying the parents. From then on a snapshot taken before the read never matches by identity, soapplySnapshotre-applies every child of it (ArrayType.applySnapshot,ModelType.applySnapshotandareSameskip a child only when given the very object it holds). An undo manager that recordsgetSnapshot(root)after a load pays O(all children) every time it undoes to that state: ~560 ms for 10,000 elements in Polotno, ~1 ms after this change.The computed now treats the recompute during
INITIALIZINGas unchanged, so MobX keeps the previous object. Instantiation changes no data;afterCreateruns after that window and propagates as before.Steps to validate locally
bun test __tests__/core/snapshot-identity.test.ts— both tests fail on master.NODE_ENV=development bun testandMST_TESTING=1 NODE_ENV=production bun testare green.