Skip to content

Feat/avoid reverse map version control - #1085

Open
Mkalbani wants to merge 2 commits into
rinafcode:mainfrom
Mkalbani:feat/avoid-reverse-map-version-control
Open

Feat/avoid reverse map version control#1085
Mkalbani wants to merge 2 commits into
rinafcode:mainfrom
Mkalbani:feat/avoid-reverse-map-version-control

Conversation

@Mkalbani

Copy link
Copy Markdown
Contributor

Fix VersionControl history rendering

Summary

Avoids the history.map(...).reverse() clone on every render and replaces unstable key={index} usage with stable history entry IDs.

What changed

  • cmsStore.ts
    • Added CMSHistoryEntry type with stable historyId
    • Persisted history snapshots with generated historyId
  • VersionControl.tsx
    • Memoized reversed history using useMemo
    • Rendered reversedHistory instead of reversing after map
    • Replaced key={index} with key={snapshot.historyId}
    • Kept Current Version and history state mapping correct using computed original index

Why

  • Prevents repeated allocation of a reversed history array each render
  • Improves React reconciliation by using stable keys when history entries shift
  • Keeps newest entries shown first without runtime .reverse() cost

Files changed

  • cmsStore.ts
  • VersionControl.tsx

Notes

  • Branch: feat/avoid-reverse-map-version-control
  • Verified no editor-reported TypeScript issues in the modified files

closes #970

@drips-wave

drips-wave Bot commented Jul 29, 2026

Copy link
Copy Markdown

@Mkalbani Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

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.

Avoid map().reverse() clone and index keys in VersionControl timeline

1 participant