Skip to content

perf(ui): align React Query cache between memory grid and graph#845

Merged
MaheshtheDev merged 1 commit intosupermemoryai:mainfrom
ishaanxgupta:ishaan/query
Apr 12, 2026
Merged

perf(ui): align React Query cache between memory grid and graph#845
MaheshtheDev merged 1 commit intosupermemoryai:mainfrom
ishaanxgupta:ishaan/query

Conversation

@ishaanxgupta
Copy link
Copy Markdown
Contributor

Summary

Aligns the React Query caching strategy for the @post/documents/documents endpoint between the main Memory Grid and the Memory Graph UI.

Previously, use-graph-api.ts used a completely different queryKey (["graph-documents", ...]) and a short staleTime of 30 seconds, while memories-grid.tsx cached the same payload for 5 minutes under ["documents-with-memories", ...].

This mismatch resulted in the client ignoring its cache and blindly re-fetching identical document arrays when the user toggled the graph view, wasting network bandwidth and blocking the main thread on parsing duplicate JSON.

Changes

  • Updated the queryKey in apps/web/components/memory-graph/hooks/use-graph-api.ts to ["documents-with-memories", containerTags, []].
  • Increased the graph's staleTime from 30s to 5m to mirror the grid cache configuration.

Impact

  • Fewer Network Calls: Zero redundant API requests when switching back and forth between the grid and the graph.
  • Improved UX: Faster transition into the graph UI since data is instantly yielded from the cache.
  • Lower CPU Usage: Avoids heavy main-thread document payload parsing on duplicate requests.

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 13bee90 into supermemoryai:main Apr 12, 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.

2 participants