Skip to content

hoist EMPTY_SET default in MemoriesGrid#856

Merged
MaheshtheDev merged 1 commit into
supermemoryai:mainfrom
ved015:perf/hoist-empty-set
May 6, 2026
Merged

hoist EMPTY_SET default in MemoriesGrid#856
MaheshtheDev merged 1 commit into
supermemoryai:mainfrom
ved015:perf/hoist-empty-set

Conversation

@ved015
Copy link
Copy Markdown
Member

@ved015 ved015 commented Apr 16, 2026

Summary

Hoisted the new Set() default parameter in MemoriesGrid to a module-level constant named EMPTY_SET.

Details

The selectedDocumentIds = new Set() default parameter was causing a performance bottleneck. Because a new Set was being instantiated on every render cycle, its reference was never stable. This invalidated the React.memo optimization on the DocumentCard components, forcing every visible card to re-render whenever the parent MemoriesGrid updated.

Use

  • Component Efficiency: Restores the effectiveness of memo() for the masonry item rendering.
  • Render Cost: Prevents cascading re-renders of 100+ cards during common actions like opening the chat sidebar or space navigation.

@Dhravya please have a look

@graphite-app graphite-app Bot requested a review from Dhravya April 16, 2026 17:41
@ved015
Copy link
Copy Markdown
Member Author

ved015 commented May 6, 2026

@MaheshtheDev this can be merged

Copy link
Copy Markdown
Member

@MaheshtheDev MaheshtheDev left a comment

Choose a reason for hiding this comment

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

LGTM

@MaheshtheDev MaheshtheDev merged commit f850a0e into supermemoryai:main May 6, 2026
6 of 7 checks 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.

3 participants