diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index 923f4c9b5..ea5966c13 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "continue", - "version": "0.9.244", + "version": "0.9.240", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "continue", - "version": "0.9.244", + "version": "0.9.240", "license": "Apache-2.0", "dependencies": { "@electron/rebuild": "^3.2.10", diff --git a/gui/src/components/mainInput/TipTapEditor.tsx b/gui/src/components/mainInput/TipTapEditor.tsx index bf6a65b85..b2c64f8c6 100644 --- a/gui/src/components/mainInput/TipTapEditor.tsx +++ b/gui/src/components/mainInput/TipTapEditor.tsx @@ -304,6 +304,7 @@ function TipTapEditor(props: TipTapEditorProps) { const mainEditorContent = useAppSelector( (store) => store.session.mainEditorContent, ); + console.log("MAIN EDITOR", mainEditorContent?.content); const { prevRef, nextRef, addRef } = useInputHistory(props.historyKey); diff --git a/gui/src/redux/thunks/handleErrors.ts b/gui/src/redux/thunks/handleErrors.ts index b0beef06f..7e6d99f49 100644 --- a/gui/src/redux/thunks/handleErrors.ts +++ b/gui/src/redux/thunks/handleErrors.ts @@ -1,17 +1,18 @@ import { createAsyncThunk } from "@reduxjs/toolkit"; -import { setInactive } from "../slices/sessionSlice"; +import { clearLastEmptyResponse, setInactive } from "../slices/sessionSlice"; import { ThunkApiType } from "../store"; -export const handleErrors = createAsyncThunk< +export const handleStreamErrors = createAsyncThunk< void, () => Promise, ThunkApiType ->("chat/handleErrors", async (runStream, { dispatch, extra }) => { +>("chat/handleStreamErrors", async (runStream, { dispatch, extra }) => { try { await runStream(); } catch (e: any) { - console.debug("Error streaming response: ", e); + console.error("Error streaming response: ", e); } finally { + dispatch(clearLastEmptyResponse()); dispatch(setInactive()); // triggerSave(!save); TODO } diff --git a/gui/src/redux/thunks/index.ts b/gui/src/redux/thunks/index.ts index c35189de3..d5445d09d 100644 --- a/gui/src/redux/thunks/index.ts +++ b/gui/src/redux/thunks/index.ts @@ -1,6 +1,6 @@ export { exitEditMode } from "./exitEditMode"; export { gatherContext } from "./gatherContext"; -export { handleErrors } from "./handleErrors"; +export { handleStreamErrors } from "./handleErrors"; export { resetStateForNewMessage } from "./resetStateForNewMessage"; export { streamNormalInput } from "./streamNormalInput"; export { streamResponseThunk } from "./streamResponse"; diff --git a/gui/src/redux/thunks/streamNormalInput.ts b/gui/src/redux/thunks/streamNormalInput.ts index 5a22a36b5..88df9d65f 100644 --- a/gui/src/redux/thunks/streamNormalInput.ts +++ b/gui/src/redux/thunks/streamNormalInput.ts @@ -17,70 +17,65 @@ export const streamNormalInput = createAsyncThunk< ChatMessage[], ThunkApiType >("chat/streamNormalInput", async (messages, { dispatch, extra, getState }) => { - try { - // Gather state - const state = getState(); - const defaultModel = selectDefaultModel(state); - const toolSettings = state.ui.toolSettings; - const streamAborter = state.session.streamAborter; - const useTools = state.ui.useTools; + // Gather state + const state = getState(); + const defaultModel = selectDefaultModel(state); + const toolSettings = state.ui.toolSettings; + const streamAborter = state.session.streamAborter; + const useTools = state.ui.useTools; - if (!defaultModel) { - throw new Error("Default model not defined"); + if (!defaultModel) { + throw new Error("Default model not defined"); + } + + // Send request + const gen = extra.ideMessenger.llmStreamChat( + defaultModel.title, + streamAborter.signal, + messages, + { + tools: useTools + ? Object.keys(toolSettings) + .filter((tool) => toolSettings[tool] !== "disabled") + .map((toolName) => + state.config.config.tools.find( + (tool) => tool.function.name === toolName, + ), + ) + .filter(Boolean) + : undefined, + }, + ); + + // Stream response + let next = await gen.next(); + while (!next.done) { + if (!getState().session.isStreaming) { + dispatch(abortStream()); + break; } - // Send request - const gen = extra.ideMessenger.llmStreamChat( - defaultModel.title, - streamAborter.signal, - messages, - { - tools: useTools - ? Object.keys(toolSettings) - .filter((tool) => toolSettings[tool] !== "disabled") - .map((toolName) => - state.config.config.tools.find( - (tool) => tool.function.name === toolName, - ), - ) - .filter(Boolean) - : undefined, - }, - ); + const updates = next.value as ChatMessage[]; + dispatch(streamUpdate(updates)); + next = await gen.next(); + } - // Stream response - let next = await gen.next(); - while (!next.done) { - if (!getState().session.isStreaming) { - dispatch(abortStream()); - break; - } + // Attach prompt log + let returnVal = next.value as PromptLog; + if (returnVal) { + dispatch(addPromptCompletionPair([returnVal])); + } - const updates = next.value as ChatMessage[]; - dispatch(streamUpdate(updates)); - next = await gen.next(); + // If it's a tool call that is automatically accepted, we should call it + const toolCallState = selectCurrentToolCall(getState()); + if (toolCallState) { + dispatch(setToolGenerated()); + + if ( + toolSettings[toolCallState.toolCall.function.name] === + "allowedWithoutPermission" + ) { + await dispatch(callTool()); } - - // Attach prompt log - let returnVal = next.value as PromptLog; - if (returnVal) { - dispatch(addPromptCompletionPair([returnVal])); - } - - // If it's a tool call that is automatically accepted, we should call it - const toolCallState = selectCurrentToolCall(getState()); - if (toolCallState) { - dispatch(setToolGenerated()); - - if ( - toolSettings[toolCallState.toolCall.function.name] === - "allowedWithoutPermission" - ) { - await dispatch(callTool()); - } - } - } catch (e) { - // If there's an error, we should clear the response so there aren't two input boxes - dispatch(clearLastEmptyResponse()); } }); diff --git a/gui/src/redux/thunks/streamResponse.ts b/gui/src/redux/thunks/streamResponse.ts index 1ee3d65d5..0103e57df 100644 --- a/gui/src/redux/thunks/streamResponse.ts +++ b/gui/src/redux/thunks/streamResponse.ts @@ -18,7 +18,7 @@ import { } from "../slices/sessionSlice"; import { ThunkApiType } from "../store"; import { gatherContext } from "./gatherContext"; -import { handleErrors } from "./handleErrors"; +import { handleStreamErrors } from "./handleErrors"; import { resetStateForNewMessage } from "./resetStateForNewMessage"; import { streamNormalInput } from "./streamNormalInput"; import { streamSlashCommand } from "./streamSlashCommand"; @@ -66,7 +66,8 @@ export const streamResponseThunk = createAsyncThunk< { dispatch, extra, getState }, ) => { await dispatch( - handleErrors(async () => { + handleStreamErrors(async () => { + throw new Error("intentional"); const state = getState(); const defaultModel = selectDefaultModel(state); const slashCommands = state.config.config.slashCommands || []; diff --git a/gui/src/redux/thunks/streamResponseAfterToolCall.ts b/gui/src/redux/thunks/streamResponseAfterToolCall.ts index 52b15c13f..c516592e1 100644 --- a/gui/src/redux/thunks/streamResponseAfterToolCall.ts +++ b/gui/src/redux/thunks/streamResponseAfterToolCall.ts @@ -9,7 +9,7 @@ import { streamUpdate, } from "../slices/sessionSlice"; import { ThunkApiType } from "../store"; -import { handleErrors } from "./handleErrors"; +import { handleStreamErrors } from "./handleErrors"; import { resetStateForNewMessage } from "./resetStateForNewMessage"; import { streamNormalInput } from "./streamNormalInput"; @@ -24,7 +24,7 @@ export const streamResponseAfterToolCall = createAsyncThunk< "chat/streamAfterToolCall", async ({ toolCallId, toolOutput }, { dispatch, getState }) => { await dispatch( - handleErrors(async () => { + handleStreamErrors(async () => { const state = getState(); const initialHistory = state.session.history; const defaultModel = selectDefaultModel(state);