fix(viewer): soften graph layout velocity
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.tsgit 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.
@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.
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.
Comment @coderabbitai help to get the list of available commands and usage tips.
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.
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.