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

🏷️ refactor: Mark Message Text Containers With a Data Attribute (#16826)

Marco Beretta32ae2fd7c4eb
diff --git a/client/src/components/Chat/Messages/Content/Container.tsx b/client/src/components/Chat/Messages/Content/Container.tsx
index 7542feee84..14646b5151 100644
--- a/client/src/components/Chat/Messages/Content/Container.tsx
+++ b/client/src/components/Chat/Messages/Content/Container.tsx
@@ -5,7 +5,8 @@ import Files from './Files';
const Container = ({ children, message }: { children: React.ReactNode; message?: TMessage }) => (
<div
- className="text-message flex min-h-[1.25rem] flex-col items-start gap-3 overflow-visible [.text-message+&]:mt-5"
+ data-message-text
+ className="flex min-h-[1.25rem] flex-col items-start gap-3 overflow-visible [[data-message-text]+&]:mt-5"
dir="auto"
>
{message?.isCreatedByUser === true && (
diff --git a/client/src/components/Chat/Messages/Content/Parts/EmptyText.tsx b/client/src/components/Chat/Messages/Content/Parts/EmptyText.tsx
index ef2599a1e5..89c0e13491 100644
--- a/client/src/components/Chat/Messages/Content/Parts/EmptyText.tsx
+++ b/client/src/components/Chat/Messages/Content/Parts/EmptyText.tsx
@@ -16,7 +16,10 @@ type EmptyTextPartProps = {
/** Streaming cursor placeholder — no bottom margin to match Container's structure and prevent CLS */
const EmptyTextPart = memo(({ underHeaderIcon = false }: EmptyTextPartProps) => {
return (
- <div className="text-message flex min-h-[1.25rem] flex-col items-start gap-3 overflow-visible">
+ <div
+ data-message-text
+ className="flex min-h-[1.25rem] flex-col items-start gap-3 overflow-visible"
+ >
<div className="markdown prose dark:prose-invert light w-full break-words">
<div className={cn('absolute', underHeaderIcon && 'ps-1.5')}>
<p className="submitting relative">
diff --git a/e2e/specs/mock/private-text.spec.ts b/e2e/specs/mock/private-text.spec.ts
index bd4ca29003..f7512a46ca 100644
--- a/e2e/specs/mock/private-text.spec.ts
+++ b/e2e/specs/mock/private-text.spec.ts
@@ -50,9 +50,7 @@ test('owner sees original after reload while provider, sharing, and canonical re
).toBeVisible();
const ownerText = messagesView(page).getByText(original, { exact: true });
await expect(ownerText).toBeVisible();
- const standardContainer = ownerText.locator(
- 'xpath=ancestor::div[contains(@class,"text-message")][1]',
- );
+ const standardContainer = ownerText.locator('xpath=ancestor::div[@data-message-text][1]');
await expect(standardContainer).toHaveAttribute('dir', 'auto');
await expect(
messagesView(page).getByText('Private details hidden from the model', { exact: true }),
@@ -82,9 +80,10 @@ test('owner sees original after reload while provider, sharing, and canonical re
await page.reload();
await expect(messagesView(page).getByText(original, { exact: true })).toBeVisible();
- await expect(
- ownerText.locator('xpath=ancestor::div[contains(@class,"text-message")][1]'),
- ).toHaveAttribute('dir', 'auto');
+ await expect(ownerText.locator('xpath=ancestor::div[@data-message-text][1]')).toHaveAttribute(
+ 'dir',
+ 'auto',
+ );
for (const theme of ['light', 'dark']) {
await page.evaluate(
(dark) => document.documentElement.classList.toggle('dark', dark),
diff --git a/e2e/specs/mock/scenarios/message-text-container.spec.ts b/e2e/specs/mock/scenarios/message-text-container.spec.ts
new file mode 100644
index 0000000000..61b0a9ab01
--- /dev/null
+++ b/e2e/specs/mock/scenarios/message-text-container.spec.ts
@@ -0,0 +1,30 @@
+import { expect, test } from '@playwright/test';
+import {
+ NEW_CHAT_PATH,
+ replyText,
+ replyPrompt,
+ messagesView,
+ selectMockEndpoint,
+ sendMessageAndWaitForCompletion,
+} from '../helpers';
+
+const ENDPOINT = { label: 'Mock Provider A', model: 'mock-model-a' };
+
+test.describe('message text containers', () => {
+ test('both turns render their text in a dir=auto container marked data-message-text @scenario:message-text-container-direction', async ({
+ page,
+ }) => {
+ const label = `text-container-${Date.now()}`;
+ await page.goto(NEW_CHAT_PATH, { timeout: 10000 });
+ await selectMockEndpoint(page, ENDPOINT);
+ const response = await sendMessageAndWaitForCompletion(page, replyPrompt(label));
+ expect(response.ok()).toBeTruthy();
+
+ for (const text of [replyPrompt(label), replyText(label)]) {
+ const container = messagesView(page)
+ .getByText(text, { exact: true })
+ .locator('xpath=ancestor::div[@data-message-text][1]');
+ await expect(container).toHaveAttribute('dir', 'auto');
+ }
+ });
+});
diff --git a/eslint-suppressions.json b/eslint-suppressions.json
index 98c2925607..092341eedc 100644
--- a/eslint-suppressions.json
+++ b/eslint-suppressions.json
@@ -384,11 +384,6 @@
"count": 1
}
},
- "client/src/components/Chat/Messages/Content/Container.tsx": {
- "shadcn/no-raw-colors": {
- "count": 1
- }
- },
"client/src/components/Chat/Messages/Content/DialogImage.tsx": {
"shadcn/no-arbitrary-values": {
"count": 2
@@ -473,9 +468,6 @@
}
},
"client/src/components/Chat/Messages/Content/Parts/EmptyText.tsx": {
- "shadcn/no-raw-colors": {
- "count": 1
- },
"shadcn/no-unknown-classes": {
"count": 1
}