mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-11-18 22:14:27 +00:00
* 🎯 fix: Keep Scroll-to-Bottom Clear of Composer Panels The `ask_user_question` popover and the tool-approval review float up from the composer (`bottom-28`, measured from the composer's bottom) while the scroll-to-bottom control floats up from the thread's edge (20px above the composer's top), so the two meet on the panel's footer whenever the composer is taller than 92px — it is 96px empty. Each panel now registers itself as an open composer overlay for exactly as long as it renders, and the control stands down while any is open. The in-flight steer stack keeps its existing lift: it publishes its height and stays short enough for that to read well. The overlap also exposed a stagger that was there all along: the control sat flush with the column edge at 40px, while every composer control is 36px on the `theme-control` tokens and Send is inset `mr-2`. It now shares Send's inset and geometry, so the two read as one rail rather than two edges. `ScrollButton` moves out of `MessagesView` into its own module so the gate can be exercised against a stubbed IntersectionObserver. * 🎯 refactor: Keep the Scroll Control on the Shared Button and Host Surface Codex round 1. The control goes back on the shared `Button`, which gains the composer row's geometry as `size="icon-theme"` (`size-theme-control p-0`) and `shape="round"` (`rounded-theme-control-round`) instead of a feature- local class list. The overlay count and its registration hook move out of the global store into `Chat/Input/overlay.ts`, since only chat panels write it and only the chat thread reads it. The extracted `ScrollButton` and `ScrollToBottom` no longer read `showScrollButton` / `maximizeChatSpace` from the app store: `MessagesView` takes both from the host's `ChatSurface` and passes them down, and the subagent activity host does the same for the column width.
74 lines
2.8 KiB
TypeScript
74 lines
2.8 KiB
TypeScript
import { forwardRef } from 'react';
|
|
import { ChevronDown } from 'lucide-react';
|
|
import { Button } from '@librechat/client';
|
|
import { useLocalize } from '~/hooks';
|
|
import { cn } from '~/utils';
|
|
|
|
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.
|
|
*/
|
|
overlayHeight?: number;
|
|
/**
|
|
* True once the enter transition has settled. The wrapper spans the column
|
|
* and stays inert so it never swallows clicks meant for the thread, which
|
|
* leaves the button to opt back in; gate that opt-in, because a descendant
|
|
* that opts in is hit-testable even while its parent fades, so a fading or
|
|
* not-yet-visible button would still take the click. Pointers are only half
|
|
* of it: until this is true the control is also disabled, since an enabled
|
|
* button stays in the tab order and answers Enter however it paints.
|
|
*/
|
|
interactive?: boolean;
|
|
};
|
|
|
|
const ScrollToBottom = forwardRef<HTMLDivElement, Props>(
|
|
({ scrollHandler, maximizeChatSpace, overlayHeight = 0, interactive = false }, ref) => {
|
|
const localize = useLocalize();
|
|
|
|
return (
|
|
<div
|
|
ref={ref}
|
|
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. */}
|
|
<div
|
|
className={cn(
|
|
'mx-auto flex justify-end sm:px-2',
|
|
maximizeChatSpace ? 'max-w-full' : 'md:max-w-3xl xl:max-w-4xl',
|
|
)}
|
|
>
|
|
<Button
|
|
type="button"
|
|
variant="outline"
|
|
size="icon-theme"
|
|
shape="round"
|
|
onClick={scrollHandler}
|
|
disabled={!interactive}
|
|
aria-label={localize('com_ui_scroll_to_bottom')}
|
|
className={cn(
|
|
'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 not
|
|
dim the control on its way in on top of it. */
|
|
'disabled:opacity-100',
|
|
interactive ? 'pointer-events-auto' : 'pointer-events-none',
|
|
)}
|
|
>
|
|
<ChevronDown className="size-4" aria-hidden="true" />
|
|
</Button>
|
|
</div>
|
|
</div>
|
|
);
|
|
},
|
|
);
|
|
|
|
ScrollToBottom.displayName = 'ScrollToBottom';
|
|
|
|
export default ScrollToBottom;
|