Skip to content

Selecting a class goes straight to its highlight - #534

Merged
WaylandYang merged 2 commits into
devfrom
fix/revealing-a-class-does-not-rebuild
Sep 9, 2026
Merged

WaylandYang merged 2 commits into
devfrom
fix/revealing-a-class-does-not-rebuild

Conversation

@WaylandYang

Copy link
Copy Markdown
Contributor

Click a class in the ontology rail that is not currently drawn, and the diagram
flickers: for one frame every node and edge lights up at full brightness, then
everything dims to the new selection. On a dense canvas that reads as a white
flash.

Measured on one node, sampling sigma's own afterRender, before the fix. Class A
was already selected, then class B was clicked:

frame node size meaning
before 4.68 A selected, this node dimmed
11ms 9.00 nothing selected — everything at full brightness
39ms on 4.68 B selected, dimmed again

Two causes, one symptom

The reducer silently downgrades "selected but not drawn yet" to "nothing
selected."
Its guard is sel.kind === "class" && g.hasNode(sel.id). Clicking an
undrawn class reveals it asynchronously, so for one render hasNode is false and
the whole graph comes up unlit. Opening the detail panel shrinks the canvas at the
same moment, forcing exactly that repaint, which is why it is so visible.

Fixed by holding the selection until the class is actually in the graph. The canvas
keeps the previous highlight for those ~30ms and then switches once, cleanly.

Revealing a class rebuilt the entire renderer. reveal() changes the drawn
scope, which recomputes the graph, which tore down Sigma and built a new one — seven
canvases destroyed and recreated, GPU buffers, camera, hover and selection state all
thrown away, plus a fresh first frame. The camera restarted from its default fit,
so the view jumped to "see everything" and then panned to the target.

Fixed by splitting the two lifecycles. The graph is now a single persistent instance
that new content is merged into (syncGraph in graphCanvas.ts; graphology emits
events and Sigma listens, so in-place mutation is the supported path). The renderer
is built once. Measured after: zero canvas churn, same graph and renderer
objects, node count 44 → 45, camera untouched at 0.340, 0.660, r=0.42.

Three values the renderer closes over (onSelect, relationById) moved to refs,
since the effect no longer re-runs.

Also here

Selecting a property whose Subject and Object are both "Any type" — there are 184
of them in a schema.org knowledge base, and the legend already counts them —
dimmed the entire diagram and lit nothing, because the endpoint set is empty and
every node fell into the "not part of the selection" branch. It read as "I selected
it and it broke." Now the canvas simply does not react; the panel already says
Subject and Object are Any type. Scoped properties are unaffected: about still
dims 43 nodes and thickens its edges.

Not the same as #532

That one makes the blur on a glass panel arrive on the same schedule as its opacity.
It is a real defect and worth keeping, but it is not the cause of the flash
reported here — this is.

Conflicts

Touches OntologySchemaGraph.tsx, which #529 also touches. Whichever lands second
will need a small merge.

Checked

  • pnpm build clean; style guard 46/46.
  • Flash gone: the same node holds 4.68 across the whole transition, no bright frame.
  • Focus still fires on reveal, with the right target and the camera's own ratio
    preserved (verified by spying on camera.animate; the animation itself cannot be
    observed in the headless preview pane, which does not run rAF).
  • End state correct: selected class ×1.02 with the inverted bold label, neighbours
    full size, non-neighbours muted, panel titled correctly.

🤖 Generated with Claude Code

WaylandYang and others added 2 commits September 9, 2026 15:49
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Signed-off-by: WaylandYang <wayland0916@gmail.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Signed-off-by: WaylandYang <wayland0916@gmail.com>
@WaylandYang
WaylandYang force-pushed the fix/revealing-a-class-does-not-rebuild branch from 5385a3a to c59845b Compare September 9, 2026 07:50
@WaylandYang
WaylandYang merged commit b50df8f into dev Sep 9, 2026
4 checks passed
@WaylandYang
WaylandYang deleted the fix/revealing-a-class-does-not-rebuild branch September 9, 2026 07:53
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