Skip to content

hoist EMPTY_SET default in MemoriesGrid#856

Open
ved015 wants to merge 1 commit intosupermemoryai:mainfrom
ved015:perf/hoist-empty-set
Open

hoist EMPTY_SET default in MemoriesGrid#856
ved015 wants to merge 1 commit intosupermemoryai:mainfrom
ved015:perf/hoist-empty-set

Conversation

@ved015
Copy link
Copy Markdown
Contributor

@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
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