fix(dashboard): sort chat session switcher by most-recent activity (#49104)

The Chat-tab session switcher rendered rows in the API's default
order="created" (original start time) while each row displays
last_active — so a session you just messaged in could sit below an
older one, and the list looked unsorted against its own timestamps.

Pass order="recent" from ChatSessionList so the switcher sorts by
latest activity across the compression chain (most-recently-used at
top, ChatGPT-style; long conversations that auto-compressed into a new
continuation id stay on the first page). Adds an optional, defaulted
`order` arg to api.getSessions; the paginated Sessions page keeps the
stable created order.
This commit is contained in:
Teknium 2026-06-19 07:58:56 -07:00 committed by GitHub
parent 1b04e4ede5
commit 0d7abd555c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 11 additions and 3 deletions

View file

@ -85,7 +85,7 @@ export function ChatSessionList({
setLoading(true);
setError(null);
api
.getSessions(SESSION_LIMIT, 0, scopeKey)
.getSessions(SESSION_LIMIT, 0, scopeKey, "recent")
.then((res) => {
if (reqRef.current !== myReq) return;
setSessions(res.sessions);

View file

@ -344,9 +344,17 @@ export const api = {
window.location.assign("/login");
return r;
}),
getSessions: (limit = 20, offset = 0, profile = getManagementProfile()) =>
getSessions: (
limit = 20,
offset = 0,
profile = getManagementProfile(),
order: "created" | "recent" = "created",
) =>
fetchJSON<PaginatedSessions>(
appendProfileParam(`/api/sessions?limit=${limit}&offset=${offset}`, profile),
appendProfileParam(
`/api/sessions?limit=${limit}&offset=${offset}&order=${order}`,
profile,
),
),
getSessionMessages: (id: string, profile = getManagementProfile()) =>
fetchJSON<SessionMessagesResponse>(