Summary
In backend/src/models/conversationModel.ts, the lastMessageAt field has a Mongoose default:
lastMessageAt: {
type: Date,
default: () => new Date() // ← fires on every insert, including upserts in getMessages
}
When getMessages upserts a new conversation (e.g. a user opens a chat before any message is sent), Mongoose applies this default on insert, so the empty conversation immediately appears at the top of the conversation list with a fresh timestamp.
Expected fix
Remove the default so lastMessageAt is only set when a message is actually sent:
lastMessageAt: {
type: Date
// no default
}
References
Alpha milestone
Required before alpha — empty conversations polluting the list is a visible UX bug.
Summary
In
backend/src/models/conversationModel.ts, thelastMessageAtfield has a Mongoose default:When
getMessagesupserts a new conversation (e.g. a user opens a chat before any message is sent), Mongoose applies this default on insert, so the empty conversation immediately appears at the top of the conversation list with a fresh timestamp.Expected fix
Remove the default so
lastMessageAtis only set when a message is actually sent:References
Alpha milestone
Required before alpha — empty conversations polluting the list is a visible UX bug.