Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions interface/src/components/MemoryGraph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export function MemoryGraph({ agentId, sort, typeFilter }: MemoryGraphProps) {
const [edgeCount, setEdgeCount] = useState(0);
const [selectedNode, setSelectedNode] = useState<NodeDetail | null>(null);
const [hoveredNode, setHoveredNode] = useState<string | null>(null);
const hoveredNodeRef = useRef<string | null>(null);
const [expandingNode, setExpandingNode] = useState<string | null>(null);
// Track loaded node IDs so we can exclude them when fetching neighbors
const loadedNodeIds = useRef<Set<string>>(new Set());
Expand Down Expand Up @@ -156,11 +157,17 @@ export function MemoryGraph({ agentId, sort, typeFilter }: MemoryGraphProps) {
},
nodeReducer: (node, data) => {
const res = { ...data };
if (hoveredNode && hoveredNode !== node) {
const graph = graphRef.current;
if (graph && !graph.hasEdge(hoveredNode, node) && !graph.hasEdge(node, hoveredNode)) {
res.color = FADED_NODE_COLOR;
res.label = "";
const hovered = hoveredNodeRef.current;
if (hovered) {
if (hovered === node) {
res.highlighted = true;
res.zIndex = 1;
} else {
const g = graphRef.current;
if (g && !g.hasEdge(hovered, node) && !g.hasEdge(node, hovered)) {
res.color = FADED_NODE_COLOR;
res.label = "";
}
}
}
return res;
Expand Down Expand Up @@ -271,8 +278,9 @@ export function MemoryGraph({ agentId, sort, typeFilter }: MemoryGraphProps) {
};
}, [isLoading]);

// Re-render sigma when hoveredNode changes (for fade effect)
// Sync ref and re-render sigma when hoveredNode changes (for fade effect)
useEffect(() => {
hoveredNodeRef.current = hoveredNode;
sigmaRef.current?.refresh();
}, [hoveredNode]);
Comment on lines +281 to 285
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Clear hover state before rebuilding the graph.

If the query changes while a node is hovered, the old id survives in both state and hoveredNodeRef. The next graph can therefore mount already dimmed or pre-highlighted until another hover event fires.

🩹 Suggested fix
 async function loadGraph() {
   setIsLoading(true);
   setError(null);
   setSelectedNode(null);
+  setHoveredNode(null);
+  hoveredNodeRef.current = null;
   cleanup();
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@interface/src/components/MemoryGraph.tsx` around lines 281 - 285, The current
useEffect syncing hoveredNode to hoveredNodeRef lets stale hover IDs linger
across graph rebuilds; add logic to clear the hover state when the underlying
graph/query changes by either expanding this effect or adding a new effect that
watches the query (or graph data) prop and sets hoveredNode to null and
hoveredNodeRef.current = null, then calls sigmaRef.current?.refresh(); update
references to hoveredNodeRef, hoveredNode, setHoveredNode (or equivalent state
setter), and sigmaRef to implement this clearing so the new graph mounts without
pre-dimmed/pre-highlighted nodes.


Expand Down Expand Up @@ -495,7 +503,7 @@ export function MemoryGraph({ agentId, sort, typeFilter }: MemoryGraphProps) {
{/* Sigma container */}
<div
ref={containerRef}
className="h-full w-full"
className="absolute inset-0 z-0"
style={{ background: "transparent" }}
/>

Expand Down
Loading