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.

Studio: mount the API monitor inside a host that stays mounted, so opening it in Glass stops restyling the app (#17418)

Daniel Han817a00c83510
diff --git a/studio/frontend/src/features/api-monitor/api-monitor-overlay.tsx b/studio/frontend/src/features/api-monitor/api-monitor-overlay.tsx
index d2933742cd1..8d053a5d3c7 100644
--- a/studio/frontend/src/features/api-monitor/api-monitor-overlay.tsx
+++ b/studio/frontend/src/features/api-monitor/api-monitor-overlay.tsx
@@ -267,18 +267,22 @@ export function ApiMonitorOverlay(): ReactElement | null {
}
wasVisibleRef.current = visible;
}, [visible]);
+ // A host that stays mounted, so opening and closing the panel never inserts a first child of #root:
+ // Chromium then restyles the whole app root (about 1,700 elements) under Reduce motion in Glass.
return (
- <AnimatePresence>
- {visible && (
- <ApiMonitorPanel
- key={panelKey}
- data={data}
- unreachable={unreachable}
- close={close}
- setAutoOpen={setAutoOpen}
- />
- )}
- </AnimatePresence>
+ <div data-api-monitor-host="" className="contents">
+ <AnimatePresence>
+ {visible && (
+ <ApiMonitorPanel
+ key={panelKey}
+ data={data}
+ unreachable={unreachable}
+ close={close}
+ setAutoOpen={setAutoOpen}
+ />
+ )}
+ </AnimatePresence>
+ </div>
);
}
diff --git a/studio/frontend/tests/api-monitor-stable-host.test.ts b/studio/frontend/tests/api-monitor-stable-host.test.ts
new file mode 100644
index 00000000000..02b2cb2e2c4
--- /dev/null
+++ b/studio/frontend/tests/api-monitor-stable-host.test.ts
@@ -0,0 +1,54 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+
+// __root.tsx renders ApiMonitorOverlay before the sidebar, so a panel mounted straight into #root is
+// inserted as its first child. Under Reduce motion in Glass, Chromium then restyles the whole app root
+// on every open and close (about 1,700 elements against about 50). The panel mounts inside a host that
+// is always there, so #root's children never change when it opens.
+
+import assert from "node:assert/strict";
+import test from "node:test";
+
+import { readSrc } from "./helpers/kit.ts";
+
+const CONDITIONAL_HOST = /visible\s*&&\s*\(\s*<div data-api-monitor-host/;
+const LAYOUT_FREE_HOST = /data-api-monitor-host=""\s+className="contents"/;
+const ROOT_MOUNT = /\{!isAuthFlowRoute && <ApiMonitorOverlay \/>\}/;
+
+const overlay = readSrc("features/api-monitor/api-monitor-overlay.tsx");
+const root = readSrc("app/routes/__root.tsx");
+
+function overlayReturn(): string {
+ const start = overlay.indexOf("export function ApiMonitorOverlay");
+ assert.ok(start >= 0, "ApiMonitorOverlay not found");
+ const body = overlay.slice(
+ start,
+ overlay.indexOf("\nfunction ApiMonitorPanel", start),
+ );
+ const ret = body.lastIndexOf("return (");
+ assert.ok(ret >= 0, "ApiMonitorOverlay has no JSX return");
+ return body.slice(ret);
+}
+
+test("the API monitor panel mounts inside a host that stays mounted", () => {
+ const jsx = overlayReturn();
+ const host = jsx.indexOf("<div data-api-monitor-host");
+ const presence = jsx.indexOf("<AnimatePresence");
+ assert.ok(
+ host >= 0,
+ "ApiMonitorOverlay must return its always-mounted host element",
+ );
+ assert.ok(
+ presence > host,
+ "AnimatePresence (and the panel) must sit inside the host",
+ );
+ assert.ok(
+ !CONDITIONAL_HOST.test(jsx),
+ "the host itself must not be conditional",
+ );
+ assert.match(jsx, LAYOUT_FREE_HOST, "the host must not take part in layout");
+});
+
+test("the overlay is still rendered where the root layout always had it", () => {
+ assert.match(root, ROOT_MOUNT);
+});