Closes #2070. The Map<rootId, Set<nodeId>> in useCanvasViewport.ts accumulated entries indefinitely — adds on every successful auto-fit, never deletes when a root left state.nodes (cascade delete or manual remove). Operationally invisible until thousands of imports, but the fix is cheap. Adds pruneStaleSubtreeIds(map, liveNodeIds) — a pure helper exported alongside the existing shouldFitGrowing helper, called at the top of runFit before any read or write to the map. Bounds the map to "roots present right now" instead of "every root ever auto-fitted in this session." O(map_size) per fit; runs only at user-driven cadence. Tests in __tests__/useCanvasViewport.test.ts cover the four cases: delete-some / no-op / clear-all / never-add. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| __tests__ | ||
| app | ||
| components | ||
| hooks | ||
| lib | ||
| store | ||
| stores | ||
| styles | ||
| types | ||
| middleware.ts | ||