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.
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).
ref: PR https://github.com/danny-avila/LibreChat/pull/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 overridecreatedAt
with the current time, which is the default iftimestamps
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).