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:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user