Settle camera + simulation presets: fix the first-load feel - #6
Merged
Conversation
Two measured problems on every fresh force mount (800-node clustered
protocol, max displacement sampled at 500ms): the first-data fit frames
the seed ring while the simulation contracts the graph to 5-17% viewport
fill across the whole parameter space (a distant blob), and the engine's
default cooling never reaches visible stillness inside 20s (reads as
endless jitter).
- fitViewOnSettle construction option ('follow' default | 'once' | false):
'follow' keeps the settling graph framed with periodic animated refits
riding the engine frame fan-out (frame-counted — no timers, no rAF of
its own, dies with the frames it rides), plus a final fit at first
quiescence; user camera input (pointer/wheel on the container or any
public camera call) cancels it. Fixed layouts never arm.
- simulation accepts preset names ('calm' | 'spread' | 'tight' |
'lively'); SIMULATION_PRESETS + resolveSimulation exported; presets are
frozen singletons so identity comparison keeps working.
- DEFAULT changed: omitted simulation resolves to 'calm' (visually still
in ~5s) instead of engine defaults; the old feel is simulation="lively".
- Verified live: fill 0.5x0.8 after settle vs 0.07x0.12 before.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018SeFxK217ZrHSERqK6kjcb
Review finding: a deep-linked setViewState restore during the first settle window would have its explicitly restored camera overwritten by the follow's next periodic or final fit. The restore now cancels the follow; pinned by a test asserting the restored viewport stands.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem (measured)
Storybook made it obvious: every fresh force-layout graph renders tiny and jittery. Two mechanisms, quantified on an 800-node clustered protocol:
fitViewOnFirstDataframes the seed ring; the simulation then contracts the graph to 5–17% viewport fill across the entire parameter space (12-combo sweep; physics cannot fix this, only the camera can).Fix
fitViewOnSettle: 'follow' (default) | 'once' | false. 'follow' keeps the settling graph framed with periodic animated refits riding the engine frame fan-out (frame-counted: no timers, no rAF of its own — it dies with the frames it rides, honoring the quiescence invariant), plus one final fit at first quiescence. Any user camera input (pointer/wheel on the container, or any public camera call) cancels it. Fixed layouts never arm.simulationaccepts'calm' | 'spread' | 'tight' | 'lively'alongside a full config;SIMULATION_PRESETSandresolveSimulationexported. Values chosen by measured time-to-stillness, not vibes.simulationnow resolves to'calm'; the previous engine-default feel is one prop away (simulation="lively").Result (live, same fixture)
Tests
Nine new pinning tests (
settle-camera.test.ts): default-calm config reaches the engine, preset identity no-ops, follow cadence + quiescence finale + post-settle silence, 'once'/false modes, frame cap, user-camera cancellation, fixed-layout never arms. One existing assertion updated (sim-controls): the mount replay now legitimately carries the default simulation config. Full check green: 1,794 tests.🤖 Generated with Claude Code
https://claude.ai/code/session_018SeFxK217ZrHSERqK6kjcb
Greptile Summary
This PR improves first-load force-layout behavior by adding a settle-aware camera mode and named simulation presets, with calm simulation behavior as the new default.
Confidence Score: 5/5
The PR appears safe to merge.
No blocking failure remains.
Important Files Changed
Reviews (2): Last reviewed commit: "Settle follow yields to a restored view-..." | Re-trigger Greptile