-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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: forking a long conversation breaks chat structure #4778
Conversation
Is it possible to reference the same buildTree function in the tests instead of duplicating the code? Changes made to buildTree would have to be reflected in two different places. Another thing is, this change would make imported (from file) messages not having createdAt field, which mighe become problematic when in the future we call |
I don't plan on changing this function, and it's really not needed in the backend except for this test with the database logic, so it's not worth it to me.
can you elaborate more on this? I think this would be simple to handle the edge case here then: LibreChat/api/server/utils/import/importBatchBuilder.js Lines 99 to 110 in 7a5b697
to this: async saveBatch() {
try {
// Set default timestamp for messages that don't have one
const defaultTimestamp = new Date();
this.messages = this.messages.map(message => ({
...message,
createdAt: message.createdAt || defaultTimestamp,
updatedAt: message.updatedAt || defaultTimestamp
}));
await bulkSaveConvos(this.conversations);
// Keep overrideTimestamp as true to use our explicitly set timestamps
await bulkSaveMessages(this.messages, true);
logger.debug(
`user: ${this.requestUserId} | Added ${this.conversations.length} conversations and ${this.messages.length} messages to the DB.`,
);
} catch (error) {
logger.error('Error saving batch', error);
throw error;
}
}
} |
also maybe the above needs to be adjusted to account for child messages not being earlier than parent messages |
Absolutely! Changing
This could be accomplished by d38953b However, through testing, this will make the page unresponsive for some reason. But if it's done correctly, the previously broken conversations could be fixed as well. |
…#4778) * fix: branching and forking sometimes break conversation structure * fix test for forking. * chore: message type issues * test: add conversation structure tests for message handling --------- Co-authored-by: xyqyear <[email protected]>
…#4778) * fix: branching and forking sometimes break conversation structure * fix test for forking. * chore: message type issues * test: add conversation structure tests for message handling --------- Co-authored-by: xyqyear <[email protected]>
ref: PR #4772
Closes #4761
Originally #4777