Skip to content

Resolve canvas vertices, ids, and style scope in one pass - #2124

Closed
kmcginnes wants to merge 1 commit into
release-display-vertex-atom-entriesfrom
fuse-canvas-vertex-passes
Closed

Resolve canvas vertices, ids, and style scope in one pass#2124
kmcginnes wants to merge 1 commit into
release-display-vertex-atom-entriesfrom
fuse-canvas-vertex-passes

Conversation

@kmcginnes

Copy link
Copy Markdown
Collaborator

Description

Three passes over the canvas vertices become one, and the resolver layer from #2119 collapses.

The visible-ids atom iterated every vertex; the style-scope atom iterated them again re-testing membership; useRenderedVertices iterated a third time re-testing it once more. Two passes existed only to re-discover a decision the first had already made. canvasVerticesAtom returns the drawn vertices, their ids, and the styles of the types they draw from a single loop.

That also removes the reason a missing icon used to be silent. Style data was assembled from two inputs of different totality — scalar fields from a lookup that answers for any type, the icon from a partial scope list — so resolveStyleData(type) always succeeded and always looked plausible, and a scope miss was indistinguishable from a type that genuinely has no icon. Now a drawn vertex's primaryType is in stylesByType by construction (same loop), the style data derives entirely from that scoped list, and a type absent from it throws rather than quietly drawing a node without its icon.

The memoizing resolver layer goes with it: five exported symbols, two factories and two cache closures replaced by one hook returning a plain per-type map. The lazy memoization bought nothing because every caller knows its full key set up front — and the resolver function shape is what forced the total-lookup dependency, since a function must answer for any argument where a map need not.

The edge half is inlined rather than kept as a hook: the drawn edge types are only knowable while filtering, so producing them up front would need the extra pass this PR removes. Each consumer fills a per-render map on first sight of a type inside its existing loop — still one Color parse per type rather than per edge.

Iteration order is unchanged; rendered vertices stay in canvas insertion order.

How to read

  1. renderedEntities.tscanvasVerticesAtom, then the two hooks.
  2. styleDataResolvers.ts — down to a single hook.
  3. useSchemaGraphData.ts — mirrors the same invariant assertion.

Three passes over the canvas vertices became one. The visible-ids atom iterated
every vertex, the style-scope atom iterated them again re-testing membership, and
the render hook iterated a third time re-testing it once more — two passes existed
only to re-discover a decision the first had already made.

`canvasVerticesAtom` returns the drawn vertices, their ids, and the styles of the
types they draw from a single loop, so the style scope and the drawn set cannot
disagree: a drawn vertex's `primaryType` is in `stylesByType` by construction.

That also collapses the reason a missing icon used to be silent. Style data was
assembled from two inputs of different totality — scalar fields from a lookup
that answers for any type, the icon from a partial scope list — so a scope miss
was indistinguishable from a type that genuinely has no icon. The style data now
derives entirely from the scoped style list, and a type absent from it is a
loud throw rather than a node quietly drawn without its icon.

The memoizing resolver layer is gone with it: five exported symbols, two factories
and two cache closures replaced by one hook returning a plain per-type map. Edge
style data is resolved on first sight of a type inside the existing filter loop,
since the drawn edge types are only known while filtering.
@kmcginnes

Copy link
Copy Markdown
Collaborator Author

Superseded by #2128, which consolidates this stack into a single PR targeting #2112. Same commits, same end state — the branch there is byte-identical to the tree these were cut from, rebased onto schema-view-style-perf after #2118 was squash-merged into it.

@kmcginnes kmcginnes closed this Aug 14, 2026
@kmcginnes
kmcginnes deleted the fuse-canvas-vertex-passes branch August 14, 2026 21:11
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