From ba1b6e4817c2919de1989bd32e2d7779f74ffaaa Mon Sep 17 00:00:00 2001 From: Zane <75694352+zanesq@users.noreply.github.com> Date: Tue, 24 Feb 2026 13:36:13 -0800 Subject: [PATCH] fix: ensure latest session always displays in sidebar (#7489) --- ui/desktop/src/hooks/useNavigationSessions.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/ui/desktop/src/hooks/useNavigationSessions.ts b/ui/desktop/src/hooks/useNavigationSessions.ts index 1dacbe603c..1bc49e525b 100644 --- a/ui/desktop/src/hooks/useNavigationSessions.ts +++ b/ui/desktop/src/hooks/useNavigationSessions.ts @@ -1,6 +1,6 @@ import { useState, useEffect, useRef, useCallback } from 'react'; import { useNavigate, useLocation, useSearchParams } from 'react-router-dom'; -import { listSessions } from '../api'; +import { getSession, listSessions } from '../api'; import { useChatContext } from '../contexts/ChatContext'; import { useConfig } from '../components/ConfigContext'; import { useNavigation } from './useNavigation'; @@ -66,6 +66,19 @@ export function useNavigationSessions(options: UseNavigationSessionsOptions = {} } }, [fetchOnMount, fetchSessions]); + useEffect(() => { + if (!activeSessionId) return; + if (recentSessions.some((s) => s.id === activeSessionId)) return; + + getSession({ path: { session_id: activeSessionId }, throwOnError: false }).then((response) => { + if (!response.data) return; + setRecentSessions((prev) => { + if (prev.some((s) => s.id === activeSessionId)) return prev; + return [response.data as Session, ...prev].slice(0, MAX_RECENT_SESSIONS); + }); + }); + }, [activeSessionId, recentSessions]); + useEffect(() => { let pollingTimeouts: ReturnType[] = []; let isPolling = false;