fix: a saved layout that stacks nodes is not a usable layout - #53
Merged
Conversation
Requiring a saved layout to cover every node turned out not to be enough. A layout captured before its nodes were ever placed names all of them and puts several at the same point — the origin, usually, since that is where a node starts life. It passes the coverage check, suppresses the layout run, and is then restored faithfully on every open. So the diagram opens stacked, opens stacked again after a reload, and the only thing that ever fixes it is running a layout by hand — which saves a good layout and hides the cause. Two nodes at identical coordinates is a reliable signature. No layout engine produces it, and nobody drags one node exactly on top of another, so it means the positions were recorded rather than computed. The check is now coverage AND no coincidence. Both are properties of the saved file rather than guesses about where it came from, and both fail toward laying out again, which is the recoverable direction: a needless layout costs one run and is persisted immediately, while a wrongly trusted one persists forever. `countCoincidentNodes` is exported and tested beside the rule it feeds. It counts every extra at a shared point rather than the pairs, because the number is only ever compared against zero and the simpler definition is the one that stays true if that changes.
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.
The problem
Requiring a saved layout to cover every node — the previous fix — turned out not to be enough.
A layout captured before its nodes were ever placed names all of them and puts several at the same point, usually the origin, since that is where a node starts life. Observed in the wild:
It passes the coverage check, suppresses the layout run, and is then restored faithfully on every open. The diagram opens stacked, opens stacked again after a reload, and the only thing that fixes it is running a layout by hand — which saves a good layout and so hides the cause from whoever looks next.
The change
The check is now coverage and no coincidence.
Two nodes at identical coordinates is a reliable signature of positions that were recorded rather than computed. No layout engine produces it, and nobody drags one node exactly on top of another.
Both conditions are properties of the saved file rather than guesses about its provenance, and both fail toward laying out again — the recoverable direction. A needless layout costs one run and is persisted immediately; a wrongly trusted one persists forever.
countCoincidentNodesis exported and tested beside the rule it feeds. It counts every extra at a shared point rather than the pairs, since the number is only compared against zero and the simpler definition survives that changing.Verified
npm run build,npm run typecheck(5/5),npm run check:neutrality(5/5),npm test— green by exit code.