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

🧹 chore: address minor issues (#3710)

Danny Avila14ddfec9b7db
diff --git a/api/app/clients/OpenAIClient.js b/api/app/clients/OpenAIClient.js
index efb09a6ed3..0d9e43e196 100644
--- a/api/app/clients/OpenAIClient.js
+++ b/api/app/clients/OpenAIClient.js
@@ -1250,14 +1250,23 @@ ${convo}
throw new Error('Chat completion failed');
}
- const { message, finish_reason } = chatCompletion.choices[0];
- if (chatCompletion) {
- this.metadata = { finish_reason };
+ const { choices } = chatCompletion;
+ if (!Array.isArray(choices) || choices.length === 0) {
+ logger.warn('[OpenAIClient] Chat completion response has no choices');
+ return intermediateReply;
}
+ const { message, finish_reason } = choices[0] ?? {};
+ this.metadata = { finish_reason };
+
logger.debug('[OpenAIClient] chatCompletion response', chatCompletion);
- if (!message?.content?.trim() && intermediateReply.length) {
+ if (!message) {
+ logger.warn('[OpenAIClient] Message is undefined in chatCompletion response');
+ return intermediateReply;
+ }
+
+ if (typeof message.content !== 'string' || message.content.trim() === '') {
logger.debug(
'[OpenAIClient] chatCompletion: using intermediateReply due to empty message.content',
{ intermediateReply },
diff --git a/client/src/components/Chat/Messages/Content/Markdown.tsx b/client/src/components/Chat/Messages/Content/Markdown.tsx
index 07c64d6443..be66f61c8e 100644
--- a/client/src/components/Chat/Messages/Content/Markdown.tsx
+++ b/client/src/components/Chat/Messages/Content/Markdown.tsx
@@ -144,7 +144,7 @@ const Markdown = memo(({ content = '', isEdited, showCursor, isLatestMessage }:
return (
<div className="absolute">
<p className="relative">
- <span className="result-thinking" />
+ <span className={isLatestMessage ? 'result-thinking' : ''} />
</p>
</div>
);
diff --git a/client/src/components/Chat/Messages/Content/MessageContent.tsx b/client/src/components/Chat/Messages/Content/MessageContent.tsx
index d191aecb87..e0f6b70d07 100644
--- a/client/src/components/Chat/Messages/Content/MessageContent.tsx
+++ b/client/src/components/Chat/Messages/Content/MessageContent.tsx
@@ -77,6 +77,7 @@ const DisplayMessage = ({ text, isCreatedByUser, message, showCursor }: TDisplay
<Container message={message}>
<div
className={cn(
+ isSubmitting ? 'submitting' : '',
showCursorState && !!text.length ? 'result-streaming' : '',
'markdown prose message-content dark:prose-invert light w-full break-words',
isCreatedByUser ? 'whitespace-pre-wrap dark:text-gray-20' : 'dark:text-gray-100',
diff --git a/client/src/components/Chat/Messages/Content/Part.tsx b/client/src/components/Chat/Messages/Content/Part.tsx
index bb6673b753..436afdc9c6 100644
--- a/client/src/components/Chat/Messages/Content/Part.tsx
+++ b/client/src/components/Chat/Messages/Content/Part.tsx
@@ -34,6 +34,7 @@ const DisplayMessage = ({ text, isCreatedByUser = false, message, showCursor }:
return (
<div
className={cn(
+ isSubmitting ? 'submitting' : '',
showCursorState && !!text.length ? 'result-streaming' : '',
'markdown prose message-content dark:prose-invert light w-full break-words',
isCreatedByUser ? 'whitespace-pre-wrap dark:text-gray-20' : 'dark:text-gray-70',
diff --git a/client/src/style.css b/client/src/style.css
index b0d97bc77e..dd07363308 100644
--- a/client/src/style.css
+++ b/client/src/style.css
@@ -1742,7 +1742,7 @@ button.scroll-convo {
transform: scale3d(1.25, 1.25, 1);
}
}
-.result-thinking:empty:last-child:after {
+.submitting .result-thinking:empty:last-child:after {
-webkit-font-smoothing: subpixel-antialiased;
-webkit-animation: pulseSize 1.25s ease-in-out infinite;
animation: pulseSize 1.25s ease-in-out infinite;