Skip to content

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

Open
ishaanxgupta wants to merge 1 commit intosupermemoryai:mainfrom
ishaanxgupta:ishaan/query
Open

perf(ui): align React Query cache between memory grid and graph#845
ishaanxgupta wants to merge 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.

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