-
Notifications
You must be signed in to change notification settings - Fork 50.9k
perf(editor): Render chat sidebar faster (no-changelog) #22039
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
BundleMonUnchanged files (2)
No change in files bundle size Groups updated (2)
Final result: ✅ View report in BundleMon website ➡️ |
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
| async getConversations( | ||
| req: AuthenticatedRequest, | ||
| _res: Response, | ||
| @Query query: ChatHubConversationsRequest, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The conversation list endpoint is fast enough without pagination, but it does slow down rendering UI when many items are returned. This is still the case if the user scrolls the list very far, but I think we can keep it for later
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this seems good enough for now I think 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
5 issues found across 15 files
Prompt for AI agents (all 5 issues)
Understand the root cause of the following 5 issues and fix them.
<file name="packages/cli/src/modules/chat-hub/chat-hub.service.ts">
<violation number="1" location="packages/cli/src/modules/chat-hub/chat-hub.service.ts:1514">
Rule violated: **Tests**
Cursor-based pagination (`nextCursor`/`hasMore`) was added to `getConversations` without any tests covering the new limit/cursor invariants, leaving this core listing logic unverified despite the Community PR Guideline requiring tests for new functionality.</violation>
</file>
<file name="packages/cli/src/modules/chat-hub/chat-session.repository.ts">
<violation number="1" location="packages/cli/src/modules/chat-hub/chat-session.repository.ts:61">
Rule violated: **Tests**
Community PR Guidelines §2 require tests for core functionality. The new paginated/cursor-aware `getManyByUserId` implementation adds limit handling and a NotFound error path but the chat-hub test suite contains no coverage for cursor pagination or the new error case. Please add unit or integration tests that verify limiting, cursor-based continuation, and the missing-cursor error.</violation>
<violation number="2" location="packages/cli/src/modules/chat-hub/chat-session.repository.ts:76">
Cursor pagination can return duplicate items: the filter uses `lastMessageAt <= cursor` with `id != cursor`, so records with the same timestamp but smaller IDs (already seen in a prior page) satisfy the cursor clause and get re-sent. Use a lexicographical comparison matching the sort order to advance strictly past the cursor.</violation>
</file>
<file name="packages/frontend/editor-ui/src/features/ai/chatHub/chat.store.ts">
<violation number="1" location="packages/frontend/editor-ui/src/features/ai/chatHub/chat.store.ts:282">
`sessionsLoadingMore` is set to true before the API call but never reset when `fetchSessionsApi` rejects, so a failed request permanently blocks further pagination. Wrap the call in try/finally to clear the flag on both success and error.</violation>
<violation number="2" location="packages/frontend/editor-ui/src/features/ai/chatHub/chat.store.ts:333">
Calling `.some` on `sessions.value?.data` will throw if `sessions.value` is still undefined; use optional chaining on `data` (or default to an empty array) so the check doesn’t crash when the session list hasn’t loaded yet.</violation>
</file>
Reply to cubic to teach it or ask questions. Re-run a review with @cubic-dev-ai review this PR
This comment has been minimized.
This comment has been minimized.
| .addOrderBy('session.id', 'ASC'); | ||
|
|
||
| if (cursor) { | ||
| const cursorSession = await this.findOne({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of just ID as the cursor we could also make the endpoint receive lastMessageAt from the FE, skipping the need for this query 🤔
but I think we don't need to improve this further, seems fast enough & this ensures the session belongs to the user too which is nice
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We still might need to revisit these performance improvements to skip loading all the credentials which is slow on internal (with thousands of credentials available). but this seems like an improvement to the initial draw speed anyways 👍
I was thinking it would be nice if we could only load credentials of relevant types. We could also change the model selector to load the providers only one by one when it is opened / providers are expanded, instead of loading all models from all providers like we do now 🤔
|
Actually it looks like one of the tests is actually failing on postgres, you might want to take a look on that 🤔 |
This comment has been minimized.
This comment has been minimized.
yes, the main chat pane is still slow. Fetching only relevant models/credentials sounds a good idea. |
|
E2E Tests: n8n tests passed after 11m 58.6s Run Details
Groups
This message was posted automatically by
currents.dev | Integration Settings
|
|
Got released with |
Summary
This PR improves chat sidebar performance by introducing pagination of the conversation list and optimizing the UI logic for rendering to reduce dependent API responses. Also adds skeleton to provide clear feedback to users while loading.
Related Linear tickets, Github issues, and Community forum posts
Review / Merge checklist
release/backport(if the PR is an urgent fix that needs to be backported)