Skip to content

Commit 0cd009e

Browse files
mvalancyclaude
andauthored
Fix #30: node type change now updates the card in graph view (color/border/icon) (#73)
Changing a node's type elsewhere (dashboard/editor) updated the badge text in the graph but not the type-derived card color/border/icon — the selective update path (updateVisualizationData) refreshes text but not type visuals, and the reinit gatekeeper only watched edge signatures + node COUNT (a type change keeps count the same). Add a per-node id+type signature: when it changes, force a full reinitialization (same approach already used for edge type/flip), so the card re-renders with the new type's color, border and icon. Fixes #30. Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent aad5179 commit 0cd009e

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

packages/web/src/components/InteractiveGraphVisualization.tsx

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4271,6 +4271,11 @@ export function InteractiveGraphVisualization({ onResetLayout, onNodeSelected }:
42714271
// TYPE change or a direction FLIP — which keep the edge COUNT the same — still
42724272
// forces a rebuild. Without this the edge label/arrow keep the stale value.
42734273
const prevEdgeSigRef = useRef<string>('');
4274+
// Track a per-node id+type signature: a node TYPE change keeps node COUNT the
4275+
// same, and the selective update path refreshes the badge text but NOT the
4276+
// type-derived card color/border/icon, so the graph showed a stale type. A
4277+
// signature change forces a full rebuild (same approach as edges). (#30)
4278+
const prevNodeSigRef = useRef<string>('');
42744279

42754280
// Comprehensive reinitialization effect - ONLY when actually needed
42764281
useEffect(() => {
@@ -4300,6 +4305,14 @@ export function InteractiveGraphVisualization({ onResetLayout, onNodeSelected }:
43004305
.join(',');
43014306
const edgesChanged = prevEdgeSigRef.current !== '' && prevEdgeSigRef.current !== edgeSig;
43024307

4308+
// Detect a node TYPE change (same count → length checks miss it). The
4309+
// selective path refreshes the badge text but not the card color/icon. (#30)
4310+
const nodeSig = (nodes as any[])
4311+
.map((n) => `${n.id}:${n.type}`)
4312+
.sort()
4313+
.join(',');
4314+
const nodesChanged = prevNodeSigRef.current !== '' && prevNodeSigRef.current !== nodeSig;
4315+
43034316
// Only reinitialize if this is truly necessary
43044317
const shouldReinit =
43054318
!svgRef.current ||
@@ -4308,7 +4321,8 @@ export function InteractiveGraphVisualization({ onResetLayout, onNodeSelected }:
43084321
!d3.select(svgRef.current).select('.main-graph-group').node() ||
43094322
reinitTrigger > 0 ||
43104323
transitioningFromEmpty || // Force reinit when adding first node to empty graph
4311-
edgesChanged; // relationship type changed or direction flipped
4324+
edgesChanged || // relationship type changed or direction flipped
4325+
nodesChanged; // a node's type changed — re-render its color/border/icon
43124326

43134327
if (shouldReinit) {
43144328
console.log('[Graph Debug] Full reinitialization required');
@@ -4326,6 +4340,7 @@ export function InteractiveGraphVisualization({ onResetLayout, onNodeSelected }:
43264340
// Update previous node count + edge signature for next comparison
43274341
prevNodeCountRef.current = nodes.length;
43284342
prevEdgeSigRef.current = edgeSig;
4343+
prevNodeSigRef.current = nodeSig;
43294344

43304345
const handleResize = () => {
43314346
if (!containerRef.current || !svgRef.current || !simulationRef.current) return;

0 commit comments

Comments
 (0)