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: keep Glass fast on WebKit by giving glass surface contents their own layers (#16921)

Daniel Han1a4e758e9dd6
diff --git a/studio/frontend/src/features/chat-background/material.ts b/studio/frontend/src/features/chat-background/material.ts
index 7760e4c3ee3..d1df5d90acc 100644
--- a/studio/frontend/src/features/chat-background/material.ts
+++ b/studio/frontend/src/features/chat-background/material.ts
@@ -170,6 +170,14 @@ export function useGlassStrength(): number {
let nativeApplied = false;
+// WebKit repaints a glass surface's blurred shadows and backdrop whenever anything inside it
+// changes, and on CPU painting that dominates scrolling and typing. Its children get their own
+// layers there (index.css, data-glass-layers); Chromium composites these already.
+const WEBKIT_LAYERS =
+ typeof navigator !== "undefined" &&
+ /AppleWebKit/.test(navigator.userAgent) &&
+ !/Chrom|Edg|Android/i.test(navigator.userAgent);
+
export function WindowMaterialMount({ route }: { route?: BackgroundRoute }) {
const material = useMaterialStore((s) => s.material);
const menus = useMaterialStore((s) => s.menus);
@@ -217,6 +225,13 @@ export function WindowMaterialMount({ route }: { route?: BackgroundRoute }) {
);
}, [menus, material, here]);
useEffect(() => {
+ document.documentElement.toggleAttribute(
+ "data-glass-layers",
+ WEBKIT_LAYERS && material !== "solid" && material !== "transparent" && here,
+ );
+ }, [material, here]);
+ useEffect(() => {
+ const root = document.documentElement;
const wantsNative = material === "macos" && nativeMaterialAvailable();
let cancelled = false;
if (!wantsNative) {
diff --git a/studio/frontend/src/features/chat/prompt-storage/prompt-storage-dialog.tsx b/studio/frontend/src/features/chat/prompt-storage/prompt-storage-dialog.tsx
index a06d062f103..1ccc2482327 100644
--- a/studio/frontend/src/features/chat/prompt-storage/prompt-storage-dialog.tsx
+++ b/studio/frontend/src/features/chat/prompt-storage/prompt-storage-dialog.tsx
@@ -2610,8 +2610,9 @@ export function PromptStorageDialog({
</DialogDescription>
</DialogHeader>
- <div className="px-6 pt-4 pb-3 shrink-0 flex flex-col gap-3">
- {/* */}
+ {/* relative z-10: on WebKit glass each dialog child is its own layer, so the inline
+ suggestions must ride a toolbar stacked above the editor grid that follows. */}
+ <div className="relative z-10 px-6 pt-4 pb-3 shrink-0 flex flex-col gap-3">
<div className="flex items-center gap-1 self-start rounded-full bg-muted/60 p-1">
{(["prompts", "lists"] as Tab[]).map((tab) => (
<button
diff --git a/studio/frontend/src/index.css b/studio/frontend/src/index.css
index f5529d0330a..2dbe18211b8 100644
--- a/studio/frontend/src/index.css
+++ b/studio/frontend/src/index.css
@@ -6254,6 +6254,15 @@ html[data-chat-wallpaper-ready] [data-slot="window-titlebar"][data-viewport-back
:is([data-wallpaper-workspace], [data-chat-content-root]):has(> .chat-wallpaper[data-ready][data-outline="false"]) .unsloth-composer-surface,
.wallpaper-preview:has(> .chat-wallpaper[data-outline="false"]) .wallpaper-preview-composer { --composer-shadow: none; }
+/* WebKit only (data-glass-layers, set by WindowMaterialMount): give the children of the large glass
+ surfaces their own layers, so scrolling or typing inside one repaints that layer instead of
+ re-blurring the surface's shadows and backdrop. Appearance is unchanged; opacity, unlike transform,
+ leaves containing blocks alone, so positioned descendants stay where they were. Each child is also
+ a stacking context, so an inline (non-portaled) dropdown nested in one child cannot rise above a
+ later sibling: give that child its own z-index (Prompt Storage's search toolbar is relative z-10). */
+html[data-glass][data-glass-layers] :is([data-slot="dialog-content"], [data-slot="sidebar-inner"], .unsloth-composer-surface, .unsloth-files-panel) > * {
+ will-change: opacity;
+}
/* Glass materials (html[data-glass]): unprefixed backdrop-filter goes last, the minifier keeps only the last of the pair and Chromium ignores -webkit-. */
html[data-glass] {
--glass-tint: var(--glass-tint-base);
diff --git a/studio/frontend/tests/glass-webkit-layers.test.ts b/studio/frontend/tests/glass-webkit-layers.test.ts
new file mode 100644
index 00000000000..94580aae19b
--- /dev/null
+++ b/studio/frontend/tests/glass-webkit-layers.test.ts
@@ -0,0 +1,48 @@
+// 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 MATERIAL = readSrc("features/chat-background/material.ts");
+const CSS = readSrc("index.css");
+const PROMPT_STORAGE = readSrc("features/chat/prompt-storage/prompt-storage-dialog.tsx");
+
+test("glass surfaces get child layers only on WebKit and only while glass is on", () => {
+ assert.match(
+ MATERIAL,
+ /const WEBKIT_LAYERS =\s*typeof navigator !== "undefined" &&\s*\/AppleWebKit\/\.test\(navigator\.userAgent\) &&\s*!\/Chrom\|Edg\|Android\/i\.test\(navigator\.userAgent\);/,
+ "Chromium and WebView2 composite these already; only WebKit re-blurs a surface when its contents repaint",
+ );
+ assert.match(
+ MATERIAL,
+ /toggleAttribute\(\s*"data-glass-layers",\s*WEBKIT_LAYERS && material !== "solid" && material !== "transparent" && here,\s*\)/,
+ "solid, Transparent and out-of-scope routes never carry the flag, so turning glass off restores the exact previous tree",
+ );
+});
+
+test("the layer rule keeps containing blocks and never uses :has()", () => {
+ const at = CSS.indexOf("html[data-glass][data-glass-layers]");
+ assert.ok(at > 0, "the rule exists");
+ const rule = CSS.slice(at, CSS.indexOf("}", at) + 1);
+ assert.match(rule, /will-change: opacity;/);
+ assert.doesNotMatch(rule, /transform/, "a transform would re-anchor absolute and fixed descendants");
+ assert.doesNotMatch(rule, /:has\(/);
+});
+
+test("Prompt Storage search suggestions stay above the editor grid while dialog children are layers", () => {
+ // Each promoted dialog child is a stacking context, so the inline suggestions (z-50 inside the
+ // toolbar) only clear the following editor grid if the toolbar itself is stacked above it.
+ const toolbar = PROMPT_STORAGE.indexOf('<div className="relative z-10 px-6 pt-4 pb-3 shrink-0 flex flex-col gap-3">');
+ assert.ok(toolbar > 0, "the search toolbar wrapper carries relative z-10");
+ const dropdown = PROMPT_STORAGE.indexOf("dropdown-surface absolute top-full", toolbar);
+ const grid = PROMPT_STORAGE.indexOf('<div className="flex-1 min-h-0 overflow-y-auto', toolbar);
+ assert.ok(dropdown > toolbar && grid > dropdown, "the suggestions live in that toolbar, before the editor grid");
+ assert.doesNotMatch(
+ PROMPT_STORAGE.slice(toolbar, dropdown),
+ /<DialogContent|createPortal/,
+ "the toolbar is a direct dialog child holding the inline dropdown",
+ );
+});