🚧 cancel /edit generation

This commit is contained in:
Nate Sesti 2023-12-11 15:04:42 -08:00
parent 87ce373da3
commit 4ddec0b6ad
6 changed files with 15 additions and 5 deletions

View file

@ -16,7 +16,7 @@ export interface ContinueSDK {
export interface SlashCommand {
name: string;
description: string;
run: (sdk: ContinueSDK) => AsyncGenerator<string>;
run: (sdk: ContinueSDK) => AsyncGenerator<string | undefined>;
}
export function slashFromCustomCommand(

View file

@ -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];

View file

@ -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)

View file

@ -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}
</span>

View file

@ -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));
}
}
}

View file

@ -52,7 +52,8 @@ function useSetup(dispatch: Dispatch<any>) {
case "serverStatus":
dispatch(setServerStatusMessage(event.data.message));
break;
case "stopSession":
case "setInactive":
dispatch(setInactive());
break;
case "configUpdate":
dispatch(setConfig(event.data.config));