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

🪀 fix: Stop the Textarea Jump During File Uploads (#16623)

lia-by-librechat[bot]99015144e486
diff --git a/client/src/components/Chat/Input/Composer/Hints.tsx b/client/src/components/Chat/Input/Composer/Hints.tsx
index 53400b5303..e52a16c454 100644
--- a/client/src/components/Chat/Input/Composer/Hints.tsx
+++ b/client/src/components/Chat/Input/Composer/Hints.tsx
@@ -12,11 +12,12 @@ export const composerHintId = (index: number) => `composer-hint-${index}`;
* which had no on-screen presence at all before.
*
* Ambient tips are opt-in and off by default: they are discovery copy, and the
- * row they sit on costs the thread height on every turn. Live state (uploads, a
- * paused question, the during-run modifiers) reports itself either way; those
- * are things happening now, not things worth teaching.
+ * row they sit on costs the thread height on every turn. A paused question and
+ * the during-run modifiers report themselves either way. Upload progress is
+ * already visible on the file chips, so uploads update the accessible description
+ * and any existing hint row without mounting another row that moves the textarea.
*
- * The visible line is `aria-hidden`; the same string is mirrored into a
+ * The visible line is `aria-hidden`; the current hint or upload status lives in a
* visually-hidden node that the textarea points at via `aria-describedby`, which
* is why hiding the line costs a screen reader nothing. An `aria-live` region
* here would re-announce on every keystroke as the hint flips between idle and
@@ -29,7 +30,13 @@ function Hints({
...state
}: ComposerHintState & { index: number; showTips: boolean }) {
const hint = useComposerHint({ ...state, enterToSend });
- const visible = showTips || hint.kind === 'state';
+ const visible =
+ showTips ||
+ (hint.kind === 'state' &&
+ (state.uploadingCount === 0 ||
+ state.answerModeActive ||
+ state.isSubmitting ||
+ (state.duringRunActive && state.hasText)));
return (
<>
diff --git a/client/src/components/Chat/Input/Composer/__tests__/Hints.spec.tsx b/client/src/components/Chat/Input/Composer/__tests__/Hints.spec.tsx
new file mode 100644
index 0000000000..f66f89e1b8
--- /dev/null
+++ b/client/src/components/Chat/Input/Composer/__tests__/Hints.spec.tsx
@@ -0,0 +1,103 @@
+import React from 'react';
+import { render, screen } from '@testing-library/react';
+import type { ComposerHintState } from '~/hooks/Input/useComposerHint';
+import Hints, { composerHintId } from '../Hints';
+
+jest.mock('~/hooks/Input/useComposerBindings', () => ({
+ __esModule: true,
+ default: () => ({
+ shortcutsEnabled: true,
+ submitOverride: undefined,
+ yieldedChords: new Set<string>(),
+ }),
+}));
+
+jest.mock('~/hooks/useKeyboardShortcuts', () => ({
+ useShortcutDisplay: () => 'Ctrl+Shift+X',
+}));
+
+const baseState: ComposerHintState = {
+ hasText: true,
+ isSubmitting: false,
+ duringRunActive: false,
+ canControlGeneration: true,
+ duringRunAction: 'queue',
+ canSteer: true,
+ answerModeActive: false,
+ uploadingCount: 0,
+ enterToSend: true,
+ idleActions: { prompts: true, mentions: true, attach: true },
+};
+
+function hints(state: Partial<ComposerHintState> = {}, showTips = false, index = 0) {
+ return <Hints {...baseState} {...state} showTips={showTips} index={index} />;
+}
+
+const description = (index = 0) => document.getElementById(composerHintId(index));
+
+describe('composer upload hints', () => {
+ it.each([{ hasText: false }, { hasText: true }, { hasText: false, duringRunActive: true }])(
+ 'keeps uploads out of the visible hint row through progress, completion and cancellation (%j)',
+ (state) => {
+ const { rerender } = render(hints(state));
+ const idleDescription = description()?.textContent;
+
+ for (const uploadingCount of [1, 2, 1, 0, 1, 0]) {
+ rerender(hints({ ...state, uploadingCount }));
+ expect(screen.queryByTestId('composer-hints')).not.toBeInTheDocument();
+ if (uploadingCount > 0) {
+ expect(description()).toHaveTextContent(/Uploading/);
+ expect(description()).toHaveClass('sr-only');
+ } else {
+ expect(description()?.textContent).toBe(idleDescription);
+ }
+ }
+ },
+ );
+
+ it.each([
+ ['enabled tips', {}, true],
+ ['an active run', { isSubmitting: true, duringRunActive: true }, false],
+ ] as const)('preserves %s while an upload starts and finishes', (_name, state, showTips) => {
+ const { rerender } = render(hints(state, showTips));
+ const visibleHint = screen.getByTestId('composer-hints');
+ const text = visibleHint.textContent;
+
+ for (const uploadingCount of [1, 2, 0]) {
+ rerender(hints({ ...state, uploadingCount }, showTips));
+ expect(screen.getByTestId('composer-hints')).toBe(visibleHint);
+ expect(visibleHint).toHaveAttribute('aria-hidden', 'true');
+ if (uploadingCount > 0) {
+ expect(visibleHint).toHaveTextContent(/Uploading/);
+ expect(description()).toHaveTextContent(/Uploading/);
+ } else {
+ expect(visibleHint.textContent).toBe(text);
+ expect(description()?.textContent).toBe(text);
+ }
+ }
+ });
+
+ it('keeps answer mode ahead of upload status', () => {
+ const { rerender } = render(hints({ answerModeActive: true }));
+ const answer = description()?.textContent;
+
+ rerender(hints({ answerModeActive: true, uploadingCount: 1 }));
+
+ expect(description()?.textContent).toBe(answer);
+ expect(screen.getByTestId('composer-hints').textContent).toBe(answer);
+ expect(description()).not.toHaveTextContent(/Uploading/);
+ });
+
+ it('keeps the accessible upload descriptions scoped to each pane', () => {
+ render(
+ <>
+ {hints({ uploadingCount: 1 }, false, 0)}
+ {hints({ uploadingCount: 2 }, false, 1)}
+ </>,
+ );
+
+ expect(description(0)).toHaveTextContent('Uploading 1 file');
+ expect(description(1)).toHaveTextContent('Uploading 2 files');
+ expect(screen.queryByTestId('composer-hints')).not.toBeInTheDocument();
+ });
+});
diff --git a/e2e/specs/mock/composer-upload-layout.spec.ts b/e2e/specs/mock/composer-upload-layout.spec.ts
new file mode 100644
index 0000000000..2b03bce080
--- /dev/null
+++ b/e2e/specs/mock/composer-upload-layout.spec.ts
@@ -0,0 +1,78 @@
+import { expect, test } from '@playwright/test';
+import {
+ MOCK_ENDPOINTS,
+ NEW_CHAT_PATH,
+ selectMockEndpoint,
+ sendMessageAndWaitForCompletion,
+ uploadViaUnifiedButton,
+ uniqueName,
+} from './helpers';
+
+for (const viewport of [
+ { width: 1280, height: 800 },
+ { width: 390, height: 844 },
+]) {
+ test.describe(`composer uploads at ${viewport.width}px`, () => {
+ test.use({ viewport });
+
+ test('keeps the textarea in place when uploading starts and finishes', async ({
+ page,
+ }, testInfo) => {
+ await page.addInitScript(() => {
+ localStorage.setItem('showComposerTips', 'false');
+ });
+ await page.goto(NEW_CHAT_PATH);
+ await selectMockEndpoint(page, MOCK_ENDPOINTS[1]);
+ await sendMessageAndWaitForCompletion(page, 'E2E_REPLY:upload layout');
+
+ const input = page.getByRole('textbox', { name: 'Message input' });
+ await expect(page.getByTestId('composer-hints')).toHaveCount(0);
+ await input.fill('Keep this draft');
+ const before = await input.boundingBox();
+ expect(before).not.toBeNull();
+
+ let releaseUpload = () => {};
+ const uploadGate = new Promise<void>((resolve) => {
+ releaseUpload = resolve;
+ });
+ await page.route('**/api/files', async (route) => {
+ if (route.request().method() === 'POST') {
+ await uploadGate;
+ }
+ await route.continue();
+ });
+
+ try {
+ const upload = uploadViaUnifiedButton(page, {
+ name: `${uniqueName('layout')}.md`,
+ mimeType: 'text/markdown',
+ content: '# Upload layout regression\n',
+ });
+ await expect(input).toHaveAccessibleDescription(/Uploading 1 file/);
+ await expect(page.getByTestId('composer-tray')).toBeVisible();
+ await expect(page.getByTestId('send-button')).toBeDisabled();
+ const uploading = await input.boundingBox();
+
+ releaseUpload();
+ expect((await upload).ok()).toBeTruthy();
+ await expect(input).not.toHaveAccessibleDescription(/Uploading/);
+ await expect(page.getByTestId('send-button')).toBeEnabled();
+ const complete = await input.boundingBox();
+
+ await testInfo.attach('textarea-bounds', {
+ body: JSON.stringify({ before, uploading, complete }),
+ contentType: 'application/json',
+ });
+ expect(uploading).not.toBeNull();
+ expect(complete).not.toBeNull();
+ expect(Math.abs(uploading!.y - before!.y)).toBeLessThan(1);
+ expect(Math.abs(complete!.y - uploading!.y)).toBeLessThan(1);
+ expect(complete!.height).toBe(before!.height);
+ await expect(input).toHaveValue('Keep this draft');
+ await expect(page.getByTestId('composer-hints')).toHaveCount(0);
+ } finally {
+ releaseUpload();
+ }
+ });
+ });
+}