fix(viewer): clear selection on cluster collapse to kill ghost edges#219
Merged
Conversation
Collapsing a cluster while one of its member nodes was selected left the
node-level selection edges rendering from the collapsed cluster's center
(getNodePos falls back to clusterPos) — visible as lines fanning from an
empty bubble. The existing guard only covered the chat-driven collapse
path; manual collapse via toggleCluster never cleared the selection.
- toggleCluster: when collapsing the cluster holding the selected node,
clear selectedId/affectedIds (mirrors the chat-collapse guard).
- ClusterGraph selection-edge map: replace index key (key={i}) with a
stable edge-id key to avoid reconciliation leaving stale <line>s.
Verified with browser automation: the collapse-while-selected case went
from 9 ghost edges to 0; select/deselect/clear sequence pixel-diffs 0%
against a pristine baseline.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Extract the "does the selected node live in the collapsing cluster" predicate into a pure helper (selectionBelongsToCluster) so the ghost-edge fix is guarded by a fast, browser-free test. toggleCluster now delegates to it; behavior is unchanged. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Problem
In
openlore view(clusters graph), collapsing a cluster while one of its member nodes was selected left the node-level selection edges rendering from the collapsed cluster's center — bright lines fanning out from an empty bubble to nodes across the graph. Since the "clear" button collapses all clusters, this also surfaced as ghost edges lingering after clear.Root cause
The "Node-level edges when a node is selected" block in
ClusterGraph.jsxrenders wheneverselectedIdis set. Its position helper falls back to the cluster center:An existing guard in
InteractiveGraphViewer.jsxclears the selection on the chat-driven collapse path, buttoggleCluster(manual bubble click) never did — same bug class, uncovered path.Fix
toggleCluster: when collapsing the cluster that holds the selected node, clearselectedId/affectedIds(mirrors the chat-collapse guard).ClusterGraphselection-edge map: replace index key (key={i}) with a stable edge-id key so reconciliation can't leave stale<line>s.Verification (browser automation)
🤖 Generated with Claude Code