Skip to content

feat(graph): live force simulation with node dragging - #980

Merged
h4yfans merged 2 commits into
mainfrom
graph-live-physics-drag
Aug 6, 2026
Merged

feat(graph): live force simulation with node dragging#980
h4yfans merged 2 commits into
mainfrom
graph-live-physics-drag

Conversation

@h4yfans

@h4yfans h4yfans commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

What

  • Replace the one-shot ForceAtlas2 pre-layout with a continuously running simulation that settles on its own and wakes on interaction
  • Add node dragging: linked neighbours follow the grabbed node, a 3px threshold keeps a drag from opening a tab
  • New dependency-free GraphPhysics (link springs, grid-cutoff repulsion, centering, collision, alpha decay/reheat, fx/fy pinning)
  • animateLayout now means "live motion", defaults on, and is finally exposed in the control panel

Why

The graph looked dead: graph-builder baked a static layout at build time and sigma drew frozen coordinates, the force worker was gated off with no UI to enable it, and no drag handlers existed.

Written in-repo rather than pulling in d3-force — adding it re-resolved shared transitives (@floating-ui/dom 1.7.6 → 1.8.0) and broke 1151 renderer tests. Lockfile is untouched.

h4yfans added 2 commits August 6, 2026 15:24
Replace the one-shot ForceAtlas2 pre-layout with a continuously running
simulation so the graph organises itself on open, settles, and reacts when
a node is dragged.

- add dependency-free GraphPhysics (link springs, grid-cutoff repulsion,
  centering, collision, alpha decay/reheat, fx/fy pinning)
- drive it one tick per animation frame; park when settled, wake on grab
- add node dragging with a 3px threshold so a drag never opens a tab
- stop baking a static layout in graph-builder; seed at simulation scale
- animateLayout now means "live motion", defaults on, and is exposed in the
  control panel
Copilot AI lite review requested due to automatic review settings August 6, 2026 12:25

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions github-actions Bot added documentation Improvements or additions to documentation enhancement New feature or request test labels Aug 6, 2026
@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown

React Doctor found 1 new issue in 1 file · 1 warning · score 92 / 100 (Great) · 0 fixed · vs main

1 warning

src/renderer/src/components/graph/physics-layout.tsx

  • ⚠️ L62 requestAnimationFrame loop never cancelled effect-raf-loop-needs-cancel

Reviewed by React Doctor for commit 14a34a2. See inline comments for fixes.

@h4yfans
h4yfans marked this pull request as ready for review August 6, 2026 12:33
@h4yfans
h4yfans merged commit efaff6c into main Aug 6, 2026
16 checks passed
}
}

frame = requestAnimationFrame(step)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

React Doctor · react-doctor/effect-raf-loop-needs-cancel (warning)

This requestAnimationFrame loop can schedule another frame but is never cancelled, so pending work may continue after unmount; store every frame id in one handle and cancel that handle from the returned effect cleanup.

Fix → Store the frame id and return a cleanup that calls cancelAnimationFrame(id) so self-scheduling work cannot continue after unmount.

Docs

@codecov

codecov Bot commented Aug 6, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.24060% with 10 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
apps/desktop/src/renderer/src/lib/graph-physics.ts 96.66% 6 Missing ⚠️
...enderer/src/components/graph/local-graph-panel.tsx 62.50% 3 Missing ⚠️
...derer/src/components/graph/graph-control-panel.tsx 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants