⌨️ feat: Change Default Chat Preferences (#16932)
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 (full suite) (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
Sync Locize Translations & Create Translation PR / Sync Translation Keys with Locize (push) Waiting to run
Sync Locize Translations & Create Translation PR / Create Translation PR on Version Published (push) Blocked by required conditions
Main Promotion Policy Tests / Main promotion denial and fast-forward tests (push) Waiting to run

This commit is contained in:
Marco Beretta 2026-10-12 00:55:36 +02:00 • committed by GitHub
parent b24bfc0dd0
commit 5ee091e99d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 125 additions and 27 deletions

View file

@ -1083,9 +1083,9 @@ function ChatFormWrapper({
project,
routePending = false,
isLandingPage,
/** 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. */
/** 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. */
enterToSend = true,
/** Same reason, from `atomWithLocalStorage('autoSendText', -1)`. */
autoSendText = -1,

View file

@ -24,10 +24,9 @@ const conversation = {
} as TConversation;
/**
* The atom default (`atomWithLocalStorage('enterToSend', true)`) always stays
* true here: these tests prove the composer follows the `enterToSend` prop
* ChatView passes it, not the atom it used to read directly, so the prop is
* deliberately set opposite to that default.
* The atom keeps its default (`atomWithLocalStorage('enterToSend', false)`)
* 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.
*/
function Harness({ enterToSend }: { enterToSend: boolean }) {
const [files, setFiles] = useRecoilState(store.filesByIndex(0));
@ -111,7 +110,7 @@ describe('ChatForm enterToSend prop', () => {
localStorage.clear();
});
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: false });
const textarea = await screen.findByTestId('text-input');
@ -123,7 +122,7 @@ describe('ChatForm enterToSend prop', () => {
expect(hint).not.toHaveTextContent('Enter to send');
}, 20000);
test('reflects the prop when it agrees with the persisted default', async () => {
test('follows the prop when it disagrees with the persisted default', async () => {
renderComposer({ enterToSend: true });
const textarea = await screen.findByTestId('text-input');

View file

@ -134,11 +134,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(false));
localStorage.setItem('enterToSend', JSON.stringify(true));
render(<ChatView />);
expect(mockChatFormProps).toHaveBeenCalledWith(expect.objectContaining({ enterToSend: false }));
expect(mockChatFormProps).toHaveBeenCalledWith(expect.objectContaining({ enterToSend: true }));
});
/** The same boundary for the dictation preferences: ChatForm consumes them
@ -161,7 +161,7 @@ describe('ChatView composer preferences', () => {
test('falls back to the atom default when nothing is persisted', () => {
render(<ChatView />);
expect(mockChatFormProps).toHaveBeenCalledWith(expect.objectContaining({ enterToSend: true }));
expect(mockChatFormProps).toHaveBeenCalledWith(expect.objectContaining({ enterToSend: false }));
});
});

View file

@ -132,10 +132,10 @@ describe('useClientResize', () => {
expect(result.current.isEnforced).toBe(false);
});
it('defaults to off when the user has no stored setting', () => {
it('defaults to on when the user has no stored setting', () => {
const { result } = renderHook(() => useClientResize(), { wrapper });
expect(result.current.isEnabled).toBe(false);
expect(result.current.isEnabled).toBe(true);
});
});

View file

@ -0,0 +1,73 @@
import { createStore } from 'jotai';
import { snapshot_UNSTABLE } from 'recoil';
import type { RecoilState } from 'recoil';
import settings from '../settings';
const readRecoil = <T>(atom: RecoilState<T>): T =>
snapshot_UNSTABLE().getLoadable(atom).valueOrThrow();
/**
* The Jotai atom reads storage once, when its module is evaluated (as on page
* load), so each case seeds storage first and then loads a fresh copy.
*/
const readAutoScroll = (): boolean => {
let value = false;
jest.isolateModules(() => {
const { autoScrollAtom } = jest.requireActual<typeof import('../autoScroll')>('../autoScroll');
value = createStore().get(autoScrollAtom);
});
return value;
};
describe('preference defaults with nothing persisted', () => {
beforeEach(() => {
localStorage.clear();
});
it('adds a newline on Enter instead of sending', () => {
expect(readRecoil(settings.enterToSend)).toBe(false);
});
it('collapses long user messages', () => {
expect(readRecoil(settings.collapseLongUserMessages)).toBe(true);
});
it('resizes images before upload', () => {
expect(readRecoil(settings.clientImageResize)).toBe(true);
});
it('scrolls to the latest message on chat open', () => {
expect(readAutoScroll()).toBe(true);
});
});
/** Guards: a choice saved under the old defaults survives the change. */
describe('persisted preferences', () => {
beforeEach(() => {
localStorage.clear();
});
it('keeps a saved Enter to send', () => {
localStorage.setItem('enterToSend', JSON.stringify(true));
expect(readRecoil(settings.enterToSend)).toBe(true);
});
it('keeps a saved opt-out of collapsing', () => {
localStorage.setItem('collapseLongUserMessages', JSON.stringify(false));
expect(readRecoil(settings.collapseLongUserMessages)).toBe(false);
});
it('keeps a saved opt-out of resizing', () => {
localStorage.setItem('clientImageResize', JSON.stringify(false));
expect(readRecoil(settings.clientImageResize)).toBe(false);
});
it('keeps a saved opt-out of auto-scroll', () => {
localStorage.setItem('autoScroll', JSON.stringify(false));
expect(readAutoScroll()).toBe(false);
});
});

View file

@ -1,6 +1,6 @@
import { createStorageAtom } from './jotai-utils';
const DEFAULT_AUTO_SCROLL = false;
const DEFAULT_AUTO_SCROLL = true;
/**
* Whether opening a conversation lands the reader on its newest message.

View file

@ -57,7 +57,7 @@ const localStorageAtoms = {
chatTitleInTab: atomWithLocalStorage(CHAT_TITLE_IN_TAB_KEY, true),
// Chat settings
enterToSend: atomWithLocalStorage('enterToSend', true),
enterToSend: atomWithLocalStorage('enterToSend', false),
maximizeChatSpace: atomWithLocalStorage('maximizeChatSpace', false),
chatDirection: atomWithLocalStorage('chatDirection', 'LTR'),
autoExpandTools: atomWithLocalStorage(LocalStorageKeys.AUTO_EXPAND_TOOLS, false),
@ -67,7 +67,7 @@ const localStorageAtoms = {
* "Show more" toggle. The clamp is visual only; the full text stays in
* the DOM, copyable and searchable.
*/
collapseLongUserMessages: atomWithLocalStorage('collapseLongUserMessages', false),
collapseLongUserMessages: atomWithLocalStorage('collapseLongUserMessages', true),
/**
* Whether pasting a large block of text attaches it as a `.txt` file instead of
* flooding the composer. The text still reaches the model in full.
@ -79,7 +79,7 @@ const localStorageAtoms = {
rememberDefaultFork: atomWithLocalStorage(LocalStorageKeys.REMEMBER_FORK_OPTION, false),
saveBadgesState: atomWithLocalStorage('saveBadgesState', false),
/** User preference for downscaling images before upload; ignored when the admin config sets it */
clientImageResize: atomWithLocalStorage('clientImageResize', false),
clientImageResize: atomWithLocalStorage('clientImageResize', true),
/**
* Whether copying a message also puts a rendered HTML version on the
* clipboard, so apps that ignore Markdown (Teams, Outlook, Word) paste the

View file

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

View file

@ -316,8 +316,10 @@ 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,9 +42,13 @@ 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());
await page.evaluate(() => {
localStorage.clear();
localStorage.setItem('enterToSend', 'true');
});
await page.goto(NEW_CHAT_PATH, { timeout: 10000 });
}

View file

@ -1,6 +1,6 @@
import { expect, test } from '@playwright/test';
import type { Page } from '@playwright/test';
import { NEW_CHAT_PATH, messagesView, replyPrompt, replyText, sendMessage } from '../helpers';
import { NEW_CHAT_PATH, isAgentsStream, messagesView, replyPrompt, replyText } from '../helpers';
/**
* A browser that denies Web Storage by policy throws a `SecurityError` from the
@ -71,7 +71,14 @@ test.describe('denied web storage', () => {
await denyWebStorage(page);
await page.goto(NEW_CHAT_PATH, { timeout: 15000 });
await sendMessage(page, replyPrompt('denied-storage'));
/** 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. */
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'),
]);
await expect(messagesView(page).getByText(replyText('denied-storage'))).toBeVisible({
timeout: 30000,
});

View file

@ -25,10 +25,14 @@ 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). */
/** 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. */
async function startFresh(page: Page) {
await page.goto(NEW_CHAT_PATH, { timeout: 10000 });
await page.evaluate(() => localStorage.clear());
await page.evaluate(() => {
localStorage.clear();
localStorage.setItem('enterToSend', 'true');
});
await page.goto(NEW_CHAT_PATH, { timeout: 10000 });
}
@ -198,7 +202,10 @@ 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());
await page.evaluate(() => {
localStorage.clear();
localStorage.setItem('enterToSend', 'true');
});
await page.goto(NEW_CHAT_PATH, { timeout: 10000 });
await expect(modelTrigger(page)).toContainText(SOFT_DEFAULT_LABEL, { timeout: 15000 });
});

View file

@ -180,6 +180,10 @@ test.describe('mid-run steering and queuing', () => {
page,
}) => {
test.setTimeout(150000);
/* This covers code layout, not collapsing, which is on by default. */
await page.addInitScript(() => {
localStorage.setItem('collapseLongUserMessages', JSON.stringify(false));
});
const label = uniqueLabel('steer-code-layout');
const steerText = `Please use this example:\n\n\`\`\`js\n${`const payload = '${'x'.repeat(300)}';\n`.repeat(12)}\`\`\``;
@ -233,7 +237,7 @@ test.describe('mid-run steering and queuing', () => {
await language.scrollIntoViewIfNeeded();
await expect(language).toBeInViewport();
}
// Canary collapses long user messages only when that preference is enabled.
// Long user messages collapse only while that preference is on; it is off here.
await expect(row.getByRole('button', { name: 'Show more' })).toHaveCount(0);
});

View file

@ -1426,7 +1426,7 @@ endpoints:
# # Users can toggle this in Settings > Chat. Setting `enabled` here overrides
# # that choice for everyone and locks the toggle; omit it to leave users in control.
# clientImageResize:
# enabled: false # Enable/disable client-side image resizing (default: false)
# enabled: false # Force resizing on (true) or off (false) for everyone; omit it and each user decides, with resizing on by default
# maxWidth: 1900 # Maximum width for resized images (default: 1900)
# maxHeight: 1900 # Maximum height for resized images (default: 1900)
# quality: 0.92 # JPEG quality for compression (0.0-1.0, default: 0.92)