Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions gui/src/hooks/ParallelListeners.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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,
Expand All @@ -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]) => {
Expand Down Expand Up @@ -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(() => {
Expand All @@ -125,7 +131,7 @@ function ParallelListeners() {
}, 2_000);

return () => clearInterval(interval);
}, [hasDoneInitialConfigLoad, ideMessenger]);
}, [hasDoneInitialConfigLoad, ideMessenger, initialSessionId]);

useWebviewListener(
"configUpdate",
Expand Down
Loading