From 78f7a5f7c08bf05729206cbbc9cfd52828cee6dd Mon Sep 17 00:00:00 2001 From: Ryker_Feng <90562015+18062706139fcz@users.noreply.github.com> Date: Sun, 2 Aug 2026 22:56:18 +0800 Subject: [PATCH] fix(frontend): sort chats page by pinned state (#4643) --- frontend/src/core/threads/thread-list-model.ts | 2 +- .../tests/unit/core/threads/thread-list-model.test.ts | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/frontend/src/core/threads/thread-list-model.ts b/frontend/src/core/threads/thread-list-model.ts index 7666a5689..9242e39b5 100644 --- a/frontend/src/core/threads/thread-list-model.ts +++ b/frontend/src/core/threads/thread-list-model.ts @@ -34,7 +34,7 @@ export function buildThreadListModel( .slice(0, MAX_VISIBLE_THREADS); const model: ThreadListModel = { byId, - threads, + threads: sortedThreads, displayedThreads: [...pinnedThreads, ...recentThreads], canLoadMore: recentThreads.length < MAX_VISIBLE_THREADS, }; diff --git a/frontend/tests/unit/core/threads/thread-list-model.test.ts b/frontend/tests/unit/core/threads/thread-list-model.test.ts index 22e48b1c4..eeb8094b0 100644 --- a/frontend/tests/unit/core/threads/thread-list-model.test.ts +++ b/frontend/tests/unit/core/threads/thread-list-model.test.ts @@ -22,6 +22,16 @@ function pinnedThread(id: string, updatedAt: string): AgentThread { } describe("thread list model", () => { + it("sorts the full thread list with pinned threads first", () => { + const unpinned = thread("unpinned", "2026-01-02T00:00:00.000Z"); + const pinned = pinnedThread("pinned", "2026-01-01T00:00:00.000Z"); + + const model = buildThreadListModel([[unpinned, pinned]]); + + expect(model.threads).toEqual([pinned, unpinned]); + expect(model.displayedThreads).toEqual([pinned, unpinned]); + }); + it("deduplicates once while only bounding recent sidebar rows", () => { const pages = Array.from({ length: 5 }, (_, page) => Array.from({ length: 50 }, (_, index) => {