From ab42ec81e6838fb2205eba389f00b99b0e21e1d4 Mon Sep 17 00:00:00 2001 From: amosblomqvist Date: Mon, 14 Sep 2026 03:53:23 +0300 Subject: [PATCH] Fix settings-load race: region/physics tuning never reached the renderer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The settings fetch resolves before the graph snapshot creates the renderer, so the load-time run of the region/physics feed effects hit a null rendererRef and never re-fired — every reload silently kept the DEFAULT region/physics tuning (a stored blur 10 rendered as 6). Feeds #4/#5 now carry isEmpty in their deps, the same guard Feed #2 (setSettings) already had. Sizes were unaffected only because their stored values happened to equal the defaults. --- components/graph-view.tsx | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/components/graph-view.tsx b/components/graph-view.tsx index ecc3f38..9ce650e 100644 --- a/components/graph-view.tsx +++ b/components/graph-view.tsx @@ -460,17 +460,20 @@ export function GraphView() { setSelected((sel) => (sel && visibleIds.has(sel.node.id) ? sel : null)); }, [visibleIds, query]); - // Feed #4 — region tuning (dev number inputs): its own update path, - // independent of the server-persisted render settings. + // Feed #4 — region tuning. `isEmpty` in the deps (same as Feed #2): + // the settings fetch resolves BEFORE the snapshot creates the renderer, + // so the load-time run hits a null renderer and would never re-fire — + // the renderer would silently keep the default tuning forever. useEffect(() => { rendererRef.current?.setRegionTuning(regionTuning); - }, [regionTuning]); + }, [regionTuning, isEmpty]); // Feed #5 — physics tuning: rebuilds the live sim in place (drag pins - // survive; a mid-settle change re-anneals, the honest response). + // survive; a mid-settle change re-anneals, the honest response). Same + // isEmpty dep as Feed #4 — see there. useEffect(() => { rendererRef.current?.setPhysicsTuning(physicsTuning); - }, [physicsTuning]); + }, [physicsTuning, isEmpty]); // Position the detail card: below the clicked node, flipped above near // the bottom edge, clamped horizontally. Imperative (ref + layout effect,