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

fix(chatGPTBrowser): render markdown formatting by setting isCreatedByUser, fix(useMessageHandler): avoid double appearance of cursor by setting latest message at initial response creation time

Danny Avilaae5c06f38148
diff --git a/api/server/routes/ask/askChatGPTBrowser.js b/api/server/routes/ask/askChatGPTBrowser.js
index 2b2472b89e..088e1da4a3 100644
--- a/api/server/routes/ask/askChatGPTBrowser.js
+++ b/api/server/routes/ask/askChatGPTBrowser.js
@@ -103,6 +103,7 @@ const ask = async ({
unfinished: true,
cancelled: false,
error: false,
+ isCreatedByUser: false,
});
}
},
@@ -110,6 +111,7 @@ const ask = async ({
getPartialMessage = getPartialText;
const abortController = new AbortController();
+ let i = 0;
let response = await browserClient({
text,
parentMessageId: userParentMessageId,
@@ -128,8 +130,12 @@ const ask = async ({
sendMessage(res, {
message: { ...userMessage, conversationId: data.conversation_id },
- created: true,
+ created: i === 0,
});
+
+ if (i === 0) {
+ i++;
+ }
},
});
@@ -152,6 +158,7 @@ const ask = async ({
unfinished: false,
cancelled: false,
error: false,
+ isCreatedByUser: false,
};
await saveMessage(responseMessage);
@@ -220,7 +227,8 @@ const ask = async ({
parentMessageId: overrideParentMessageId || userMessageId,
unfinished: false,
cancelled: false,
- // error: true,
+ error: true,
+ isCreatedByUser: false,
text: `${getPartialMessage() ?? ''}\n\nError message: "${error.message}"`,
};
await saveMessage(errorMessage);
diff --git a/client/src/hooks/useMessageHandler.ts b/client/src/hooks/useMessageHandler.ts
index 3b019a012a..cb596eedab 100644
--- a/client/src/hooks/useMessageHandler.ts
+++ b/client/src/hooks/useMessageHandler.ts
@@ -6,7 +6,7 @@ import type { TAskFunction } from '~/common';
import store from '~/store';
const useMessageHandler = () => {
- const latestMessage = useRecoilValue(store.latestMessage);
+ const [latestMessage, setLatestMessage] = useRecoilState(store.latestMessage);
const setSiblingIdx = useSetRecoilState(
store.messagesSiblingIdxFamily(latestMessage?.parentMessageId),
);
@@ -134,6 +134,7 @@ const useMessageHandler = () => {
} else {
setMessages([...submission.messages, currentMsg, initialResponse]);
}
+ setLatestMessage(initialResponse);
setSubmission(submission);
};