diff --git a/gui/src/hooks/ParallelListeners.tsx b/gui/src/hooks/ParallelListeners.tsx index e0a2dcf37ce..3b7d4557d7a 100644 --- a/gui/src/hooks/ParallelListeners.tsx +++ b/gui/src/hooks/ParallelListeners.tsx @@ -1,4 +1,4 @@ -import { useCallback, useContext, useEffect, useRef } from "react"; +import { useCallback, useContext, useEffect, useRef, useState } from "react"; import { IdeMessengerContext } from "../context/IdeMessenger"; import { FromCoreProtocol } from "core/protocol"; @@ -22,10 +22,7 @@ import { setTTSActive } from "../redux/slices/uiSlice"; import { modelSupportsReasoning } from "core/llm/autodetect"; import { cancelStream } from "../redux/thunks/cancelStream"; import { handleApplyStateUpdate } from "../redux/thunks/handleApplyStateUpdate"; -import { - loadLastSession, - refreshSessionMetadata, -} from "../redux/thunks/session"; +import { loadSession, refreshSessionMetadata } from "../redux/thunks/session"; import { updateFileSymbolsFromHistory } from "../redux/thunks/updateFileSymbols"; import { setDocumentStylesFromLocalStorage, @@ -48,6 +45,8 @@ function ParallelListeners() { // Load symbols for chat on any session change const sessionId = useAppSelector((state) => state.session.id); + const lastSessionId = useAppSelector((store) => store.session.lastSessionId); + const [initialSessionId] = useState(sessionId || lastSessionId); const handleConfigUpdate = useCallback( async (isInitial: boolean, result: FromCoreProtocol["configUpdate"][0]) => { @@ -107,7 +106,14 @@ function ParallelListeners() { await handleConfigUpdate(true, result.content); } dispatch(setConfigLoading(false)); - await dispatch(loadLastSession()); + if (initialSessionId) { + await dispatch( + loadSession({ + sessionId: initialSessionId, + saveCurrentSession: false, + }), + ); + } } void initialLoadConfig(); const interval = setInterval(() => { @@ -125,7 +131,7 @@ function ParallelListeners() { }, 2_000); return () => clearInterval(interval); - }, [hasDoneInitialConfigLoad, ideMessenger]); + }, [hasDoneInitialConfigLoad, ideMessenger, initialSessionId]); useWebviewListener( "configUpdate",