Skip to content
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 #4777

Closed
wants to merge 2 commits into from
Closed

fix: forking a long conversation breaks chat structure #4777

wants to merge 2 commits into from

Conversation

xyqyear
Copy link
Contributor

@xyqyear xyqyear commented Nov 22, 2024

ref: PR #4772 and issue #4761

I think I've found the culprit.

This issue is due to the forking doesn't copy over the createdAt attribute of the messages, so the message list queried might be our of order, hence a messed up tree.

The main change is here:

https://github.com/xyqyear/LibreChat/blob/cb98456ba034a86857adaeaa564d2ac7f17cebc8/api/models/Message.js#L80-L86

If timestamps is true, then mongoose will override createdAt with the current time, which is the default if timestamps is set to true for the schema.

Testing

I've modified exiting tests and the api tests passed.

However, this PR should not be merged right away and should be further investigated to make sure importing doesn't break since importing use the same mechanics.

The current behavior for importing I believe is to just use the default createdAt time that mongoose auto inserts. So imports a conversations with more than 16 messages should be having the same issue (needs testing).

@danny-avila
Copy link
Owner

Adding my changes here, added some tests to simulate the behavior, since I can't directly reproduce it with mongodb memory server. #4778

@xyqyear xyqyear deleted the fix-fork branch November 23, 2024 03:28
@quacrobat
Copy link

@xyqyear @danny-avila
Revisiting an older conversation after a recent update to 0.75, i see the same bug again. Has there been a regression?
thanks

@danny-avila
Copy link
Owner

@xyqyear @danny-avila Revisiting an older conversation after a recent update to 0.75, i see the same bug again. Has there been a regression? thanks

if you are updating 0.7.5, the bug is present there. It would not be on latest builds, however, as the fix is slated for 0.7.6 (this coming week).

There are tests for this behavior now and can't reproduce it on my end.

@quacrobat
Copy link

ah good to know, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants