mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-11-18 14:08:21 +00:00
* refactor: Move the Subagent Transcript Into @librechat/chat Behind a Subagents Host SubagentActivity, its scroll surface, content, status and guidance history move into @librechat/chat/components, and ScrollToBottom moves into the package with them. A new SubagentsHost carries what still lives in the app: the content-parts and steer renderers, the animated jump-to-latest control, and the read of a shortened guidance receipt, which stays an app query. The prompt preview reuses renderMarkdown with a new codeExecution flag, and the task content scope becomes a plain package context. * refactor: Draw Content Parts Through the Message Parts Host renderContentParts moves from SubagentsHost onto MessagePartsHost as the one content slot, typed as ContentPartsSlotProps: the transcript fields plus the optional row fields message rows pass. The app fills it through a registered renderer, so the host module does not import the content stack, and omitted row fields keep an assistant reply's defaults. * refactor: Let the Content Parts Slot Carry Sparse Content Main message rows keep holes at streaming and parallel indexes, and part indexes depend on those positions, so the slot's content keeps undefined entries as ContentParts already accepts them. * test: Exercise the Real App Renderers in the Host Registration Spec The transcript host test now renders the app's ContentParts and SteerPart under the providers they read, so the registered content renderer and steer slot are proven against the real components; only the receipt request stays mocked.
117 lines
4.5 KiB
JavaScript
117 lines
4.5 KiB
JavaScript
import { useEffect } from 'react';
|
|
import { RecoilRoot } from 'recoil';
|
|
import { DndProvider } from 'react-dnd';
|
|
import { RouterProvider } from 'react-router-dom';
|
|
import { HTML5Backend } from 'react-dnd-html5-backend';
|
|
import { Toast, ToastViewport, ToastProvider, useInputModality } from '@librechat/client';
|
|
import { QueryClient, QueryClientProvider, QueryCache, MutationCache } from '@tanstack/react-query';
|
|
import { FilesHostProvider, appFilesHost } from '~/Providers/FilesHostContext';
|
|
import Direction, { ToastSwipeProvider } from '~/Providers/Direction';
|
|
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 UiScaleSync from '~/components/System/UiScaleSync';
|
|
import { initializeFontSize } from '~/store/fontSize';
|
|
import { reopenTermsOnRefusal } from '~/utils/terms';
|
|
import { LiveAnnouncer } from '~/a11y';
|
|
import { router } from './routes';
|
|
import '~/Providers/MessagePartsHostContext';
|
|
import '~/Providers/MessagesHostContext';
|
|
import '~/Providers/SubagentsHostContext';
|
|
import '~/components/Chat/Messages/Content/register';
|
|
|
|
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);
|
|
}
|
|
},
|
|
}),
|
|
mutationCache: new MutationCache({
|
|
onError: (error) => {
|
|
reopenTermsOnRefusal(queryClient, error?.response?.data);
|
|
},
|
|
}),
|
|
});
|
|
|
|
useEffect(() => {
|
|
initializeFontSize();
|
|
}, []);
|
|
|
|
return (
|
|
<QueryClientProvider client={queryClient}>
|
|
<RecoilRoot>
|
|
<LanguageSync />
|
|
<UiScaleSync />
|
|
<Direction>
|
|
<LiveAnnouncer>
|
|
<DeploymentTheme>
|
|
<ToastSwipeProvider>
|
|
<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. */}
|
|
<FilesHostProvider host={appFilesHost}>
|
|
<RouterProvider router={router} useTransitions={false} />
|
|
</FilesHostProvider>
|
|
<WakeLockManager />
|
|
<QueryDevtoolsGate />
|
|
<Toast />
|
|
<ToastViewport />
|
|
</DndProvider>
|
|
</ToastProvider>
|
|
</ToastSwipeProvider>
|
|
</DeploymentTheme>
|
|
</LiveAnnouncer>
|
|
</Direction>
|
|
</RecoilRoot>
|
|
</QueryClientProvider>
|
|
);
|
|
};
|
|
|
|
export default () => (
|
|
<ScreenshotProvider>
|
|
<App />
|
|
<iframe
|
|
src="assets/silence.mp3"
|
|
allow="autoplay"
|
|
id="audio"
|
|
title="audio-silence"
|
|
className="hidden"
|
|
/>
|
|
</ScreenshotProvider>
|
|
);
|