agentmemory icon indicating copy to clipboard operation
agentmemory copied to clipboard

fix(viewer): soften graph layout velocity

Open Rex57 opened this issue 6 months ago β€’ 2 comments

Summary

  • Add a gradual velocity cap to the viewer graph simulation so large graphs start lively but slow down over time.
  • Keep the original graph layout, node sizing, controls, rendering, and backend APIs unchanged.
  • Add a viewer regression test for the decaying velocity cap.

Verification

  • npx vitest run test/viewer-session-id.test.ts test/viewer-security.test.ts
  • git diff --check upstream/main...HEAD

Summary by CodeRabbit

  • Improvements

    • The Graph tab's force-directed simulation now applies a time-decaying velocity cap, improving animation stability, reducing acceleration spikes, and producing smoother node motion during interactive graph visualization.
  • Tests

    • New tests validate that the velocity cap decreases over time and maintains a safe minimum to ensure stable long-term animation.

Review Change Stack

Rex57 avatar May 18 '26 14:05 Rex57

@Rex57 is attempting to deploy a commit to the rohitg00's projects Team on Vercel.

A member of the Team first needs to authorize it.

vercel[bot] avatar May 18 '26 14:05 vercel[bot]

No actionable comments were generated in the recent review. πŸŽ‰

ℹ️ Recent review info
βš™οΈ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6a723f8c-62df-4059-8396-2a43d6e9b30a

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 65f70c40b696e9bd1bb25be083a7338d87fcb7b9 and acb4866842a38c5376bccb92c95753cdbd45d3e7.

πŸ“’ Files selected for processing (1)
  • src/viewer/index.html
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/viewer/index.html

πŸ“ Walkthrough

Walkthrough

The graph simulation adds a tick counter and a decaying, node-count-aware velocity cap computed by getGraphVelocityCap(nodeCount, tick). Each simulation step computes the cap, clamps non-dragged node velocities by rescaling vx/vy when necessary, updates positions, renders, and increments the tick. A test verifies cap decay over time.

Changes

Graph velocity capping

Layer / File(s) Summary
Velocity cap algorithm and state management
src/viewer/index.html
graphSim state adds a tick counter initialized to 0. New getGraphVelocityCap(nodeCount, tick) computes a decaying velocity limit based on node count and elapsed ticks.
Velocity clamping in simulation loop
src/viewer/index.html
Each simulation step retrieves the computed velocity cap, measures node speeds, and rescales vx/vy for non-dragged nodes that exceed the cap; graphSim.tick is incremented after rendering.
Velocity cap decay validation
test/viewer-session-id.test.ts
New test asserts getGraphVelocityCap(1500, t) returns decreasing values for increasing ticks and that the late-time value is at least 6.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

πŸ‡
In frames I count each tiny tick,
I whisper "slow" when nodes move quick,
A gentle cap tames wild display,
Tick after tick we find our way,
The graph hops calm β€” hooray, hooray!

πŸš₯ Pre-merge checks | βœ… 5
βœ… Passed checks (5 passed)
Check name Status Explanation
Description Check βœ… Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check βœ… Passed The title 'fix(viewer): soften graph layout velocity' accurately summarizes the main change: adding a velocity cap mechanism to reduce animation speed in the graph viewer.
Docstring Coverage βœ… Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check βœ… Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check βœ… Passed Check skipped because no linked issues were found for this pull request.

✏️ 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.

coderabbitai[bot] avatar May 18 '26 14:05 coderabbitai[bot]

Hey @Rex57 β€” deferring this against the minimal-surface rule.

The velocity-decay clamp is a pure animation polish β€” agentmemory's graph view layout isn't broken without it, just slightly less restful. We're trying to keep the surface area focused on bug fixes + features tied to tracked user issues.

If there's a specific report of users finding the layout jarring (e.g. nodes oscillating, motion sickness complaint), link it and I'll reconsider. Otherwise the change is correct + harmless but doesn't pass the bar for merge today.

Closing as not-needed-now rather than letting it sit. Reopen if a tracked issue surfaces this as a real complaint.

rohitg00 avatar May 19 '26 12:05 rohitg00

Per the comment above β€” closing to align with the minimal-surface rule on agentmemory. Re-open with a linked user issue if the smooth-motion ask becomes real.

rohitg00 avatar May 19 '26 12:05 rohitg00