fix(graph): stop the compat engine's flow particles at flowSpeed=0 - #178
fix(graph): stop the compat engine's flow particles at flowSpeed=0#178Coding-Dev-Tools wants to merge 2 commits into
Conversation
…laxy mode The Galactic gravity, Black hole mass, Local solar gravity, and Space damping sliders previously only fed the galaxy-mode integrator. In the default overview/communities/compact views a settled d3 layout had already cooled, so a force-only re-render was invisible and the user-facing effect of the sliders was "nothing happens when I drag it". This change wires each spacetime slider into the d3-force installation so the layout visibly responds in every non-galaxy mode: - gravitationalConstant (0..200) scales the charge (node repulsion) strength. Default 100 -> 1.0x; max 200 -> 2.0x; min 0 -> 0x. - blackHoleMass (0..500) scales the existing gravity-driven centering strength via the same multiplier used by the galaxy-mode integrator (linear above the 160 baseline, value/160 below). Default 160 -> 1.0x; 500 -> 7.8x; 80 -> 0.5x. - localGravitationalConstant (0..200) scales the link spring strength. The existing d3 path used 1/(min degree) as the base; we now multiply by the same scalar so the slider tightens or loosens the visible link force. - damping (1..15) maps to fg.velocityDecay. At 1 the layout is bouncy (decay 0.05); at 15 it settles quickly (decay 0.85). Bounded 0.05..0.85 so the extreme ends stay usable. Two small helpers (clamp, blackHoleMassMultiplier) are inlined next to the d3-force install path; the existing helper in ledger.js is unchanged. A new regression test test_spacetime_sliders_reach_d3_forces_in_non_galaxy_mode instruments fg.d3Force / fg.velocityDecay to confirm each spacetime setting lands on the d3 wire. Fixes the user-reported "Galactic gravity / Black hole mass / Local solar gravity / Space damping sliders STILL NOT WORKING CORRECTLY" complaint.
The Flow speed slider in the compat engine had a residual floor of 0.002 at flowSpeed=0, so the particles kept crawling even when the user dragged the slider to zero. The every-node engine already enforced this with a `moving = speed > 0` guard; the compat engine is brought into line: - `flowActive` is true iff `flowSpeed > 0`. When false, the `flowing` flag short-circuits, the per-link particle count drops to 0, and the per-link speed callback returns 0 (no motion at all). - The visible end-to-end range is now floor (0) to 0.01 (at flowSpeed=100), with no residual motion at the low end. A new regression test `test_flow_speed_zero_stops_particle_motion_in_compat_engine` confirms the compat engine installs both `linkDirectionalParticles` and `linkDirectionalParticleSpeed` closures after a flowSpeed=0 setSettings. Bench: 293 dashboard+graph tests pass.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 97bc724b12
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const gravityMultiplier = clamp(Number(state.settings.gravitationalConstant || 0) / 100, 0, 2); | ||
| const massMultiplier = clamp(blackHoleMassMultiplier(Number(state.settings.blackHoleMass ?? 160)), 0.25, 4); | ||
| const localMultiplier = clamp(Number(state.settings.localGravitationalConstant || 0) / 100, 0, 2); |
There was a problem hiding this comment.
Use normalized spacetime values without scaling them again
In every non-galaxy dashboard view, ledger.js::graphSpacetimeEngineSettings() already converts the controls to normalized engine multipliers—at the defaults it passes gravitationalConstant=2, localGravitationalConstant=2, and blackHoleMass=1. Dividing the gravity values by 100 reduces charge and link forces to 2% of their prior strength, while passing the already-normalized mass through the raw-control conversion and clamping it produces 0.25; in fact, the entire supported engine mass range through 16 remains clamped to 0.25, so that slider has no D3 effect. Use the normalized settings directly so compact/community/radial layouts retain their calibrated forces.
Useful? React with 👍 / 👎.
| already enforces this via a `moving = speed > 0` check; the compat engine must do | ||
| the same. Otherwise the slider visibly does nothing at the low end (particles keep | ||
| crawling at the residual 0.002 floor). */ | ||
| const flowActive = Number.isFinite(flowSpeed) ? flowSpeed > 0 : true; |
There was a problem hiding this comment.
Restore the default speed before enabling flow
When the engine is used before the dashboard synchronizes settings—for example, standalone G.create(...); api.setPreset('constellation')—state.settings.flowSpeed is undefined because no preset supplies it. This condition treats the resulting NaN as active, so links receive a nonzero particle count, but the changed speed callback later computes with NaN instead of the previous fallback of 45. Normalize a non-finite speed to the default before using it for both the active check and speed calculation.
Useful? React with 👍 / 👎.
fix(graph): stop the compat engine's flow particles at flowSpeed=0
The Flow speed slider in the compat engine had a residual floor of 0.002 at
flowSpeed=0, so the particles kept crawling even when the user dragged the
slider to zero. The every-node engine already enforced this with a
moving = speed > 0guard; the compat engine is brought into line:flowActiveis true iffflowSpeed > 0. When false, theflowingflag short-circuits, the per-link particle count drops to 0, and the
per-link speed callback returns 0 (no motion at all).
with no residual motion at the low end.
A new regression test
test_flow_speed_zero_stops_particle_motion_in_compat_engineconfirms the compat engine installs both
linkDirectionalParticlesandlinkDirectionalParticleSpeedclosures after a flowSpeed=0 setSettings.Bench: 293 dashboard+graph tests pass.