From 7cdd3c9d42ff1d53c50d1a3a8ed2b9fbf871710c Mon Sep 17 00:00:00 2001 From: Nathan Nguyen Date: Mon, 15 Dec 2025 03:32:28 -0500 Subject: [PATCH] app: sort conversations by last user message Conversations in the sidebar were being sorted by the timestamp of the last message (including assistant responses). This changes the sorting to use only user messages, matching the behavior of ChatGPT and Claude. Fixes #12958 --- app/store/database.go | 2 +- app/ui/ui.go | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/store/database.go b/app/store/database.go index 0f268c6fa..d95f235cf 100644 --- a/app/store/database.go +++ b/app/store/database.go @@ -513,7 +513,7 @@ func (db *database) getAllChats() ([]Chat, error) { WHERE role = 'user' GROUP BY chat_id ) first_msg ON c.id = first_msg.chat_id - LEFT JOIN messages m ON c.id = m.chat_id + LEFT JOIN messages m ON c.id = m.chat_id AND m.role = 'user' GROUP BY c.id, c.title, c.created_at, first_msg.content ORDER BY last_updated DESC ` diff --git a/app/ui/ui.go b/app/ui/ui.go index 5a64705de..d0ef25023 100644 --- a/app/ui/ui.go +++ b/app/ui/ui.go @@ -1365,8 +1365,9 @@ func chatInfoFromChat(chat store.Chat) responses.ChatInfo { if msg.Role == "user" && userExcerpt == "" { userExcerpt = msg.Content } - // update the updated at time - if msg.UpdatedAt.After(updatedAt) { + // update the updated at time based on user messages only + // this ensures conversations are sorted by last user message, not last response + if msg.Role == "user" && msg.UpdatedAt.After(updatedAt) { updatedAt = msg.UpdatedAt } }