Skip to content

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

Merged
mafredri merged 1 commit intomainfrom
fix/child-chat-sort-and-prepend
Apr 20, 2026
Merged

fix: sort child chats newest-first and prepend on creation#24524
mafredri merged 1 commit intomainfrom
fix/child-chat-sort-and-prepend

Conversation

@mafredri
Copy link
Copy Markdown
Member

Follow-up to #24404. Three changes that were developed during review but not pushed before the squash-merge:

  1. SQL: GetChildChatsByParentIDs sort changed from created_at ASC to created_at DESC, id DESC so newest children appear first, matching the root-chat sidebar convention.

  2. Cache: appendChildToParentInCache renamed to addChildToParentInCache (position-neutral name) and changed from append to prepend so newly created children appear at the top immediately, consistent with the API sort.

  3. Test: ordering assertion updated to expect newest-first.

🤖 Generated with Coder Agents

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.
Copy link
Copy Markdown
Member

@johnstcn johnstcn left a comment

Choose a reason for hiding this comment

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

stamp

@mafredri mafredri enabled auto-merge (squash) April 20, 2026 10:34
@mafredri mafredri merged commit 467430d into main Apr 20, 2026
30 of 31 checks passed
@mafredri mafredri deleted the fix/child-chat-sort-and-prepend branch April 20, 2026 10:43
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 20, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants