From 858d3d8a052e25ae525046a04a97fc0355144285 Mon Sep 17 00:00:00 2001 From: Nate Date: Tue, 3 Dec 2024 21:56:06 -0800 Subject: [PATCH] fix lag on new sesssion --- gui/src/hooks/useHistory.tsx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/gui/src/hooks/useHistory.tsx b/gui/src/hooks/useHistory.tsx index 415e8bffc..cedf9210d 100644 --- a/gui/src/hooks/useHistory.tsx +++ b/gui/src/hooks/useHistory.tsx @@ -4,9 +4,9 @@ import { renderChatMessage } from "core/util/messageContent"; import { useCallback, useContext } from "react"; import { IdeMessengerContext } from "../context/IdeMessenger"; import { useLastSessionContext } from "../context/LastSessionContext"; +import { useAppSelector } from "../redux/hooks"; import { newSession, updateSessionTitle } from "../redux/slices/sessionSlice"; import { getLocalStorage, setLocalStorage } from "../util/localStorage"; -import { useAppSelector } from "../redux/hooks"; const MAX_TITLE_LENGTH = 100; @@ -52,6 +52,11 @@ function useHistory(dispatch: Dispatch) { async function saveSession(openNewSession: boolean = true) { if (history.length === 0) return; + if (openNewSession) { + dispatch(newSession()); + updateLastSessionId(sessionId); + } + let currentTitle = title; if (config?.ui?.getChatTitles && currentTitle === "New Session") { try { @@ -91,10 +96,7 @@ function useHistory(dispatch: Dispatch) { await ideMessenger.request("history/save", session); - if (openNewSession) { - dispatch(newSession()); - updateLastSessionId(sessionId); - } else { + if (!openNewSession) { dispatch(updateSessionTitle(newTitle)); } }