fix(webui): sort Chats group among projects by recency

In project-based sidebar grouping, the "Chats" section (non-project
conversations) was always appended at the end regardless of its most
recent updated_at. This meant the newest conversation could appear
below older project groups.

Move Chats group insertion before the global sort, compute its
updatedAt from its most recently updated session, and sort all groups
together by updatedAt descending.
This commit is contained in:
chengyongru
2026-06-02 14:08:45 +08:00
committed by Xubin Ren
parent edf34d857a
commit a70871679c
2 changed files with 73 additions and 9 deletions
+17 -9
View File
@@ -281,19 +281,18 @@ function groupSessionsByProject(
),
}));
groups.sort((a, b) => {
const timeOrder = dateToTime(b.updatedAt) - dateToTime(a.updatedAt);
if (timeOrder !== 0) return timeOrder;
return a.label.localeCompare(b.label, "en", {
numeric: true,
sensitivity: "base",
});
});
if (conversations.length) {
const chatsUpdatedAt = conversations.reduce<string | null>(
(best, s) => {
const candidate = s.updatedAt ?? s.createdAt ?? null;
return isNewerDate(candidate, best) ? candidate : best;
},
null,
);
groups.push({
id: "workspace:chats",
label: labels.all,
updatedAt: chatsUpdatedAt,
sessions: sortProjectSessions(
conversations,
options.sort,
@@ -304,6 +303,15 @@ function groupSessionsByProject(
});
}
groups.sort((a, b) => {
const timeOrder = dateToTime(b.updatedAt) - dateToTime(a.updatedAt);
if (timeOrder !== 0) return timeOrder;
return a.label.localeCompare(b.label, "en", {
numeric: true,
sensitivity: "base",
});
});
return groups;
}