Merge pull request #3240 from continuedev/nate/quick-edit-e6e1

cancelStream
This commit is contained in:
Nate Sesti 2024-12-06 19:07:57 -08:00 • committed by GitHub
commit f3387b755a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 17 additions and 1 deletions

View file

@ -57,6 +57,7 @@ import {
setShowDialog,
} from "../../redux/slices/uiSlice";
import { RootState } from "../../redux/store";
import { cancelStream } from "../../redux/thunks/cancelStream";
import { exitEditMode } from "../../redux/thunks/exitEditMode";
import { streamResponseThunk } from "../../redux/thunks/streamResponse";
import {
@ -203,7 +204,7 @@ export function Chat() {
isMetaEquivalentKeyPressed(e) &&
!e.shiftKey
) {
// dispatch(cancelGeneration()); TODO!!!
dispatch(cancelStream());
}
};
window.addEventListener("keydown", listener);

View file

@ -0,0 +1,15 @@
import { createAsyncThunk } from "@reduxjs/toolkit";
import { abortStream, setInactive } from "../slices/sessionSlice";
import { ThunkApiType } from "../store";
export const cancelStream = createAsyncThunk<void, undefined, ThunkApiType>(
"chat/cancelStream",
async (messages, { dispatch, extra, getState }) => {
dispatch(setInactive());
dispatch(abortStream());
// If the assistant message is empty, then remove it and the user message, placing the user input in the main text box
// TODO: Waiting until next release
// dispatch(clearLastEmptyResponse());
},
);