From 26a63eb14836e37c1697c84bbf0015db052f3adf Mon Sep 17 00:00:00 2001 From: Danny Avila Date: Fri, 13 Dec 2024 14:38:36 -0500 Subject: [PATCH 1/8] =?UTF-8?q?=F0=9F=94=83=20fix:=20Safeguard=20against?= =?UTF-8?q?=20null=20token=20in=20SSE=20refresh=20token=20handling?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/src/hooks/SSE/useSSE.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/client/src/hooks/SSE/useSSE.ts b/client/src/hooks/SSE/useSSE.ts index 7d0a63757d0..3ee0e9d50e5 100644 --- a/client/src/hooks/SSE/useSSE.ts +++ b/client/src/hooks/SSE/useSSE.ts @@ -190,11 +190,16 @@ export default function useSSE( /* token expired, refresh and retry */ try { const refreshResponse = await request.refreshToken(); + const token = refreshResponse?.token ?? ''; + if (!token) { + throw new Error('Token refresh failed.'); + } sse.headers = { 'Content-Type': 'application/json', - Authorization: `Bearer ${refreshResponse.token}`, + Authorization: `Bearer ${token}`, }; - request.dispatchTokenUpdatedEvent(refreshResponse.token); + + request.dispatchTokenUpdatedEvent(token); sse.stream(); return; } catch (error) { From 531a37b9c3805dea3b3b3c3a6191d986d7b9e65a Mon Sep 17 00:00:00 2001 From: Danny Avila Date: Fri, 13 Dec 2024 14:38:58 -0500 Subject: [PATCH 2/8] =?UTF-8?q?=F0=9F=94=83=20fix:=20Update=20import=20pat?= =?UTF-8?q?h=20for=20AnnounceOptions=20in=20LiveAnnouncer=20component?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/src/a11y/LiveAnnouncer.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/a11y/LiveAnnouncer.tsx b/client/src/a11y/LiveAnnouncer.tsx index 9df48bf2e98..29912b49af7 100644 --- a/client/src/a11y/LiveAnnouncer.tsx +++ b/client/src/a11y/LiveAnnouncer.tsx @@ -1,6 +1,6 @@ // client/src/a11y/LiveAnnouncer.tsx import React, { useState, useCallback, useRef, useEffect, useMemo } from 'react'; -import type { AnnounceOptions } from '~/Providers/AnnouncerContext'; +import type { AnnounceOptions } from '~/common'; import AnnouncerContext from '~/Providers/AnnouncerContext'; import useLocalize from '~/hooks/useLocalize'; import Announcer from './Announcer'; From 1c936b0a088d516bf6c67ac224a8bbcb4f004952 Mon Sep 17 00:00:00 2001 From: Danny Avila Date: Fri, 13 Dec 2024 14:39:22 -0500 Subject: [PATCH 3/8] =?UTF-8?q?=F0=9F=94=83=20a11y:=20Add=20aria-live=20at?= =?UTF-8?q?tribute=20for=20accessibility=20in=20error=20messages?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/src/components/Auth/AuthLayout.tsx | 10 ++++++---- client/src/components/Auth/ErrorMessage.tsx | 3 ++- .../Chat/Messages/Content/MessageContent.tsx | 2 ++ 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/client/src/components/Auth/AuthLayout.tsx b/client/src/components/Auth/AuthLayout.tsx index 0ff99f357cf..d8c52a82555 100644 --- a/client/src/components/Auth/AuthLayout.tsx +++ b/client/src/components/Auth/AuthLayout.tsx @@ -9,8 +9,9 @@ import Footer from './Footer'; const ErrorRender = ({ children }: { children: React.ReactNode }) => (
{children}
@@ -36,8 +37,9 @@ function AuthLayout({ }) { const localize = useLocalize(); + const hasStartupConfigError = startupConfigError !== null && startupConfigError !== undefined; const DisplayError = () => { - if (startupConfigError !== null && startupConfigError !== undefined) { + if (hasStartupConfigError) { return {localize('com_auth_error_login_server')}; } else if (error === 'com_auth_error_invalid_reset_token') { return ( @@ -49,7 +51,7 @@ function AuthLayout({ {localize('com_auth_to_try_again')} ); - } else if (error) { + } else if (error != null && error) { return {localize(error)}; } return null; @@ -70,7 +72,7 @@ function AuthLayout({
- {!startupConfigError && !isFetching && ( + {!hasStartupConfigError && !isFetching && (

(
{children}
diff --git a/client/src/components/Chat/Messages/Content/MessageContent.tsx b/client/src/components/Chat/Messages/Content/MessageContent.tsx index 01957be3cb9..4afabdcde98 100644 --- a/client/src/components/Chat/Messages/Content/MessageContent.tsx +++ b/client/src/components/Chat/Messages/Content/MessageContent.tsx @@ -56,6 +56,8 @@ export const ErrorMessage = ({ return (
Date: Fri, 13 Dec 2024 14:46:00 -0500 Subject: [PATCH 4/8] fix: prevent double screen reader notification for toast --- client/src/components/ui/Toast.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/client/src/components/ui/Toast.tsx b/client/src/components/ui/Toast.tsx index 6781a503273..54dcc4ed0ef 100644 --- a/client/src/components/ui/Toast.tsx +++ b/client/src/components/ui/Toast.tsx @@ -26,7 +26,6 @@ export default function Toast() { className={`alert-root pointer-events-auto inline-flex flex-row gap-2 rounded-md border px-3 py-2 text-white ${ severityClassName[toast.severity] }`} - role="alert" > {toast.showIcon && (
From a8d29d112e4474542a17d1574cb5dc5e5d40a083 Mon Sep 17 00:00:00 2001 From: Danny Avila Date: Fri, 13 Dec 2024 15:15:20 -0500 Subject: [PATCH 5/8] =?UTF-8?q?=F0=9F=94=83=20a11y:=20Enhance=20accessibil?= =?UTF-8?q?ity=20for=20main=20menus=20and=20buttons=20with=20ARIA=20roles?= =?UTF-8?q?=20and=20labels?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/src/components/Chat/Menus/EndpointsMenu.tsx | 5 +++++ .../src/components/Chat/Menus/Models/MenuButton.tsx | 11 ++++++++++- client/src/components/Chat/Menus/Models/ModelSpec.tsx | 4 +++- .../src/components/Chat/Menus/Models/ModelSpecs.tsx | 4 ++-- .../components/Chat/Menus/Models/ModelSpecsMenu.tsx | 6 +++++- client/src/components/Chat/Menus/UI/MenuItem.tsx | 4 +++- client/src/components/Chat/Menus/UI/TitleButton.tsx | 10 +++++++--- client/src/localization/languages/Eng.ts | 4 ++++ 8 files changed, 39 insertions(+), 9 deletions(-) diff --git a/client/src/components/Chat/Menus/EndpointsMenu.tsx b/client/src/components/Chat/Menus/EndpointsMenu.tsx index f4ac27ccc4b..fc92c89d984 100644 --- a/client/src/components/Chat/Menus/EndpointsMenu.tsx +++ b/client/src/components/Chat/Menus/EndpointsMenu.tsx @@ -5,6 +5,7 @@ import type { FC } from 'react'; import { useChatContext, useAgentsMapContext, useAssistantsMapContext } from '~/Providers'; import { mapEndpoints, getEntity } from '~/utils'; import EndpointItems from './Endpoints/MenuItems'; +import useLocalize from '~/hooks/useLocalize'; import TitleButton from './UI/TitleButton'; const EndpointsMenu: FC = () => { @@ -12,6 +13,7 @@ const EndpointsMenu: FC = () => { select: mapEndpoints, }); + const localize = useLocalize(); const agentsMap = useAgentsMapContext(); const assistantMap = useAssistantsMapContext(); const { conversation } = useChatContext(); @@ -51,6 +53,9 @@ const EndpointsMenu: FC = () => { diff --git a/client/src/components/Chat/Menus/Models/MenuButton.tsx b/client/src/components/Chat/Menus/Models/MenuButton.tsx index aa568231e40..24ef1e94520 100644 --- a/client/src/components/Chat/Menus/Models/MenuButton.tsx +++ b/client/src/components/Chat/Menus/Models/MenuButton.tsx @@ -1,3 +1,4 @@ +import { useState } from 'react'; import { Trigger } from '@radix-ui/react-popover'; import type { TModelSpec, TEndpointsConfig } from 'librechat-data-provider'; import { useLocalize } from '~/hooks'; @@ -20,6 +21,8 @@ export default function MenuButton({ endpointsConfig: TEndpointsConfig; }) { const localize = useLocalize(); + const [isExpanded, setIsExpanded] = useState(false); + return (