Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

fix(studio): restore eager Settings and keep startup splash until ready (#10629)

Wasim Yousef Saide3e457a7d786
diff --git a/studio/frontend/src/app/provider.tsx b/studio/frontend/src/app/provider.tsx
index 6209254ec94..9612967d6f6 100644
--- a/studio/frontend/src/app/provider.tsx
+++ b/studio/frontend/src/app/provider.tsx
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+import { AppReadinessBoundary } from "@/components/app-readiness";
import { LlamaUpdateBanner } from "@/components/llama-update-banner";
import {
ClosingScreen,
@@ -550,6 +551,24 @@ function TauriWrapper({ children }: { children: ReactNode }) {
const [desktopAuthReady, setDesktopAuthReady] = useState(!isTauri);
const [desktopAuthRetry, setDesktopAuthRetry] = useState(0);
const [nativeMacControlsHidden, setNativeMacControlsHidden] = useState(false);
+ const [appShellReady, setAppShellReady] = useState(false);
+ const canMountApp = status === "running" && desktopAuthReady;
+
+ // Readiness is delivered by the mounted AppReadinessBoundary, not the
+ // global reload-snapshot event: an obsolete async load cannot reveal us.
+
+ useEffect(() => {
+ if (!isTauri) return;
+ if (!canMountApp) {
+ setAppShellReady(false);
+ return;
+ }
+ if (appShellReady) return;
+ // A failed route/chunk must not strand the user behind the splash. Reveal
+ // its error/recovery UI after a bounded wait; never bypass credential auth.
+ const timeout = window.setTimeout(() => setAppShellReady(true), 15_000);
+ return () => window.clearTimeout(timeout);
+ }, [canMountApp, appShellReady]);
const [windowRevealRevision, setWindowRevealRevision] = useState(0);
const usesCustomTitlebar = shouldUseCustomWindowTitlebar();
@@ -717,40 +736,56 @@ function TauriWrapper({ children }: { children: ReactNode }) {
);
}
- const showApp = status === "running" && desktopAuthReady;
+ const showApp = canMountApp && appShellReady;
const startupStatus = status === "running" ? "starting" : status;
const startupProgressDetail = progressDetail;
- const shell = showApp ? (
- <TauriUpdateLayer
- isExternalServer={isExternalServer}
- appContent={
- <>
- <NativeIntentDrain />
- {children}
- </>
- }
- >
- <LlamaUpdateBanner positioned={false} enabled={!hidesTitlebarSidebar} />
- <DownloadManagerPanel positioned={false} />
- <LoadedModelsIndicator positioned={false} />
- </TauriUpdateLayer>
- ) : (
- <StartupScreen
- status={startupStatus}
- logs={logs}
- error={error}
- currentStepIndex={currentStepIndex}
- progressDetail={startupProgressDetail}
- startupMessage={startupMessage}
- elevationPackages={elevationPackages}
- onInstall={startInstall}
- onRetry={retry}
- onRetryInstall={retryInstall}
- onApproveElevation={approveElevation}
- onStartServer={retry}
- onCopyDiagnostics={copyDiagnostics}
- />
+ const shell = (
+ <>
+ {canMountApp && (
+ <div
+ className="h-full min-h-0"
+ style={{ visibility: showApp ? "visible" : "hidden" }}
+ inert={!showApp}
+ aria-hidden={!showApp}
+ >
+ <AppReadinessBoundary onReady={setAppShellReady} revealed={showApp}>
+ <TauriUpdateLayer
+ isExternalServer={isExternalServer}
+ appContent={
+ <>
+ {showApp && <NativeIntentDrain />}
+ {children}
+ </>
+ }
+ >
+ <LlamaUpdateBanner positioned={false} enabled={!hidesTitlebarSidebar} />
+ <DownloadManagerPanel positioned={false} />
+ <LoadedModelsIndicator positioned={false} />
+ </TauriUpdateLayer>
+ </AppReadinessBoundary>
+ </div>
+ )}
+ {!showApp && (
+ <div className="fixed inset-0 z-40 bg-background">
+ <StartupScreen
+ status={startupStatus}
+ logs={logs}
+ error={error}
+ currentStepIndex={currentStepIndex}
+ progressDetail={startupProgressDetail}
+ startupMessage={startupMessage}
+ elevationPackages={elevationPackages}
+ onInstall={startInstall}
+ onRetry={retry}
+ onRetryInstall={retryInstall}
+ onApproveElevation={approveElevation}
+ onStartServer={retry}
+ onCopyDiagnostics={copyDiagnostics}
+ />
+ </div>
+ )}
+ </>
);
// Over the shell, not instead of it: a declined quit must not remount the tree.
diff --git a/studio/frontend/src/app/routes/__root.tsx b/studio/frontend/src/app/routes/__root.tsx
index 63f8f564b3e..e9ea92e5da8 100644
--- a/studio/frontend/src/app/routes/__root.tsx
+++ b/studio/frontend/src/app/routes/__root.tsx
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+import { useAppShellReadySignal } from "@/components/app-readiness";
import { AppSidebar } from "@/components/app-sidebar";
import { Navbar } from "@/components/navbar";
import { SidebarInset, SidebarProvider } from "@/components/ui/sidebar";
@@ -80,14 +81,19 @@ function RouteFallback() {
// Retires the retained reload shell (public/reload-snapshot.js). It rides
// inside the route's own Suspense boundary, so a lazy page that is still
// resolving keeps the shell up instead of uncovering RouteFallback.
-function signalReloadSnapshotReady() {
- window.dispatchEvent(new Event("unsloth:app-shell-ready"));
+function InitialReadyPage({
+ children,
+}: {
+ children: (signalReady: () => void) => ReactNode;
+}) {
+ return children(useAppShellReadySignal());
}
function ReloadSnapshotReady() {
+ const signalReady = useAppShellReadySignal();
useLayoutEffect(() => {
- signalReloadSnapshotReady();
- }, []);
+ signalReady();
+ }, [signalReady]);
return null;
}
@@ -598,10 +604,11 @@ function RootLayout() {
inert={!isImagesRoute || undefined}
>
<Suspense fallback={<RouteFallback />}>
- <ImagesPage
- active={isImagesRoute}
- onInitialReady={signalReloadSnapshotReady}
- />
+ <InitialReadyPage>
+ {(signalReady) => (
+ <ImagesPage active={isImagesRoute} onInitialReady={signalReady} />
+ )}
+ </InitialReadyPage>
</Suspense>
</div>
)}
@@ -616,10 +623,11 @@ function RootLayout() {
inert={!isVideoRoute || undefined}
>
<Suspense fallback={<RouteFallback />}>
- <VideoPage
- active={isVideoRoute}
- onInitialReady={signalReloadSnapshotReady}
- />
+ <InitialReadyPage>
+ {(signalReady) => (
+ <VideoPage active={isVideoRoute} onInitialReady={signalReady} />
+ )}
+ </InitialReadyPage>
</Suspense>
</div>
)}
@@ -634,10 +642,11 @@ function RootLayout() {
inert={!isAudioRoute || undefined}
>
<Suspense fallback={<RouteFallback />}>
- <AudioPage
- active={isAudioRoute}
- onInitialReady={signalReloadSnapshotReady}
- />
+ <InitialReadyPage>
+ {(signalReady) => (
+ <AudioPage active={isAudioRoute} onInitialReady={signalReady} />
+ )}
+ </InitialReadyPage>
</Suspense>
</div>
)}
diff --git a/studio/frontend/src/components/app-readiness.ts b/studio/frontend/src/components/app-readiness.ts
new file mode 100644
index 00000000000..f202007f487
--- /dev/null
+++ b/studio/frontend/src/components/app-readiness.ts
@@ -0,0 +1,62 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+
+import {
+ createContext,
+ createElement,
+ useContext,
+ useLayoutEffect,
+ useState,
+ type ReactNode,
+} from "react";
+
+function signalReloadSnapshotReady(): void {
+ window.dispatchEvent(new Event("unsloth:app-shell-ready"));
+}
+
+/** Each mounted desktop subtree owns its callback; late work cannot reveal its successor. */
+export function createAppReadinessScope(onReady: () => void) {
+ let active = true;
+ return {
+ activate: () => { active = true; },
+ dispose: () => { active = false; },
+ signalReady: () => {
+ if (!active) return;
+ onReady();
+ signalReloadSnapshotReady();
+ },
+ };
+}
+
+const AppShellReadyContext = createContext(signalReloadSnapshotReady);
+export const AppRevealedContext = createContext(true);
+
+export function useAppShellReadySignal(): () => void {
+ return useContext(AppShellReadyContext);
+}
+
+/** Suppress the portal itself, without changing its owner's controlled/open store state. */
+export function AppPortalGate({ children }: { children: ReactNode }): ReactNode {
+ return useContext(AppRevealedContext) ? children : null;
+}
+
+export function AppReadinessBoundary({
+ onReady,
+ revealed,
+ children,
+}: {
+ onReady: (ready: boolean) => void;
+ revealed: boolean;
+ children: ReactNode;
+}): ReactNode {
+ const [scope] = useState(() => createAppReadinessScope(() => onReady(true)));
+ useLayoutEffect(() => {
+ scope.activate();
+ return scope.dispose;
+ }, [scope]);
+ return createElement(
+ AppShellReadyContext.Provider,
+ { value: scope.signalReady },
+ createElement(AppRevealedContext.Provider, { value: revealed }, children),
+ );
+}
diff --git a/studio/frontend/src/components/ui/alert-dialog.tsx b/studio/frontend/src/components/ui/alert-dialog.tsx
index 1b78659a603..2ac5cefc8fb 100644
--- a/studio/frontend/src/components/ui/alert-dialog.tsx
+++ b/studio/frontend/src/components/ui/alert-dialog.tsx
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+import { AppPortalGate } from "@/components/app-readiness";
import { AlertDialog as AlertDialogPrimitive } from "radix-ui";
import type * as React from "react";
@@ -25,7 +26,9 @@ function AlertDialogPortal({
...props
}: React.ComponentProps<typeof AlertDialogPrimitive.Portal>) {
return (
- <AlertDialogPrimitive.Portal data-slot="alert-dialog-portal" {...props} />
+ <AppPortalGate>
+ <AlertDialogPrimitive.Portal data-slot="alert-dialog-portal" {...props} />
+ </AppPortalGate>
);
}
diff --git a/studio/frontend/src/components/ui/dialog.tsx b/studio/frontend/src/components/ui/dialog.tsx
index 018b92f1073..fa169271b73 100644
--- a/studio/frontend/src/components/ui/dialog.tsx
+++ b/studio/frontend/src/components/ui/dialog.tsx
@@ -3,6 +3,8 @@
"use client";
+import { AppPortalGate } from "@/components/app-readiness";
+
import { Dialog as DialogPrimitive } from "radix-ui";
import type * as React from "react";
import { createContext, useContext } from "react";
@@ -33,7 +35,11 @@ function DialogTrigger({
function DialogPortal({
...props
}: React.ComponentProps<typeof DialogPrimitive.Portal>) {
- return <DialogPrimitive.Portal data-slot="dialog-portal" {...props} />;
+ return (
+ <AppPortalGate>
+ <DialogPrimitive.Portal data-slot="dialog-portal" {...props} />
+ </AppPortalGate>
+ );
}
function DialogClose({
diff --git a/studio/frontend/src/components/ui/sheet.tsx b/studio/frontend/src/components/ui/sheet.tsx
index f23db055186..a1d37ac52d7 100644
--- a/studio/frontend/src/components/ui/sheet.tsx
+++ b/studio/frontend/src/components/ui/sheet.tsx
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+import { AppPortalGate } from "@/components/app-readiness";
import { Dialog as SheetPrimitive } from "radix-ui";
import type * as React from "react";
import { useState } from "react";
@@ -51,7 +52,11 @@ function SheetCloseButton({ className }: { className?: string }) {
function SheetPortal({
...props
}: React.ComponentProps<typeof SheetPrimitive.Portal>) {
- return <SheetPrimitive.Portal data-slot="sheet-portal" {...props} />;
+ return (
+ <AppPortalGate>
+ <SheetPrimitive.Portal data-slot="sheet-portal" {...props} />
+ </AppPortalGate>
+ );
}
function SheetOverlay({
diff --git a/studio/frontend/src/features/api-monitor/api-monitor-page.tsx b/studio/frontend/src/features/api-monitor/api-monitor-page.tsx
index 42026722e8b..e366316f133 100644
--- a/studio/frontend/src/features/api-monitor/api-monitor-page.tsx
+++ b/studio/frontend/src/features/api-monitor/api-monitor-page.tsx
@@ -1,6 +1,8 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+import { useAppShellReadySignal } from "@/components/app-readiness";
+
// Full-page monitor for Unsloth's OpenAI-compatible API server. Settings still owns
// configuration (keys, auto-switch, examples); this page owns observability.
@@ -523,6 +525,7 @@ function RequestDetail({
}
export function ApiMonitorPage(): ReactElement {
+ const signalReady = useAppShellReadySignal();
const {
data,
entries,
@@ -544,8 +547,8 @@ export function ApiMonitorPage(): ReactElement {
return;
}
reloadReadySent.current = true;
- window.dispatchEvent(new Event("unsloth:app-shell-ready"));
- }, [loading]);
+ signalReady();
+ }, [loading, signalReady]);
const serverUrl = usePlatformStore((s) => s.serverUrl);
const cloudflareUrl = usePlatformStore((s) => s.cloudflareUrl);
const [unloading, setUnloading] = useState(false);
diff --git a/studio/frontend/src/features/auth/components/auth-form.tsx b/studio/frontend/src/features/auth/components/auth-form.tsx
index fb5aed4bb66..989732ea5bd 100644
--- a/studio/frontend/src/features/auth/components/auth-form.tsx
+++ b/studio/frontend/src/features/auth/components/auth-form.tsx
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+import { useAppShellReadySignal } from "@/components/app-readiness";
import { apiUrl } from "@/lib/api-base";
import { Button } from "@/components/ui/button";
import { MascotImg } from "@/components/mascot-img";
@@ -81,6 +82,7 @@ type AuthFormProps = {
const HIDDEN_LOGIN_USERNAME = "unsloth";
export function AuthForm({ mode }: AuthFormProps): ReactElement | null {
+ const signalReady = useAppShellReadySignal();
const navigate = useNavigate();
const isLoginMode = mode === "login";
const [showPassword, setShowPassword] = useState(false);
@@ -181,8 +183,8 @@ export function AuthForm({ mode }: AuthFormProps): ReactElement | null {
useEffect(() => {
if (statusLoading || reloadReadySent.current) return;
reloadReadySent.current = true;
- window.dispatchEvent(new Event("unsloth:app-shell-ready"));
- }, [statusLoading]);
+ signalReady();
+ }, [statusLoading, signalReady]);
// Seed password from bootstrap credentials injected into HTML by web CLI.
useEffect(() => {
diff --git a/studio/frontend/src/features/chat/chat-page.tsx b/studio/frontend/src/features/chat/chat-page.tsx
index 1483c5a6947..ae20438ecff 100644
--- a/studio/frontend/src/features/chat/chat-page.tsx
+++ b/studio/frontend/src/features/chat/chat-page.tsx
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+import { useAppShellReadySignal } from "@/components/app-readiness";
import {
applyModelLoadConfigToRuntime,
clearModelConfigHandoff,
@@ -750,6 +751,7 @@ function ComparePane({
}
function useCompareReloadReadiness(pairId: string): (pane: string) => void {
+ const signalReady = useAppShellReadySignal();
const stateRef = useRef({
pairId,
panes: new Set<string>(),
@@ -769,9 +771,9 @@ function useCompareReloadReadiness(pairId: string): (pane: string) => void {
return;
}
state.sent = true;
- window.dispatchEvent(new Event("unsloth:app-shell-ready"));
+ signalReady();
},
- [pairId],
+ [pairId, signalReady],
);
}
@@ -1332,6 +1334,7 @@ function ProjectLanding({
// view switch now (#8908), so the owner of that one reports readiness down.
runtimeReady: boolean;
}): ReactElement {
+ const signalReady = useAppShellReadySignal();
const navigate = useNavigate();
// Gates body-portaled surfaces so they cannot linger or act while the landing is off-route.
const active = useChatActive();
@@ -1692,8 +1695,8 @@ function ProjectLanding({
return;
}
reloadReadySent.current = true;
- window.dispatchEvent(new Event("unsloth:app-shell-ready"));
- }, [dataLoaded, items, previews, runtimeReady]);
+ signalReady();
+ }, [dataLoaded, items, previews, runtimeReady, signalReady]);
return (
<>
diff --git a/studio/frontend/src/features/chat/projects-page.tsx b/studio/frontend/src/features/chat/projects-page.tsx
index 59cd60b4a2b..14d28bc8f94 100644
--- a/studio/frontend/src/features/chat/projects-page.tsx
+++ b/studio/frontend/src/features/chat/projects-page.tsx
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+import { useAppShellReadySignal } from "@/components/app-readiness";
import { Button } from "@/components/ui/button";
import {
Dialog,
@@ -112,6 +113,7 @@ function formatModified(ts: number): string {
}
export function ProjectsPage() {
+ const signalReady = useAppShellReadySignal();
const navigate = useNavigate();
const { projects, hasLoaded } = useChatProjects();
@@ -263,8 +265,8 @@ export function ProjectsPage() {
return;
}
reloadReadySent.current = true;
- window.dispatchEvent(new Event("unsloth:app-shell-ready"));
- }, [hasLoaded]);
+ signalReady();
+ }, [hasLoaded, signalReady]);
// Estimate how many rows fit below the list's top so the first page fills the screen without
// loading everything up front.
diff --git a/studio/frontend/src/features/chat/runtime-provider.tsx b/studio/frontend/src/features/chat/runtime-provider.tsx
index ece53085b88..0f153230446 100644
--- a/studio/frontend/src/features/chat/runtime-provider.tsx
+++ b/studio/frontend/src/features/chat/runtime-provider.tsx
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+import { useAppShellReadySignal } from "@/components/app-readiness";
import { authFetch } from "@/features/auth";
import {
classifiedAttachmentFile,
@@ -1620,6 +1621,7 @@ function useStudioRuntimeAdapters(
backgroundedRef?: { current: boolean },
newThreadSwitchStateRef?: { current: NewThreadSwitchState },
): StudioRuntimeAdapters {
+ const signalReady = useAppShellReadySignal();
const aui = useAui();
useEffect(() => {
@@ -1820,7 +1822,7 @@ function useStudioRuntimeAdapters(
!pairId &&
loadedTheRequestedThread
) {
- window.dispatchEvent(new Event("unsloth:app-shell-ready"));
+ signalReady();
}
return result;
};
@@ -2204,6 +2206,7 @@ function useStudioRuntimeAdapters(
onInitialHistoryReady,
pairId,
reloadReadyThreadId,
+ signalReady,
],
);
@@ -3275,6 +3278,7 @@ export function ChatRuntimeProvider({
backgrounded?: boolean;
onInitialHistoryReady?: () => void;
}): ReactElement {
+ const signalReady = useAppShellReadySignal();
// Read by the history adapter's own active-thread publication, the sibling of
// ThreadBackendAutosave's, which needs the same stand-down. Kept in a ref so the memo below
// never sees it change, since rebuilding the runtime hook would rebuild the runtime.
@@ -3310,9 +3314,9 @@ export function ChatRuntimeProvider({
if (onInitialHistoryReady) {
onInitialHistoryReady();
} else if (modelType === "base" && !pairId) {
- window.dispatchEvent(new Event("unsloth:app-shell-ready"));
+ signalReady();
}
- }, [modelType, onInitialHistoryReady, pairId]);
+ }, [modelType, onInitialHistoryReady, pairId, signalReady]);
const aui = useAui({});
useEffect(() => {
diff --git a/studio/frontend/src/features/data-recipes/pages/data-recipes-page.tsx b/studio/frontend/src/features/data-recipes/pages/data-recipes-page.tsx
index ad05ca01cd4..c0ce418a3aa 100644
--- a/studio/frontend/src/features/data-recipes/pages/data-recipes-page.tsx
+++ b/studio/frontend/src/features/data-recipes/pages/data-recipes-page.tsx
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+import { useAppShellReadySignal } from "@/components/app-readiness";
import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
import {
@@ -311,6 +312,7 @@ function LearningRecipeCards({
}
export function DataRecipesPage(): ReactElement {
+ const signalReady = useAppShellReadySignal();
const navigate = useNavigate();
const { recipes, ready } = useRecipes();
const [creatingRecipe, setCreatingRecipe] = useState(false);
@@ -325,8 +327,8 @@ export function DataRecipesPage(): ReactElement {
return;
}
reloadReadySent.current = true;
- window.dispatchEvent(new Event("unsloth:app-shell-ready"));
- }, [ready]);
+ signalReady();
+ }, [ready, signalReady]);
useEffect(() => {
if (sessionStorage.getItem(OPEN_LEARNING_RECIPES_ON_ARRIVAL_KEY) !== "1") {
diff --git a/studio/frontend/src/features/data-recipes/pages/edit-recipe-page.tsx b/studio/frontend/src/features/data-recipes/pages/edit-recipe-page.tsx
index 2c6dd1f9a38..87d56874c13 100644
--- a/studio/frontend/src/features/data-recipes/pages/edit-recipe-page.tsx
+++ b/studio/frontend/src/features/data-recipes/pages/edit-recipe-page.tsx
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+import { useAppShellReadySignal } from "@/components/app-readiness";
import { Button } from "@/components/ui/button";
import { RecipeStudioPage, type RecipePayload } from "@/features/recipe-studio";
import { useNavigate } from "@tanstack/react-router";
@@ -43,6 +44,7 @@ function RecipeLoadState({
}
export function EditRecipePage({ recipeId }: EditRecipePageProps): ReactElement {
+ const signalReady = useAppShellReadySignal();
const navigate = useNavigate();
const reloadReadySent = useRef(false);
const [loadState, setLoadState] = useState<LoadState>(() => {
@@ -83,8 +85,8 @@ export function EditRecipePage({ recipeId }: EditRecipePageProps): ReactElement
return;
}
reloadReadySent.current = true;
- window.dispatchEvent(new Event("unsloth:app-shell-ready"));
- }, [loadState.status]);
+ signalReady();
+ }, [loadState.status, signalReady]);
const handlePersist = useCallback(
async (input: { id: string | null; name: string; payload: RecipePayload }) => {
diff --git a/studio/frontend/src/features/export/export-page.tsx b/studio/frontend/src/features/export/export-page.tsx
index f8b8d0e38c0..91e2d3c2833 100644
--- a/studio/frontend/src/features/export/export-page.tsx
+++ b/studio/frontend/src/features/export/export-page.tsx
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+import { useAppShellReadySignal } from "@/components/app-readiness";
import { SectionCard } from "@/components/section-card";
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
import { Button } from "@/components/ui/button";
@@ -169,6 +170,7 @@ function siblingGgufDirectory(sourcePath: string): string | null {
}
export function ExportPage() {
+ const signalReady = useAppShellReadySignal();
const { hfToken, setHfToken } = useHfTokenStore(
useShallow((s) => ({
hfToken: s.token,
@@ -381,8 +383,8 @@ export function ExportPage() {
return;
}
reloadReadySent.current = true;
- window.dispatchEvent(new Event("unsloth:app-shell-ready"));
- }, [isLoadingLocalModels, loadingCheckpoints]);
+ signalReady();
+ }, [isLoadingLocalModels, loadingCheckpoints, signalReady]);
// ---- Derived state ----
const selectedModelData = useMemo(
diff --git a/studio/frontend/src/features/hub/hub-page.tsx b/studio/frontend/src/features/hub/hub-page.tsx
index 9b681bdc591..571b18cfbde 100644
--- a/studio/frontend/src/features/hub/hub-page.tsx
+++ b/studio/frontend/src/features/hub/hub-page.tsx
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+import { useAppShellReadySignal } from "@/components/app-readiness";
import { usePlatformStore } from "@/config/env";
import {
applyActiveModelStatusToStore,
@@ -405,6 +406,7 @@ function selectedRepoMatchesRuntime(
}
export function ModelsPage() {
+ const signalReady = useAppShellReadySignal();
const navigate = useNavigate();
const gpu = useGpuInfo();
// The saved VRAM Budget the loader admits against. The "Fits on device" filter scored against
@@ -864,8 +866,9 @@ export function ModelsPage() {
return;
}
reloadReadySent.current = true;
- window.dispatchEvent(new Event("unsloth:app-shell-ready"));
+ signalReady();
}, [
+ signalReady,
initialResidentStatusSettled,
inventorySettled,
isDiscoverTab,
diff --git a/studio/frontend/src/features/settings/settings-dialog-mount.tsx b/studio/frontend/src/features/settings/settings-dialog-mount.tsx
index 4dd1f72073e..52da320949b 100644
--- a/studio/frontend/src/features/settings/settings-dialog-mount.tsx
+++ b/studio/frontend/src/features/settings/settings-dialog-mount.tsx
@@ -1,160 +1,15 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
-import {
- LazyImportBoundary,
- LazyImportFailure,
-} from "@/components/lazy-import-boundary";
-import { useT } from "@/i18n";
-import {
- Suspense,
- lazy,
- useEffect,
- useLayoutEffect,
- useRef,
- useState,
-} from "react";
-import { isImeComposing } from "./hooks/use-shortcut";
-import { useMonitorOverlayStore } from "./stores/monitor-overlay-store";
-import { useSettingsDialogStore } from "./stores/settings-dialog-store";
-
-const SettingsDialog = lazy(() =>
- import("./settings-dialog").then((module) => ({
- default: module.SettingsDialog,
- })),
-);
-const FloatingMonitor = lazy(() =>
- import("@/components/floating-monitor").then((module) => ({
- default: module.FloatingMonitor,
- })),
-);
-
-function restoreSettingsOpener(
- opener: HTMLElement | null,
- openerFallback: HTMLElement | null,
-): void {
- requestAnimationFrame(() => {
- const focusTarget = [opener, openerFallback].find(
- (element) =>
- element?.isConnected && !element.closest("[inert], [hidden]"),
- );
- focusTarget?.focus({ preventScroll: true });
- });
-}
-
-function SettingsDialogLoading({ active }: { active: boolean }) {
- const t = useT();
-
- const dialogRef = useRef<HTMLDialogElement>(null);
- const closeDialog = useSettingsDialogStore((state) => state.closeDialog);
- useEffect(() => {
- if (!active) return;
- const cancel = (event: KeyboardEvent) => {
- if (event.key !== "Escape" || isImeComposing(event)) return;
- event.preventDefault();
- event.stopPropagation();
- closeDialog();
- };
- window.addEventListener("keydown", cancel, true);
- return () => window.removeEventListener("keydown", cancel, true);
- }, [active, closeDialog]);
- useLayoutEffect(() => {
- const dialog = dialogRef.current;
- if (!active || !dialog) return;
- dialog.showModal();
- dialog.focus();
- return () => dialog.close();
- }, [active]);
-
- if (!active) return null;
- return (
- <dialog
- ref={dialogRef}
- tabIndex={-1}
- className="fixed inset-0 z-[100] m-0 grid h-full max-h-none w-full max-w-none place-items-center border-0 bg-black/50 p-4"
- data-testid="settings-dialog-loading"
- aria-label={t("common.loading")}
- onCancel={(event) => {
- event.preventDefault();
- closeDialog();
- }}
- onPointerDown={(event) => {
- if (event.target === event.currentTarget) closeDialog();
- }}
- >
- <div className="rounded-xl border border-border bg-popover px-6 py-4 text-popover-foreground shadow-xl">
- {t("common.loading")}
- </div>
- </dialog>
- );
-}
+import { FloatingMonitor } from "@/components/floating-monitor";
+import { SettingsDialog } from "./settings-dialog";
export function SettingsDialogMount({ active }: { active: boolean }) {
- const t = useT();
- const closeDialog = useSettingsDialogStore((state) => state.closeDialog);
- const opener = useSettingsDialogStore((state) => state.opener);
- const openerFallback = useSettingsDialogStore(
- (state) => state.openerFallback,
- );
- const settingsOpen = useSettingsDialogStore((state) => state.open);
- const monitorOpen = useMonitorOverlayStore((state) => state.isOpen);
- const setMonitorOpen = useMonitorOverlayStore((state) => state.setIsOpen);
- const [settingsMounted, setSettingsMounted] = useState(settingsOpen);
- const [monitorMounted, setMonitorMounted] = useState(monitorOpen);
-
- useEffect(() => {
- if (settingsOpen) setSettingsMounted(true);
- }, [settingsOpen]);
- useEffect(() => {
- if (monitorOpen) setMonitorMounted(true);
- }, [monitorOpen]);
-
- if (!active || !(settingsMounted || monitorMounted)) return null;
+ if (!active) return null;
return (
<>
- {settingsMounted && (
- <LazyImportBoundary
- fallback={
- settingsOpen ? (
- <LazyImportFailure
- message={t("settings.dialog.panelFailed")}
- reloadLabel={t("settings.dialog.panelReload")}
- dismissLabel={t("common.close")}
- onDismiss={() => {
- closeDialog();
- restoreSettingsOpener(opener, openerFallback);
- }}
- testId="settings-dialog-load-failure"
- className="fixed top-1/2 left-1/2 z-[100] max-w-sm -translate-x-1/2 -translate-y-1/2 rounded-xl border border-border bg-popover p-5 text-popover-foreground shadow-xl"
- />
- ) : null
- }
- >
- <Suspense fallback={<SettingsDialogLoading active={settingsOpen} />}>
- <SettingsDialog />
- </Suspense>
- </LazyImportBoundary>
- )}
- {monitorMounted && (
- <LazyImportBoundary
- fallback={
- monitorOpen ? (
- <LazyImportFailure
- message={t("settings.dialog.panelFailed")}
- reloadLabel={t("settings.dialog.panelReload")}
- dismissLabel={t("common.close")}
- onDismiss={() => setMonitorOpen(false)}
- testId="floating-monitor-load-failure"
- className="fixed top-16 right-4 z-[100] max-w-xs rounded-xl border border-border bg-popover p-4 text-popover-foreground shadow-lg"
- />
- ) : null
- }
- >
- <Suspense fallback={null}>
- <FloatingMonitor />
- </Suspense>
- </LazyImportBoundary>
- )}
+ <SettingsDialog />
+ <FloatingMonitor />
</>
);
}
diff --git a/studio/frontend/src/features/studio/studio-page.tsx b/studio/frontend/src/features/studio/studio-page.tsx
index fc8dd683972..60ba336fdf4 100644
--- a/studio/frontend/src/features/studio/studio-page.tsx
+++ b/studio/frontend/src/features/studio/studio-page.tsx
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+import { useAppShellReadySignal } from "@/components/app-readiness";
import { usePlatformStore } from "@/config/env";
import { Button } from "@/components/ui/button";
import { useSidebar } from "@/components/ui/sidebar";
@@ -50,6 +51,7 @@ import { useParamMode } from "./wizard/training-param-mode";
import { TrainingWizard } from "./wizard/training-wizard";
export function StudioPage(): ReactElement {
+ const signalReady = useAppShellReadySignal();
const t = useT();
const [paramMode, setParamMode] = useParamMode();
useTrainingRuntimeLifecycle();
@@ -172,8 +174,8 @@ export function StudioPage(): ReactElement {
return;
}
reloadReadySent.current = true;
- window.dispatchEvent(new Event("unsloth:app-shell-ready"));
- }, [capabilitiesUnknown, hasHydratedRuntime, isHydratingRuntime]);
+ signalReady();
+ }, [capabilitiesUnknown, hasHydratedRuntime, isHydratingRuntime, signalReady]);
// Two waits share this panel. Hardware detection is a cold `import torch` that can run for
// minutes and says so, the way the Video page does; a hydrating runtime is quick and keeps
// the runtime wording, which on a machine still being measured just reads as a hang.
diff --git a/studio/frontend/tests/app-readiness.test.ts b/studio/frontend/tests/app-readiness.test.ts
new file mode 100644
index 00000000000..7cab17dfb89
--- /dev/null
+++ b/studio/frontend/tests/app-readiness.test.ts
@@ -0,0 +1,74 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+
+import assert from "node:assert/strict";
+import test from "node:test";
+import { createElement } from "react";
+import { renderToStaticMarkup } from "react-dom/server";
+import {
+ AppPortalGate,
+ AppRevealedContext,
+ createAppReadinessScope,
+} from "../src/components/app-readiness.ts";
+import { readSrc } from "./helpers/kit.ts";
+
+test("late completion cannot reveal either an unavailable app or its new generation", async () => {
+ const target = new EventTarget();
+ const previousWindow = Object.getOwnPropertyDescriptor(globalThis, "window");
+ Object.defineProperty(globalThis, "window", { configurable: true, value: target });
+ try {
+ let reveals = 0;
+ let reloadSignals = 0;
+ target.addEventListener("unsloth:app-shell-ready", () => reloadSignals++);
+ const oldMount = createAppReadinessScope(() => reveals++);
+ // Capture the callback before awaiting, just like the history adapter.
+ const oldCompleteLoad = oldMount.signalReady;
+ oldMount.dispose();
+ await Promise.resolve().then(oldCompleteLoad);
+ assert.equal(reveals, 0, "must ignore completion while backend is unavailable");
+ const newMount = createAppReadinessScope(() => reveals++);
+ await Promise.resolve().then(oldCompleteLoad);
+ assert.equal(reveals, 0, "must also ignore old work after the replacement mounts");
+ assert.equal(reloadSignals, 0, "stale completion must not retire a reload snapshot either");
+ newMount.signalReady();
+ assert.equal(reveals, 1);
+ assert.equal(reloadSignals, 1, "current readiness still notifies reload-snapshot.js");
+ newMount.dispose();
+ newMount.signalReady();
+ assert.equal(reveals, 1);
+ } finally {
+ if (previousWindow) Object.defineProperty(globalThis, "window", previousWindow);
+ else Reflect.deleteProperty(globalThis, "window");
+ }
+});
+
+test("retained-open portal children do not mount until reveal, without changing owner state", () => {
+ const owner = { open: true, tab: "api-keys" };
+ let childMounts = 0;
+ function PortalChild() {
+ childMounts++;
+ return createElement("div", { role: "dialog" }, owner.tab);
+ }
+ const render = (revealed: boolean) => renderToStaticMarkup(
+ createElement(AppRevealedContext.Provider, { value: revealed },
+ createElement(AppPortalGate, { children: owner.open ? createElement(PortalChild) : null })),
+ );
+ assert.equal(render(false), "");
+ assert.equal(childMounts, 0);
+ assert.deepEqual(owner, { open: true, tab: "api-keys" });
+ assert.match(render(true), /role="dialog"/);
+ assert.equal(childMounts, 1);
+ assert.equal(render(false), "", "backend restart suppresses the retained dialog again");
+ assert.equal(childMounts, 1);
+ assert.match(render(true), /api-keys/);
+ assert.equal(childMounts, 2);
+ for (const file of ["dialog", "sheet", "alert-dialog"]) {
+ assert.match(readSrc(`components/ui/${file}.tsx`), /<AppPortalGate>[\s\S]*?Primitive\.Portal[\s\S]*?<\/AppPortalGate>/);
+ }
+});
+
+test("web portals retain their default visible behavior", () => {
+ assert.equal(renderToStaticMarkup(createElement(AppPortalGate, {
+ children: createElement("span", null, "visible"),
+ })), "<span>visible</span>");
+});
diff --git a/studio/frontend/tests/monitor-frame-ownership.test.ts b/studio/frontend/tests/monitor-frame-ownership.test.ts
index 641a5cced3a..5ef5e839923 100644
--- a/studio/frontend/tests/monitor-frame-ownership.test.ts
+++ b/studio/frontend/tests/monitor-frame-ownership.test.ts
@@ -188,65 +188,16 @@ test("the publish hook drops an unmeasurable box rather than publishing it", ()
);
});
-test("closed lazy settings surfaces cannot leave load failures on screen", () => {
- const mount = readSrc("features/settings/settings-dialog-mount.tsx");
- // Keep rejected boundaries mounted for a later retry, but only show their errors while the user is
- // still asking for that surface. A slow rejected chunk must not outlive a quick Open -> Close.
- for (const [open, testId] of [
- ["settingsOpen", "settings-dialog-load-failure"],
- ["monitorOpen", "floating-monitor-load-failure"],
- ]) {
- assert.match(
- mount,
- new RegExp(
- `fallback=\\{\\s*${open}\\s*\\?\\s*\\(\\s*<LazyImportFailure[\\s\\S]*?testId="${testId}"[\\s\\S]*?\\)\\s*:\\s*null\\s*\\}`,
- ),
- );
- }
+test("settings and monitor are eagerly imported and mounted without outer loading UI", () => {
+ assert.match(SETTINGS_MOUNT_SOURCE, /import \{ SettingsDialog \} from "\.\/settings-dialog"/);
+ assert.match(SETTINGS_MOUNT_SOURCE, /import \{ FloatingMonitor \} from "@\/components\/floating-monitor"/);
+ assert.match(SETTINGS_MOUNT_SOURCE, /<SettingsDialog \/>/);
+ assert.match(SETTINGS_MOUNT_SOURCE, /<FloatingMonitor \/>/);
+ assert.doesNotMatch(SETTINGS_MOUNT_SOURCE, /lazy\(|Suspense|LazyImport|settingsMounted|monitorMounted|settingsOpen|monitorOpen|settings-dialog-loading/);
});
-// Once either surface has loaded, an auth-route round trip must not forget its lazy-entry latch.
-// Both surfaces stay dormant there, then resume independently after authentication.
-test("the lazy Settings mount survives an auth-route round trip", () => {
- assert.match(
- ROOT_SOURCE,
- /<CredentialBootstrapGate active=\{!isAuthFlowRoute\}>/,
- );
- assert.match(
- ROOT_SOURCE,
- /<SettingsDialogMount active=\{active && ready\} \/>/,
- );
- assert.match(
- SETTINGS_MOUNT_SOURCE,
- /if \(!active \|\| !\(settingsMounted \|\| monitorMounted\)\) return null;/,
- );
- assert.match(
- SETTINGS_MOUNT_SOURCE,
- /const \[settingsMounted, setSettingsMounted\] = useState\(settingsOpen\)/,
- );
- assert.match(
- SETTINGS_MOUNT_SOURCE,
- /const \[monitorMounted, setMonitorMounted\] = useState\(monitorOpen\)/,
- );
-
- assert.equal(
- (
- SETTINGS_MOUNT_SOURCE.match(/dismissLabel=\{t\("common\.close"\)\}/g) ??
- []
- ).length,
- 2,
- );
- assert.match(SETTINGS_MOUNT_SOURCE, /data-testid="settings-dialog-loading"/);
- assert.match(SETTINGS_MOUNT_SOURCE, /dialog\.showModal\(\)/);
- assert.match(SETTINGS_MOUNT_SOURCE, /tabIndex=\{-1\}/);
- assert.match(SETTINGS_MOUNT_SOURCE, /onCancel=\{\(event\) =>/);
- assert.match(SETTINGS_MOUNT_SOURCE, /event\.target === event\.currentTarget/);
- assert.match(
- SETTINGS_MOUNT_SOURCE,
- /onDismiss=\{\(\) => \{\s*closeDialog\(\);\s*restoreSettingsOpener\(opener, openerFallback\);/,
- );
- assert.match(
- SETTINGS_MOUNT_SOURCE,
- /onDismiss=\{\(\) => setMonitorOpen\(false\)\}/,
- );
+test("eager settings surfaces remain gated on auth and credential readiness", () => {
+ assert.match(ROOT_SOURCE, /<CredentialBootstrapGate active=\{!isAuthFlowRoute\}>/);
+ assert.match(ROOT_SOURCE, /<SettingsDialogMount active=\{active && ready\} \/>/);
+ assert.match(SETTINGS_MOUNT_SOURCE, /if \(!active\) return null;/);
});
diff --git a/studio/frontend/tests/reload-snapshot.test.ts b/studio/frontend/tests/reload-snapshot.test.ts
index 29a5d7427b2..fa42b13b5e0 100644
--- a/studio/frontend/tests/reload-snapshot.test.ts
+++ b/studio/frontend/tests/reload-snapshot.test.ts
@@ -38,6 +38,20 @@ const studioPageSource = readSrc("features/studio/studio-page.tsx");
const apiMonitorPageSource = readSrc("features/api-monitor/api-monitor-page.tsx");
const authFormSource = readSrc("features/auth/components/auth-form.tsx");
+test("scoped readiness still emits the reload snapshot event", () => {
+ const readinessSource = readSrc("components/app-readiness.ts");
+ assert.match(readinessSource, /function signalReloadSnapshotReady\(\): void \{\s*window\.dispatchEvent\(new Event\("unsloth:app-shell-ready"\)\)/);
+ assert.match(readinessSource, /signalReady: \(\) => \{\s*if \(!active\) return;\s*onReady\(\);\s*signalReloadSnapshotReady\(\)/);
+ assert.match(readinessSource, /value: scope\.signalReady/);
+ assert.match(readinessSource, /return useContext\(AppShellReadyContext\)/);
+ for (const source of [rootRouteSource, runtimeProviderSource, chatPageSource,
+ hubPageSource, projectsPageSource, dataRecipesPageSource, editRecipePageSource,
+ exportPageSource, studioPageSource, apiMonitorPageSource, authFormSource]) {
+ assert.match(source, /useAppShellReadySignal/);
+ }
+});
+
+
type Listener = (event: Record<string, unknown>) => void;
/** A node of the fake #root subtree the capture walks. */
@@ -728,7 +742,7 @@ test("mirrors Temporary Chat privacy and lets history completion retire chat she
);
assert.match(
runtimeProviderSource,
- /async load\(\) \{[\s\S]*?const completeLoad =[\s\S]*?unsloth:app-shell-ready[\s\S]*?await loadGenerationOverlaySnapshot\([\s\S]*?listStoredChatMessages[\s\S]*?return completeLoad/,
+ /async load\(\) \{[\s\S]*?const completeLoad =[\s\S]*?signalReady\(\)[\s\S]*?await loadGenerationOverlaySnapshot\([\s\S]*?listStoredChatMessages[\s\S]*?return completeLoad/,
);
assert.match(
runtimeProviderSource,
@@ -753,7 +767,7 @@ test("mirrors Temporary Chat privacy and lets history completion retire chat she
);
assert.match(
runtimeProviderSource,
- /const signalFailedInitialSwitchReady = useCallback[\s\S]*?onInitialHistoryReady\(\)[\s\S]*?unsloth:app-shell-ready[\s\S]*?onSwitchFailed=\{signalFailedInitialSwitchReady\}/,
+ /const signalFailedInitialSwitchReady = useCallback[\s\S]*?onInitialHistoryReady\(\)[\s\S]*?signalReady\(\)[\s\S]*?onSwitchFailed=\{signalFailedInitialSwitchReady\}/,
);
assert.match(
runtimeProviderSource,
@@ -772,7 +786,7 @@ test("mirrors Temporary Chat privacy and lets history completion retire chat she
);
assert.match(
chatPageSource,
- /state\.panes\.add\(pane\)[\s\S]*?state\.panes\.size < 2[\s\S]*?unsloth:app-shell-ready/,
+ /state\.panes\.add\(pane\)[\s\S]*?state\.panes\.size < 2[\s\S]*?signalReady\(\)/,
);
assert.match(
chatPageSource,
@@ -788,7 +802,7 @@ test("mirrors Temporary Chat privacy and lets history completion retire chat she
);
assert.match(
chatPageSource,
- /const previewsReady = items\.every[\s\S]*?!dataLoaded \|\|[\s\S]*?!runtimeReady \|\|[\s\S]*?!previewsReady \|\|[\s\S]*?unsloth:app-shell-ready/,
+ /const previewsReady = items\.every[\s\S]*?!dataLoaded \|\|[\s\S]*?!runtimeReady \|\|[\s\S]*?!previewsReady \|\|[\s\S]*?signalReady\(\)/,
);
assert.match(
chatPageSource,
@@ -843,11 +857,11 @@ test("data-backed routes own reload readiness until hydration settles", () => {
);
assert.match(
hubPageSource,
- /!initialResidentStatusSettled[\s\S]*?\(isDiscoverTab \? isLoading : !inventorySettled\)[\s\S]*?unsloth:app-shell-ready/,
+ /!initialResidentStatusSettled[\s\S]*?\(isDiscoverTab \? isLoading : !inventorySettled\)[\s\S]*?signalReady\(\)/,
);
assert.match(
projectsPageSource,
- /if \(!hasLoaded \|\| reloadReadySent\.current\) \{\s*return;\s*\}[\s\S]*?unsloth:app-shell-ready/,
+ /if \(!hasLoaded \|\| reloadReadySent\.current\) \{\s*return;\s*\}[\s\S]*?signalReady\(\)/,
);
assert.match(
rootRouteSource,
@@ -855,32 +869,32 @@ test("data-backed routes own reload readiness until hydration settles", () => {
);
assert.match(
dataRecipesPageSource,
- /if \(!ready \|\| reloadReadySent\.current\) \{\s*return;\s*\}[\s\S]*?unsloth:app-shell-ready/,
+ /if \(!ready \|\| reloadReadySent\.current\) \{\s*return;\s*\}[\s\S]*?signalReady\(\)/,
);
assert.match(
editRecipePageSource,
- /if \(loadState\.status === "loading" \|\| reloadReadySent\.current\) \{\s*return;\s*\}[\s\S]*?unsloth:app-shell-ready/,
+ /if \(loadState\.status === "loading" \|\| reloadReadySent\.current\) \{\s*return;\s*\}[\s\S]*?signalReady\(\)/,
);
assert.match(rootRouteSource, /pathname === "\/export"/);
assert.match(
exportPageSource,
- /loadingCheckpoints \|\|[\s\S]*?isLoadingLocalModels \|\|[\s\S]*?unsloth:app-shell-ready/,
+ /loadingCheckpoints \|\|[\s\S]*?isLoadingLocalModels \|\|[\s\S]*?signalReady\(\)/,
);
assert.match(rootRouteSource, /pathname === "\/studio"/);
assert.match(
studioPageSource,
- /capabilitiesUnknown \|\|[\s\S]*?!hasHydratedRuntime \|\|[\s\S]*?isHydratingRuntime \|\|[\s\S]*?unsloth:app-shell-ready/,
+ /capabilitiesUnknown \|\|[\s\S]*?!hasHydratedRuntime \|\|[\s\S]*?isHydratingRuntime \|\|[\s\S]*?signalReady\(\)/,
);
assert.match(rootRouteSource, /pathname === "\/api-monitor"/);
assert.match(
apiMonitorPageSource,
- /if \(loading \|\| reloadReadySent\.current\) \{\s*return;\s*\}[\s\S]*?unsloth:app-shell-ready/,
+ /if \(loading \|\| reloadReadySent\.current\) \{\s*return;\s*\}[\s\S]*?signalReady\(\)/,
);
assert.match(rootRouteSource, /pathname === "\/login"/);
assert.match(rootRouteSource, /pathname === "\/change-password"/);
assert.match(
authFormSource,
- /if \(statusLoading \|\| reloadReadySent\.current\) return;[\s\S]*?unsloth:app-shell-ready/,
+ /if \(statusLoading \|\| reloadReadySent\.current\) return;[\s\S]*?signalReady\(\)/,
);
});
diff --git a/studio/frontend/tests/route-loading-fallback.test.ts b/studio/frontend/tests/route-loading-fallback.test.ts
new file mode 100644
index 00000000000..ad66454d172
--- /dev/null
+++ b/studio/frontend/tests/route-loading-fallback.test.ts
@@ -0,0 +1,14 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+
+import assert from "node:assert/strict";
+import test from "node:test";
+import { readSrc } from "./helpers/kit.ts";
+
+test("route loading retains the original centered loading label", () => {
+ const source = readSrc("app/routes/__root.tsx");
+ const fallback = source.match(/function RouteFallback\(\) \{[\s\S]*?\n\}/)?.[0];
+ assert.ok(fallback);
+ assert.match(fallback, /flex h-full min-h-0 flex-1 items-center justify-center text-muted-foreground text-sm/);
+ assert.match(fallback, />\s*\{t\("common\.loading"\)\}\s*<\/div>/);
+});
diff --git a/studio/frontend/tests/startup-handoff.test.ts b/studio/frontend/tests/startup-handoff.test.ts
new file mode 100644
index 00000000000..7b434a67e36
--- /dev/null
+++ b/studio/frontend/tests/startup-handoff.test.ts
@@ -0,0 +1,34 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+
+import assert from "node:assert/strict";
+import test from "node:test";
+import { readSrc } from "./helpers/kit.ts";
+
+const source = readSrc("app/provider.tsx");
+
+test("desktop splash waits for scoped route readiness, not global events or backend auth", () => {
+ assert.match(source, /<AppReadinessBoundary onReady=\{setAppShellReady\} revealed=\{showApp\}>/);
+ assert.doesNotMatch(source, /addEventListener\("unsloth:app-shell-ready"/);
+ assert.match(source, /const showApp = canMountApp && appShellReady/);
+ assert.match(source, /\{canMountApp && \(/);
+ assert.match(source, /inert=\{!showApp\}/);
+ assert.match(source, /\{!showApp && \(/);
+ assert.match(source, /<StartupScreen/);
+});
+
+test("missing readiness has a bounded escape and backend restarts reset the handoff", () => {
+ assert.match(source, /if \(!canMountApp\) \{\s*setAppShellReady\(false\)/);
+ assert.match(source, /window\.setTimeout\(\(\) => setAppShellReady\(true\), 15_000\)/);
+ assert.match(source, /window\.clearTimeout\(timeout\)/);
+});
+
+test("handoff keeps app geometry and identity while deferring native intents", () => {
+ assert.match(source, /style=\{\{ visibility: showApp \? "visible" : "hidden" \}\}/);
+ assert.match(source, /\{showApp && <NativeIntentDrain \/>\}/);
+ // The startup layer stays below the draggable/titlebar controls (z-50/z-70).
+ assert.match(source, /fixed inset-0 z-40 bg-background/);
+ const root = readSrc("app/routes/__root.tsx");
+ assert.match(root, /<CredentialBootstrapGate active=\{!isAuthFlowRoute\}>/);
+ assert.match(root, /\{active && !ready \? <RouteFallback \/> : children\}/);
+});