⏎ fix: Restore Enter to Send as the Default (#17374)
Some checks are pending
Backend Unit Tests / Build packages (push) Waiting to run
Backend Unit Tests / Codegraph select (push) Waiting to run
Backend Unit Tests / TypeScript type checks (push) Blocked by required conditions
Backend Unit Tests / Circular dependency checks (push) Waiting to run
Backend Unit Tests / Tests: api (shard 1/3) (push) Blocked by required conditions
Backend Unit Tests / Tests: api (shard 2/3) (push) Blocked by required conditions
Backend Unit Tests / Tests: api (shard 3/3) (push) Blocked by required conditions
Backend Unit Tests / Tests: data-provider (push) Blocked by required conditions
Backend Unit Tests / Tests: data-schemas (push) Blocked by required conditions
Backend Unit Tests / Tests: @librechat/api (shard 1/4) (push) Blocked by required conditions
Backend Unit Tests / Tests: @librechat/api (shard 2/4) (push) Blocked by required conditions
Backend Unit Tests / Tests: @librechat/api (shard 3/4) (push) Blocked by required conditions
Backend Unit Tests / Tests: @librechat/api (shard 4/4) (push) Blocked by required conditions
Codegraph E2E Votes / vote (shard 1/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 10/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 2/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 3/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 4/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 5/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 6/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 7/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 8/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 9/10) (push) Waiting to run
Docker Dev Branch Images Build / publish (push) Waiting to run
Frontend Unit Tests / Client build recovery regression (push) Waiting to run
Frontend Unit Tests / Codegraph select (push) Waiting to run
Frontend Unit Tests / Build packages (push) Waiting to run
Frontend Unit Tests / TypeScript type checks (client) (push) Blocked by required conditions
Frontend Unit Tests / Tests: @librechat/chat (push) Blocked by required conditions
Frontend Unit Tests / Tests: @librechat/client (push) Blocked by required conditions
Frontend Unit Tests / Tests: Ubuntu (shard 1/2) (push) Blocked by required conditions
Frontend Unit Tests / Tests: Ubuntu (shard 2/2) (push) Blocked by required conditions
Frontend Unit Tests / Vite build verification (push) Blocked by required conditions

* fix: Restore Enter to Send as the Default Composer Behavior

* test: Cover the Enter to Send Default in E2E Scenarios
This commit is contained in:
Marco Beretta 2026-10-23 00:10:44 +02:00 • committed by GitHub
parent 76e3c6b134
commit cd6edcea74
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 100 additions and 38 deletions

View file

@ -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,

View file

@ -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');

View file

@ -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 }));
});
});

View file

@ -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', () => {

View file

@ -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),

View file

@ -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 page
await page.context().addInitScript(() => {
localStorage.setItem('navVisible', 'true');
localStorage.setItem('enterToSend', 'true');
});
console.log('🤖: ✔️ localStorage: set Nav as Visible', storageState);

View file

@ -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 });

View file

@ -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 });
}

View file

@ -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,

View file

@ -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');
});
});

View file

@ -25,14 +25,10 @@ const uniqueName = (prefix: string) => `${prefix} ${Date.now()}-${Math.floor(Mat
const 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 });
});