Conversation
- Replaced the useDocuments hook with React Query for better caching and deduplication of document requests. - Updated the ConnectorIndicator component to fetch document type counts using a new atom for real-time updates. - Enhanced the useComments hook to manage batch requests more effectively, reducing race conditions and improving performance. - Set default query options in the query client to optimize stale time and refetch behavior.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Review by RecurseML
🔍 Review performed on 0a28014..cc64e18
✨ No bugs found, your code is sparkling clean
✅ Files analyzed, no issues (4)
• surfsense_web/components/assistant-ui/connector-popup.tsx
• surfsense_web/hooks/use-comments.ts
• surfsense_web/hooks/use-documents.ts
• surfsense_web/lib/query-client/client.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Motivation and Context
FIX #
Screenshots
API Changes
Change Type
Testing Performed
Checklist
High-level PR Summary
This PR refactors document fetching to use React Query for better caching and deduplication, eliminating redundant API calls when multiple components mount. It also fixes a race condition in comment batching by introducing a promise-based gate mechanism (
_batchReady) that ensures individual queries wait for batch prefetch logic to initialize before deciding whether to piggyback or fetch independently. The connector popup component is updated to use a lightweight cached endpoint for document type counts instead of the previous Electric SQL approach.⏱️ Estimated Review Time: 15-30 minutes
💡 Review Order Suggestion
surfsense_web/lib/query-client/client.tssurfsense_web/hooks/use-documents.tssurfsense_web/hooks/use-comments.tssurfsense_web/components/assistant-ui/connector-popup.tsx