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: Hide Scroll-to-Bottom Under Composer Panels (#15746)
Danny Avilaab5273058207
diff --git a/client/src/components/Chat/Input/AskUserQuestionPopover.tsx b/client/src/components/Chat/Input/AskUserQuestionPopover.tsxindex 1c967d48d0..246850bd25 100644--- a/client/src/components/Chat/Input/AskUserQuestionPopover.tsx+++ b/client/src/components/Chat/Input/AskUserQuestionPopover.tsx@@ -6,6 +6,7 @@ import AskUserQuestions from '~/components/Chat/Messages/Content/AskUserQuestionimport useAskAnswerMode from '~/hooks/Input/useAskAnswerMode';import AskOptions from '~/components/Chat/ask/options';import { useChatFormContext } from '~/Providers';+import { useComposerOverlay } from './overlay';import { useLocalize } from '~/hooks';/**@@ -19,7 +20,9 @@ import { useLocalize } from '~/hooks';* free-form answer box. The chevron moves the question to the chat card and* releases the composer (the card's chevron moves it back). Pure rendering* off {@link useAskAnswerMode}; disappears the moment an answer submits from- * any surface, and locks while one is in flight.+ * any surface, and locks while one is in flight. Registers as an open composer+ * panel for as long as it shows, so the thread's scroll-to-bottom control+ * stands down instead of landing on its footer.*/function AskUserQuestionPopoverContent({conversationId,@@ -29,6 +32,7 @@ function AskUserQuestionPopoverContent({textAreaRef?: React.RefObject<HTMLTextAreaElement>;}) {const ask = useAskAnswerMode(conversationId);+ useComposerOverlay(conversationId, ask.popoverVisible);if (!ask.popoverVisible || !ask.liveAsk) {return null;diff --git a/client/src/components/Chat/Input/__tests__/appearanceTokens.spec.ts b/client/src/components/Chat/Input/__tests__/appearanceTokens.spec.tsindex 82147cd3f6..4e9aa1379c 100644--- a/client/src/components/Chat/Input/__tests__/appearanceTokens.spec.ts+++ b/client/src/components/Chat/Input/__tests__/appearanceTokens.spec.ts@@ -21,6 +21,10 @@ const themedControls = [['Files/AttachFile.tsx', ['size-theme-control', 'rounded-theme-control-round']],['Files/AttachFileMenu.tsx', ['size-theme-control', 'rounded-theme-control-round']],['ToolsDropdown.tsx', ['size-theme-control', 'rounded-theme-control-round']],+ /** Floats over the thread rather than sitting in the composer, but stacks+ * over Send on the same rail, so it takes the row's geometry from the shared+ * `Button` recipe; the tokens behind those variants are asserted in `Button.spec`. */+ ['../../Messages/ScrollToBottom.tsx', ['size="icon-theme"', 'shape="round"']],] as const;describe('Composer appearance tokens', () => {diff --git a/client/src/components/Chat/Input/__tests__/overlay.spec.tsx b/client/src/components/Chat/Input/__tests__/overlay.spec.tsxnew file mode 100644index 0000000000..f798fd7c5c--- /dev/null+++ b/client/src/components/Chat/Input/__tests__/overlay.spec.tsx@@ -0,0 +1,61 @@+import React from 'react';+import { Provider, createStore } from 'jotai';+import { renderHook } from '@testing-library/react';+import { composerOverlayCountFamily, useComposerOverlay } from '../overlay';++const CONVO_ID = 'convo-1';++describe('useComposerOverlay', () => {+ let jotaiStore = createStore();+ const wrapper = ({ children }: { children: React.ReactNode }) => (+ <Provider store={jotaiStore}>{children}</Provider>+ );+ const count = (conversationId = CONVO_ID) =>+ jotaiStore.get(composerOverlayCountFamily(conversationId));++ beforeEach(() => {+ jotaiStore = createStore();+ });++ it('counts the panel only while it is open', () => {+ const { rerender, unmount } = renderHook(+ ({ open }: { open: boolean }) => useComposerOverlay(CONVO_ID, open),+ { wrapper, initialProps: { open: false } },+ );+ expect(count()).toBe(0);++ rerender({ open: true });+ expect(count()).toBe(1);++ rerender({ open: false });+ expect(count()).toBe(0);++ rerender({ open: true });+ unmount();+ expect(count()).toBe(0);+ });++ it('adds up across panels so the last to close releases the band', () => {+ const first = renderHook(() => useComposerOverlay(CONVO_ID, true), { wrapper });+ const second = renderHook(() => useComposerOverlay(CONVO_ID, true), { wrapper });+ expect(count()).toBe(2);++ first.unmount();+ expect(count()).toBe(1);++ second.unmount();+ expect(count()).toBe(0);+ });++ it('follows the panel to another conversation', () => {+ const { rerender } = renderHook(+ ({ conversationId }: { conversationId: string }) => useComposerOverlay(conversationId, true),+ { wrapper, initialProps: { conversationId: CONVO_ID } },+ );+ expect(count()).toBe(1);++ rerender({ conversationId: 'convo-2' });+ expect(count()).toBe(0);+ expect(count('convo-2')).toBe(1);+ });+});diff --git a/client/src/components/Chat/Input/overlay.ts b/client/src/components/Chat/Input/overlay.tsnew file mode 100644index 0000000000..393187796c--- /dev/null+++ b/client/src/components/Chat/Input/overlay.ts@@ -0,0 +1,33 @@+import { useEffect } from 'react';+import { atomFamily } from 'jotai/utils';+import { atom, useSetAtom } from 'jotai';++/**+ * How many composer panels are open over the bottom of a conversation's+ * thread — an `ask_user_question` popover, a tool-approval review. They float+ * up from the composer (`bottom-28`) while the scroll-to-bottom control floats+ * up from the thread's edge, so the two meet in the same strip whenever the+ * composer is taller than ~92px, which it always is. The control stands down+ * while the count is above zero. Each panel registers through+ * {@link useComposerOverlay} for exactly as long as it renders, so the count+ * can never go stale; like `steerOverlayHeightFamily`, the family is never+ * GC'd but holds one number per visited conversation.+ */+export const composerOverlayCountFamily = atomFamily((_conversationId: string) => atom<number>(0));++/**+ * Registers a composer panel as open for `conversationId` while `open` holds.+ * Call it before the panel's early return; the effect's cleanup unregisters on+ * close, unmount, and conversation change alike.+ */+export function useComposerOverlay(conversationId: string, open: boolean): void {+ const setCount = useSetAtom(composerOverlayCountFamily(conversationId));++ useEffect(() => {+ if (!open) {+ return;+ }+ setCount((count) => count + 1);+ return () => setCount((count) => count - 1);+ }, [open, setCount]);+}diff --git a/client/src/components/Chat/Messages/MessagesView.tsx b/client/src/components/Chat/Messages/MessagesView.tsxindex 8b6269f754..0b7642f1b9 100644--- a/client/src/components/Chat/Messages/MessagesView.tsx+++ b/client/src/components/Chat/Messages/MessagesView.tsx@@ -1,99 +1,23 @@-import { memo, useState, useRef, useEffect } from 'react';+import { useState } from 'react';import { useAtomValue } from 'jotai';import { useRecoilValue } from 'recoil';import { Constants } from 'librechat-data-provider';-import { CSSTransition } from 'react-transition-group';import type { TMessage } from 'librechat-data-provider';import { useScreenshot, useMessageScrolling, useScrollbarGutter, useLocalize } from '~/hooks';import { MessagesViewProvider, useChatContext, useFileMapContext } from '~/Providers';import { RowMountProvider, useProgressiveRowMount } from '~/hooks/Messages';-import ScrollToBottom from '~/components/Messages/ScrollToBottom';+import { useChatSurface } from '~/components/Chat/Subagents/surface';import useThreadRows from '~/hooks/Messages/useThreadRows';import { steerOverlayHeightFamily } from '~/store/steer';import { autoScrollAtom } from '~/store/autoScroll';import { FLAT_THREAD, ThreadList } from './Thread';import { fontSizeAtom } from '~/store/fontSize';import MultiMessage from './MultiMessage';+import ScrollButton from './ScrollButton';import MessageNav from './MessageNav';import { cn } from '~/utils';import store from '~/store';-const intersectionThreshold = 0.85;-const visibilityDebounceRate = 150;--/**- * Owns the messages-end IntersectionObserver and the button visibility state,- * so scroll-position flips re-render only this component instead of the whole- * message tree host. Intersection is reported up through `onNearBottomChange`- * for the resize-follow logic in `useMessageScrolling`.- */-const ScrollButton = memo(function ScrollButton({- scrollableRef,- messagesEndRef,- scrollHandler,- onNearBottomChange,- overlayHeight,-}: {- scrollableRef: React.RefObject<HTMLDivElement | null>;- messagesEndRef: React.RefObject<HTMLDivElement | null>;- scrollHandler: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;- onNearBottomChange: (isNearBottom: boolean) => void;- overlayHeight: number;-}) {- const scrollButtonPreference = useRecoilValue(store.showScrollButton);- const [showScrollButton, setShowScrollButton] = useState(false);- const [isSettled, setIsSettled] = useState(false);- const scrollToBottomRef = useRef<HTMLDivElement>(null);- const timeoutIdRef = useRef<NodeJS.Timeout>();-- useEffect(() => {- if (!messagesEndRef.current || !scrollableRef.current) {- return;- }-- const observer = new IntersectionObserver(- ([entry]) => {- onNearBottomChange(entry.isIntersecting);- clearTimeout(timeoutIdRef.current);- timeoutIdRef.current = setTimeout(() => {- setShowScrollButton(!entry.isIntersecting);- }, visibilityDebounceRate);- },- { root: scrollableRef.current, threshold: intersectionThreshold },- );-- observer.observe(messagesEndRef.current);-- return () => {- observer.disconnect();- clearTimeout(timeoutIdRef.current);- };- }, [messagesEndRef, scrollableRef, onNearBottomChange]);-- return (- <CSSTransition- in={showScrollButton && scrollButtonPreference}- timeout={{- enter: 300,- exit: 180,- }}- classNames="scroll-animation"- unmountOnExit={true}- appear={true}- nodeRef={scrollToBottomRef}- onEntered={() => setIsSettled(true)}- onExit={() => setIsSettled(false)}- >- <ScrollToBottom- ref={scrollToBottomRef}- scrollHandler={scrollHandler}- overlayHeight={overlayHeight}- interactive={isSettled}- />- </CSSTransition>- );-});-function MessagesViewContent({messagesTree: _messagesTree,messages,@@ -124,6 +48,7 @@ function MessagesViewContent({const { index, latestMessageDepth } = useChatContext();const isSubmitting = useRecoilValue(store.isSubmittingFamily(index));+ const { showScrollButton, maximizeChatSpace } = useChatSurface();const autoScroll = useAtomValue(autoScrollAtom);/** Re-arm from the conversation that owns the RENDERED tree: the Recoil* conversation id lags the route during warm-cache navigation, and keying@@ -141,9 +66,8 @@ function MessagesViewContent({/** The in-flight steer overlay floats above the composer over the bottom of* the thread (see `InFlightSteers`); reserve an equal band here so the* newest message rests above it and older ones scroll behind. */- const steerOverlayHeight = useAtomValue(- steerOverlayHeightFamily(conversationId ?? Constants.NEW_CONVO),- );+ const overlayConversationId = conversationId ?? Constants.NEW_CONVO;+ const steerOverlayHeight = useAtomValue(steerOverlayHeightFamily(overlayConversationId));return (<>@@ -212,6 +136,9 @@ function MessagesViewContent({</div><ScrollButton+ conversationId={overlayConversationId}+ enabled={showScrollButton}+ maximizeChatSpace={maximizeChatSpace}scrollableRef={scrollableRef}messagesEndRef={messagesEndRef}scrollHandler={handleSmoothToRef}diff --git a/client/src/components/Chat/Messages/ScrollButton.tsx b/client/src/components/Chat/Messages/ScrollButton.tsxnew file mode 100644index 0000000000..39da1701a9--- /dev/null+++ b/client/src/components/Chat/Messages/ScrollButton.tsx@@ -0,0 +1,99 @@+import { memo, useState, useRef, useEffect } from 'react';+import { useAtomValue } from 'jotai';+import { CSSTransition } from 'react-transition-group';+import { composerOverlayCountFamily } from '~/components/Chat/Input/overlay';+import ScrollToBottom from '~/components/Messages/ScrollToBottom';++const intersectionThreshold = 0.85;+const visibilityDebounceRate = 150;++/**+ * Owns the messages-end IntersectionObserver and the button visibility state,+ * so scroll-position flips re-render only this component instead of the whole+ * message tree host. Intersection is reported up through `onNearBottomChange`+ * for the resize-follow logic in `useMessageScrolling`.+ *+ * Stands down while a composer panel (an `ask_user_question` popover, a+ * tool-approval review) is open over the bottom of the thread: the panel+ * floats up from the composer and the button up from the thread's edge, so+ * the two would meet on the panel's footer. The in-flight steer stack is the+ * one overlay the button lifts clear of instead — it publishes its height as+ * `overlayHeight` and stays short enough for that to read well.+ */+const ScrollButton = memo(function ScrollButton({+ conversationId,+ enabled,+ maximizeChatSpace,+ scrollableRef,+ messagesEndRef,+ scrollHandler,+ onNearBottomChange,+ overlayHeight,+}: {+ conversationId: string;+ /** The user's show-scroll-button preference, handed down by the host. */+ enabled: boolean;+ /** The host's chat-width preference, which sets the column the control sits in. */+ maximizeChatSpace: boolean;+ scrollableRef: React.RefObject<HTMLDivElement | null>;+ messagesEndRef: React.RefObject<HTMLDivElement | null>;+ scrollHandler: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;+ onNearBottomChange: (isNearBottom: boolean) => void;+ overlayHeight: number;+}) {+ const panelOpen = useAtomValue(composerOverlayCountFamily(conversationId)) > 0;+ const [showScrollButton, setShowScrollButton] = useState(false);+ const [isSettled, setIsSettled] = useState(false);+ const scrollToBottomRef = useRef<HTMLDivElement>(null);+ const timeoutIdRef = useRef<NodeJS.Timeout>();++ useEffect(() => {+ if (!messagesEndRef.current || !scrollableRef.current) {+ return;+ }++ const observer = new IntersectionObserver(+ ([entry]) => {+ onNearBottomChange(entry.isIntersecting);+ clearTimeout(timeoutIdRef.current);+ timeoutIdRef.current = setTimeout(() => {+ setShowScrollButton(!entry.isIntersecting);+ }, visibilityDebounceRate);+ },+ { root: scrollableRef.current, threshold: intersectionThreshold },+ );++ observer.observe(messagesEndRef.current);++ return () => {+ observer.disconnect();+ clearTimeout(timeoutIdRef.current);+ };+ }, [messagesEndRef, scrollableRef, onNearBottomChange]);++ return (+ <CSSTransition+ in={showScrollButton && enabled && !panelOpen}+ timeout={{+ enter: 300,+ exit: 180,+ }}+ classNames="scroll-animation"+ unmountOnExit={true}+ appear={true}+ nodeRef={scrollToBottomRef}+ onEntered={() => setIsSettled(true)}+ onExit={() => setIsSettled(false)}+ >+ <ScrollToBottom+ ref={scrollToBottomRef}+ scrollHandler={scrollHandler}+ maximizeChatSpace={maximizeChatSpace}+ overlayHeight={overlayHeight}+ interactive={isSettled}+ />+ </CSSTransition>+ );+});++export default ScrollButton;diff --git a/client/src/components/Chat/Messages/__tests__/ScrollButton.spec.tsx b/client/src/components/Chat/Messages/__tests__/ScrollButton.spec.tsxnew file mode 100644index 0000000000..30ae84f74e--- /dev/null+++ b/client/src/components/Chat/Messages/__tests__/ScrollButton.spec.tsx@@ -0,0 +1,152 @@+import React from 'react';+import { Provider, createStore } from 'jotai';+import { act, render, screen } from '@testing-library/react';+import { composerOverlayCountFamily } from '~/components/Chat/Input/overlay';+import ScrollButton from '../ScrollButton';++jest.mock('~/hooks', () => ({+ useLocalize: () => (key: string) => key,+}));++const CONVO_ID = 'convo-1';+/** `visibilityDebounceRate` in the component, plus the exit transition. */+const VISIBILITY_DEBOUNCE = 150;+const EXIT_TRANSITION = 180;++class MockIntersectionObserver {+ static instances: MockIntersectionObserver[] = [];+ static last(): MockIntersectionObserver {+ const last = MockIntersectionObserver.instances[MockIntersectionObserver.instances.length - 1];+ if (last == null) {+ throw new Error('no IntersectionObserver was created');+ }+ return last;+ }++ callback: IntersectionObserverCallback;+ observe = jest.fn();+ unobserve = jest.fn();+ disconnect = jest.fn();+ takeRecords = jest.fn(() => []);++ constructor(callback: IntersectionObserverCallback) {+ this.callback = callback;+ MockIntersectionObserver.instances.push(this);+ }++ trigger(isIntersecting: boolean) {+ this.callback(+ [{ isIntersecting } as IntersectionObserverEntry],+ this as unknown as IntersectionObserver,+ );+ }+}++const originalIO = global.IntersectionObserver;+let jotaiStore = createStore();++function renderButton({ enabled = true }: { enabled?: boolean } = {}) {+ const scrollable = document.createElement('div');+ const messagesEnd = document.createElement('div');+ scrollable.appendChild(messagesEnd);+ return render(+ <Provider store={jotaiStore}>+ <ScrollButton+ conversationId={CONVO_ID}+ enabled={enabled}+ maximizeChatSpace={false}+ scrollableRef={{ current: scrollable }}+ messagesEndRef={{ current: messagesEnd }}+ scrollHandler={jest.fn()}+ onNearBottomChange={jest.fn()}+ overlayHeight={0}+ />+ </Provider>,+ );+}++/** The thread end leaves the viewport and the visibility debounce settles. */+const scrollAway = () =>+ act(() => {+ MockIntersectionObserver.last().trigger(false);+ jest.advanceTimersByTime(VISIBILITY_DEBOUNCE + 1);+ });++const setOpenPanels = (count: number) =>+ act(() => {+ jotaiStore.set(composerOverlayCountFamily(CONVO_ID), count);+ });++const finishExit = () =>+ act(() => {+ jest.advanceTimersByTime(EXIT_TRANSITION + 1);+ });++const button = () => screen.queryByRole('button', { name: 'com_ui_scroll_to_bottom' });++describe('ScrollButton', () => {+ beforeEach(() => {+ jest.useFakeTimers();+ MockIntersectionObserver.instances = [];+ global.IntersectionObserver =+ MockIntersectionObserver as unknown as typeof IntersectionObserver;+ jotaiStore = createStore();+ });++ afterEach(() => {+ global.IntersectionObserver = originalIO;+ jest.useRealTimers();+ });++ it('appears once the thread end scrolls out of view', () => {+ renderButton();+ expect(button()).toBeNull();++ scrollAway();+ expect(button()).toBeInTheDocument();+ });++ /* A pause panel floats up from the composer over the same corner; rather+ than land on its footer, the control leaves the band to the panel. */+ it('stands down while a composer panel is open and returns when it closes', () => {+ renderButton();+ scrollAway();+ expect(button()).toBeInTheDocument();++ setOpenPanels(1);+ finishExit();+ expect(button()).toBeNull();++ setOpenPanels(0);+ expect(button()).toBeInTheDocument();+ });++ it('waits for the last open panel, not the first to close', () => {+ renderButton();+ scrollAway();++ setOpenPanels(2);+ finishExit();+ expect(button()).toBeNull();++ setOpenPanels(1);+ finishExit();+ expect(button()).toBeNull();++ setOpenPanels(0);+ expect(button()).toBeInTheDocument();+ });++ it('does not show a scrolled-up thread under an already open panel', () => {+ setOpenPanels(1);+ renderButton();+ scrollAway();+ expect(button()).toBeNull();+ });++ it('stays hidden when the host preference turns it off', () => {+ renderButton({ enabled: false });+ scrollAway();+ expect(button()).toBeNull();+ });+});diff --git a/client/src/components/Chat/Subagents/SubagentActivity.tsx b/client/src/components/Chat/Subagents/SubagentActivity.tsxindex 5811afacd7..ad6d90f255 100644--- a/client/src/components/Chat/Subagents/SubagentActivity.tsx+++ b/client/src/components/Chat/Subagents/SubagentActivity.tsx@@ -141,7 +141,7 @@ export function SubagentActivityScrollSurface({const scrollButtonRef = useRef<HTMLDivElement>(null);const [isAtBottom, setIsAtBottom] = useState(true);const [isSettled, setIsSettled] = useState(false);- const { showScrollButton: scrollButtonPreference } = useChatSurface();+ const { showScrollButton: scrollButtonPreference, maximizeChatSpace } = useChatSurface();useEffect(() => {const scroll = scrollRef.current;@@ -194,6 +194,7 @@ export function SubagentActivityScrollSurface({<ScrollToBottomref={scrollButtonRef}scrollHandler={scrollToBottom}+ maximizeChatSpace={maximizeChatSpace}interactive={isSettled}/></CSSTransition>diff --git a/client/src/components/Chat/approval/Review.tsx b/client/src/components/Chat/approval/Review.tsxindex 586b796e34..b38742afa7 100644--- a/client/src/components/Chat/approval/Review.tsx+++ b/client/src/components/Chat/approval/Review.tsx@@ -12,6 +12,7 @@ import {import { buildApprovalPreview, buildApprovalPreviews } from '~/components/Chat/approval/preview';import { pendingApprovalActionFamily } from '~/components/Chat/approval/state';import ToolApproval from '~/components/Chat/Messages/Content/ToolApproval';+import { useComposerOverlay } from '~/components/Chat/Input/overlay';import { useLocalize } from '~/hooks';const approvalPanelOpenFamily = atomFamily((_conversationId: string) => atom(false));@@ -68,6 +69,8 @@ export const PendingToolApprovalPanel = memo(function PendingToolApprovalPanel({}}, [actionId, setOpen]);+ useComposerOverlay(conversationId, open && pendingAction != null);+const reviews = useMemo(() => {if (pendingAction == null) return [];const configById = new Map(diff --git a/client/src/components/Chat/approval/__tests__/Review.test.tsx b/client/src/components/Chat/approval/__tests__/Review.test.tsxindex c0b894a784..0441bcefa2 100644--- a/client/src/components/Chat/approval/__tests__/Review.test.tsx+++ b/client/src/components/Chat/approval/__tests__/Review.test.tsx@@ -4,6 +4,7 @@ import { Provider as JotaiProvider, createStore } from 'jotai';import { fireEvent, render, screen } from '@testing-library/react';import type { Agents } from 'librechat-data-provider';import { PendingToolApprovalButton, PendingToolApprovalPanel } from '../Review';+import { composerOverlayCountFamily } from '~/components/Chat/Input/overlay';import ApprovalProvider from '../../Messages/Content/ApprovalContext';import { pendingApprovalActionFamily } from '../state';@@ -102,6 +103,7 @@ describe('PendingToolApproval', () => {);expect(await screen.findByRole('region', { name: 'Review 2 actions' })).toBeInTheDocument();+ expect(jotaiStore.get(composerOverlayCountFamily('conversation-1'))).toBe(1);expect(screen.getByText(/Create src\/new\.ts/)).toBeInTheDocument();expect(screen.getByText('npm test -- new')).toBeInTheDocument();expect(screen.getByText('0 of 2 decisions selected')).toBeInTheDocument();@@ -116,6 +118,7 @@ describe('PendingToolApproval', () => {fireEvent.click(screen.getByRole('button', { name: 'Collapse' }));expect(screen.queryByRole('region', { name: 'Review 2 actions' })).not.toBeInTheDocument();+ expect(jotaiStore.get(composerOverlayCountFamily('conversation-1'))).toBe(0);expect(screen.getByTestId('pending-tool-approval-button')).toHaveAttribute('aria-expanded','false',diff --git a/client/src/components/Messages/ScrollToBottom.tsx b/client/src/components/Messages/ScrollToBottom.tsxindex b993f17fec..5c16ae865d 100644--- a/client/src/components/Messages/ScrollToBottom.tsx+++ b/client/src/components/Messages/ScrollToBottom.tsx@@ -1,13 +1,13 @@import { forwardRef } from 'react';-import { useRecoilValue } from 'recoil';import { ChevronDown } from 'lucide-react';import { Button } from '@librechat/client';import { useLocalize } from '~/hooks';import { cn } from '~/utils';-import store from '~/store';type Props = {scrollHandler: React.MouseEventHandler<HTMLButtonElement>;+ /** The host's chat-width preference: the control sits in the composer's column. */+ maximizeChatSpace: boolean;/*** Height of the in-flight steer overlay, which stacks upward from the* composer into this same corner. Lifts the button clear of it.@@ -26,9 +26,8 @@ type Props = {};const ScrollToBottom = forwardRef<HTMLDivElement, Props>(- ({ scrollHandler, overlayHeight = 0, interactive = false }, ref) => {+ ({ scrollHandler, maximizeChatSpace, overlayHeight = 0, interactive = false }, ref) => {const localize = useLocalize();- const maximizeChatSpace = useRecoilValue(store.maximizeChatSpace);return (<div@@ -36,21 +35,26 @@ const ScrollToBottom = forwardRef<HTMLDivElement, Props>(className="scrollbar-gutter-spacer pointer-events-none absolute inset-x-0 z-10"style={{ bottom: `calc(1.25rem + ${overlayHeight}px)` }}>+ {/* The composer's own column, so the control stacks over the send+ button one row down: the same end inset (`me-2`, mirroring Send's+ `mr-2`) and, through `icon-theme` + `round`, the same control+ geometry as every button in the composer's action row. */}<divclassName={cn(- 'mx-auto flex justify-end px-4 sm:px-2',+ 'mx-auto flex justify-end sm:px-2',maximizeChatSpace ? 'max-w-full' : 'md:max-w-3xl xl:max-w-4xl',)}><Buttontype="button"variant="outline"- size="icon"+ size="icon-theme"+ shape="round"onClick={scrollHandler}disabled={!interactive}aria-label={localize('com_ui_scroll_to_bottom')}className={cn(- 'rounded-full bg-surface-chat/90 text-text-primary active:scale-[0.96] motion-reduce:active:scale-100',+ 'me-2 bg-surface-chat/90 text-text-primary active:scale-[0.96] motion-reduce:active:scale-100',/* The wrapper owns the fade, so being briefly unreachable must notdim the control on its way in on top of it. */'disabled:opacity-100',diff --git a/client/src/components/Messages/__tests__/ScrollToBottom.spec.tsx b/client/src/components/Messages/__tests__/ScrollToBottom.spec.tsxindex e131022a5e..cd7ea098d1 100644--- a/client/src/components/Messages/__tests__/ScrollToBottom.spec.tsx+++ b/client/src/components/Messages/__tests__/ScrollToBottom.spec.tsx@@ -1,7 +1,5 @@-import { RecoilRoot } from 'recoil';import { render, screen } from '@testing-library/react';import ScrollToBottom from '../ScrollToBottom';-import store from '~/store';jest.mock('~/hooks', () => ({useLocalize: () => (key: string) => key,@@ -17,17 +15,12 @@ const renderButton = ({interactive?: boolean;} = {}) =>render(- <RecoilRoot- initializeState={({ set }) => {- set(store.maximizeChatSpace, maximizeChatSpace);- }}- >- <ScrollToBottom- scrollHandler={jest.fn()}- overlayHeight={overlayHeight}- interactive={interactive}- />- </RecoilRoot>,+ <ScrollToBottom+ scrollHandler={jest.fn()}+ maximizeChatSpace={maximizeChatSpace}+ overlayHeight={overlayHeight}+ interactive={interactive}+ />,);describe('ScrollToBottom', () => {@@ -35,10 +28,23 @@ describe('ScrollToBottom', () => {const { container } = renderButton();const column = container.querySelector('.sm\\:px-2');- expect(column).toHaveClass('px-4', 'md:max-w-3xl', 'xl:max-w-4xl');+ expect(column).toHaveClass('md:max-w-3xl', 'xl:max-w-4xl');+ expect(column).not.toHaveClass('px-4');expect(container.firstChild).toHaveClass('scrollbar-gutter-spacer');});+ /* The send button sits one row below at the composer's `mr-2`. Sharing its+ end inset and control geometry is what makes the two read as one rail+ instead of a stagger: the column edge is 8px out, and `size-10` is 4px+ larger than every other control in the band. */+ it('stacks over the send button on the composer rail', () => {+ renderButton();+ const button = screen.getByRole('button');++ expect(button).toHaveClass('me-2', 'size-theme-control', 'rounded-theme-control-round');+ expect(button).not.toHaveClass('size-10');+ });+/* The gutter has to be reserved with padding rather than by reserving a realone: a scroll container clips, and the button's focus ring is paintedoutside its box. */diff --git a/packages/client/src/components/Button.spec.tsx b/packages/client/src/components/Button.spec.tsxindex 67cfe5b0c4..ca5825a06e 100644--- a/packages/client/src/components/Button.spec.tsx+++ b/packages/client/src/components/Button.spec.tsx@@ -18,6 +18,20 @@ describe('Button', () => {);});+ it('offers the composer action row geometry as a size and a shape', () => {+ render(+ <Button size="icon-theme" shape="round" aria-label="Scroll to bottom">+ v+ </Button>,+ );++ expect(screen.getByRole('button', { name: 'Scroll to bottom' })).toHaveClass(+ 'size-theme-control',+ 'p-0',+ 'rounded-theme-control-round',+ );+ });+it('renders the header-action toggle from semantic tokens', () => {render(<Button variant="header-action">Toggle</Button>);diff --git a/packages/client/src/components/Button.tsx b/packages/client/src/components/Button.tsxindex 49a8e082e9..f3d6f0f1ba 100644--- a/packages/client/src/components/Button.tsx+++ b/packages/client/src/components/Button.tsx@@ -21,8 +21,18 @@ type ButtonVariantOptions =| 'header-action'| null| undefined;- size?: 'default' | 'icon' | 'icon-sm' | 'icon-xs' | 'sm' | 'lg' | 'theme' | null | undefined;- shape?: 'default' | 'theme' | null | undefined;+ size?:+ | 'default'+ | 'icon'+ | 'icon-sm'+ | 'icon-xs'+ | 'icon-theme'+ | 'sm'+ | 'lg'+ | 'theme'+ | null+ | undefined;+ shape?: 'default' | 'theme' | 'round' | null | undefined;} & ClassProp)| undefined;@@ -79,11 +89,18 @@ const buttonVariantRecipe = cva(icon: 'size-10','icon-sm': 'size-8 p-0','icon-xs': 'size-7',+ /**+ * A square icon control on the theme's control height — the size of+ * every button in the composer's action row, for a control that has to+ * line up with them.+ */+ 'icon-theme': 'size-theme-control p-0',theme: 'h-theme-control gap-theme-compact px-theme-normal',},shape: {default: 'rounded-lg',theme: 'rounded-theme-control',+ round: 'rounded-theme-control-round',unset: '',},},