Skip to content

fix: a saved layout that stacks nodes is not a usable layout - #53

Merged
endrix merged 1 commit into
mainfrom
fix/a-layout-that-stacks-nodes-is-not-a-layout
Sep 4, 2026
Merged

fix: a saved layout that stacks nodes is not a usable layout#53
endrix merged 1 commit into
mainfrom
fix/a-layout-that-stacks-nodes-is-not-a-layout

Conversation

@endrix

@endrix endrix commented Sep 4, 2026

Copy link
Copy Markdown
Owner

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:

"wen":   { "x": 0, "y": 0 },
"rdata": { "x": 0, "y": 0 },
"ram":   { "x": -340, "y": -150 }

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.

countCoincidentNodes is 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.

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.
@endrix
endrix merged commit d164592 into main Sep 4, 2026
1 check passed
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