Conversation
- improved search_knowledgebase_tool - Added new endpoint to batch-fetch comments for multiple messages, reducing the number of API calls. - Introduced CommentBatchRequest and CommentBatchResponse schemas for handling batch requests and responses. - Updated chat_comments_service to validate message existence and permissions before fetching comments. - Enhanced frontend with useBatchCommentsPreload hook to optimize comment loading for assistant messages.
|
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 11a38a2..08829c1
✨ No bugs found, your code is sparkling clean
✅ Files analyzed, no issues (13)
• surfsense_backend/app/agents/new_chat/tools/knowledge_base.py
• surfsense_backend/app/indexing_pipeline/indexing_pipeline_service.py
• surfsense_backend/app/retriever/chunks_hybrid_search.py
• surfsense_backend/app/retriever/documents_hybrid_search.py
• surfsense_backend/app/routes/chat_comments_routes.py
• surfsense_backend/app/schemas/chat_comments.py
• surfsense_backend/app/services/chat_comments_service.py
• surfsense_backend/app/services/connector_service.py
• surfsense_backend/app/services/llm_router_service.py
• surfsense_web/components/assistant-ui/thread.tsx
• surfsense_web/contracts/types/chat-comments.types.ts
• surfsense_web/hooks/use-comments.ts
• surfsense_web/lib/apis/chat-comments-api.service.ts
Description
Motivation and Context
FIX #
Screenshots
API Changes
Change Type
Testing Performed
Checklist
High-level PR Summary
This PR introduces performance optimizations through two main strategies: batch API endpoints for comments to eliminate N+1 query problems on the frontend, and parallel search execution with embedding reuse in the backend retrieval pipeline. The batch comments API allows fetching comments for multiple messages in a single request, while the search optimizations execute chunk and document retrievers concurrently using separate database sessions and share pre-computed query embeddings. Additional cleanup includes formatting multi-line logging statements for better readability across the codebase.
⏱️ Estimated Review Time: 30-90 minutes
💡 Review Order Suggestion
surfsense_web/contracts/types/chat-comments.types.tssurfsense_backend/app/schemas/chat_comments.pysurfsense_web/lib/apis/chat-comments-api.service.tssurfsense_backend/app/routes/chat_comments_routes.pysurfsense_backend/app/services/chat_comments_service.pysurfsense_web/hooks/use-comments.tssurfsense_web/components/assistant-ui/thread.tsxsurfsense_backend/app/retriever/chunks_hybrid_search.pysurfsense_backend/app/retriever/documents_hybrid_search.pysurfsense_backend/app/services/connector_service.pysurfsense_backend/app/agents/new_chat/tools/knowledge_base.pysurfsense_backend/app/indexing_pipeline/indexing_pipeline_service.pysurfsense_backend/app/services/llm_router_service.py