fix: sort child chats newest-first and prepend on creation (#24524)

GetChildChatsByParentIDs sorted created_at ASC, but the cache
helper appended new children to the end. On refetch the API and
cache agreed on oldest-first, putting the just-created child at
the bottom. Users expect newest first, matching the root-chat
sidebar convention.

- SQL: change child sort to created_at DESC, id DESC.
- Cache: prepend instead of append in addChildToParentInCache
  (renamed from appendChildToParentInCache to avoid leaking
  position semantics).
- Test: update ordering assertion to expect newest-first.

Refs #24404
This commit is contained in:
Mathias Fredriksson
2026-04-20 10:43:31 +00:00
committed by GitHub
parent df7e838c21
commit 467430d8fa
6 changed files with 19 additions and 19 deletions
+2 -2
View File
@@ -6881,8 +6881,8 @@ WHERE
ELSE chats.archived = $2 :: boolean
END
ORDER BY
chats.created_at ASC,
chats.id ASC
chats.created_at DESC,
chats.id DESC
`
type GetChildChatsByParentIDsParams struct {
+2 -2
View File
@@ -418,8 +418,8 @@ WHERE
ELSE chats.archived = sqlc.narg('archived') :: boolean
END
ORDER BY
chats.created_at ASC,
chats.id ASC;
chats.created_at DESC,
chats.id DESC;
-- name: InsertChat :one
INSERT INTO chats (