mirror of
https://github.com/aaif-goose/goose.git
synced 2026-07-03 14:10:03 +02:00
fix: ensure latest session always displays in sidebar (#7489)
This commit is contained in:
@@ -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<typeof setTimeout>[] = [];
|
||||
let isPolling = false;
|
||||
|
||||
Reference in New Issue
Block a user