diff --git a/frontends/src/primitivus/chat.py b/frontends/src/primitivus/chat.py index 7bd420dd..eb471588 100644 --- a/frontends/src/primitivus/chat.py +++ b/frontends/src/primitivus/chat.py @@ -297,7 +297,8 @@ class Chat(urwid.WidgetWrap, QuickChat): if timestamp and self.content: for idx in range(len(self.content) - 1, -1, -1): current_text = self.content[idx] - if new_text.timestamp < current_text.timestamp and idx > 0: + older = new_text.timestamp < current_text.timestamp + if older and idx > 0: continue # the new message is older, we need to insert it upper #we discard double messages, to avoid backlog / history conflict @@ -306,7 +307,7 @@ class Chat(urwid.WidgetWrap, QuickChat): (idx < len(self.content) - 2 and self.content[idx + 1].message)): return - self.content.insert(idx + 1, new_text) + self.content.insert(0 if older else idx + 1, new_text) break else: self.content.append(new_text)