Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -170,18 +170,14 @@ fun resolveStatusIcon(
lastCommonReadMessageId: Int,
isTemporary: Boolean,
sendStatus: SendStatus?
): MessageStatusIcon {
val status = if (sendStatus == SendStatus.FAILED) {
MessageStatusIcon.FAILED
} else if (isTemporary) {
MessageStatusIcon.SENDING
} else if (jsonMessageId <= lastCommonReadMessageId) {
MessageStatusIcon.READ
} else {
MessageStatusIcon.SENT
): MessageStatusIcon =
when {
sendStatus == SendStatus.FAILED -> MessageStatusIcon.FAILED
sendStatus == SendStatus.SENT_PENDING_ACK -> MessageStatusIcon.SENT
isTemporary -> MessageStatusIcon.SENDING
jsonMessageId <= lastCommonReadMessageId -> MessageStatusIcon.READ
else -> MessageStatusIcon.SENT
}
return status
}

fun getMessageTypeContent(user: User, message: ChatMessage): MessageTypeContent? =
if (message.isSystemMessage) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ interface ChatMessagesDao {
FROM ChatMessages
WHERE internalConversationId = :internalConversationId
AND (:threadId IS NULL OR threadId = :threadId)
AND id >= :oldestMessageId
AND (id >= :oldestMessageId OR isTemporary = 1)
Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using an OR condition like this commonly prevents SQLite from using an index on id efficiently, which can degrade performance as the table grows. If this query is on a hot path, consider rewriting to preserve index usage (e.g., UNION ALL of two indexed queries: one for id >= :oldestMessageId and one for isTemporary = 1, keeping the same conversation/thread filters) and then ordering the combined result.

Copilot uses AI. Check for mistakes.
ORDER BY timestamp ASC, id ASC
"""
)
Expand Down
Loading