diff --git a/gui/src/redux/thunks/session.ts b/gui/src/redux/thunks/session.ts index f0553f4bb..9e4bbddc2 100644 --- a/gui/src/redux/thunks/session.ts +++ b/gui/src/redux/thunks/session.ts @@ -174,15 +174,19 @@ export const saveCurrentSession = createAsyncThunk< ?.message?.content?.toString(); if (assistantResponse) { - const result = await extra.ideMessenger.request( - "chatDescriber/describe", - { - text: assistantResponse, - selectedModelTitle: state.config.defaultModelTitle, - }, - ); - if (result.status === "success" && result.content) { - title = result.content; + try { + const result = await extra.ideMessenger.request( + "chatDescriber/describe", + { + text: assistantResponse, + selectedModelTitle: state.config.defaultModelTitle, + }, + ); + if (result.status === "success" && result.content) { + title = result.content; + } + } catch (e) { + console.error("Error generating chat title", e); } } } diff --git a/gui/src/redux/thunks/streamThunkWrapper.ts b/gui/src/redux/thunks/streamThunkWrapper.ts index 7b9000be8..d0827d13a 100644 --- a/gui/src/redux/thunks/streamThunkWrapper.ts +++ b/gui/src/redux/thunks/streamThunkWrapper.ts @@ -7,7 +7,7 @@ export const streamThunkWrapper = createAsyncThunk< void, () => Promise, ThunkApiType ->("chat/streamWrapper", async (runStream, { dispatch, extra }) => { +>("chat/streamWrapper", async (runStream, { dispatch, extra, getState }) => { try { await runStream(); } catch (e: any) { @@ -16,10 +16,13 @@ export const streamThunkWrapper = createAsyncThunk< dispatch(clearLastEmptyResponse()); } finally { dispatch(setInactive()); - await dispatch( - saveCurrentSession({ - openNewSession: false, - }), - ); + const state = getState(); + if (state.session.mode === "chat") { + await dispatch( + saveCurrentSession({ + openNewSession: false, + }), + ); + } } });