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: Keep the Batch Question Card On Screen Above a Long Draft (#17222)
Marco Berettace9a9d80f4f0
diff --git a/client/src/components/Chat/Input/ChatForm.tsx b/client/src/components/Chat/Input/ChatForm.tsxindex b77001066b..1a7dfacabf 100644--- a/client/src/components/Chat/Input/ChatForm.tsx+++ b/client/src/components/Chat/Input/ChatForm.tsx@@ -308,6 +308,9 @@ const ChatForm = memo(function ChatForm({* answer box, or is locked behind the batch card that owns the answer. A* collapsed batch is neither, it hands the composer back to the thread. */const composerReserved = answerMode.composerAnswers || answerMode.composerLocked;+ /** A batch card stacks above the composer with its own height cap, so a+ * locked composer keeps the draft to one line to leave the card on screen. */+ const compactComposer = isCollapsed || answerMode.composerLocked;const { consumeDraft, preserveText, settleText } = useAutoSave({index,@@ -685,10 +688,10 @@ const ChatForm = memo(function ChatForm({() =>cn('composer-text md:py-3.5 m-0 w-full resize-none py-3.25 placeholder:text-text-tertiary bg-transparent [&:has(textarea:focus)]:shadow-[0_2px_6px_rgba(0,0,0,.05)]',- isCollapsed ? 'max-h-[3.25rem]' : 'max-h-[45vh] md:max-h-[55vh]',+ compactComposer ? 'max-h-[3.25rem]' : 'max-h-[45vh] md:max-h-[55vh]','px-5',),- [isCollapsed],+ [compactComposer],);const bottomClearance = composerClearance({@@ -867,7 +870,7 @@ const ChatForm = memo(function ChatForm({answerMode.composerLocked && '[&_textarea]:select-none',)}style={- isCollapsed+ compactComposer? {WebkitMaskImage:'linear-gradient(to bottom, black 60%, transparent 90%)',@@ -937,7 +940,7 @@ const ChatForm = memo(function ChatForm({<div className="absolute right-2 bottom-1 z-10"><CollapseChatisCollapsed={isCollapsed}- isScrollable={isMoreThanThreeRows}+ isScrollable={isMoreThanThreeRows && !answerMode.composerLocked}setIsCollapsed={setIsCollapsed}/></div>diff --git a/client/src/components/Chat/Input/__tests__/ChatForm.askBatch.spec.tsx b/client/src/components/Chat/Input/__tests__/ChatForm.askBatch.spec.tsxnew file mode 100644index 0000000000..56176bf641--- /dev/null+++ b/client/src/components/Chat/Input/__tests__/ChatForm.askBatch.spec.tsx@@ -0,0 +1,146 @@+import React, { useMemo, useState } from 'react';+import { getDefaultStore, useAtom } from 'jotai';+import { filesFamily, isSubmittingFamily, resetSubmitting } from '@librechat/chat/react';+import '@testing-library/jest-dom';+import { RecoilRoot } from 'recoil';+import { DndProvider } from 'react-dnd';+import { useForm } from 'react-hook-form';+import { HTML5Backend } from 'react-dnd-html5-backend';+import { render, screen } from '@testing-library/react';+import { BrowserRouter as Router } from 'react-router-dom';+import { QueryKeys, EModelEndpoint } from 'librechat-data-provider';+import { QueryClient, QueryClientProvider } from '@tanstack/react-query';+import type { TFile, TConversation } from 'librechat-data-provider';+import type { ChatFormValues } from '~/common';+import { ChatContext, ChatFormProvider } from '~/Providers';+import { AuthContextProvider } from '~/hooks/AuthContext';+import ChatForm from '../ChatForm';+import '~/Providers/SteerHostContext';++let mockComposerLocked = false;++/** The batch card itself is covered by AskUserQuestionCollapse; this pins only+ * what ChatForm does with the lock, so the popover renders nothing here. */+jest.mock('~/hooks/Input/useAskAnswerMode', () => ({+ __esModule: true,+ default: () => ({+ active: mockComposerLocked,+ batchMode: mockComposerLocked,+ composerAnswers: false,+ composerLocked: mockComposerLocked,+ popoverVisible: false,+ liveAsk: null,+ draftId: null,+ otherLabel: undefined,+ handleComposerKeyDown: () => false,+ }),+}));++const conversation = {+ conversationId: 'conversation-1',+ endpoint: EModelEndpoint.agents,+ agent_id: 'agent-1',+ title: 'Batch',+} as TConversation;++const draft = Array.from({ length: 30 }, (_, line) => `draft line ${line}`).join('\n');++function Harness() {+ const [files, setFiles] = useAtom(filesFamily(0));+ const [isSubmitting] = useAtom(isSubmittingFamily(0));+ const [, setFilesLoading] = useState(false);+ const methods = useForm<ChatFormValues>({ defaultValues: { text: draft } });++ const chatHelpers = useMemo(+ () =>+ ({+ index: 0,+ conversation,+ setConversation: () => undefined,+ files,+ setFiles,+ isSubmitting,+ setIsSubmitting: () => undefined,+ filesLoading: false,+ setFilesLoading,+ newConversation: () => undefined,+ handleStopGenerating: () => undefined,+ stopGenerating: () => undefined,+ getMessages: () => undefined,+ setMessages: () => undefined,+ ask: () => undefined,+ regenerate: () => undefined,+ setSiblingIdx: () => undefined,+ abortScroll: false,+ setAbortScroll: () => undefined,+ preset: null,+ setPreset: () => undefined,+ optionSettings: {},+ setOptionSettings: () => undefined,+ handleRegenerate: () => undefined,+ handleContinue: () => undefined,+ }) as unknown as React.ContextType<typeof ChatContext>,+ [files, setFiles, isSubmitting],+ );++ return (+ <ChatFormProvider {...methods}>+ <ChatContext.Provider value={chatHelpers}>+ <ChatForm index={0} isLandingPage={false} footerBelow={false} centerFormOnLanding={false} />+ </ChatContext.Provider>+ </ChatFormProvider>+ );+}++function renderComposer() {+ const queryClient = new QueryClient({+ defaultOptions: { queries: { retry: false }, mutations: { retry: false } },+ });+ queryClient.setQueryData<TFile[]>([QueryKeys.files], []);+ queryClient.setQueryData([QueryKeys.endpoints], { [EModelEndpoint.agents]: { order: 0 } });++ return render(+ <QueryClientProvider client={queryClient}>+ <RecoilRoot>+ <Router>+ <AuthContextProvider authConfig={{ loginRedirect: '', test: true }}>+ <DndProvider backend={HTML5Backend}>+ <Harness />+ </DndProvider>+ </AuthContextProvider>+ </Router>+ </RecoilRoot>+ </QueryClientProvider>,+ );+}++afterEach(() => {+ resetSubmitting(getDefaultStore());+ getDefaultStore().set(filesFamily(0), new Map());+});++describe('ChatForm behind a batch question', () => {+ beforeEach(() => {+ localStorage.clear();+ });++ test('holds a long draft to one line while the batch card owns the composer', async () => {+ mockComposerLocked = true;+ renderComposer();++ const textarea = await screen.findByTestId('text-input');+ expect(textarea).toBeDisabled();+ expect(textarea).toHaveClass('max-h-[3.25rem]');+ expect(textarea).not.toHaveClass('max-h-[45vh]');+ }, 20000);++ test('gives the draft its full height back once the batch releases the composer', async () => {+ mockComposerLocked = false;+ renderComposer();++ const textarea = await screen.findByTestId('text-input');+ expect(textarea).toBeEnabled();+ expect(textarea).toHaveClass('max-h-[45vh]');+ expect(textarea).not.toHaveClass('max-h-[3.25rem]');+ }, 20000);+});diff --git a/e2e/specs/mock/scenarios/ask-question-refine.spec.ts b/e2e/specs/mock/scenarios/ask-question-refine.spec.tsindex e04d229831..e06ada2c64 100644--- a/e2e/specs/mock/scenarios/ask-question-refine.spec.ts+++ b/e2e/specs/mock/scenarios/ask-question-refine.spec.ts@@ -289,6 +289,54 @@ test.describe('ask question batch refinements', () => {}});+ test('a long composer draft keeps the batch card and its controls on screen @scenario:ask-batch-fits-above-long-draft', async ({+ page,+ }) => {+ test.setTimeout(120000);+ await page.setViewportSize({ width: 1280, height: 640 });+ const label = `${Date.now()}-${Math.floor(Math.random() * 1e4)}`;+ const questions = buildBatch(label);+ const draft = Array.from({ length: 40 }, (_, line) => `draft line ${line + 1}`).join('\n');+ let agentId: string | undefined;++ try {+ const agent = await createAgent(page);+ agentId = agent.id;+ const popover = await openBatch(page, agent, label);++ /** The composer is only writable while the card owns the batch, so the draft is+ * typed there and the batch moved back over it, the order a user would hit. */+ await popover.getByRole('button', { name: MOVE_TO_CHAT }).click();+ await expect(popover).toBeHidden();+ const composer = page.getByRole('textbox', { name: 'Message input' });+ await composer.fill(draft);+ await expect+ .poll(async () => (await composer.boundingBox())?.height ?? 0)+ .toBeGreaterThan(640 * 0.4);++ await messagesView(page).getByRole('button', { name: MOVE_TO_COMPOSER }).click();+ await expect(popover).toBeVisible();+ await expect(composer).toBeDisabled();+ await expect(composer).toHaveValue(draft);++ await expect+ .poll(async () => (await popover.boundingBox())?.y ?? -1, { timeout: 5000 })+ .toBeGreaterThanOrEqual(0);+ await expect(popover.getByText(questions[0].question, { exact: true })).toBeInViewport();+ await expect(popover.getByRole('button', { name: MOVE_TO_CHAT })).toBeInViewport();++ await popover.getByRole('button', { name: MOVE_TO_CHAT }).click();+ await expect(popover).toBeHidden();+ await expect(composer).toBeEnabled();+ await expect(composer).toHaveValue(draft);+ await expect+ .poll(async () => (await composer.boundingBox())?.height ?? 0)+ .toBeGreaterThan(640 * 0.4);+ } finally {+ await cleanupAgent(page, agentId);+ }+ });+test('a typed answer deselects the option and locks the rows until cleared @scenario:ask-typed-answer-locks-options', async ({page,}) => {