-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
🚑 fix(export): Export Issue with New Chat #2777
🚑 fix(export): Export Issue with New Chat #2777
Conversation
Thanks for studying this! 3 is not a good option because of the con you listed:
it's likely true. This is a known bug for me but it should be simple to fix with a 4th option When the current path is "new" we can simply get the query data. I can get to it soon or you could try that yourself. Looking |
@danny-avila Oh, so you mean that we should use the same logic as At first, I thought there might be a case where no data existed for the key |
Not quite, you don't need another query call, you can simply retrieve the latest cache. I'll show how soon |
Oops, thanks, that helps me understand. |
Was hoping to get to this today along with a few other PRs but ran out of time. Will try to be back on it Sunday/Monday |
See 5addf12 for my main changes |
* 🚑 fix: re-fetch messages when exporting * Revert "🚑 fix: re-fetch messages when exporting" This reverts commit 693b86e. * 🚑 fix: use the same logic to get export data as useChatHelper * refactor(useExportConversation): use query cache to build messages tree on request * chore: organize imports --------- Co-authored-by: Danny Avila <danny@librechat.ai>
* 🚑 fix: re-fetch messages when exporting * Revert "🚑 fix: re-fetch messages when exporting" This reverts commit 693b86e. * 🚑 fix: use the same logic to get export data as useChatHelper * refactor(useExportConversation): use query cache to build messages tree on request * chore: organize imports --------- Co-authored-by: Danny Avila <danny@librechat.ai>
* 🚑 fix: re-fetch messages when exporting * Revert "🚑 fix: re-fetch messages when exporting" This reverts commit 693b86e. * 🚑 fix: use the same logic to get export data as useChatHelper * refactor(useExportConversation): use query cache to build messages tree on request * chore: organize imports --------- Co-authored-by: Danny Avila <danny@librechat.ai>
Summary
When starting a new chat, sending a few messages, and then exporting the conversation, the exported text only includes the first message. This issue is reproducible across all output file formats.
This issue occurs in a rare use case, so it might be unimportant. However, I investigated it to learn the code. If you plan to refactor or fix this differently, please feel free to close this PR.
Issue
How to Reproduce
Cause
Premise
setMessages
function fromuseChatHelpers
, with conversationId as the key.Flow
useChatHelpers
fetches messages from the API using the actual conversationId and sets them in the cache with the actual conversationId as the key. At this point, only one message exists for this conversationId.(Please let me know if my understanding is incorrect)
Fix
There are several options to fix this
Cons: This is very simple but the export icon might be inconsistently displayed for chats, which could confuse users.
useChatHelpers
to avoid caching the first messageCons: The reason for fetching messages here is unclear(these messages might not be used anywhere in the hook), and removing them might cause side effects.
refetchOnMount
totrue
in useGetMessagesByConvoId withinuseExportConversation
to ensure the latest conversation,Cons: This might cause unnecessary network access every time the export modal is opened.
I chose the third option. Although it might cause unnecessary network access, it ensures that the latest conversation is always exported.
Again, if you choose a different option, do not worry about it and close this PR.
Change Type
Testing
I verified that I could export correctly in the new chat by doing the reproduction steps above.
Checklist