From 0d7abd555c37dcda2c7ee6de9a5d9c2752b5cff0 Mon Sep 17 00:00:00 2001 From: Teknium <127238744+teknium1@users.noreply.github.com> Date: Fri, 19 Jun 2026 07:58:56 -0700 Subject: [PATCH] fix(dashboard): sort chat session switcher by most-recent activity (#49104) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- web/src/components/ChatSessionList.tsx | 2 +- web/src/lib/api.ts | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/web/src/components/ChatSessionList.tsx b/web/src/components/ChatSessionList.tsx index c1988681f35..a926440aa79 100644 --- a/web/src/components/ChatSessionList.tsx +++ b/web/src/components/ChatSessionList.tsx @@ -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); diff --git a/web/src/lib/api.ts b/web/src/lib/api.ts index 3955d3324c9..ba898924196 100644 --- a/web/src/lib/api.ts +++ b/web/src/lib/api.ts @@ -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( - appendProfileParam(`/api/sessions?limit=${limit}&offset=${offset}`, profile), + appendProfileParam( + `/api/sessions?limit=${limit}&offset=${offset}&order=${order}`, + profile, + ), ), getSessionMessages: (id: string, profile = getManagementProfile()) => fetchJSON(