mirror of
https://github.com/bytedance/deer-flow.git
synced 2026-08-06 21:08:43 +00:00
fix(frontend): sort chats page by pinned state (#4643)
This commit is contained in:
parent
c8cf1bf2fb
commit
78f7a5f7c0
@ -34,7 +34,7 @@ export function buildThreadListModel(
|
|||||||
.slice(0, MAX_VISIBLE_THREADS);
|
.slice(0, MAX_VISIBLE_THREADS);
|
||||||
const model: ThreadListModel = {
|
const model: ThreadListModel = {
|
||||||
byId,
|
byId,
|
||||||
threads,
|
threads: sortedThreads,
|
||||||
displayedThreads: [...pinnedThreads, ...recentThreads],
|
displayedThreads: [...pinnedThreads, ...recentThreads],
|
||||||
canLoadMore: recentThreads.length < MAX_VISIBLE_THREADS,
|
canLoadMore: recentThreads.length < MAX_VISIBLE_THREADS,
|
||||||
};
|
};
|
||||||
|
|||||||
@ -22,6 +22,16 @@ function pinnedThread(id: string, updatedAt: string): AgentThread {
|
|||||||
}
|
}
|
||||||
|
|
||||||
describe("thread list model", () => {
|
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", () => {
|
it("deduplicates once while only bounding recent sidebar rows", () => {
|
||||||
const pages = Array.from({ length: 5 }, (_, page) =>
|
const pages = Array.from({ length: 5 }, (_, page) =>
|
||||||
Array.from({ length: 50 }, (_, index) => {
|
Array.from({ length: 50 }, (_, index) => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user