mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-11-21 07:23:11 +00:00
* feat: pick the deployment theme in librechat.yaml
Add `interface.theme` to the config schema, accepting a bundled theme name
or an inline theme definition. The interface loader passes it through, the
pre-login config payload carries it so the login page paints it, and a
DeploymentTheme wrapper around ThemeProvider resolves and validates it and
applies it without persisting it over the user's stored theme.
* fix: restore the user theme when the deployment theme is withdrawn
Move the pre-login interface selection out of the /api route into
buildPreLoginInterface in packages/api, so the route only wires it up.
When an authenticated config drops interface.theme (a principal override
tombstoning it), hand ThemeProvider the user's stored theme instead of
clearing to the LibreChat palette. The e2e scenarios now cover inline and
invalid themes, the withdrawn case, and high-contrast precedence.
* fix: read a legacy stored theme behind a corrupt stored definition
* perf: rebind the deployment theme observer on a cache add, not every event
useIsFetching recomputed the fetch count across every query on each cache
event, which slowed streamed renders enough to break the highlight-throttle
scenario. Subscribe to the query cache and re-render only when a startup
config query is rebuilt.
* test: wait for the composer after sign-in so mobile runs pass
* fix: keep deployment themes whole and restore legacy themes as legacy
A principal override with an inline theme merged into the base theme,
keeping the base's other mode, brands and tokens; interfaceConfig.theme
now replaces whole during override merging.
A withdrawn deployment theme restored a legacy-source stored theme as a
versioned definition, dropping its colors in dark mode; it now goes back
through ThemeProvider's legacy color path.
* fix: persist the user's theme changes after the deployment theme is withdrawn
Persistence now stays off only while a deployment theme is applied and for
the render that restores the stored theme, so later changes through the
theme API are saved again.
* refactor: derive deployment theme persistence from the current theme
(cherry picked from commit f0cbc9a3c0)
Original-PR: https://github.com/LibreChat-AI/LibreChat/pull/16286
100 lines
3.9 KiB
JavaScript
100 lines
3.9 KiB
JavaScript
import { useEffect } from 'react';
|
|
import { RecoilRoot } from 'recoil';
|
|
import { DndProvider } from 'react-dnd';
|
|
import { RouterProvider } from 'react-router-dom';
|
|
import * as RadixToast from '@radix-ui/react-toast';
|
|
import { HTML5Backend } from 'react-dnd-html5-backend';
|
|
import { Toast, ToastProvider, useInputModality } from '@librechat/client';
|
|
import { QueryClient, QueryClientProvider, QueryCache } from '@tanstack/react-query';
|
|
import { ScreenshotProvider, useApiErrorBoundary } from './hooks';
|
|
import WakeLockManager from '~/components/System/WakeLockManager';
|
|
import QueryDevtoolsGate from '~/components/QueryDevtoolsGate';
|
|
import LanguageSync from '~/components/System/LanguageSync';
|
|
import DeploymentTheme from '~/Providers/DeploymentTheme';
|
|
import { initializeFontSize } from '~/store/fontSize';
|
|
import { LiveAnnouncer } from '~/a11y';
|
|
import { router } from './routes';
|
|
|
|
const App = () => {
|
|
const { setError } = useApiErrorBoundary();
|
|
useInputModality();
|
|
|
|
const queryClient = new QueryClient({
|
|
defaultOptions: {
|
|
queries: {
|
|
// Always attempt network requests, even when navigator.onLine is false
|
|
// This is needed because localhost is reachable without WiFi
|
|
networkMode: 'always',
|
|
},
|
|
mutations: {
|
|
networkMode: 'always',
|
|
},
|
|
},
|
|
queryCache: new QueryCache({
|
|
onError: (error) => {
|
|
if (error?.response?.status === 401) {
|
|
setError(error);
|
|
}
|
|
},
|
|
}),
|
|
});
|
|
|
|
useEffect(() => {
|
|
initializeFontSize();
|
|
}, []);
|
|
|
|
return (
|
|
<QueryClientProvider client={queryClient}>
|
|
<RecoilRoot>
|
|
<LanguageSync />
|
|
<LiveAnnouncer>
|
|
<DeploymentTheme>
|
|
<RadixToast.Provider>
|
|
<ToastProvider>
|
|
<DndProvider backend={HTML5Backend}>
|
|
{/* Location updates commit in the caller's own task instead
|
|
of React's transition lane. A transition keeps the
|
|
OUTGOING route painted until the incoming one finishes
|
|
rendering, so switching conversations left the previous
|
|
transcript on screen under the new URL for as long as the
|
|
next thread took to render.
|
|
|
|
Set here rather than per navigation because the property
|
|
is route-shaped, not caller-shaped: fourteen call sites
|
|
across components, chat hooks and SSE handlers navigate
|
|
into `/c/*`, and an opt-out passed at each one is a list
|
|
that silently rots as call sites are added. Nothing in the
|
|
app reads route data through router loaders or renders
|
|
pending UI from `useNavigation`, so the transition buys no
|
|
interstitial on any route — it only defers the commit. And
|
|
conversation state still lives in Recoil, whose
|
|
transition-safe reads are gated behind
|
|
`_TRANSITION_SUPPORT_UNSTABLE` hooks this app does not use.
|
|
Worth revisiting once that state has moved to Jotai. */}
|
|
<RouterProvider router={router} useTransitions={false} />
|
|
<WakeLockManager />
|
|
<QueryDevtoolsGate />
|
|
<Toast />
|
|
<RadixToast.Viewport className="pointer-events-none fixed inset-x-0 top-0 z-[1000] mx-auto my-2 flex max-w-[560px] flex-col items-stretch justify-start" />
|
|
</DndProvider>
|
|
</ToastProvider>
|
|
</RadixToast.Provider>
|
|
</DeploymentTheme>
|
|
</LiveAnnouncer>
|
|
</RecoilRoot>
|
|
</QueryClientProvider>
|
|
);
|
|
};
|
|
|
|
export default () => (
|
|
<ScreenshotProvider>
|
|
<App />
|
|
<iframe
|
|
src="assets/silence.mp3"
|
|
allow="autoplay"
|
|
id="audio"
|
|
title="audio-silence"
|
|
className="hidden"
|
|
/>
|
|
</ScreenshotProvider>
|
|
);
|