Skip to content

#1 PDF Application on GitHub that lets you edit PDFs on any device anywhere

Hoist platform providers to be global for the app (#8728)

James Brunton00cd05d229f5
diff --git a/frontend/src/editor/core/App.tsx b/frontend/src/editor/core/App.tsx
index 25f7642791..5dc059fbb4 100644
--- a/frontend/src/editor/core/App.tsx
+++ b/frontend/src/editor/core/App.tsx
@@ -1,6 +1,7 @@
import { Suspense, lazy } from "react";
import { Routes, Route } from "react-router-dom";
import { AppProviders } from "@editor/components/AppProviders";
+import { PlatformProviders } from "@editor/components/PlatformProviders";
import { AppFrame } from "@editor/components/layout/AppFrame";
import { AppLayout } from "@editor/components/AppLayout";
import { LoadingFallback } from "@editor/components/shared/LoadingFallback";
@@ -55,8 +56,14 @@ export default function App() {
/>
{/* The app, under a shared frame so the rail renders once outside it. */}
- <Route element={<AppFrame />}>
- {/* All other routes need AppProviders for backend integration */}
+ <Route
+ element={
+ <PlatformProviders>
+ <AppFrame />
+ </PlatformProviders>
+ }
+ >
+ {/* Everything else is the editor. */}
<Route
path="*"
element={
diff --git a/frontend/src/editor/core/components/AppProviders.tsx b/frontend/src/editor/core/components/AppProviders.tsx
index 6dfcc96ba7..b7fd3c41a5 100644
--- a/frontend/src/editor/core/components/AppProviders.tsx
+++ b/frontend/src/editor/core/components/AppProviders.tsx
@@ -1,10 +1,7 @@
-import { ReactNode, useEffect, useState } from "react";
-import { QueryClientProvider } from "@tanstack/react-query";
-import { createAppQueryClient } from "@editor/query/queryClient";
+import { ReactNode, useEffect } from "react";
import { ThemeProvider } from "@editor/components/shared/ThemeProvider";
import { FileContextProvider } from "@editor/contexts/FileContext";
import { NavigationProvider } from "@editor/contexts/NavigationContext";
-import { ToolRegistryProvider } from "@editor/contexts/ToolRegistryProvider";
import { FilesModalProvider } from "@editor/contexts/FilesModalContext";
import { ToolWorkflowProvider } from "@editor/contexts/ToolWorkflowContext";
import { DamagedFileRepairProvider } from "@editor/contexts/DamagedFileRepairContext";
@@ -14,12 +11,7 @@ import {
PreferencesProvider,
usePreferences,
} from "@editor/contexts/PreferencesContext";
-import {
- AppConfigProvider,
- AppConfigProviderProps,
- AppConfigRetryOptions,
- useAppConfig,
-} from "@editor/contexts/AppConfigContext";
+import { useAppConfig } from "@editor/contexts/AppConfigContext";
import { WorkbenchBarProvider } from "@editor/contexts/WorkbenchBarContext";
import { ViewerProvider } from "@editor/contexts/ViewerContext";
import { SignatureProvider } from "@editor/contexts/SignatureContext";
@@ -73,16 +65,8 @@ function BrandingAssetManager() {
return null;
}
-// Avoid requirement to have props which are required in app providers anyway
-type AppConfigProviderOverrides = Omit<
- AppConfigProviderProps,
- "children" | "retryOptions"
->;
-
export interface AppProvidersProps {
children: ReactNode;
- appConfigRetryOptions?: AppConfigRetryOptions;
- appConfigProviderProps?: Partial<AppConfigProviderOverrides>;
}
// Component to sync server defaults to preferences when AppConfig loads
@@ -122,79 +106,59 @@ function ServerDefaultsSync() {
return null;
}
-/**
- * Core application providers
- * Contains all providers needed for the core
- */
-export function AppProviders({
- children,
- appConfigRetryOptions,
- appConfigProviderProps,
-}: AppProvidersProps) {
- const [queryClient] = useState(createAppQueryClient);
+/** The editor's own providers. Expects PlatformProviders above it. */
+export function AppProviders({ children }: AppProvidersProps) {
return (
- <QueryClientProvider client={queryClient}>
- <PreferencesProvider>
- <ThemeProvider>
- <ErrorBoundary>
- <BannerProvider>
- <AppConfigProvider
- retryOptions={appConfigRetryOptions}
- {...appConfigProviderProps}
- >
- <AppConfigLoader />
- <ServerDefaultsSync />
- {/* Auto-popup on startup when a newer Stirling-PDF release is available.
- No-ops inside Tauri — the desktop popup handles that flow. */}
- <UpdateStartupPopup />
- <FileContextProvider
- enableUrlSync={true}
- enablePersistence={true}
- >
- <FolderProvider>
- <AppInitializer />
- <BrandingAssetManager />
- <ToolRegistryProvider>
- <NavigationProvider>
- <FilesModalProvider>
- <ToolWorkflowProvider>
- <HotkeyProvider>
- <SidebarProvider>
- <ViewerProvider>
- <SignatureProvider>
- <SigningOverlayProvider>
- <RedactionProvider>
- <FormFillProvider>
- <AnnotationProvider>
- <WorkbenchBarProvider>
- <TourOrchestrationProvider>
- <AdminTourOrchestrationProvider>
- <WorkbenchSessionPersistence />
- <DamagedFileRepairProvider>
- {children}
- </DamagedFileRepairProvider>
- </AdminTourOrchestrationProvider>
- </TourOrchestrationProvider>
- </WorkbenchBarProvider>
- </AnnotationProvider>
- </FormFillProvider>
- </RedactionProvider>
- </SigningOverlayProvider>
- </SignatureProvider>
- </ViewerProvider>
- </SidebarProvider>
- </HotkeyProvider>
- </ToolWorkflowProvider>
- </FilesModalProvider>
- </NavigationProvider>
- </ToolRegistryProvider>
- </FolderProvider>
- </FileContextProvider>
- </AppConfigProvider>
- </BannerProvider>
- </ErrorBoundary>
- </ThemeProvider>
- </PreferencesProvider>
- </QueryClientProvider>
+ <PreferencesProvider>
+ <ThemeProvider>
+ <ErrorBoundary>
+ <BannerProvider>
+ <AppConfigLoader />
+ <ServerDefaultsSync />
+ {/* Auto-popup on startup when a newer Stirling-PDF release is available.
+ No-ops inside Tauri — the desktop popup handles that flow. */}
+ <UpdateStartupPopup />
+ <FileContextProvider enableUrlSync={true} enablePersistence={true}>
+ <FolderProvider>
+ <AppInitializer />
+ <BrandingAssetManager />
+ <NavigationProvider>
+ <FilesModalProvider>
+ <ToolWorkflowProvider>
+ <HotkeyProvider>
+ <SidebarProvider>
+ <ViewerProvider>
+ <SignatureProvider>
+ <SigningOverlayProvider>
+ <RedactionProvider>
+ <FormFillProvider>
+ <AnnotationProvider>
+ <WorkbenchBarProvider>
+ <TourOrchestrationProvider>
+ <AdminTourOrchestrationProvider>
+ <WorkbenchSessionPersistence />
+ <DamagedFileRepairProvider>
+ {children}
+ </DamagedFileRepairProvider>
+ </AdminTourOrchestrationProvider>
+ </TourOrchestrationProvider>
+ </WorkbenchBarProvider>
+ </AnnotationProvider>
+ </FormFillProvider>
+ </RedactionProvider>
+ </SigningOverlayProvider>
+ </SignatureProvider>
+ </ViewerProvider>
+ </SidebarProvider>
+ </HotkeyProvider>
+ </ToolWorkflowProvider>
+ </FilesModalProvider>
+ </NavigationProvider>
+ </FolderProvider>
+ </FileContextProvider>
+ </BannerProvider>
+ </ErrorBoundary>
+ </ThemeProvider>
+ </PreferencesProvider>
);
}
diff --git a/frontend/src/editor/core/components/PlatformProviders.tsx b/frontend/src/editor/core/components/PlatformProviders.tsx
new file mode 100644
index 0000000000..b6ef1acfbd
--- /dev/null
+++ b/frontend/src/editor/core/components/PlatformProviders.tsx
@@ -0,0 +1,43 @@
+import { ReactNode, useState } from "react";
+import { QueryClientProvider } from "@tanstack/react-query";
+import { createAppQueryClient } from "@editor/query/queryClient";
+import { ToolRegistryProvider } from "@editor/contexts/ToolRegistryProvider";
+import {
+ AppConfigProvider,
+ AppConfigProviderProps,
+ AppConfigRetryOptions,
+} from "@editor/contexts/AppConfigContext";
+
+type AppConfigProviderOverrides = Omit<
+ AppConfigProviderProps,
+ "children" | "retryOptions"
+>;
+
+export interface PlatformProvidersProps {
+ children: ReactNode;
+ appConfigRetryOptions?: AppConfigRetryOptions;
+ appConfigProviderProps?: Partial<AppConfigProviderOverrides>;
+}
+
+/**
+ * Session-wide state every app reads. Mounted above the app frame, so it
+ * survives switching between apps; each app's own providers sit inside it and
+ * must not mount a second copy of anything here.
+ */
+export function PlatformProviders({
+ children,
+ appConfigRetryOptions,
+ appConfigProviderProps,
+}: PlatformProvidersProps) {
+ const [queryClient] = useState(createAppQueryClient);
+ return (
+ <QueryClientProvider client={queryClient}>
+ <AppConfigProvider
+ retryOptions={appConfigRetryOptions}
+ {...appConfigProviderProps}
+ >
+ <ToolRegistryProvider>{children}</ToolRegistryProvider>
+ </AppConfigProvider>
+ </QueryClientProvider>
+ );
+}
diff --git a/frontend/src/editor/core/components/startup/StartupPrompts.test.tsx b/frontend/src/editor/core/components/startup/StartupPrompts.test.tsx
index 2bfe440c10..9a7c572a75 100644
--- a/frontend/src/editor/core/components/startup/StartupPrompts.test.tsx
+++ b/frontend/src/editor/core/components/startup/StartupPrompts.test.tsx
@@ -291,17 +291,17 @@ describe("startup prompts", () => {
expect(h.tracking).not.toHaveBeenCalled();
});
- it("uses the latest server choice when entering another app with stale config", async () => {
+ it("reads the shared app config on entering an app instead of fetching it again", async () => {
const client = new QueryClient({
defaultOptions: { queries: { retry: false, gcTime: 0 } },
});
- client.setQueryData(["editor", "appConfig"], {
- ...config,
- enableAnalytics: null,
- });
+ client.setQueryData(["editor", "appConfig"], { ...config });
renderAt("/processor", client);
await waitFor(() => expect(h.tracking).toHaveBeenCalled());
- expect(screen.queryByRole("dialog")).not.toBeInTheDocument();
+ expect(h.get).not.toHaveBeenCalledWith(
+ "/api/v1/config/app-config",
+ expect.anything(),
+ );
});
it("preserves agreement acceptance when changing apps or reloading", async () => {
diff --git a/frontend/src/editor/core/components/startup/StartupSetup.tsx b/frontend/src/editor/core/components/startup/StartupSetup.tsx
index f6c556bbbe..7dc8ee2848 100644
--- a/frontend/src/editor/core/components/startup/StartupSetup.tsx
+++ b/frontend/src/editor/core/components/startup/StartupSetup.tsx
@@ -33,14 +33,8 @@ function requiresMfaSetup(account: AccountData): boolean {
}
}
-/** Rechecks setup on app entry; deferred backends can supply config without another fetch. */
-export function StartupSetup({
- children,
- refreshConfigOnMount = true,
-}: {
- children: ReactNode;
- refreshConfigOnMount?: boolean;
-}) {
+/** Rechecks setup on app entry. */
+export function StartupSetup({ children }: { children: ReactNode }) {
const { t } = useTranslation();
const { config, refetch } = useAppConfig();
const { user, signOut, isAnonymous } = useAuth();
@@ -55,9 +49,6 @@ export function StartupSetup({
const requirements = useQuery({
queryKey: ["startup", "requirements", user?.id, loginEnabled],
queryFn: async () => {
- // Editor and Processor have separate query caches. Re-read server settings
- // on entry so an analytics choice made in the other app is respected.
- if (refreshConfigOnMount) await refetch();
if (!loginEnabled || !user || isAnonymous) return null;
const [account, login] = await Promise.all([
accountService.getAccountData(),
diff --git a/frontend/src/editor/core/contexts/ToolWorkflowContext.startupView.test.tsx b/frontend/src/editor/core/contexts/ToolWorkflowContext.startupView.test.tsx
index a58a921c88..3c2243b071 100644
--- a/frontend/src/editor/core/contexts/ToolWorkflowContext.startupView.test.tsx
+++ b/frontend/src/editor/core/contexts/ToolWorkflowContext.startupView.test.tsx
@@ -10,6 +10,7 @@ import {
import { beforeEach, describe, expect, it, vi } from "vitest";
import { MemoryRouter, useLocation, useNavigate } from "react-router-dom";
import { AppProviders } from "@editor/components/AppProviders";
+import { PlatformProviders } from "@editor/components/PlatformProviders";
import { useAppConfig } from "@editor/contexts/AppConfigContext";
import { usePreferences } from "@editor/contexts/PreferencesContext";
import { useToolWorkflow } from "@editor/contexts/ToolWorkflowContext";
@@ -63,15 +64,15 @@ function renderLaunch(
const { config = null, path = "/", autoFetch = false } = options;
render(
<MemoryRouter initialEntries={[path]}>
- <AppProviders
+ <PlatformProviders
appConfigProviderProps={{
initialConfig: config,
bootstrapMode: "non-blocking",
autoFetch,
}}
>
- {ui}
- </AppProviders>
+ <AppProviders>{ui}</AppProviders>
+ </PlatformProviders>
</MemoryRouter>,
);
return screen.getByTestId("launch");
diff --git a/frontend/src/editor/core/hooks/useNotifications.ts b/frontend/src/editor/core/hooks/useNotifications.ts
index 74e33a78a7..66eed4eb31 100644
--- a/frontend/src/editor/core/hooks/useNotifications.ts
+++ b/frontend/src/editor/core/hooks/useNotifications.ts
@@ -9,10 +9,7 @@ import {
type RetryPayload,
} from "@editor/services/notificationRetry";
-/**
- * One polled store for however many bells are mounted. A module store rather than a context because
- * the portal mounts its bell as a sibling of AppProviders, so there is no single tree to provide in.
- */
+/** One polled store for however many bells are mounted. */
// TODO: read state is per-browser. Move it server-side when notifications get their own table.
const POLL_INTERVAL_MS = 30_000;
@@ -220,12 +217,7 @@ function loadFresh(): void {
});
}
-/**
- * The bell sits in the quick-nav rail, which renders above AppProviders and so
- * above the query client - hence this store rather than a query. The one thing
- * the client would give for free has to be spelled out: a backgrounded tab
- * otherwise reads every 30s for the whole session, on every page.
- */
+// A backgrounded tab otherwise reads every 30s for the whole session, on every page.
function pollIfWatching(): void {
if (document.visibilityState === "visible") void load();
}
diff --git a/frontend/src/editor/core/pages/HomePage.startupView.test.tsx b/frontend/src/editor/core/pages/HomePage.startupView.test.tsx
index 19a304332d..8a93803092 100644
--- a/frontend/src/editor/core/pages/HomePage.startupView.test.tsx
+++ b/frontend/src/editor/core/pages/HomePage.startupView.test.tsx
@@ -5,6 +5,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { MemoryRouter, useLocation, useNavigate } from "react-router-dom";
import { MantineProvider } from "@mantine/core";
import { AppProviders } from "@editor/components/AppProviders";
+import { PlatformProviders } from "@editor/components/PlatformProviders";
import HomePage from "@editor/pages/HomePage";
import SettingsPage from "@editor/pages/SettingsPage";
import { useToolWorkflow } from "@editor/contexts/ToolWorkflowContext";
@@ -74,15 +75,17 @@ function renderApp(late = false) {
<MantineProvider>
<QuickNavHostProvider>
<QuickNavRailHost />
- <AppProviders
+ <PlatformProviders
appConfigProviderProps={{
initialConfig: {},
bootstrapMode: "non-blocking",
autoFetch: false,
}}
>
- <Page late={late} />
- </AppProviders>
+ <AppProviders>
+ <Page late={late} />
+ </AppProviders>
+ </PlatformProviders>
</QuickNavHostProvider>
</MantineProvider>
</MemoryRouter>,
diff --git a/frontend/src/editor/desktop/components/AppProviders.tsx b/frontend/src/editor/desktop/components/AppProviders.tsx
index 3a8e3cc922..3ed740e0d4 100644
--- a/frontend/src/editor/desktop/components/AppProviders.tsx
+++ b/frontend/src/editor/desktop/components/AppProviders.tsx
@@ -16,7 +16,6 @@ import { OPEN_SIGN_IN_EVENT } from "@editor/constants/signInEvents";
import { ToolActionsContext } from "@editor/contexts/ToolActionsContext";
import { useFirstLaunchCheck } from "@editor/hooks/useFirstLaunchCheck";
import { useBackendInitializer } from "@editor/hooks/useBackendInitializer";
-import { DESKTOP_DEFAULT_APP_CONFIG } from "@editor/config/defaultAppConfig";
import {
connectionModeService,
JWT_EXPIRED_PROMPTED_KEY,
@@ -51,7 +50,6 @@ const COMMON_TOOL_ENDPOINTS = [
/**
* Desktop application providers
* Wraps proprietary providers and adds desktop-specific configuration
- * - Enables retry logic for app config (needed for Tauri mode when backend is starting)
* - Shows setup wizard on first launch
*/
export function AppProviders({ children }: { children: ReactNode }) {
@@ -343,17 +341,7 @@ export function AppProviders({ children }: { children: ReactNode }) {
if (!authChecked) {
return (
- <ProprietaryAppProviders
- appConfigRetryOptions={{
- maxRetries: 5,
- initialDelay: 1000,
- }}
- appConfigProviderProps={{
- initialConfig: DESKTOP_DEFAULT_APP_CONFIG,
- bootstrapMode: "non-blocking",
- autoFetch: false,
- }}
- >
+ <ProprietaryAppProviders>
{/* Also here: the auth check below switches mode pre-authChecked. */}
<DesktopQueryCacheReset />
{/* The title-bar strip (window controls) comes from AppFrame, which wraps
@@ -366,17 +354,7 @@ export function AppProviders({ children }: { children: ReactNode }) {
// Normal app flow
return (
- <ProprietaryAppProviders
- appConfigRetryOptions={{
- maxRetries: 5,
- initialDelay: 1000,
- }}
- appConfigProviderProps={{
- initialConfig: DESKTOP_DEFAULT_APP_CONFIG,
- bootstrapMode: "non-blocking",
- autoFetch: false,
- }}
- >
+ <ProprietaryAppProviders>
<ToolActionsContext.Provider
value={{
onEndpointUnavailableClick: () =>
diff --git a/frontend/src/editor/desktop/components/PlatformProviders.tsx b/frontend/src/editor/desktop/components/PlatformProviders.tsx
new file mode 100644
index 0000000000..a34277fe42
--- /dev/null
+++ b/frontend/src/editor/desktop/components/PlatformProviders.tsx
@@ -0,0 +1,25 @@
+import { ReactNode } from "react";
+import { PlatformProviders as ProprietaryPlatformProviders } from "@editor-proprietary/components/PlatformProviders";
+import { DESKTOP_DEFAULT_APP_CONFIG } from "@editor/config/defaultAppConfig";
+
+/**
+ * Retries the app config because the bundled backend may still be starting,
+ * and renders on the bundled defaults until DesktopConfigSync fetches it.
+ */
+export function PlatformProviders({ children }: { children: ReactNode }) {
+ return (
+ <ProprietaryPlatformProviders
+ appConfigRetryOptions={{
+ maxRetries: 5,
+ initialDelay: 1000,
+ }}
+ appConfigProviderProps={{
+ initialConfig: DESKTOP_DEFAULT_APP_CONFIG,
+ bootstrapMode: "non-blocking",
+ autoFetch: false,
+ }}
+ >
+ {children}
+ </ProprietaryPlatformProviders>
+ );
+}
diff --git a/frontend/src/editor/desktop/components/startup/StartupSetup.test.tsx b/frontend/src/editor/desktop/components/startup/StartupSetup.test.tsx
index adf9109e5f..ac560b8668 100644
--- a/frontend/src/editor/desktop/components/startup/StartupSetup.test.tsx
+++ b/frontend/src/editor/desktop/components/startup/StartupSetup.test.tsx
@@ -13,11 +13,8 @@ vi.mock("@editor/contexts/AppConfigContext", () => ({
useAppConfig: () => ({ config: { appVersion: h.appVersion } }),
}));
vi.mock("@editor-core/components/startup/StartupSetup", () => ({
- StartupSetup: (props: {
- children: ReactNode;
- refreshConfigOnMount: boolean;
- }) => {
- h.setup(props.refreshConfigOnMount);
+ StartupSetup: (props: { children: ReactNode }) => {
+ h.setup();
return <>{props.children}</>;
},
}));
@@ -28,12 +25,12 @@ beforeEach(() => {
});
afterEach(cleanup);
-it("waits for desktop config readiness without fetching the bundled backend", () => {
+it("waits for desktop config readiness", () => {
const view = render(<StartupSetup>Consent</StartupSetup>);
expect(h.setup).not.toHaveBeenCalled();
h.appVersion = "1.0";
view.rerender(<StartupSetup>Consent</StartupSetup>);
- expect(h.setup).toHaveBeenCalledWith(false);
+ expect(h.setup).toHaveBeenCalled();
});
it("leaves hosted account setup to the identity provider", () => {
diff --git a/frontend/src/editor/desktop/components/startup/StartupSetup.tsx b/frontend/src/editor/desktop/components/startup/StartupSetup.tsx
index 708acf0294..b2fea9378e 100644
--- a/frontend/src/editor/desktop/components/startup/StartupSetup.tsx
+++ b/frontend/src/editor/desktop/components/startup/StartupSetup.tsx
@@ -8,7 +8,5 @@ export function StartupSetup({ children }: { children: ReactNode }) {
const isSaaSMode = useSaaSMode();
const { config } = useAppConfig();
if (isSaaSMode || !config?.appVersion) return <>{children}</>;
- return (
- <CoreStartupSetup refreshConfigOnMount={false}>{children}</CoreStartupSetup>
- );
+ return <CoreStartupSetup>{children}</CoreStartupSetup>;
}
diff --git a/frontend/src/editor/proprietary/App.tsx b/frontend/src/editor/proprietary/App.tsx
index ae5d0a16d5..669bf4fdce 100644
--- a/frontend/src/editor/proprietary/App.tsx
+++ b/frontend/src/editor/proprietary/App.tsx
@@ -1,6 +1,7 @@
import { Suspense, lazy } from "react";
import { Routes, Route, Navigate, useParams } from "react-router-dom";
import { AppProviders } from "@editor/components/AppProviders";
+import { PlatformProviders } from "@editor/components/PlatformProviders";
import { AppLayout } from "@editor/components/AppLayout";
import { LoadingFallback } from "@editor/components/shared/LoadingFallback";
import { PreferencesProvider } from "@editor/contexts/PreferencesContext";
@@ -69,8 +70,8 @@ function MainRoutes() {
);
}
-// All other routes need AppProviders for backend integration. RootGate routes
-// "/" by role before any of it mounts.
+// All other routes need the editor's providers. RootGate routes "/" by role
+// before any of them mount.
function MainApp() {
return (
<RootGate>
@@ -119,7 +120,13 @@ export default function App() {
/>
{/* Both apps, under a shared frame so the rail renders once outside them. */}
- <Route element={<AppFrame />}>
+ <Route
+ element={
+ <PlatformProviders>
+ <AppFrame />
+ </PlatformProviders>
+ }
+ >
{/* The portal: its own shell, before the catch-all. An empty stub in core. */}
{getAdminRouteExtensions()}
<Route path="*" element={<MainApp />} />
diff --git a/frontend/src/editor/proprietary/auth/UseSession.tsx b/frontend/src/editor/proprietary/auth/UseSession.tsx
index f91de2958b..21ef830a95 100644
--- a/frontend/src/editor/proprietary/auth/UseSession.tsx
+++ b/frontend/src/editor/proprietary/auth/UseSession.tsx
@@ -8,7 +8,7 @@ import {
import { useAuth as useSharedAuth } from "@editor/auth/context";
import type { AuthUser } from "@editor/auth/types";
// Side-effect import: wires the editor's transport + platform seams into the
-// shared Spring engine before AppProviders mounts the provider below.
+// shared Spring engine before PlatformProviders mounts the provider below.
import "@editor/auth/configureSpringAuth";
export type { AuthUser as User } from "@editor/auth/types";
diff --git a/frontend/src/editor/proprietary/auth/configureSpringAuth.ts b/frontend/src/editor/proprietary/auth/configureSpringAuth.ts
index 73a6fb7293..9d60a23651 100644
--- a/frontend/src/editor/proprietary/auth/configureSpringAuth.ts
+++ b/frontend/src/editor/proprietary/auth/configureSpringAuth.ts
@@ -1,7 +1,7 @@
/**
* Wires the editor's transport + platform seams into the shared Spring auth
* engine. Import this module for its side effect (it configures the engine on
- * load) before any auth call runs - AppProviders does so via UseSession.
+ * load) before any auth call runs - PlatformProviders does so via UseSession.
*
* The `@editor/*` imports resolve per build flavor: proprietary/web gets the no-op
* web defaults, the desktop build gets the Tauri-backed implementations. So the
diff --git a/frontend/src/editor/proprietary/components/AppProviders.tsx b/frontend/src/editor/proprietary/components/AppProviders.tsx
index f277d7804f..0d7a9ef6a4 100644
--- a/frontend/src/editor/proprietary/components/AppProviders.tsx
+++ b/frontend/src/editor/proprietary/components/AppProviders.tsx
@@ -2,38 +2,22 @@ import {
AppProviders as CoreAppProviders,
AppProvidersProps,
} from "@editor-core/components/AppProviders";
-import { AuthProvider } from "@editor/auth/UseSession";
-import { LicenseProvider } from "@editor/contexts/LicenseContext";
import { CheckoutProvider } from "@editor/contexts/CheckoutContext";
import { UpgradeBannerInitializer } from "@editor/components/shared/UpgradeBannerInitializer";
-import { ServerExperienceProvider } from "@editor/contexts/ServerExperienceContext";
import { UpdateSeatsProvider } from "@editor/contexts/UpdateSeatsContext";
import { ChatProvider } from "@editor/components/chat/ChatContext";
import { AccountLinkNotice } from "@editor/components/AccountLinkNotice";
-export function AppProviders({
- children,
- appConfigRetryOptions,
- appConfigProviderProps,
-}: AppProvidersProps) {
+export function AppProviders({ children }: AppProvidersProps) {
return (
- <AuthProvider>
- <CoreAppProviders
- appConfigRetryOptions={appConfigRetryOptions}
- appConfigProviderProps={appConfigProviderProps}
- >
- <LicenseProvider>
- <UpdateSeatsProvider>
- <ServerExperienceProvider>
- <CheckoutProvider>
- <UpgradeBannerInitializer />
- <AccountLinkNotice />
- <ChatProvider>{children}</ChatProvider>
- </CheckoutProvider>
- </ServerExperienceProvider>
- </UpdateSeatsProvider>
- </LicenseProvider>
- </CoreAppProviders>
- </AuthProvider>
+ <CoreAppProviders>
+ <UpdateSeatsProvider>
+ <CheckoutProvider>
+ <UpgradeBannerInitializer />
+ <AccountLinkNotice />
+ <ChatProvider>{children}</ChatProvider>
+ </CheckoutProvider>
+ </UpdateSeatsProvider>
+ </CoreAppProviders>
);
}
diff --git a/frontend/src/editor/proprietary/components/PlatformProviders.tsx b/frontend/src/editor/proprietary/components/PlatformProviders.tsx
new file mode 100644
index 0000000000..5c61c9bb4b
--- /dev/null
+++ b/frontend/src/editor/proprietary/components/PlatformProviders.tsx
@@ -0,0 +1,28 @@
+import {
+ PlatformProviders as CorePlatformProviders,
+ PlatformProvidersProps,
+} from "@editor-core/components/PlatformProviders";
+import { AuthProvider } from "@editor/auth/UseSession";
+import { LicenseProvider } from "@editor/contexts/LicenseContext";
+import { ServerExperienceProvider } from "@editor/contexts/ServerExperienceContext";
+
+export type { PlatformProvidersProps };
+
+export function PlatformProviders({
+ children,
+ appConfigRetryOptions,
+ appConfigProviderProps,
+}: PlatformProvidersProps) {
+ return (
+ <AuthProvider>
+ <CorePlatformProviders
+ appConfigRetryOptions={appConfigRetryOptions}
+ appConfigProviderProps={appConfigProviderProps}
+ >
+ <LicenseProvider>
+ <ServerExperienceProvider>{children}</ServerExperienceProvider>
+ </LicenseProvider>
+ </CorePlatformProviders>
+ </AuthProvider>
+ );
+}
diff --git a/frontend/src/editor/proprietary/routes/Login.test.tsx b/frontend/src/editor/proprietary/routes/Login.test.tsx
index 290d6310d0..a5174cc90c 100644
--- a/frontend/src/editor/proprietary/routes/Login.test.tsx
+++ b/frontend/src/editor/proprietary/routes/Login.test.tsx
@@ -93,7 +93,7 @@ vi.mock("react-router-dom", async () => {
});
// AuthLayout renders <Footer>, which reads useFooterInfo. In the real router
-// /login sits inside AppProviders, which supplies the client.
+// /login sits inside PlatformProviders, which supplies the client.
const TestWrapper = ({ children }: { children: React.ReactNode }) => (
<TestQueryProvider>
<MantineProvider>
diff --git a/frontend/src/editor/proprietary/routes/RootGate.tsx b/frontend/src/editor/proprietary/routes/RootGate.tsx
index 472a83ae33..eac00693cc 100644
--- a/frontend/src/editor/proprietary/routes/RootGate.tsx
+++ b/frontend/src/editor/proprietary/routes/RootGate.tsx
@@ -18,9 +18,9 @@ interface Decision {
*
* Wraps the app rather than being a route of its own, which buys two things:
* - The editor never boots just to be redirected away from. Mounting the
- * decision inside the app booted IndexedDB, the file context, onboarding and
- * the license fetch on the way to the processor, then tore it all down - the
- * visible "editor flashes, then jumps" glitch.
+ * decision inside the app booted IndexedDB, the file context and onboarding
+ * on the way to the processor, then tore it all down - the visible "editor
+ * flashes, then jumps" glitch.
* - Every other path shares one element position with the app, so navigating
* away from "/" is a plain render, not a remount.
*
@@ -34,9 +34,8 @@ interface Decision {
* own destination (see resolveLandingPath) rather than bouncing through here,
* so signing in never tears the app back down.
*
- * Context-free by necessity, since it sits above the providers: apiClient
- * resolves its own auth token, and the opt-in arrives on the same
- * `/api/v1/auth/me` response. Builds with no processor (core, desktop) use the
+ * Context-free: apiClient resolves its own auth token, and the opt-in arrives
+ * on the same `/api/v1/auth/me` response. Builds with no processor (core, desktop) use the
* pass-through override.
*/
export function RootGate({ children }: { children: ReactNode }) {
diff --git a/frontend/src/editor/saas/App.tsx b/frontend/src/editor/saas/App.tsx
index ebb4bd5d2e..e6b0528ed2 100644
--- a/frontend/src/editor/saas/App.tsx
+++ b/frontend/src/editor/saas/App.tsx
@@ -2,6 +2,7 @@ import { Suspense, lazy } from "react";
import { Routes, Route, useLocation } from "react-router-dom";
import { isAuthRoute } from "@editor/utils/pathUtils";
import { AppProviders } from "@editor/components/AppProviders";
+import { PlatformProviders } from "@editor/components/PlatformProviders";
import { PublicRouteProviders } from "@editor/components/PublicRouteProviders";
import { RunLocationGate } from "@editor/components/runLocation/RunLocationGate";
import { setBaseUrl } from "@editor/constants/app";
@@ -87,14 +88,12 @@ function MainRoutes() {
);
}
-// Everything else needs the auth/backend providers. RootGate routes "/" by role
-// before any of it mounts.
+// Everything else needs the editor's providers. RootGate routes "/" by role
+// before any of them mount.
function MainApp() {
return (
<RootGate>
- <AppProviders
- appConfigProviderProps={{ onConfigLoaded: handleConfigLoaded }}
- >
+ <AppProviders>
<AppLayout>
<NonAuthBootstraps />
<ResumePendingConnect />
@@ -135,7 +134,15 @@ export default function App() {
{/* Before the frame and auth, so a first visit sees the chooser alone. */}
<Route element={<RunLocationGate />}>
{/* Both apps, under a shared frame so the rail renders once outside them. */}
- <Route element={<AppFrame />}>
+ <Route
+ element={
+ <PlatformProviders
+ appConfigProviderProps={{ onConfigLoaded: handleConfigLoaded }}
+ >
+ <AppFrame />
+ </PlatformProviders>
+ }
+ >
{/* The portal: its own top-level shell, before the catch-all. */}
{getAdminRouteExtensions()}
<Route path="*" element={<MainApp />} />
diff --git a/frontend/src/editor/saas/components/AppProviders.tsx b/frontend/src/editor/saas/components/AppProviders.tsx
index 4a3c4b1794..613621903c 100644
--- a/frontend/src/editor/saas/components/AppProviders.tsx
+++ b/frontend/src/editor/saas/components/AppProviders.tsx
@@ -2,16 +2,9 @@ import { AppProviders as ProprietaryAppProviders } from "@editor-proprietary/com
import { AppProvidersProps } from "@editor-core/components/AppProviders";
import { SaaSTeamProvider } from "@editor/contexts/SaaSTeamContext";
-export function AppProviders({
- children,
- appConfigRetryOptions,
- appConfigProviderProps,
-}: AppProvidersProps) {
+export function AppProviders({ children }: AppProvidersProps) {
return (
- <ProprietaryAppProviders
- appConfigRetryOptions={appConfigRetryOptions}
- appConfigProviderProps={appConfigProviderProps}
- >
+ <ProprietaryAppProviders>
<SaaSTeamProvider>{children}</SaaSTeamProvider>
</ProprietaryAppProviders>
);
diff --git a/frontend/src/editor/saas/components/PublicRouteProviders.tsx b/frontend/src/editor/saas/components/PublicRouteProviders.tsx
index 879ceaeb9d..54831f4004 100644
--- a/frontend/src/editor/saas/components/PublicRouteProviders.tsx
+++ b/frontend/src/editor/saas/components/PublicRouteProviders.tsx
@@ -4,7 +4,7 @@ import { ThemeProvider } from "@editor/components/shared/ThemeProvider";
/**
* Theme and preferences only, for pages that render without a session: no
- * AppProviders, so no auth and no backend bootstrap.
+ * PlatformProviders, so no auth and no backend bootstrap.
*/
export function PublicRouteProviders({ children }: { children: ReactNode }) {
return (
diff --git a/frontend/src/processor/proprietary/PortalApp.tsx b/frontend/src/processor/proprietary/PortalApp.tsx
index 2d68c63b71..5c1e29f9e2 100644
--- a/frontend/src/processor/proprietary/PortalApp.tsx
+++ b/frontend/src/processor/proprietary/PortalApp.tsx
@@ -4,7 +4,6 @@ import { PortalAuthBoundary } from "@processor/auth/PortalAuthBoundary";
import { ThemeProvider, useTheme } from "@processor/contexts/ThemeContext";
import { SuiProvider } from "@processor/theme/SuiProvider";
import { PortalProviders } from "@processor/PortalProviders";
-import { ToolRegistryProvider } from "@editor/contexts/ToolRegistryProvider";
import { getPortalQueryClient } from "@processor/queryClient";
// Reset + typography, scoped to .portal-scope below.
import "@processor/theme/base.css";
@@ -21,10 +20,11 @@ function ThemedSuiProvider({ children }: { children: ReactNode }) {
/**
* The portal, mounted as a route-set under /processor/* inside the editor app
- * (via the admin-route seam). It supplies its own providers and its own i18next
- * instance (the `portal` namespace), but NOT a router — the editor's
- * <BrowserRouter> is the one and only router; the portal's routes are relative
- * to the /processor mount (see ViewRouter).
+ * (via the admin-route seam). Session-wide state (auth, app config, licence,
+ * tool registry) comes from the PlatformProviders above the frame; this adds
+ * only what the portal owns, and NOT a router — the editor's <BrowserRouter> is
+ * the one and only router; the portal's routes are relative to the /processor
+ * mount (see ViewRouter).
*
* The provider stack itself is a per-flavor seam (see {@link PortalProviders}):
* self-hosted mounts the account-link layer, SaaS does not.
@@ -37,13 +37,9 @@ export function PortalApp() {
<ThemedSuiProvider>
{/* Scopes base.css to the portal so it doesn't restyle the host editor. */}
<div className="portal-scope">
- {/* Tool registry is read by portal views (e.g. the policy setup
- wizard); mount it above the per-flavor provider split. */}
- <ToolRegistryProvider>
- <PortalAuthBoundary>
- <PortalProviders />
- </PortalAuthBoundary>
- </ToolRegistryProvider>
+ <PortalAuthBoundary>
+ <PortalProviders />
+ </PortalAuthBoundary>
</div>
</ThemedSuiProvider>
</ThemeProvider>
diff --git a/frontend/src/processor/proprietary/PortalProviders.startup.test.tsx b/frontend/src/processor/proprietary/PortalProviders.startup.test.tsx
index 440640893a..46ed9ea7f4 100644
--- a/frontend/src/processor/proprietary/PortalProviders.startup.test.tsx
+++ b/frontend/src/processor/proprietary/PortalProviders.startup.test.tsx
@@ -1,10 +1,10 @@
import type { ReactNode } from "react";
import { cleanup, render, screen } from "@testing-library/react";
import { afterEach, expect, it, vi } from "vitest";
-import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { MemoryRouter } from "react-router-dom";
import { MantineProvider } from "@mantine/core";
import { PortalProviders } from "@processor/PortalProviders";
+import { PlatformProviders } from "@editor/components/PlatformProviders";
const h = vi.hoisted(() => ({
get: vi.fn(),
@@ -16,14 +16,18 @@ const h = vi.hoisted(() => ({
signOut: vi.fn(),
},
}));
-vi.mock("react-i18next", () => ({
+vi.mock("react-i18next", async (importOriginal) => ({
+ ...(await importOriginal<typeof import("react-i18next")>()),
useTranslation: () => ({
t: (key: string) => key,
i18n: { language: "en-US" },
}),
}));
vi.mock("@editor/auth", () => ({ useAuth: () => h.auth }));
-vi.mock("@editor/auth/UseSession", () => ({ useAuth: () => h.auth }));
+vi.mock("@editor/auth/UseSession", () => ({
+ AuthProvider: ({ children }: { children: ReactNode }) => children,
+ useAuth: () => h.auth,
+}));
vi.mock("@editor/services/apiClient", () => ({ default: { get: h.get } }));
vi.mock("@editor/extensions/accountLogout", () => ({
useAccountLogout: () => vi.fn(),
@@ -91,16 +95,13 @@ it("mounts mandatory setup on a cold Processor entry without editor providers",
return { data: { showDefaultCredentials: true } };
throw new Error(`Unexpected request: ${url}`);
});
- const client = new QueryClient({
- defaultOptions: { queries: { retry: false, gcTime: 0 } },
- });
const view = render(
<MemoryRouter initialEntries={["/processor/policies"]}>
- <QueryClientProvider client={client}>
- <MantineProvider>
+ <MantineProvider>
+ <PlatformProviders>
<PortalProviders />
- </MantineProvider>
- </QueryClientProvider>
+ </PlatformProviders>
+ </MantineProvider>
</MemoryRouter>,
);
expect(
@@ -108,5 +109,4 @@ it("mounts mandatory setup on a cold Processor entry without editor providers",
).toBeVisible();
expect(screen.getByText("Processor")).toBeVisible();
view.unmount();
- client.clear();
});
diff --git a/frontend/src/processor/proprietary/PortalProviders.test.tsx b/frontend/src/processor/proprietary/PortalProviders.test.tsx
index ed30ffea9a..9454c4b652 100644
--- a/frontend/src/processor/proprietary/PortalProviders.test.tsx
+++ b/frontend/src/processor/proprietary/PortalProviders.test.tsx
@@ -1,10 +1,10 @@
import { beforeEach, describe, expect, it, vi } from "vitest";
import { fireEvent, render, screen, waitFor } from "@testing-library/react";
-import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { MemoryRouter } from "react-router-dom";
import { MantineProvider } from "@mantine/core";
import type { ReactNode } from "react";
import { PortalProviders } from "@editor/portal/PortalProviders";
+import { PlatformProviders } from "@editor/components/PlatformProviders";
import { ServerLicenseSection } from "@editor/portal/components/billing/ServerLicenseSection";
const { fetchAppConfig, getLicenseInfo } = vi.hoisted(() => ({
@@ -15,6 +15,10 @@ const { fetchAppConfig, getLicenseInfo } = vi.hoisted(() => ({
vi.mock("@editor/auth", () => ({
useAuth: () => ({ user: { id: "owner" }, isAdmin: true, loading: false }),
}));
+vi.mock("@editor/auth/UseSession", async (importOriginal) => ({
+ ...(await importOriginal<typeof import("@editor/auth/UseSession")>()),
+ AuthProvider: ({ children }: { children: ReactNode }) => children,
+}));
vi.mock("@editor/api/config", () => ({
DEFAULT_APP_CONFIG: { enableLogin: true },
fetchAppConfig,
@@ -56,21 +60,17 @@ vi.mock("@editor/portal/components/PortalChrome", () => ({
function renderPortal() {
return render(
- <QueryClientProvider
- client={
- new QueryClient({ defaultOptions: { queries: { retry: false } } })
- }
- >
- <MemoryRouter initialEntries={["/processor/usage"]}>
- <MantineProvider>
+ <MemoryRouter initialEntries={["/processor/usage"]}>
+ <MantineProvider>
+ <PlatformProviders>
<PortalProviders />
- </MantineProvider>
- </MemoryRouter>
- </QueryClientProvider>,
+ </PlatformProviders>
+ </MantineProvider>
+ </MemoryRouter>,
);
}
-describe("PortalProviders license loading", () => {
+describe("Processor license loading", () => {
beforeEach(() => {
fetchAppConfig
.mockReset()
diff --git a/frontend/src/processor/proprietary/PortalProviders.tsx b/frontend/src/processor/proprietary/PortalProviders.tsx
index 680bc48968..6e3f57c74c 100644
--- a/frontend/src/processor/proprietary/PortalProviders.tsx
+++ b/frontend/src/processor/proprietary/PortalProviders.tsx
@@ -7,10 +7,7 @@ import { ConnectCallbackHost } from "@editor/portal/components/account-link/Conn
import { PortalChrome } from "@editor/portal/components/PortalChrome";
import { AccountLinkSessionBoundary } from "@editor/portal/components/account-link/AccountLinkSessionBoundary";
import { useFreeTierExhaustedPrompt } from "@editor/portal/hooks/useFreeTierExhaustedPrompt";
-import { LicenseProvider } from "@editor/contexts/LicenseContext";
-import { AppConfigProvider } from "@editor/contexts/AppConfigContext";
import { StartupPrompts } from "@editor/components/startup/StartupPrompts";
-import { ServerExperienceProvider } from "@editor/contexts/ServerExperienceContext";
import { CheckoutProvider } from "@editor/contexts/CheckoutContext";
function LinkModalHost() {
@@ -19,10 +16,8 @@ function LinkModalHost() {
}
/**
- * Self-hosted provider stack. Checkout is mounted here rather than inherited: the portal is its
- * own route-set, outside the {@code AppProviders} where the editor keeps its copy.
- * License and checkout both need the local app config; without its provider, license loading
- * waits indefinitely for the admin and login settings.
+ * Self-hosted provider stack. Checkout is mounted here rather than inherited: its modal renders
+ * inside whichever app opened it, so each app mounts its own under its own theme.
*/
export function PortalProviders() {
return (
@@ -31,18 +26,12 @@ export function PortalProviders() {
<AccountLinkSessionBoundary>
<UIProvider>
<AccountLinkProvider>
- <AppConfigProvider>
- <LicenseProvider>
- <CheckoutProvider>
- <ServerExperienceProvider>
- <StartupPrompts />
- <PortalChrome />
- </ServerExperienceProvider>
- <LinkModalHost />
- <ConnectCallbackHost />
- </CheckoutProvider>
- </LicenseProvider>
- </AppConfigProvider>
+ <CheckoutProvider>
+ <StartupPrompts />
+ <PortalChrome />
+ <LinkModalHost />
+ <ConnectCallbackHost />
+ </CheckoutProvider>
</AccountLinkProvider>
</UIProvider>
</AccountLinkSessionBoundary>
diff --git a/frontend/src/processor/proprietary/auth/PortalAuthBoundary.tsx b/frontend/src/processor/proprietary/auth/PortalAuthBoundary.tsx
index 1ddc27aa0d..bfa71c9a59 100644
--- a/frontend/src/processor/proprietary/auth/PortalAuthBoundary.tsx
+++ b/frontend/src/processor/proprietary/auth/PortalAuthBoundary.tsx
@@ -1,15 +1,10 @@
import { type ReactNode } from "react";
-import { AuthProvider } from "@editor/auth";
import { AuthGate } from "@processor/components/AuthGate";
/**
- * The self-hosted Processor owns its Spring session provider and uses the shared
- * /login route. SaaS overrides this boundary to use the editor's Supabase session.
+ * Gates the self-hosted Processor on the platform's Spring session, using the
+ * shared /login route. SaaS overrides this boundary to gate on the Supabase session.
*/
export function PortalAuthBoundary({ children }: { children: ReactNode }) {
- return (
- <AuthProvider mode="spring">
- <AuthGate>{children}</AuthGate>
- </AuthProvider>
- );
+ return <AuthGate>{children}</AuthGate>;
}
diff --git a/frontend/src/processor/proprietary/components/PortalChrome.stories.tsx b/frontend/src/processor/proprietary/components/PortalChrome.stories.tsx
index ff2cff2861..12e4a43e6d 100644
--- a/frontend/src/processor/proprietary/components/PortalChrome.stories.tsx
+++ b/frontend/src/processor/proprietary/components/PortalChrome.stories.tsx
@@ -1,10 +1,18 @@
import type { Meta, StoryObj } from "@storybook/react-vite";
+import { ToolRegistryProvider } from "@editor/contexts/ToolRegistryProvider";
import { PortalChrome } from "@processor/components/PortalChrome";
const meta = {
title: "Portal/Shell/PortalChrome",
component: PortalChrome,
parameters: { layout: "fullscreen" },
+ decorators: [
+ (Story) => (
+ <ToolRegistryProvider>
+ <Story />
+ </ToolRegistryProvider>
+ ),
+ ],
} satisfies Meta<typeof PortalChrome>;
export default meta;
type Story = StoryObj<typeof meta>;
diff --git a/frontend/src/processor/proprietary/components/PortalChrome.tsx b/frontend/src/processor/proprietary/components/PortalChrome.tsx
index 549b734975..eeeb644106 100644
--- a/frontend/src/processor/proprietary/components/PortalChrome.tsx
+++ b/frontend/src/processor/proprietary/components/PortalChrome.tsx
@@ -1,7 +1,5 @@
import { AccountConnectionRefresh } from "@editor/portal/components/account-link/AccountConnectionNotice";
import { useLocation } from "react-router-dom";
-import { AppConfigProvider } from "@editor/contexts/AppConfigContext";
-import { ToolRegistryProvider } from "@editor/contexts/ToolRegistryProvider";
import { ErrorBoundary } from "@editor/portal/components/ErrorBoundary";
import { AppShell } from "@editor/portal/components/AppShell";
import { ViewRouter } from "@editor/portal/ViewRouter";
@@ -22,23 +20,18 @@ function RoutedContent() {
/**
* The flavor-agnostic portal chrome: the shell (sidebar + search bar + routed
- * view) plus the global overlays that every flavor shares. Requires only the
- * Tier and UI contexts above it — both flavors provide those. Flavor-specific
- * overlays (e.g. the self-hosted account-link modal) are mounted by
- * PortalProviders, not here.
+ * view) plus the global overlays that every flavor shares. Requires the Tier
+ * and UI contexts above it, which both flavors provide, and reads the app
+ * config and tool registry from PlatformProviders. Flavor-specific overlays
+ * (e.g. the self-hosted account-link modal) are mounted by PortalProviders.
*/
export function PortalChrome() {
return (
- // One app-config instance for every portal consumer (the search gates, the
- // sidebar) so they can't fetch twice or disagree.
- <AppConfigProvider bootstrapMode="non-blocking">
- {/* The pipeline builder reads the tool registry to list and configure operations. */}
- <ToolRegistryProvider>
- <AccountConnectionRefresh />
- <AppShell>
- <RoutedContent />
- </AppShell>
- </ToolRegistryProvider>
- </AppConfigProvider>
+ <>
+ <AccountConnectionRefresh />
+ <AppShell>
+ <RoutedContent />
+ </AppShell>
+ </>
);
}
diff --git a/frontend/src/processor/proprietary/components/PortalSearchBar.tsx b/frontend/src/processor/proprietary/components/PortalSearchBar.tsx
index f1fbe5146c..d401a0f0ab 100644
--- a/frontend/src/processor/proprietary/components/PortalSearchBar.tsx
+++ b/frontend/src/processor/proprietary/components/PortalSearchBar.tsx
@@ -9,7 +9,7 @@ import "@processor/components/PortalSearchBar.css";
* The portal face of the global super search — the same bar the editor's
* workbench shows, fed by the portal-wired results provider. Cmd/Ctrl+K
* focuses it (the bar registers its own shortcut). App config (the
- * admin/login gates) comes from PortalChrome's shared provider. The distinct
+ * admin/login gates) comes from PlatformProviders. The distinct
* input id keeps this instance clear of the editor bar's stable id, which
* external focus helpers target.
*/
diff --git a/frontend/src/processor/proprietary/components/settings/PortalSettingsProviders.tsx b/frontend/src/processor/proprietary/components/settings/PortalSettingsProviders.tsx
index 88ee49f6d1..6d117c3ef3 100644
--- a/frontend/src/processor/proprietary/components/settings/PortalSettingsProviders.tsx
+++ b/frontend/src/processor/proprietary/components/settings/PortalSettingsProviders.tsx
@@ -18,7 +18,7 @@ function SettingsLinkModalHost() {
return <LinkAccountModalHost />;
}
-/** The instance link starts unknown; checkout and license are inherited from AppProviders. */
+/** The instance link starts unknown; checkout comes from AppProviders, the licence from PlatformProviders. */
export function PortalSettingsProviders({ children }: { children: ReactNode }) {
return (
<LinkProvider initialState="unlinked" statusKnown={false}>
diff --git a/frontend/src/processor/proprietary/hooks/useConnectGate.test.tsx b/frontend/src/processor/proprietary/hooks/useConnectGate.test.tsx
index 2e2420509f..21a17aa0af 100644
--- a/frontend/src/processor/proprietary/hooks/useConnectGate.test.tsx
+++ b/frontend/src/processor/proprietary/hooks/useConnectGate.test.tsx
@@ -3,6 +3,7 @@ import { fireEvent, render, screen, waitFor } from "@testing-library/react";
import { PortalTestProviders } from "@processor/test/TestQueryProvider";
import { LinkProvider, type LinkState } from "@processor/contexts/LinkContext";
import { UIProvider } from "@processor/contexts/UIContext";
+import { AppConfigProvider } from "@editor/contexts/AppConfigContext";
/**
* The gate answers two questions, and conflating them is the failure that matters: an instance
@@ -10,9 +11,9 @@ import { UIProvider } from "@processor/contexts/UIContext";
* Pipelines, Policies, Users, Sources and Integrations on every default install with no way out.
*/
const { json } = vi.hoisted(() => ({ json: vi.fn() }));
-vi.mock("@processor/api/http", () => ({
- apiClient: { local: { json } },
- errorMessage: (e: unknown) => String(e),
+vi.mock("@editor/api/config", () => ({
+ DEFAULT_APP_CONFIG: { enableLogin: true },
+ fetchAppConfig: json,
}));
import { useConnectGate } from "@processor/hooks/useConnectGate";
@@ -37,11 +38,13 @@ function Probe() {
function renderProbe(linkState: LinkState) {
return render(
<PortalTestProviders>
- <LinkProvider initialState={linkState}>
- <UIProvider>
- <Probe />
- </UIProvider>
- </LinkProvider>
+ <AppConfigProvider>
+ <LinkProvider initialState={linkState}>
+ <UIProvider>
+ <Probe />
+ </UIProvider>
+ </LinkProvider>
+ </AppConfigProvider>
</PortalTestProviders>,
);
}
@@ -55,16 +58,17 @@ describe("useConnectGate", () => {
});
it("does not require an instance status or configuration check on SaaS", async () => {
- json.mockRejectedValue(new Error("No local instance"));
+ json.mockReturnValue(new Promise(() => {}));
render(
<PortalTestProviders>
- <UIProvider>
- <Probe />
- </UIProvider>
+ <AppConfigProvider>
+ <UIProvider>
+ <Probe />
+ </UIProvider>
+ </AppConfigProvider>
</PortalTestProviders>,
);
await settled("unavailable:open");
- expect(json).not.toHaveBeenCalled();
});
it("gates an unlinked instance that can link", async () => {
diff --git a/frontend/src/processor/proprietary/hooks/useConnectGate.ts b/frontend/src/processor/proprietary/hooks/useConnectGate.ts
index da1f7ec2ad..aae32c05aa 100644
--- a/frontend/src/processor/proprietary/hooks/useConnectGate.ts
+++ b/frontend/src/processor/proprietary/hooks/useConnectGate.ts
@@ -1,15 +1,9 @@
import { useCallback } from "react";
-import { useQuery } from "@tanstack/react-query";
-import { apiClient, errorMessage } from "@processor/api/http";
-import { qk } from "@processor/queries/keys";
+import { useAppConfig } from "@editor/contexts/AppConfigContext";
import { useLinkOptional } from "@processor/contexts/LinkContext";
import { useUI } from "@processor/contexts/UIContext";
import { useAccountLinkOptional } from "@processor/contexts/AccountLinkContext";
-interface AppConfigShape {
- accountLinkAvailable?: boolean;
-}
-
interface ConnectGate {
/** Can link but has not, so gated features must ask first. */
gated: boolean;
@@ -38,27 +32,22 @@ export function useConnectGate(): ConnectGate {
const { openLinkModal } = useUI();
const accountLink = useAccountLinkOptional();
- const query = useQuery({
- enabled: link != null,
- queryKey: qk.appConfig(),
- queryFn: () =>
- apiClient.local.json<AppConfigShape>("/api/v1/config/app-config"),
- });
+ const appConfig = useAppConfig();
- const available = Boolean(query.data?.accountLinkAvailable) && link != null;
+ const available =
+ Boolean(appConfig.config?.accountLinkAvailable) && link != null;
const statusKnown = link?.statusKnown ?? false;
- const error =
- link != null && query.isError
- ? errorMessage(query.error)
- : available && !statusKnown
- ? (accountLink?.statusError ?? null)
- : null;
+ const configError = link != null ? appConfig.error : null;
+ const statusError =
+ available && !statusKnown ? (accountLink?.statusError ?? null) : null;
+ const error = configError ?? statusError;
// A disabled capability has no status endpoint. Only wait for link status when linking applies.
const loading =
- link != null && (query.isPending || (available && !statusKnown && !error));
+ link != null &&
+ (appConfig.config == null || (available && !statusKnown && !error));
const gated = !error && available && statusKnown && !link?.isLinked;
const retry = () => {
- if (query.isError) void query.refetch();
+ if (configError) void appConfig.refetch();
else void accountLink?.refresh();
};
diff --git a/frontend/src/processor/proprietary/queries/keys.ts b/frontend/src/processor/proprietary/queries/keys.ts
index 451c04fba8..3ef9a2c04b 100644
--- a/frontend/src/processor/proprietary/queries/keys.ts
+++ b/frontend/src/processor/proprietary/queries/keys.ts
@@ -17,7 +17,6 @@ export const qk = {
sources: () => ["portal", "sources"] as const,
policyPermissions: () => ["portal", "policies", "permissions"] as const,
fleetStats: () => ["portal", "fleetStats"] as const,
- appConfig: () => ["portal", "appConfig"] as const,
freeTier: () => ["portal", "freeTier"] as const,
/** Storage-encryption migration progress, polled while a run is active. */
encryptionMigration: () => ["portal", "encryptionMigration"] as const,
diff --git a/frontend/src/processor/proprietary/queryClient.ts b/frontend/src/processor/proprietary/queryClient.ts
index 0db3b3cc1b..6d59c24cec 100644
--- a/frontend/src/processor/proprietary/queryClient.ts
+++ b/frontend/src/processor/proprietary/queryClient.ts
@@ -6,11 +6,11 @@ let current: QueryClient | null = null;
/**
* One client for the session, not one per mount. The portal is a route, so
* switching to the editor unmounts it, and a per-mount client would throw the
- * cache away and refetch everything on the way back. The editor's own client
- * sits above the router and never pays that.
+ * cache away and refetch everything on the way back.
*
- * Still a separate instance from the editor's: the two namespace their keys
- * apart and invalidate independently.
+ * Still a separate instance from the platform's (see PlatformProviders): the
+ * portal invalidates and clears its own cache without touching the app config
+ * or the editor's.
*/
export function getPortalQueryClient(): QueryClient {
current ??= new QueryClient({
diff --git a/frontend/src/processor/saas/PortalProviders.test.tsx b/frontend/src/processor/saas/PortalProviders.test.tsx
index 3b9b341021..d9f189a99b 100644
--- a/frontend/src/processor/saas/PortalProviders.test.tsx
+++ b/frontend/src/processor/saas/PortalProviders.test.tsx
@@ -8,12 +8,6 @@ import { useUI } from "@editor/portal/contexts/UIContext";
vi.mock("@editor/portal/contexts/TierContext", () => ({
TierProvider: ({ children }: { children: ReactNode }) => children,
}));
-vi.mock("@editor/contexts/AppConfigContext", () => ({
- AppConfigProvider: ({ children }: { children: ReactNode }) => children,
-}));
-vi.mock("@editor/contexts/LicenseContext", () => ({
- LicenseProvider: ({ children }: { children: ReactNode }) => children,
-}));
vi.mock("@editor/contexts/CheckoutContext", () => ({
CheckoutProvider: ({ children }: { children: ReactNode }) => children,
}));
diff --git a/frontend/src/processor/saas/PortalProviders.tsx b/frontend/src/processor/saas/PortalProviders.tsx
index 97601b3cf5..ff8753a884 100644
--- a/frontend/src/processor/saas/PortalProviders.tsx
+++ b/frontend/src/processor/saas/PortalProviders.tsx
@@ -1,9 +1,7 @@
import { TierProvider } from "@processor/contexts/TierContext";
import { UIProvider } from "@processor/contexts/UIContext";
import { PortalChrome } from "@processor/components/PortalChrome";
-import { LicenseProvider } from "@editor/contexts/LicenseContext";
import { StartupPrompts } from "@editor/components/startup/StartupPrompts";
-import { AppConfigProvider } from "@editor/contexts/AppConfigContext";
import { CheckoutProvider } from "@editor/contexts/CheckoutContext";
/**
@@ -14,21 +12,15 @@ import { CheckoutProvider } from "@editor/contexts/CheckoutContext";
* machinery out of the SaaS bundle entirely.
*
* <p>Checkout is mounted so the buy doors on Usage & Billing are the same on both editions.
- * LicenseProvider comes with it rather than on its own account: CheckoutProvider calls
- * {@code useLicense}, which throws without one.
*/
export function PortalProviders() {
return (
<TierProvider>
<UIProvider>
- <AppConfigProvider>
- <LicenseProvider>
- <CheckoutProvider>
- <StartupPrompts />
- <PortalChrome />
- </CheckoutProvider>
- </LicenseProvider>
- </AppConfigProvider>
+ <CheckoutProvider>
+ <StartupPrompts />
+ <PortalChrome />
+ </CheckoutProvider>
</UIProvider>
</TierProvider>
);
diff --git a/frontend/src/processor/saas/auth/PortalAuthBoundary.test.tsx b/frontend/src/processor/saas/auth/PortalAuthBoundary.test.tsx
index 2942e8eb8e..e402f640bf 100644
--- a/frontend/src/processor/saas/auth/PortalAuthBoundary.test.tsx
+++ b/frontend/src/processor/saas/auth/PortalAuthBoundary.test.tsx
@@ -25,11 +25,6 @@ vi.mock("@editor/auth", () => ({
AuthProvider: ({ children }: { children: ReactNode }) => children,
}));
vi.mock("@editor/auth/context", () => ({ useAuth: () => authState }));
-// Passthrough too — the real one builds a Supabase client at import time, which
-// needs env this suite deliberately does not set.
-vi.mock("@editor/auth/UseSession", () => ({
- AuthProvider: ({ children }: { children: ReactNode }) => children,
-}));
vi.mock("@editor/ui", () => ({ Spinner: () => null }));
vi.mock("@processor/auth/saasSupabase", () => ({
ensureSaasSupabase: vi.fn(),
diff --git a/frontend/src/processor/saas/auth/PortalAuthBoundary.tsx b/frontend/src/processor/saas/auth/PortalAuthBoundary.tsx
index 86ff042490..3fe39b3335 100644
--- a/frontend/src/processor/saas/auth/PortalAuthBoundary.tsx
+++ b/frontend/src/processor/saas/auth/PortalAuthBoundary.tsx
@@ -1,7 +1,6 @@
import { useEffect, type ReactNode } from "react";
import { AuthProvider } from "@editor/auth";
import { useAuth } from "@editor/auth/context";
-import { AuthProvider as SaasSessionProvider } from "@editor/auth/UseSession";
import { Spinner } from "@editor/ui";
import { stripBasePath, withBasePath } from "@editor/constants/app";
import { rememberPendingDestination } from "@editor/services/pendingDestination";
@@ -81,11 +80,9 @@ function SaasPortalGate({ children }: { children: ReactNode }) {
* SaaS override of the portal auth boundary: authenticate against the SaaS Supabase
* project (inheriting the editor's session) instead of the self-hosted Spring login.
*
- * Two providers, because the Processor mounts outside the editor's AppProviders (it
- * is a sibling route, not a child). The unified AuthProvider is what gates entry;
- * the saas session provider is what the saas-layer hooks read - profile picture,
- * display name, pro status - so without it every one of them sees an unmounted
- * context and reports nothing. Both read the same persisted session.
+ * The saas session provider the saas-layer hooks read is mounted by the platform;
+ * the gate reads the unified auth context, which only the unified AuthProvider
+ * feeds, so that one is mounted here. Both read the same persisted session.
*/
export function PortalAuthBoundary({ children }: { children: ReactNode }) {
// Configure the shared Supabase client (SaaS project) synchronously here, before
@@ -95,10 +92,8 @@ export function PortalAuthBoundary({ children }: { children: ReactNode }) {
// signed into the editor is picked up from the persisted session (no second login).
ensureSaasSupabase();
return (
- <SaasSessionProvider>
- <AuthProvider mode="supabase">
- <SaasPortalGate>{children}</SaasPortalGate>
- </AuthProvider>
- </SaasSessionProvider>
+ <AuthProvider mode="supabase">
+ <SaasPortalGate>{children}</SaasPortalGate>
+ </AuthProvider>
);
}