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
👐 a11y: Improve Fork and SplitText Accessibility (#7147)
Danny Aviladd23559d1fd7
diff --git a/client/src/components/Conversations/Fork.tsx b/client/src/components/Conversations/Fork.tsxindex 5aeb62aab4..381134f87c 100644--- a/client/src/components/Conversations/Fork.tsx+++ b/client/src/components/Conversations/Fork.tsx@@ -1,21 +1,13 @@import React, { useState, useRef } from 'react';import { useRecoilState } from 'recoil';+import * as Ariakit from '@ariakit/react';+import { VisuallyHidden } from '@ariakit/react';import { GitFork, InfoIcon } from 'lucide-react';-import * as Popover from '@radix-ui/react-popover';import { ForkOptions } from 'librechat-data-provider';import { GitCommit, GitBranchPlus, ListTree } from 'lucide-react';-import {- Checkbox,- HoverCard,- HoverCardTrigger,- HoverCardPortal,- HoverCardContent,-} from '~/components/ui';-import OptionHover from '~/components/SidePanel/Parameters/OptionHover';import { TranslationKeys, useLocalize, useNavigateToConvo } from '~/hooks';import { useForkConvoMutation } from '~/data-provider';import { useToastContext } from '~/Providers';-import { ESide } from '~/common';import { cn } from '~/utils';import store from '~/store';@@ -24,11 +16,11 @@ interface PopoverButtonProps {setting: ForkOptions;onClick: (setting: ForkOptions) => void;setActiveSetting: React.Dispatch<React.SetStateAction<TranslationKeys>>;- sideOffset?: number;timeoutRef: React.MutableRefObject<NodeJS.Timeout | null>;hoverInfo?: React.ReactNode | string;hoverTitle?: React.ReactNode | string;hoverDescription?: React.ReactNode | string;+ label: string;}const optionLabels: Record<ForkOptions, TranslationKeys> = {@@ -38,57 +30,83 @@ const optionLabels: Record<ForkOptions, TranslationKeys> = {[ForkOptions.DEFAULT]: 'com_ui_fork_from_message',};+const chevronDown = (+ <svg width="1em" height="1em" viewBox="0 0 20 20" fill="currentColor">+ <path+ fillRule="evenodd"+ clipRule="evenodd"+ d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z"+ />+ </svg>+);+const PopoverButton: React.FC<PopoverButtonProps> = ({children,setting,onClick,setActiveSetting,- sideOffset = 30,timeoutRef,hoverInfo,hoverTitle,hoverDescription,+ label,}) => {+ const localize = useLocalize();return (- <HoverCard openDelay={200}>- <Popover.Close- onClick={() => onClick(setting)}- onMouseEnter={() => {- if (timeoutRef.current) {- clearTimeout(timeoutRef.current);- timeoutRef.current = null;- }- setActiveSetting(optionLabels[setting]);- }}- onMouseLeave={() => {- if (timeoutRef.current) {- clearTimeout(timeoutRef.current);+ <Ariakit.HovercardProvider>+ <div className="flex flex-col items-center">+ <Ariakit.HovercardAnchor+ render={+ <Ariakit.Button+ onClick={() => onClick(setting)}+ onMouseEnter={() => {+ if (timeoutRef.current) {+ clearTimeout(timeoutRef.current);+ timeoutRef.current = null;+ }+ setActiveSetting(optionLabels[setting]);+ }}+ onMouseLeave={() => {+ if (timeoutRef.current) {+ clearTimeout(timeoutRef.current);+ }+ timeoutRef.current = setTimeout(() => {+ setActiveSetting(optionLabels[ForkOptions.DEFAULT]);+ }, 175);+ }}+ className="mx-1 max-w-14 flex-1 rounded-lg border-2 border-border-medium bg-surface-secondary text-text-secondary transition duration-300 ease-in-out hover:border-border-xheavy hover:bg-surface-hover hover:text-text-primary"+ aria-label={label}+ >+ {children}+ <VisuallyHidden>{label}</VisuallyHidden>+ </Ariakit.Button>}- timeoutRef.current = setTimeout(() => {- setActiveSetting(optionLabels[ForkOptions.DEFAULT]);- }, 175);- }}- className="mx-1 max-w-14 flex-1 rounded-lg border-2 bg-white text-gray-700 transition duration-300 ease-in-out hover:bg-gray-200 hover:text-gray-900 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-400 dark:hover:bg-gray-600 dark:hover:text-gray-100"- type="button"- >- {children}- </Popover.Close>- {((hoverInfo != null && hoverInfo !== '') ||- (hoverTitle != null && hoverTitle !== '') ||- (hoverDescription != null && hoverDescription !== '')) && (- <HoverCardPortal>- <HoverCardContent side="right" className="z-[999] w-80 dark:bg-gray-700" sideOffset={sideOffset}>+ />+ <Ariakit.HovercardDisclosure className="rounded-full text-text-secondary focus:outline-none focus:ring-2 focus:ring-ring">+ <VisuallyHidden>+ {localize('com_ui_fork_more_details_about', { 0: label })}+ </VisuallyHidden>+ {chevronDown}+ </Ariakit.HovercardDisclosure>+ {((hoverInfo != null && hoverInfo !== '') ||+ (hoverTitle != null && hoverTitle !== '') ||+ (hoverDescription != null && hoverDescription !== '')) && (+ <Ariakit.Hovercard+ gutter={16}+ className="z-[999] w-80 rounded-md border border-border-medium bg-surface-secondary p-4 text-text-primary shadow-md"+ portal={true}+ ><div className="space-y-2">- <p className="flex flex-col gap-2 text-sm text-gray-600 dark:text-gray-300">+ <p className="flex flex-col gap-2 text-sm text-text-secondary">{hoverInfo && hoverInfo}{hoverTitle && <span className="flex flex-wrap gap-1 font-bold">{hoverTitle}</span>}{hoverDescription && hoverDescription}</p></div>- </HoverCardContent>- </HoverCardPortal>- )}- </HoverCard>+ </Ariakit.Hovercard>+ )}+ </div>+ </Ariakit.HovercardProvider>);};@@ -114,6 +132,9 @@ export default function Fork({const [activeSetting, setActiveSetting] = useState(optionLabels.default);const [splitAtTarget, setSplitAtTarget] = useRecoilState(store.splitAtTarget);const [rememberGlobal, setRememberGlobal] = useRecoilState(store.rememberDefaultFork);+ const popoverStore = Ariakit.usePopoverStore({+ placement: 'top',+ });const forkConvo = useForkConvoMutation({onSuccess: (data) => {navigateToConvo(data.conversation);@@ -157,12 +178,12 @@ export default function Fork({};return (- <Popover.Root>- <Popover.Trigger asChild>+ <>+ <Ariakit.PopoverAnchor store={popoverStore}><buttonclassName={cn(- 'hover-button active rounded-md p-1 text-gray-500 hover:bg-gray-100 hover:text-gray-500 dark:text-gray-400/70 dark:hover:bg-gray-700 dark:hover:text-gray-200 disabled:dark:hover:text-gray-400 md:invisible md:group-hover:visible ',- 'data-[state=open]:active focus:opacity-100 data-[state=open]:bg-gray-100 data-[state=open]:text-gray-500 data-[state=open]:dark:bg-gray-700 data-[state=open]:dark:text-gray-200',+ 'hover-button active rounded-md p-1 text-gray-500 hover:bg-gray-100 hover:text-gray-500 dark:text-gray-400/70 dark:hover:bg-gray-700 dark:hover:text-gray-200 disabled:dark:hover:text-gray-400 md:invisible md:group-hover:visible',+ 'data-[state=open]:active focus:opacity-100 data-[state=open]:bg-gray-100 data-[state=open]:text-gray-500 data-[state=open]:dark:bg-gray-700 data-[state=open]:dark:text-gray-200',!isLast ? 'data-[state=open]:opacity-100 md:opacity-0 md:group-hover:opacity-100' : '',)}onClick={(e) => {@@ -175,155 +196,203 @@ export default function Fork({option: forkSetting,latestMessageId,});+ } else {+ popoverStore.toggle();}}}type="button"- title={localize('com_ui_fork')}+ aria-label={localize('com_ui_fork')}><GitFork className="h-4 w-4 hover:text-gray-500 dark:hover:bg-gray-700 dark:hover:text-gray-200 disabled:dark:hover:text-gray-400" /></button>- </Popover.Trigger>- <Popover.Portal>- <div dir="ltr">- <Popover.Content- side="top"- role="menu"- className="bg-token-surface-primary flex min-h-[120px] min-w-[215px] flex-col gap-3 overflow-hidden rounded-lg bg-white p-2 px-3 shadow-lg dark:bg-gray-700"- style={{ outline: 'none', pointerEvents: 'auto', boxSizing: 'border-box' }}- tabIndex={-1}- sideOffset={5}- align="center"- >- <div className="flex h-6 w-full items-center justify-center text-sm dark:text-gray-200">- {localize(activeSetting )}- <HoverCard openDelay={50}>- <HoverCardTrigger asChild>- <InfoIcon className="ml-auto flex h-4 w-4 gap-2 text-gray-500 dark:text-white/50" />- </HoverCardTrigger>- <HoverCardPortal>- <HoverCardContent- side="right"- className="z-[999] w-80 dark:bg-gray-700"- sideOffset={19}+ </Ariakit.PopoverAnchor>+ <Ariakit.Popover+ store={popoverStore}+ gutter={5}+ className="flex min-h-[120px] min-w-[215px] flex-col gap-3 overflow-hidden rounded-lg border border-border-heavy bg-surface-secondary p-2 px-3 shadow-lg"+ style={{+ outline: 'none',+ pointerEvents: 'auto',+ zIndex: 50,+ }}+ portal={true}+ >+ <div className="flex h-8 w-full items-center justify-center text-sm text-text-primary">+ {localize(activeSetting)}+ <Ariakit.HovercardProvider>+ <div className="ml-auto flex h-6 w-6 items-center justify-center gap-1">+ <Ariakit.HovercardAnchor+ render={+ <button+ className="flex h-5 w-5 items-center rounded-full text-text-secondary"+ aria-label={localize('com_ui_fork_info_button_label')}>- <div className="flex flex-col gap-2 space-y-2 text-sm text-gray-600 dark:text-gray-300">- <span>{localize('com_ui_fork_info_1')}</span>- <span>{localize('com_ui_fork_info_2')}</span>- <span>- {localize('com_ui_fork_info_3', {- 0: localize('com_ui_fork_split_target'),- })}- </span>- </div>- </HoverCardContent>- </HoverCardPortal>- </HoverCard>- </div>- <div className="flex h-full w-full items-center justify-center gap-1">- <PopoverButton- sideOffset={155}- setActiveSetting={setActiveSetting}- timeoutRef={timeoutRef}- onClick={onClick}- setting={ForkOptions.DIRECT_PATH}- hoverTitle={- <>- <GitCommit className="h-5 w-5 rotate-90" />- {localize(optionLabels[ForkOptions.DIRECT_PATH])}- </>- }- hoverDescription={localize('com_ui_fork_info_visible')}- >- <HoverCardTrigger asChild>- <GitCommit className="h-full w-full rotate-90 p-2" />- </HoverCardTrigger>- </PopoverButton>- <PopoverButton- sideOffset={90}- setActiveSetting={setActiveSetting}- timeoutRef={timeoutRef}- onClick={onClick}- setting={ForkOptions.INCLUDE_BRANCHES}- hoverTitle={- <>- <GitBranchPlus className="h-4 w-4 rotate-180" />- {localize(optionLabels[ForkOptions.INCLUDE_BRANCHES])}- </>+ <InfoIcon />+ </button>}- hoverDescription={localize('com_ui_fork_info_branches')}- >- <HoverCardTrigger asChild>- <GitBranchPlus className="h-full w-full rotate-180 p-2" />- </HoverCardTrigger>- </PopoverButton>- <PopoverButton- sideOffset={25}- setActiveSetting={setActiveSetting}- timeoutRef={timeoutRef}- onClick={onClick}- setting={ForkOptions.TARGET_LEVEL}- hoverTitle={- <>- <ListTree className="h-5 w-5" />- {`${localize(- optionLabels[ForkOptions.TARGET_LEVEL],- )} (${localize('com_endpoint_default')})`}- </>- }- hoverDescription={localize('com_ui_fork_info_target')}- >- <HoverCardTrigger asChild>- <ListTree className="h-full w-full p-2" />- </HoverCardTrigger>- </PopoverButton>+ />+ <Ariakit.HovercardDisclosure className="rounded-full text-text-secondary focus:outline-none focus:ring-2 focus:ring-ring">+ <VisuallyHidden>{localize('com_ui_fork_more_info_options')}</VisuallyHidden>+ {chevronDown}+ </Ariakit.HovercardDisclosure></div>- <HoverCard openDelay={50}>- <HoverCardTrigger asChild>- <div className="flex h-6 w-full items-center justify-start text-sm dark:text-gray-300 dark:hover:text-gray-200">- <Checkbox+ <Ariakit.Hovercard+ gutter={19}+ className="z-[999] w-80 rounded-md border border-border-medium bg-surface-secondary p-4 text-text-primary shadow-md"+ portal={true}+ >+ <div className="flex flex-col gap-2 space-y-2 text-sm text-text-secondary">+ <span>{localize('com_ui_fork_info_1')}</span>+ <span>{localize('com_ui_fork_info_2')}</span>+ <span>+ {localize('com_ui_fork_info_3', {+ 0: localize('com_ui_fork_split_target'),+ })}+ </span>+ </div>+ </Ariakit.Hovercard>+ </Ariakit.HovercardProvider>+ </div>+ <div className="flex h-full w-full items-center justify-center gap-1">+ <PopoverButton+ setActiveSetting={setActiveSetting}+ timeoutRef={timeoutRef}+ onClick={onClick}+ setting={ForkOptions.DIRECT_PATH}+ label={localize(optionLabels[ForkOptions.DIRECT_PATH])}+ hoverTitle={+ <>+ <GitCommit className="h-5 w-5 rotate-90" />+ {localize(optionLabels[ForkOptions.DIRECT_PATH])}+ </>+ }+ hoverDescription={localize('com_ui_fork_info_visible')}+ >+ <GitCommit className="h-full w-full rotate-90 p-2" />+ </PopoverButton>+ <PopoverButton+ setActiveSetting={setActiveSetting}+ timeoutRef={timeoutRef}+ onClick={onClick}+ setting={ForkOptions.INCLUDE_BRANCHES}+ label={localize(optionLabels[ForkOptions.INCLUDE_BRANCHES])}+ hoverTitle={+ <>+ <GitBranchPlus className="h-4 w-4 rotate-180" />+ {localize(optionLabels[ForkOptions.INCLUDE_BRANCHES])}+ </>+ }+ hoverDescription={localize('com_ui_fork_info_branches')}+ >+ <GitBranchPlus className="h-full w-full rotate-180 p-2" />+ </PopoverButton>+ <PopoverButton+ setActiveSetting={setActiveSetting}+ timeoutRef={timeoutRef}+ onClick={onClick}+ setting={ForkOptions.TARGET_LEVEL}+ label={localize(optionLabels[ForkOptions.TARGET_LEVEL])}+ hoverTitle={+ <>+ <ListTree className="h-5 w-5" />+ {`${localize(+ optionLabels[ForkOptions.TARGET_LEVEL],+ )} (${localize('com_endpoint_default')})`}+ </>+ }+ hoverDescription={localize('com_ui_fork_info_target')}+ >+ <ListTree className="h-full w-full p-2" />+ </PopoverButton>+ </div>+ <Ariakit.HovercardProvider>+ <div className="flex items-center">+ <Ariakit.HovercardAnchor+ render={+ <div className="flex h-6 w-full select-none items-center justify-start rounded-md text-sm text-text-secondary hover:text-text-primary">+ <Ariakit.Checkbox+ id="split-target-checkbox"checked={splitAtTarget}- onCheckedChange={(checked: boolean) => setSplitAtTarget(checked)}- className="m-2 transition duration-300 ease-in-out"+ onChange={(event) => setSplitAtTarget(event.target.checked)}+ className="m-2 h-4 w-4 rounded-sm border border-primary ring-offset-background transition duration-300 ease-in-out focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground"+ aria-label={localize('com_ui_fork_split_target')}/>- {localize('com_ui_fork_split_target')}+ <label htmlFor="split-target-checkbox" className="ml-2 cursor-pointer">+ {localize('com_ui_fork_split_target')}+ </label></div>- </HoverCardTrigger>- <OptionHover- side={ESide.Right}- description="com_ui_fork_info_start"- langCode={true}- sideOffset={20}- />- </HoverCard>- <HoverCard openDelay={50}>- <HoverCardTrigger asChild>- <div className="flex h-6 w-full items-center justify-start text-sm dark:text-gray-300 dark:hover:text-gray-200">- <Checkbox+ }+ />+ <Ariakit.HovercardDisclosure className="rounded-full text-text-secondary focus:outline-none focus:ring-2 focus:ring-ring">+ <VisuallyHidden>+ {localize('com_ui_fork_more_info_split_target', {+ 0: localize('com_ui_fork_split_target'),+ })}+ </VisuallyHidden>+ {chevronDown}+ </Ariakit.HovercardDisclosure>+ </div>+ <Ariakit.Hovercard+ gutter={32}+ className="z-[999] w-80 select-none rounded-md border border-border-medium bg-surface-secondary p-4 text-text-primary shadow-md"+ portal={true}+ >+ <div className="space-y-2">+ <p className="text-sm text-text-secondary">{localize('com_ui_fork_info_start')}</p>+ </div>+ </Ariakit.Hovercard>+ </Ariakit.HovercardProvider>+ <Ariakit.HovercardProvider>+ <div className="flex items-center">+ <Ariakit.HovercardAnchor+ render={+ <div+ onClick={() => setRemember((prev) => !prev)}+ className="flex h-6 w-full select-none items-center justify-start rounded-md text-sm text-text-secondary hover:text-text-primary"+ >+ <Ariakit.Checkbox+ id="remember-checkbox"checked={remember}- onCheckedChange={(checked: boolean) => {+ onChange={(event) => {+ const checked = event.target.checked;+ console.log('checked', checked);if (checked) {showToast({message: localize('com_ui_fork_remember_checked'),status: 'info',});}- setRemember(checked);+ return setRemember(checked);}}- className="m-2 transition duration-300 ease-in-out"+ className="m-2 h-4 w-4 rounded-sm border border-primary ring-offset-background transition duration-300 ease-in-out focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground"+ aria-label={localize('com_ui_fork_remember')}/>- {localize('com_ui_fork_remember')}+ <label htmlFor="remember-checkbox" className="ml-2 cursor-pointer">+ {localize('com_ui_fork_remember')}+ </label></div>- </HoverCardTrigger>- <OptionHover- side={ESide.Right}- description="com_ui_fork_info_remember"- langCode={true}- sideOffset={20}- />- </HoverCard>- </Popover.Content>- </div>- </Popover.Portal>- </Popover.Root>+ }+ />+ <Ariakit.HovercardDisclosure className="rounded-full text-text-secondary focus:outline-none focus:ring-2 focus:ring-ring">+ <VisuallyHidden>+ {localize('com_ui_fork_more_info_remember', {+ 0: localize('com_ui_fork_remember'),+ })}+ </VisuallyHidden>+ {chevronDown}+ </Ariakit.HovercardDisclosure>+ </div>+ <Ariakit.Hovercard+ gutter={14}+ className="z-[999] w-80 rounded-md border border-border-medium bg-surface-secondary p-4 text-text-primary shadow-md"+ portal={true}+ >+ <div className="space-y-2">+ <p className="text-sm text-text-secondary">{localize('com_ui_fork_info_remember')}</p>+ </div>+ </Ariakit.Hovercard>+ </Ariakit.HovercardProvider>+ </Ariakit.Popover>+ </>);}diff --git a/client/src/components/Nav/SettingsTabs/Chat/ForkSettings.tsx b/client/src/components/Nav/SettingsTabs/Chat/ForkSettings.tsxindex a44b3d63c6..a01fb6ab51 100644--- a/client/src/components/Nav/SettingsTabs/Chat/ForkSettings.tsx+++ b/client/src/components/Nav/SettingsTabs/Chat/ForkSettings.tsx@@ -44,6 +44,7 @@ export const ForkSettings = () => {options={forkOptions}sizeClasses="w-[200px]"testId="fork-setting-dropdown"+ className="z-[50]"/></div></div>diff --git a/client/src/components/ui/SplitText.tsx b/client/src/components/ui/SplitText.tsxindex 962d413007..8a37def906 100644--- a/client/src/components/ui/SplitText.tsx+++ b/client/src/components/ui/SplitText.tsx@@ -90,33 +90,37 @@ const SplitText: React.FC<SplitTextProps> = ({}, [inView, text, onLineCountChange]);return (- <p- ref={ref}- className={`split-parent inline overflow-hidden ${className}`}- style={{ textAlign, whiteSpace: 'normal', wordWrap: 'break-word' }}- >- {words.map((word, wordIndex) => (- <span key={wordIndex} style={{ display: 'inline-block', whiteSpace: 'nowrap' }}>- {word.map((letter, letterIndex) => {- const index =- words.slice(0, wordIndex).reduce((acc, w) => acc + w.length, 0) + letterIndex;+ <>+ <span className="sr-only">{text}</span>+ <p+ ref={ref}+ className={`split-parent inline overflow-hidden ${className}`}+ style={{ textAlign, whiteSpace: 'normal', wordWrap: 'break-word' }}+ aria-hidden="true"+ >+ {words.map((word, wordIndex) => (+ <span key={wordIndex} style={{ display: 'inline-block', whiteSpace: 'nowrap' }}>+ {word.map((letter, letterIndex) => {+ const index =+ words.slice(0, wordIndex).reduce((acc, w) => acc + w.length, 0) + letterIndex;- return (- <animated.span- key={index}- style={springs[index] as unknown as React.CSSProperties}- className="inline-block transform transition-opacity will-change-transform"- >- {letter}- </animated.span>- );- })}- {wordIndex < words.length - 1 && (- <span style={{ display: 'inline-block', width: '0.3em' }}> </span>- )}- </span>- ))}- </p>+ return (+ <animated.span+ key={index}+ style={springs[index] as unknown as React.CSSProperties}+ className="inline-block transform transition-opacity will-change-transform"+ >+ {letter}+ </animated.span>+ );+ })}+ {wordIndex < words.length - 1 && (+ <span style={{ display: 'inline-block', width: '0.3em' }}> </span>+ )}+ </span>+ ))}+ </p>+ </>);};diff --git a/client/src/locales/en/translation.json b/client/src/locales/en/translation.jsonindex d8e572eb2d..b22cfe5128 100644--- a/client/src/locales/en/translation.json+++ b/client/src/locales/en/translation.json@@ -864,5 +864,10 @@"com_ui_yes": "Yes","com_ui_zoom": "Zoom","com_user_message": "You",- "com_warning_resubmit_unsupported": "Resubmitting the AI message is not supported for this endpoint."-}\ No newline at end of file+ "com_warning_resubmit_unsupported": "Resubmitting the AI message is not supported for this endpoint.",+ "com_ui_fork_more_details_about": "View additional information and details about the \"{{0}}\" fork option",+ "com_ui_fork_more_info_options": "View detailed explanation of all fork options and their behaviors",+ "com_ui_fork_info_button_label": "View information about forking conversations",+ "com_ui_fork_more_info_split_target": "View explanation of how the \"{{0}}\" option affects which messages are included in your fork",+ "com_ui_fork_more_info_remember": "View explanation of how the \"{{0}}\" option saves your preferences for future forks"+}