Skip to content

fix(remixer): improve tree build and rendering performance - #904

Merged
jakeaturner merged 1 commit into
stagingfrom
fix/remixer-render-perf
Aug 12, 2026
Merged

fix(remixer): improve tree build and rendering performance#904
jakeaturner merged 1 commit into
stagingfrom
fix/remixer-render-perf

Conversation

@jakeaturner

Copy link
Copy Markdown
Collaborator

memo-izes and refs various event handlers and components in the Remixer to avoid heavy tree rebuilds and unneeded re-renders

@jakeaturner
jakeaturner requested review from yghaemi and a lite review from Copilot August 12, 2026 19:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Improves Remixer tree build and rendering performance by stabilizing prop/callback identities and reducing per-node work during tree construction, so unrelated UI updates don’t trigger expensive tree rebuilds.

Changes:

  • Memoizes TreeDnd and TreeNodeContainer, and converts row handlers to stable useCallback functions that read transient state via refs.
  • Optimizes tree building by pre-indexing children by parent (avoids repeated currentBook.filter(...) per node).
  • Stabilizes RemixerDashboard props into <TreeDnd> (callbacks + empty pathLevelFormats fallback) to make memoization effective.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
client/src/components/remixer/RemixerDashboard.tsx Stabilizes <TreeDnd> props (callbacks and pathLevelFormats) to prevent unnecessary tree rebuilds on unrelated dashboard renders.
client/src/components/remixer/BookContent/TreeNodeContainer.tsx Refactors event handler props to accept page and memoizes the row component to avoid re-rendering unaffected rows.
client/src/components/remixer/BookContent/Dashboard.tsx Adds child indexing + stable row handlers and memoizes TreeDnd to reduce O(n²) work and minimize rerenders during drag/hover/selection changes.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +354 to +358
// Stable per-row handlers. Each receives the row's `page`, so a single
// identity serves every row and the memoized `TreeNodeContainer` only
// re-renders rows whose own (primitive) props actually changed. Transient
// drag/selection state is read through refs to keep these referentially stable.
const handleRowDragStart = useCallback(
@jakeaturner
jakeaturner merged commit 84bc44a into staging Aug 12, 2026
6 checks passed
@jakeaturner
jakeaturner deleted the fix/remixer-render-perf branch August 12, 2026 20:20
@libretexts-bot

Copy link
Copy Markdown
Collaborator

🎉 This PR is included in version 2.144.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants