fix(frontend): sort chats page by pinned state (#4643)

This commit is contained in:
Ryker_Feng 2026-08-02 22:56:18 +08:00 committed by GitHub
parent c8cf1bf2fb
commit 78f7a5f7c0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 1 deletions

View File

@ -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,
};

View File

@ -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) => {