Skip to content

fix(viewer): clear selection on cluster collapse to kill ghost edges#219

Merged
clay-good merged 2 commits into
mainfrom
fix/viewer-ghost-edges
Jul 1, 2026
Merged

fix(viewer): clear selection on cluster collapse to kill ghost edges#219
clay-good merged 2 commits into
mainfrom
fix/viewer-ghost-edges

Conversation

@laurentftech

Copy link
Copy Markdown
Collaborator

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.jsx renders whenever selectedId is set. Its position helper falls back to the cluster center:

if (nodeLayouts[clId]?.[nid]) return nodeLayouts[clId][nid];
return clusterPos[clId] || null;   // ← draws edge from collapsed cluster center = ghost

An existing guard in InteractiveGraphViewer.jsx clears the selection on the chat-driven collapse path, but toggleCluster (manual bubble click) never did — same bug class, uncovered path.

Fix

  • toggleCluster: when collapsing the cluster that holds 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 so reconciliation can't leave stale <line>s.

Verification (browser automation)

  • Collapse-while-selected: selection edges 9 → 0 after fix.
  • Select / deselect / clear sequence: 0% pixel diff against a pristine baseline; DOM clean (0 selection lines, 0 node-glow).

🤖 Generated with Claude Code

laurentftech and others added 2 commits July 1, 2026 23:00
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>
@laurentftech laurentftech requested a review from clay-good July 1, 2026 21:07
@clay-good clay-good merged commit faacc2f into main Jul 1, 2026
4 checks 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.

2 participants