Skip to content

fix: memory graph hover highlight and click detection on Windows#491

Open
TheDarkSkyXD wants to merge 1 commit intospacedriveapp:mainfrom
TheDarkSkyXD:fix/memory-graph-hover-click
Open

fix: memory graph hover highlight and click detection on Windows#491
TheDarkSkyXD wants to merge 1 commit intospacedriveapp:mainfrom
TheDarkSkyXD:fix/memory-graph-hover-click

Conversation

@TheDarkSkyXD
Copy link
Contributor

Summary

  • Fixed stale closure in Sigma.js nodeReducer that prevented hover highlighting — hoveredNode was captured at Sigma creation time and always read as null
  • Added hoveredNodeRef ref that stays in sync with state, so the reducer reads the current value on each refresh
  • Added visual highlight (highlighted: true, zIndex: 1) on the hovered node itself, in addition to fading non-connected nodes
  • Fixed Sigma container positioning (absolute inset-0 z-0) so the canvas properly receives pointer events above the stacking context

Test plan

  • Open the Memory Graph view for an agent with memories
  • Hover over a node — it should highlight and non-connected nodes should fade
  • Click a node — the detail panel should appear
  • Double-click a node — neighbors should expand

🤖 Generated with Claude Code

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 25, 2026

Walkthrough

Modified the MemoryGraph component to manage hover state using a ref instead of relying solely on React state. Added a synchronization effect that updates the ref and triggers Sigma refresh. Updated the container div styling from h-full w-full to absolute inset-0 z-0 for positioning adjustments.

Changes

Cohort / File(s) Summary
Sigma Graph Hover State Management
interface/src/components/MemoryGraph.tsx
Introduced hoveredNodeRef to track hovered nodes, updated nodeReducer to read from ref instead of state, added effect to synchronize hoveredNode state changes to the ref and trigger Sigma refresh, and adjusted container div styling from layout-based classes to absolute positioning.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main fix: resolving hover highlight and click detection issues in the memory graph on Windows.
Description check ✅ Passed The description is directly related to the changeset, explaining the stale closure bug fix, the ref-based solution, visual highlighting improvements, and positioning fixes, with a clear test plan.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

The nodeReducer captured hoveredNode state in a closure at Sigma creation
time, so it was always null — preventing fade/highlight effects. Fixed by
using a ref that stays in sync with state. Also fixed the Sigma container
positioning so its canvas properly receives pointer events above the
stacking context.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@TheDarkSkyXD TheDarkSkyXD force-pushed the fix/memory-graph-hover-click branch from e6cff59 to 96d245c Compare March 25, 2026 21:34
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@interface/src/components/MemoryGraph.tsx`:
- Around line 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.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 727f15a8-3b94-42fd-a68a-d20609239d21

📥 Commits

Reviewing files that changed from the base of the PR and between b7d5dd2 and 96d245c.

📒 Files selected for processing (1)
  • interface/src/components/MemoryGraph.tsx

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

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