From 4ddec0b6ade9f7e530c0cd49802188ba551d444f Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Mon, 11 Dec 2023 15:04:42 -0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=A7=20cancel=20/edit=20generation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/commands/index.ts | 2 +- core/commands/slash/edit.ts | 3 +++ extensions/vscode/src/diffs.ts | 2 +- gui/src/components/mainInput/ComboBox.tsx | 1 + gui/src/hooks/useChatHandler.ts | 9 +++++++-- gui/src/hooks/useSetup.ts | 3 ++- 6 files changed, 15 insertions(+), 5 deletions(-) diff --git a/core/commands/index.ts b/core/commands/index.ts index dead935c4..24e68e0a8 100644 --- a/core/commands/index.ts +++ b/core/commands/index.ts @@ -16,7 +16,7 @@ export interface ContinueSDK { export interface SlashCommand { name: string; description: string; - run: (sdk: ContinueSDK) => AsyncGenerator; + run: (sdk: ContinueSDK) => AsyncGenerator; } export function slashFromCustomCommand( diff --git a/core/commands/slash/edit.ts b/core/commands/slash/edit.ts index f6c248fcb..f188ced17 100644 --- a/core/commands/slash/edit.ts +++ b/core/commands/slash/edit.ts @@ -497,6 +497,9 @@ const EditSlashCommand: SlashCommand = { break; } + // Allow stopping breakpoints + yield undefined; + // Accumulate lines let chunkLines = chunk.split("\n"); chunkLines[0] = unfinishedLine + chunkLines[0]; diff --git a/extensions/vscode/src/diffs.ts b/extensions/vscode/src/diffs.ts index 914536d89..beeb1908f 100644 --- a/extensions/vscode/src/diffs.ts +++ b/extensions/vscode/src/diffs.ts @@ -296,7 +296,7 @@ class DiffManager { } // Stop the step at step_index in case it is still streaming - debugPanelWebview?.postMessage({ type: "stopSession" }); + debugPanelWebview?.postMessage({ type: "setInactive" }); vscode.workspace.textDocuments .find((doc) => doc.uri.fsPath === newFilepath) diff --git a/gui/src/components/mainInput/ComboBox.tsx b/gui/src/components/mainInput/ComboBox.tsx index df80d6654..b2abc6152 100644 --- a/gui/src/components/mainInput/ComboBox.tsx +++ b/gui/src/components/mainInput/ComboBox.tsx @@ -1606,6 +1606,7 @@ const ComboBox = React.forwardRef((props: ComboBoxProps, ref) => { textAlign: "right", }} hidden={downshiftProps.highlightedIndex !== index} + className="whitespace-nowrap overflow-hidden overflow-ellipsis ml-2" > {item.description} diff --git a/gui/src/hooks/useChatHandler.ts b/gui/src/hooks/useChatHandler.ts index e5a521454..a2c482db4 100644 --- a/gui/src/hooks/useChatHandler.ts +++ b/gui/src/hooks/useChatHandler.ts @@ -64,6 +64,7 @@ function useChatHandler(dispatch: Dispatch) { // Convert to actual slash command object with runnable function return [slashCommand, input]; }; + async function _streamSlashCommand( messages: ChatMessage[], slashCommand: SlashCommand, @@ -81,11 +82,15 @@ function useChatHandler(dispatch: Dispatch) { options: {}, // TODO: pass options to slash command }; + // TODO: if the model returned fast enough it would immediately break + // Ideally you aren't trusting that results of dispatch show up before the first yield for await (const update of slashCommand.run(sdk)) { - if (!active) { + if (!activeRef.current) { break; } - dispatch(streamUpdate(update)); + if (typeof update === "string") { + dispatch(streamUpdate(update)); + } } } diff --git a/gui/src/hooks/useSetup.ts b/gui/src/hooks/useSetup.ts index 6b3d6e50b..cc4e4806c 100644 --- a/gui/src/hooks/useSetup.ts +++ b/gui/src/hooks/useSetup.ts @@ -52,7 +52,8 @@ function useSetup(dispatch: Dispatch) { case "serverStatus": dispatch(setServerStatusMessage(event.data.message)); break; - case "stopSession": + case "setInactive": + dispatch(setInactive()); break; case "configUpdate": dispatch(setConfig(event.data.config));