Skip to content

Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active

add new reducer to ensure conversations are renewed on model change

Daniel Avila0ba92c4c03ab
diff --git a/client/src/components/Conversations/DeleteButton.jsx b/client/src/components/Conversations/DeleteButton.jsx
index 6dff5682fe..423a8a2c21 100644
--- a/client/src/components/Conversations/DeleteButton.jsx
+++ b/client/src/components/Conversations/DeleteButton.jsx
@@ -3,7 +3,7 @@ import TrashIcon from '../svg/TrashIcon';
import CrossIcon from '../svg/CrossIcon';
import manualSWR from '~/utils/fetchers';
import { useDispatch } from 'react-redux';
-import { setConversation, removeConvo } from '~/store/convoSlice';
+import { setNewConvo, removeConvo } from '~/store/convoSlice';
import { setMessages } from '~/store/messageSlice';
export default function DeleteButton({ conversationId, renaming, cancelHandler }) {
@@ -14,7 +14,8 @@ export default function DeleteButton({ conversationId, renaming, cancelHandler }
() => {
dispatch(setMessages([]));
dispatch(removeConvo(conversationId));
- dispatch(setConversation({ title: 'New chat', conversationId: null, parentMessageId: null }));
+ // dispatch(setConversation({ title: 'New chat', conversationId: null, parentMessageId: null }));
+ dispatch(setNewConvo());
}
);
diff --git a/client/src/components/Models/ModelDialog.jsx b/client/src/components/Models/ModelDialog.jsx
index 93005976e3..40030b28bf 100644
--- a/client/src/components/Models/ModelDialog.jsx
+++ b/client/src/components/Models/ModelDialog.jsx
@@ -2,6 +2,7 @@ import React, { useState, useRef } from 'react';
import TextareaAutosize from 'react-textarea-autosize';
import { useSelector, useDispatch } from 'react-redux';
import { setModel, setCustomGpt } from '~/store/submitSlice';
+import { setNewConvo } from '~/store/convoSlice';
import manualSWR from '~/utils/fetchers';
import { Button } from '../ui/Button.tsx';
import { Input } from '../ui/Input.tsx';
@@ -36,6 +37,16 @@ export default function ModelDialog({ mutate, setModelSave, handleSaveState }) {
dispatch(setCustomGpt({ chatGptLabel, promptPrefix }));
dispatch(setModel('chatgptCustom'));
handleSaveState(chatGptLabel.toLowerCase());
+ // Set new conversation
+ dispatch(setNewConvo());
+ // dispatch(
+ // setConversation({
+ // title: 'New Chat',
+ // error: false,
+ // conversationId: null,
+ // parentMessageId: null
+ // })
+ // );
// dispatch(setDisabled(false));
};
diff --git a/client/src/components/Models/ModelMenu.jsx b/client/src/components/Models/ModelMenu.jsx
index d83ec9a927..06fe2aeb28 100644
--- a/client/src/components/Models/ModelMenu.jsx
+++ b/client/src/components/Models/ModelMenu.jsx
@@ -1,7 +1,7 @@
import React, { useState, useEffect } from 'react';
import { useSelector, useDispatch } from 'react-redux';
import { setModel, setDisabled, setCustomGpt, setCustomModel } from '~/store/submitSlice';
-import { setConversation } from '~/store/convoSlice';
+import { setNewConvo } from '~/store/convoSlice';
import ModelDialog from './ModelDialog';
import MenuItems from './MenuItems';
import manualSWR from '~/utils/fetchers';
@@ -76,14 +76,15 @@ export default function ModelMenu() {
}
// Set new conversation
- dispatch(
- setConversation({
- title: 'New Chat',
- error: false,
- conversationId: null,
- parentMessageId: null
- })
- );
+ dispatch(setNewConvo());
+ // dispatch(
+ // setConversation({
+ // title: 'New Chat',
+ // error: false,
+ // conversationId: null,
+ // parentMessageId: null
+ // })
+ // );
};
const onOpenChange = (open) => {
diff --git a/client/src/components/Nav/ClearConvos.jsx b/client/src/components/Nav/ClearConvos.jsx
index 25762aa2f2..324c443c4b 100644
--- a/client/src/components/Nav/ClearConvos.jsx
+++ b/client/src/components/Nav/ClearConvos.jsx
@@ -3,7 +3,7 @@ import TrashIcon from '../svg/TrashIcon';
import { useSWRConfig } from 'swr';
import manualSWR from '~/utils/fetchers';
import { useDispatch } from 'react-redux';
-import { setConversation, removeAll } from '~/store/convoSlice';
+import { setNewConvo, removeAll } from '~/store/convoSlice';
import { setMessages } from '~/store/messageSlice';
export default function ClearConvos() {
@@ -12,14 +12,15 @@ export default function ClearConvos() {
const { trigger } = manualSWR(`http://localhost:3080/api/convos/clear`, 'post', () => {
dispatch(setMessages([]));
- dispatch(
- setConversation({
- error: false,
- title: 'New chat',
- conversationId: null,
- parentMessageId: null
- })
- );
+ dispatch(setNewConvo());
+ // dispatch(
+ // setConversation({
+ // error: false,
+ // title: 'New chat',
+ // conversationId: null,
+ // parentMessageId: null
+ // })
+ // );
mutate(`http://localhost:3080/api/convos`);
});
diff --git a/client/src/components/Nav/NewChat.jsx b/client/src/components/Nav/NewChat.jsx
index 8535995b13..70e56c4427 100644
--- a/client/src/components/Nav/NewChat.jsx
+++ b/client/src/components/Nav/NewChat.jsx
@@ -1,6 +1,6 @@
import React from 'react';
import { useDispatch } from 'react-redux';
-import { setConversation } from '~/store/convoSlice';
+import { setNewConvo } from '~/store/convoSlice';
import { setMessages } from '~/store/messageSlice';
import { setText } from '~/store/textSlice';
@@ -10,7 +10,8 @@ export default function NewChat() {
const clickHandler = () => {
dispatch(setText(''));
dispatch(setMessages([]));
- dispatch(setConversation({ title: 'New Chat', error: false, conversationId: null, parentMessageId: null }));
+ dispatch(setNewConvo());
+ // dispatch(setConversation({ title: 'New Chat', error: false, conversationId: null, parentMessageId: null }));
};
return (
diff --git a/client/src/store/convoSlice.js b/client/src/store/convoSlice.js
index 6d10c58265..2560a29298 100644
--- a/client/src/store/convoSlice.js
+++ b/client/src/store/convoSlice.js
@@ -29,6 +29,20 @@ const currentSlice = createSlice({
incrementPage: (state) => {
state.pageNumber = state.pageNumber + 1;
},
+ setNewConvo: (state) => {
+ state.error = false;
+ state.title = 'New Chat';
+ state.conversationId = null;
+ state.parentMessageId = null;
+ state.jailbreakConversationId = null;
+ state.conversationSignature = null;
+ state.clientId = null;
+ state.invocationId = null;
+ state.chatGptLabel = null;
+ state.promptPrefix = null;
+ state.convosLoading = false;
+ state.pageNumber = 1;
+ },
setConvos: (state, action) => {
const newConvos = action.payload.filter((convo) => {
return !state.convos.some((c) => c.conversationId === convo.conversationId);
@@ -46,7 +60,7 @@ const currentSlice = createSlice({
}
});
-export const { setConversation, setConvos, setError, incrementPage, removeConvo, removeAll } =
+export const { setConversation, setConvos, setNewConvo, setError, incrementPage, removeConvo, removeAll } =
currentSlice.actions;
export default currentSlice.reducer;
diff --git a/client/src/style.css b/client/src/style.css
index 961c67b597..6b17c388e2 100644
--- a/client/src/style.css
+++ b/client/src/style.css
@@ -25,7 +25,7 @@
p > small {
opacity: 0;
- animation: fadein 2s forwards;
+ animation: fadein 3s forwards;
}
@keyframes fadein {