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
TypeScript aianthropicartifactsawsazurechatgptchatgpt-cloneclaudeclonedeepseekgeminigooglegpt-5librechatmcpo1openairesponses-apivisionwebui
⏎ fix: Restore Enter to Send as the Default (#17374)
Marco Berettacd6edcea7429
diff --git a/client/src/components/Chat/Input/ChatForm.tsx b/client/src/components/Chat/Input/ChatForm.tsxindex 8b510f00e5..11aa8e135a 100644--- a/client/src/components/Chat/Input/ChatForm.tsx+++ b/client/src/components/Chat/Input/ChatForm.tsx@@ -1065,9 +1065,9 @@ function ChatFormWrapper({project,routePending = false,isLandingPage,- /** Enter sends unless told otherwise, so call sites that predate this prop,- * mainly tests, keep their prior behavior without passing it explicitly.- * ChatView always passes the user's preference, whose default is false. */+ /** Defaults to the atom's own default (`atomWithLocalStorage('enterToSend',+ * true)`) so call sites that predate this prop, mainly tests, keep their+ * prior behavior without passing it explicitly. */enterToSend = true,/** Same reason, from `atomWithLocalStorage('autoSendText', -1)`. */autoSendText = -1,diff --git a/client/src/components/Chat/Input/__tests__/ChatForm.enterToSend.spec.tsx b/client/src/components/Chat/Input/__tests__/ChatForm.enterToSend.spec.tsxindex ff2981bd99..b404064002 100644--- a/client/src/components/Chat/Input/__tests__/ChatForm.enterToSend.spec.tsx+++ b/client/src/components/Chat/Input/__tests__/ChatForm.enterToSend.spec.tsx@@ -26,7 +26,7 @@ const conversation = {} as TConversation;/**- * The atom keeps its default (`atomWithLocalStorage('enterToSend', false)`)+ * The atom keeps its default (`atomWithLocalStorage('enterToSend', true)`)* here: these tests prove the composer follows the `enterToSend` prop ChatView* passes it, not the atom it used to read directly, so each value is covered.*/@@ -116,7 +116,7 @@ describe('ChatForm enterToSend prop', () => {localStorage.clear();});- test('follows the prop when it agrees with the persisted default', async () => {+ test('follows the prop when it disagrees with the persisted default', async () => {renderComposer({ enterToSend: false });const textarea = await screen.findByTestId('text-input');@@ -128,7 +128,7 @@ describe('ChatForm enterToSend prop', () => {expect(hint).not.toHaveTextContent('Enter to send');}, 20000);- test('follows the prop when it disagrees with the persisted default', async () => {+ test('follows the prop when it agrees with the persisted default', async () => {renderComposer({ enterToSend: true });const textarea = await screen.findByTestId('text-input');diff --git a/client/src/components/Chat/__tests__/ChatView.spec.tsx b/client/src/components/Chat/__tests__/ChatView.spec.tsxindex 834a47de33..92e87a6f0d 100644--- a/client/src/components/Chat/__tests__/ChatView.spec.tsx+++ b/client/src/components/Chat/__tests__/ChatView.spec.tsx@@ -143,11 +143,11 @@ describe('ChatView composer preferences', () => {* reaching into app-global state the composer only consumes. ChatView now owns the* read and passes it down, the same boundary `showComposerTips` already follows. */test('reads the persisted enterToSend preference and passes it into ChatForm', () => {- localStorage.setItem('enterToSend', JSON.stringify(true));+ localStorage.setItem('enterToSend', JSON.stringify(false));render(<ChatView />);- expect(mockChatFormProps).toHaveBeenCalledWith(expect.objectContaining({ enterToSend: true }));+ expect(mockChatFormProps).toHaveBeenCalledWith(expect.objectContaining({ enterToSend: false }));});/** The same boundary for the dictation preferences: ChatForm consumes them@@ -170,7 +170,7 @@ describe('ChatView composer preferences', () => {test('falls back to the atom default when nothing is persisted', () => {render(<ChatView />);- expect(mockChatFormProps).toHaveBeenCalledWith(expect.objectContaining({ enterToSend: false }));+ expect(mockChatFormProps).toHaveBeenCalledWith(expect.objectContaining({ enterToSend: true }));});});diff --git a/client/src/store/__tests__/defaults.spec.ts b/client/src/store/__tests__/defaults.spec.tsindex fddc2d04de..68d9451967 100644--- a/client/src/store/__tests__/defaults.spec.ts+++ b/client/src/store/__tests__/defaults.spec.ts@@ -24,8 +24,8 @@ describe('preference defaults with nothing persisted', () => {localStorage.clear();});- it('adds a newline on Enter instead of sending', () => {- expect(readRecoil(settings.enterToSend)).toBe(false);+ it('sends on Enter', () => {+ expect(readRecoil(settings.enterToSend)).toBe(true);});it('collapses long user messages', () => {@@ -47,10 +47,10 @@ describe('persisted preferences', () => {localStorage.clear();});- it('keeps a saved Enter to send', () => {- localStorage.setItem('enterToSend', JSON.stringify(true));+ it('keeps a saved opt-out of Enter to send', () => {+ localStorage.setItem('enterToSend', JSON.stringify(false));- expect(readRecoil(settings.enterToSend)).toBe(true);+ expect(readRecoil(settings.enterToSend)).toBe(false);});it('keeps a saved opt-out of collapsing', () => {diff --git a/client/src/store/settings.ts b/client/src/store/settings.tsindex 1e44231a54..c425fb96f5 100644--- a/client/src/store/settings.ts+++ b/client/src/store/settings.ts@@ -57,7 +57,7 @@ const localStorageAtoms = {chatTitleInTab: atomWithLocalStorage(CHAT_TITLE_IN_TAB_KEY, true),// Chat settings- enterToSend: atomWithLocalStorage('enterToSend', false),+ enterToSend: atomWithLocalStorage('enterToSend', true),maximizeChatSpace: atomWithLocalStorage('maximizeChatSpace', false),autoExpandTools: atomWithLocalStorage(LocalStorageKeys.AUTO_EXPAND_TOOLS, false),saveDrafts: atomWithLocalStorage('saveDrafts', true),diff --git a/e2e/setup/authenticate.ts b/e2e/setup/authenticate.tsindex b9390b7d1d..3e5d4276a2 100644--- a/e2e/setup/authenticate.ts+++ b/e2e/setup/authenticate.ts@@ -67,11 +67,9 @@ async function authenticate(config: FullConfig, user: User) {const conversationURL = appURL(baseURL, 'c/new');const loginURL = appURL(baseURL, 'login');- // Set localStorage before navigating to the page. Specs send with Enter, which the- // app no longer does by default, so the saved state opts into it.+ // Set localStorage before navigating to the pageawait page.context().addInitScript(() => {localStorage.setItem('navVisible', 'true');- localStorage.setItem('enterToSend', 'true');});console.log('🤖: ✔️ localStorage: set Nav as Visible', storageState);diff --git a/e2e/setup/record.js b/e2e/setup/record.jsindex eac0d57d5d..70052a2b78 100644--- a/e2e/setup/record.js+++ b/e2e/setup/record.js@@ -316,10 +316,8 @@ async function writeStorageState(env, storagePath) {try {const page = await browser.newPage();- /** Specs send with Enter, which the app no longer does by default. */await page.context().addInitScript(() => {localStorage.setItem('navVisible', 'true');- localStorage.setItem('enterToSend', 'true');});await page.goto(baseURL, { timeout });diff --git a/e2e/specs/mock/code-upload.spec.ts b/e2e/specs/mock/code-upload.spec.tsindex 53f098afa6..a30c6e89b6 100644--- a/e2e/specs/mock/code-upload.spec.ts+++ b/e2e/specs/mock/code-upload.spec.ts@@ -42,13 +42,9 @@ const TURN2_MARKER_NEEDLE = 'turn1-proof-42';const uniqueName = (prefix: string) => `${prefix} ${Date.now()}-${Math.floor(Math.random() * 1e4)}`;const modelTrigger = (page: Page) => page.getByRole('button', { name: 'Select a model' }).first();-/** Restores the Enter opt-in from global setup, since the send helpers press Enter. */async function startFresh(page: Page) {await page.goto(NEW_CHAT_PATH, { timeout: 10000 });- await page.evaluate(() => {- localStorage.clear();- localStorage.setItem('enterToSend', 'true');- });+ await page.evaluate(() => localStorage.clear());await page.goto(NEW_CHAT_PATH, { timeout: 10000 });}diff --git a/e2e/specs/mock/scenarios/denied-web-storage.spec.ts b/e2e/specs/mock/scenarios/denied-web-storage.spec.tsindex 3df2d8896b..8e61dec64a 100644--- a/e2e/specs/mock/scenarios/denied-web-storage.spec.ts+++ b/e2e/specs/mock/scenarios/denied-web-storage.spec.ts@@ -71,13 +71,12 @@ test.describe('denied web storage', () => {await denyWebStorage(page);await page.goto(NEW_CHAT_PATH, { timeout: 15000 });- /** No stored preference can load, so Enter writes a newline by default and- * Ctrl/Cmd+Enter sends. `sendMessage` relies on the stored Enter opt-in. */+ /** No stored preference can load, so the default Enter to send applies. */const input = page.getByRole('textbox', { name: 'Message input' });await input.fill(replyPrompt('denied-storage'));await Promise.all([page.waitForResponse(isAgentsStream, { timeout: 30000 }),- input.press('ControlOrMeta+Enter'),+ input.press('Enter'),]);await expect(messagesView(page).getByText(replyText('denied-storage'))).toBeVisible({timeout: 30000,diff --git a/e2e/specs/mock/scenarios/enter-to-send.spec.ts b/e2e/specs/mock/scenarios/enter-to-send.spec.tsnew file mode 100644index 0000000000..8c7a10bdb6--- /dev/null+++ b/e2e/specs/mock/scenarios/enter-to-send.spec.ts@@ -0,0 +1,78 @@+import { expect, test } from '@playwright/test';+import type { Page } from '@playwright/test';+import { NEW_CHAT_PATH, isAgentsStream, messagesView, replyPrompt, replyText } from '../helpers';++/**+ * Enter sends and Shift+Enter inserts a newline for anyone who never saved the+ * preference, while a saved opt-out (Ctrl/Cmd+Enter to send) is kept.+ */++const messageInput = (page: Page) => page.getByRole('textbox', { name: 'Message input' });++async function openFreshChat(page: Page, saved?: boolean) {+ await page.goto(NEW_CHAT_PATH, { timeout: 15000 });+ await page.evaluate((value) => {+ localStorage.removeItem('enterToSend');+ if (value !== undefined) {+ localStorage.setItem('enterToSend', JSON.stringify(value));+ }+ }, saved);+ await page.goto(NEW_CHAT_PATH, { timeout: 15000 });+ await expect(messageInput(page)).toBeVisible();+}++async function expectSent(page: Page, label: string, key: string) {+ const input = messageInput(page);+ await input.fill(replyPrompt(label));+ await Promise.all([page.waitForResponse(isAgentsStream, { timeout: 30000 }), input.press(key)]);+ await expect(messagesView(page).getByText(replyText(label))).toBeVisible({ timeout: 30000 });+}++test.describe('enter to send default', () => {+ test('Enter sends a message when no preference is saved @scenario:enter-sends-message-with-no-saved-preference', async ({+ page,+ }) => {+ await openFreshChat(page);++ await messageInput(page).fill('hi');+ await expect(page.locator('#composer-hint-0')).toContainText('Enter to send');++ await expectSent(page, 'enter-default', 'Enter');+ await expect(page).toHaveURL(/\/c\/(?!new$)[^/]+$/);+ });++ test('Shift+Enter inserts a newline without sending when no preference is saved @scenario:shift-enter-inserts-newline-by-default', async ({+ page,+ }) => {+ await openFreshChat(page);+ let streamed = false;+ page.on('response', (response) => {+ if (isAgentsStream(response)) {+ streamed = true;+ }+ });++ const input = messageInput(page);+ await input.fill('first line');+ await input.press('Shift+Enter');+ await input.pressSequentially('second line');++ await expect(input).toHaveValue('first line\nsecond line');+ await expect(page).toHaveURL(/\/c\/new$/);+ expect(streamed).toBe(false);+ });++ test('a saved Ctrl/Cmd+Enter preference keeps Enter as a newline @scenario:saved-modifier-enter-preference-is-kept', async ({+ page,+ }) => {+ await openFreshChat(page, false);++ const input = messageInput(page);+ await input.fill('first line');+ await input.press('Enter');+ await expect(input).toHaveValue('first line\n');+ await expect(page).toHaveURL(/\/c\/new$/);++ await expectSent(page, 'modifier-saved', 'ControlOrMeta+Enter');+ });+});diff --git a/e2e/specs/mock/soft-default.spec.ts b/e2e/specs/mock/soft-default.spec.tsindex d433550942..20b550abf7 100644--- a/e2e/specs/mock/soft-default.spec.ts+++ b/e2e/specs/mock/soft-default.spec.ts@@ -25,14 +25,10 @@ const uniqueName = (prefix: string) => `${prefix} ${Date.now()}-${Math.floor(Matconst modelTrigger = (page: Page) => page.getByRole('button', { name: 'Select a model' }).first();-/** Reset selection state so the test starts as a fresh instance (auth stays in cookies).- * The Enter opt-in from global setup is restored because `sendMessage` presses Enter. */+/** Reset selection state so the test starts as a fresh instance (auth stays in cookies). */async function startFresh(page: Page) {await page.goto(NEW_CHAT_PATH, { timeout: 10000 });- await page.evaluate(() => {- localStorage.clear();- localStorage.setItem('enterToSend', 'true');- });+ await page.evaluate(() => localStorage.clear());await page.goto(NEW_CHAT_PATH, { timeout: 10000 });}@@ -202,10 +198,7 @@ test.describe('soft default model spec', () => {await expect(modelTrigger(page)).toContainText(agentName, { timeout: 15000 });// The soft default still owns the fresh-instance landing under this allow-list.- await page.evaluate(() => {- localStorage.clear();- localStorage.setItem('enterToSend', 'true');- });+ await page.evaluate(() => localStorage.clear());await page.goto(NEW_CHAT_PATH, { timeout: 10000 });await expect(modelTrigger(page)).toContainText(SOFT_DEFAULT_LABEL, { timeout: 15000 });});