Skip to content

Rewrite state management with pure tree operations#45

Merged
bartaxyz merged 1 commit intomasterfrom
feat/improve-state-management
Mar 18, 2026
Merged

Rewrite state management with pure tree operations#45
bartaxyz merged 1 commit intomasterfrom
feat/improve-state-management

Conversation

@bartaxyz
Copy link
Copy Markdown
Owner

Summary

  • Replace mutation-based tree operations with immutable pure functions using structural sharing
  • Remove lodash and polished from production dependencies
  • Reorganize src/ into components/, tree/, hooks/, types.ts
  • Add benchmark suite for tree operations

Performance

Compared against the previous cloneDeep-based implementation:

Operation 50 nodes 584 nodes 4680 nodes
updateById (best case) 19.7x 32.1x 23.8x
updateById (worst case) 12.1x 22.9x 19.3x
setSelectedById 11.5x 12.6x 11.4x

What changed

  • Tree operations (find, update, move, setSelected) are now pure functions that return new data instead of mutating the input array
  • Structural sharing means only nodes on the path to the target are cloned
  • triggerOnChange flag and selectedOnChange (dead code) removed
  • onChange is called directly from each handler instead of through a deferred useEffect
  • lodash removed (no more cloneDeep)
  • polished removed (replaced with CSS color-mix())

Replace mutation-based tree operations with immutable pure functions
using structural sharing. Remove lodash dependency.

- 12-32x faster updates (no more cloneDeep on every change)
- 11-13x faster selection
- Reorganize src/ into components/, tree/, hooks/, types.ts
@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@bartaxyz bartaxyz merged commit d8879ed into master Mar 18, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant