Merge pull request #4120 from continuedev/dallin/chat-bugs
Message Resubmission bugs
This commit is contained in:
commit
79070a5548
2 changed files with 8 additions and 5 deletions
|
|
@ -191,13 +191,13 @@ export const sessionSlice = createSlice({
|
|||
{
|
||||
payload,
|
||||
}: PayloadAction<{
|
||||
index?: number;
|
||||
index: number;
|
||||
editorState: JSONContent;
|
||||
}>,
|
||||
) => {
|
||||
const { index, editorState } = payload;
|
||||
|
||||
if (typeof index === "number" && index < state.history.length) {
|
||||
if (state.history.length && index < state.history.length) {
|
||||
// Resubmission - update input message, truncate history after resubmit with new empty response message
|
||||
if (index % 2 === 1) {
|
||||
console.warn(
|
||||
|
|
@ -208,6 +208,7 @@ export const sessionSlice = createSlice({
|
|||
|
||||
historyItem.message.content = ""; // IMPORTANT - this is quickly updated by resolveEditorContent based on editor state prior to streaming
|
||||
historyItem.editorState = payload.editorState;
|
||||
historyItem.contextItems = [];
|
||||
|
||||
state.history = state.history.slice(0, index + 1).concat({
|
||||
message: {
|
||||
|
|
@ -260,7 +261,7 @@ export const sessionSlice = createSlice({
|
|||
}>,
|
||||
) => {
|
||||
const { index, updates } = payload;
|
||||
if (!state.history[index]) {
|
||||
if (index !== 0 && !state.history[index]) {
|
||||
console.error(
|
||||
`attempting to update history item at nonexistent index ${index}`,
|
||||
updates,
|
||||
|
|
|
|||
|
|
@ -74,13 +74,15 @@ export const streamResponseThunk = createAsyncThunk<
|
|||
const useTools = state.ui.useTools;
|
||||
const defaultModel = selectDefaultModel(state);
|
||||
const slashCommands = state.config.config.slashCommands || [];
|
||||
const inputIndex = index ?? state.session.history.length;
|
||||
const inputIndex = index ?? state.session.history.length; // Either given index or concat to end
|
||||
|
||||
if (!defaultModel) {
|
||||
throw new Error("No chat model selected");
|
||||
}
|
||||
|
||||
dispatch(submitEditorAndInitAtIndex({ index, editorState }));
|
||||
dispatch(
|
||||
submitEditorAndInitAtIndex({ index: inputIndex, editorState }),
|
||||
);
|
||||
resetStateForNewMessage();
|
||||
|
||||
const result = await dispatch(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue