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: drop the live Glass blur while anything moves, on software-composited pages (#17007)

Daniel Han390a309f8527
diff --git a/studio/frontend/src/features/chat-background/glass-motion.ts b/studio/frontend/src/features/chat-background/glass-motion.ts
new file mode 100644
index 00000000000..dfe895837e8
--- /dev/null
+++ b/studio/frontend/src/features/chat-background/glass-motion.ts
@@ -0,0 +1,223 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+
+/*
+ * Under software compositing every frame redraws the window and recomputes every backdrop-filter, the
+ * still sidebar's included. So while something moves, the moving surface and the standing glass carry
+ * data-glass-moving, which index.css turns into a near-opaque fill; the blur returns after SETTLE_MS.
+ * The flag sits on each surface and only that surface's rules read it, so it never restyles the chat.
+ */
+
+/** Glass surfaces that can move: the composer, menus, popovers, tooltips, dialogs and floating buttons. */
+export const GLASS_MOTION_SURFACES = [
+ ".unsloth-composer-surface",
+ ".unsloth-files-panel",
+ '[data-slot$="menu-content"]',
+ '[data-slot$="menu-sub-content"]',
+ '[data-slot="select-content"]',
+ '[data-slot="combobox-content"]',
+ '[data-slot="popover-content"]',
+ '[data-slot="hover-card-content"]',
+ ".menu-soft-surface",
+ ".menu-soft-surface-up",
+ ".dropdown-surface",
+ ".tooltip-compact",
+ ".tooltip-rich",
+ '[data-slot="dialog-content"]',
+ "[data-glass-float]",
+ ".aui-thread-scroll-to-bottom",
+].join(", ");
+
+/** Surfaces that pause only themselves: hovering a control shows them, which should not flicker the sidebar. */
+const LOCAL_ONLY = '.tooltip-compact, .tooltip-rich, [data-slot="hover-card-content"]';
+/** The page's standing glass, paused with anything that moves. */
+const PAGE_SIDEBAR = '[data-slot="sidebar-inner"]';
+const PAGE_FRAME = "[data-windows-glass-frame]";
+const PAGE_CLASSES = ["unsloth-composer-surface", "unsloth-files-panel"];
+/** The standing glass is looked up again at most this often (or when one of them left the page). */
+const PAGE_REFRESH_MS = 2000;
+const THREAD_SCROLLER = ".aui-thread-viewport";
+const TEXT_FIELDS = 'textarea, input, [contenteditable]:not([contenteditable="false"])';
+
+export const GLASS_MOVING_ATTR = "data-glass-moving";
+export const GLASS_SETTLING_ATTR = "data-glass-settling";
+/** How long transitions stay off after the blur returns: a few frames, so its style is resolved without one. */
+export const SETTLING_MS = 100;
+/** How long a surface must be still before its blur comes back. */
+export const SETTLE_MS = 200;
+/** A surface that just mounted: its open animation (100-200 ms) plus SETTLE_MS. */
+export const MOUNT_HOLD_MS = 350;
+/** Upper bound while an animation runs whose end event never arrives (an element removed mid-animation). */
+export const ANIMATION_HOLD_MS = 1000;
+
+type Timer = ReturnType<typeof setTimeout>;
+
+export interface GlassMotion {
+ /** Mark `el` moving for `ms` from now (extends a hold already running). Idempotent. */
+ hold(el: Element, ms: number): void;
+ /** Surfaces a scroll of `scroller` moves: the surface holding it and the glass floating over it (null: typing). */
+ scrollTargets(scroller: Element): Element[] | null;
+ stop(): void;
+}
+
+function isElement(node: unknown): node is Element {
+ return typeof Element !== "undefined" && node instanceof Element;
+}
+
+/** Start pausing glass blur during motion; returns the controller (stop() removes every listener and flag). */
+export function startGlassMotion(doc: Document = document): GlassMotion {
+ const timers = new Map<Element, Timer>();
+ const settling = new Map<Element, Timer>();
+ const settled = (el: Element) => {
+ settling.delete(el);
+ if (el.hasAttribute(GLASS_SETTLING_ATTR)) el.removeAttribute(GLASS_SETTLING_ATTR);
+ };
+ // The blur comes back in one frame: for that frame the surface's own transitions are off (data-glass-settling),
+ // or a dialog's transition-all would fade the blur in over 100 ms and compute it again on every one of those frames.
+ const release = (el: Element) => {
+ timers.delete(el);
+ until.delete(el);
+ if (!el.hasAttribute(GLASS_MOVING_ATTR)) return;
+ el.setAttribute(GLASS_SETTLING_ATTR, "");
+ el.removeAttribute(GLASS_MOVING_ATTR);
+ const prev = settling.get(el);
+ if (prev !== undefined) clearTimeout(prev);
+ settling.set(el, setTimeout(() => settled(el), SETTLING_MS));
+ };
+ const until = new Map<Element, number>();
+ // `extend`: only ever lengthen the hold, for glass that several motions may be holding at once.
+ const hold = (el: Element, ms: number, extend = false) => {
+ const end = performance.now() + ms;
+ if (extend && (until.get(el) ?? Number.NEGATIVE_INFINITY) >= end) return;
+ const prev = timers.get(el);
+ if (prev !== undefined) clearTimeout(prev);
+ // Only write on a change: an attribute write restyles the element even when the value is the same.
+ if (!el.hasAttribute(GLASS_MOVING_ATTR)) el.setAttribute(GLASS_MOVING_ATTR, "");
+ until.set(el, end);
+ timers.set(el, setTimeout(() => release(el), ms));
+ };
+
+ // The native macOS material keeps its sidebar: there the window itself is the frosted layer.
+ let page: Element[] = [];
+ let pageAt = Number.NEGATIVE_INFINITY;
+ const pageGlass = (): Element[] => {
+ const now = performance.now();
+ if (now - pageAt < PAGE_REFRESH_MS && page.every((el) => el.isConnected)) return page;
+ page = [];
+ pageAt = now;
+ if (doc.documentElement?.getAttribute("data-glass") !== "macos") {
+ const sidebar = doc.querySelector(PAGE_SIDEBAR);
+ if (sidebar) {
+ page.push(sidebar);
+ const frame = sidebar.closest(PAGE_FRAME);
+ if (frame) page.push(frame);
+ }
+ }
+ for (const name of PAGE_CLASSES) for (const el of doc.getElementsByClassName(name)) page.push(el);
+ return page;
+ };
+ /** Pause `el` (a surface that moves) for `ms` and, unless it is a tooltip, the page's standing glass for
+ * `pageMs` with it; the standing glass is only ever held longer, since other motion may be holding it too. */
+ const holdMotion = (el: Element | null, ms: number, pageMs = ms) => {
+ if (el) hold(el, ms);
+ if (el && el.matches(LOCAL_ONLY)) return;
+ for (const still of pageGlass()) if (still !== el) hold(still, pageMs, true);
+ };
+
+ const scrollTargets = (scroller: Element): Element[] | null => {
+ // Text scrolling inside a field is typing, not motion.
+ if (scroller.matches(TEXT_FIELDS)) return null;
+ const out: Element[] = [];
+ const own = scroller.closest(GLASS_MOTION_SURFACES);
+ if (own) out.push(own);
+ // The glass floating over the chat (the composer dock, the scroll-to-bottom button) sits beside the
+ // thread viewport. Only those siblings' own subtrees are searched, never the viewport's.
+ const parent = scroller.parentElement;
+ if (parent && !own && scroller.matches(THREAD_SCROLLER)) {
+ for (const sibling of parent.children) {
+ if (sibling === scroller) continue;
+ if (sibling.matches(GLASS_MOTION_SURFACES)) out.push(sibling);
+ for (const el of sibling.querySelectorAll(GLASS_MOTION_SURFACES)) out.push(el);
+ }
+ }
+ return out;
+ };
+
+ // Scrolls fire every frame; the targets are looked up once per scroller per gesture.
+ let lastScroller: Element | null = null;
+ let lastTargets: Element[] | null = null;
+ let lastScrollAt = 0;
+ const onScroll = (event: Event) => {
+ const target = event.target;
+ const scroller = isElement(target)
+ ? target
+ : target === doc
+ ? doc.scrollingElement
+ : null;
+ if (!scroller) return;
+ const now = performance.now();
+ if (scroller !== lastScroller || now - lastScrollAt > SETTLE_MS) {
+ lastScroller = scroller;
+ lastTargets = scrollTargets(scroller);
+ }
+ lastScrollAt = now;
+ if (!lastTargets) return;
+ for (const el of lastTargets) hold(el, SETTLE_MS);
+ holdMotion(null, SETTLE_MS);
+ };
+
+ const onAnimationStart = (event: Event) => {
+ const el = event.target;
+ if (isElement(el) && el.matches(GLASS_MOTION_SURFACES)) holdMotion(el, ANIMATION_HOLD_MS, MOUNT_HOLD_MS);
+ };
+ // The animation is over: everything it paused gets its blur back SETTLE_MS from now.
+ const onAnimationEnd = (event: Event) => {
+ const el = event.target;
+ if (isElement(el) && timers.has(el)) holdMotion(el, SETTLE_MS);
+ };
+
+ // Menus, dialogs and tooltips mount into portals on <body>. Marking them before their first frame keeps
+ // even that frame (the costliest: the blur is created) free of the blur. Only body's own children are
+ // watched, not the subtree, so streaming chat text never wakes this.
+ const onMutations = (records: MutationRecord[]) => {
+ for (const record of records) {
+ for (const node of record.addedNodes) {
+ if (!isElement(node)) continue;
+ const surfaces = [...node.querySelectorAll(GLASS_MOTION_SURFACES)];
+ if (node.matches(GLASS_MOTION_SURFACES)) surfaces.unshift(node);
+ for (const el of surfaces) holdMotion(el, MOUNT_HOLD_MS);
+ }
+ }
+ };
+ const observer =
+ typeof MutationObserver !== "undefined" ? new MutationObserver(onMutations) : null;
+ if (observer && doc.body) observer.observe(doc.body, { childList: true });
+
+ const opts = { capture: true, passive: true } as const;
+ doc.addEventListener("scroll", onScroll, opts);
+ doc.addEventListener("animationstart", onAnimationStart, opts);
+ doc.addEventListener("animationend", onAnimationEnd, opts);
+ doc.addEventListener("animationcancel", onAnimationEnd, opts);
+
+ const stop = () => {
+ observer?.disconnect();
+ doc.removeEventListener("scroll", onScroll, opts);
+ doc.removeEventListener("animationstart", onAnimationStart, opts);
+ doc.removeEventListener("animationend", onAnimationEnd, opts);
+ doc.removeEventListener("animationcancel", onAnimationEnd, opts);
+ until.clear();
+ for (const [el, timer] of timers) {
+ clearTimeout(timer);
+ timers.delete(el);
+ if (el.hasAttribute(GLASS_MOVING_ATTR)) el.removeAttribute(GLASS_MOVING_ATTR);
+ }
+ for (const [el, timer] of settling) {
+ clearTimeout(timer);
+ settled(el);
+ }
+ lastScroller = null;
+ lastTargets = null;
+ page = [];
+ };
+ return { hold, scrollTargets, stop };
+}
diff --git a/studio/frontend/src/features/chat-background/material.ts b/studio/frontend/src/features/chat-background/material.ts
index c7c98ad17a2..ed352efcc3c 100644
--- a/studio/frontend/src/features/chat-background/material.ts
+++ b/studio/frontend/src/features/chat-background/material.ts
@@ -28,6 +28,8 @@ import {
sanitizeStrength,
sanitizeStrengths,
} from "./model";
+import { startGlassMotion } from "./glass-motion";
+import { softwareCompositing } from "./software-compositing";
import { useChatWelcomeShown } from "./welcome";
export const MATERIAL_STORAGE_KEY = "unsloth_window_material";
@@ -243,6 +245,18 @@ export function WindowMaterialMount({ route }: { route?: BackgroundRoute }) {
WEBKIT_GTK && material !== "solid" && material !== "transparent" && here,
);
}, [material, here]);
+ useEffect(() => {
+ // Only where compositing is in software, which recomputes every blur on every frame; with a GPU glass
+ // keeps its blur while things move. WebKitGTK already has no live blur outside the sidebar (data-glass-cpu).
+ const on =
+ !WEBKIT_GTK &&
+ material !== "solid" &&
+ material !== "transparent" &&
+ here &&
+ softwareCompositing();
+ document.documentElement.toggleAttribute("data-glass-motion", on);
+ return on ? startGlassMotion().stop : undefined;
+ }, [material, here]);
useEffect(() => {
const root = document.documentElement;
const wantsNative = material === "macos" && nativeMaterialAvailable();
diff --git a/studio/frontend/src/features/chat-background/software-compositing.ts b/studio/frontend/src/features/chat-background/software-compositing.ts
new file mode 100644
index 00000000000..d1dc3d54d3d
--- /dev/null
+++ b/studio/frontend/src/features/chat-background/software-compositing.ts
@@ -0,0 +1,85 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+
+/*
+ * Whether this page is composited in software: no WebGL at all, or WebGL on a software rasterizer
+ * (SwiftShader, llvmpipe, softpipe, Microsoft Basic Render Driver). There every frame redraws the whole
+ * window and recomputes every backdrop-filter on screen, which is what glass-motion.ts pauses. With a GPU
+ * the blur is cheap and the pause would only change the look, so glass keeps it.
+ * Checked once per page and cached. For testing, `window.__UNSLOTH_SOFTWARE_COMPOSITING__ = true | false`
+ * or localStorage `unsloth_software_compositing` = "1" | "0" overrides the probe.
+ */
+
+export const SOFTWARE_RENDERER = /swiftshader|llvmpipe|softpipe|basic render/i;
+export const SOFTWARE_OVERRIDE_KEY = "unsloth_software_compositing";
+export const SOFTWARE_OVERRIDE_GLOBAL = "__UNSLOTH_SOFTWARE_COMPOSITING__";
+
+type GL = Pick<WebGLRenderingContext, "getExtension" | "getParameter" | "RENDERER">;
+
+export interface CompositingEnv {
+ /** A WebGL context, or null when none can be created. */
+ webgl(): GL | null;
+ /** The test override: true / false, or null for none. */
+ override(): boolean | null;
+}
+
+/** The WebGL renderer string, unmasked when the browser allows it. */
+export function rendererOf(gl: GL): string {
+ const info = gl.getExtension("WEBGL_debug_renderer_info") as { UNMASKED_RENDERER_WEBGL: number } | null;
+ const name = info ? gl.getParameter(info.UNMASKED_RENDERER_WEBGL) : gl.getParameter(gl.RENDERER);
+ return typeof name === "string" ? name : "";
+}
+
+export function detectSoftwareCompositing(env: CompositingEnv): boolean {
+ const forced = env.override();
+ if (forced !== null) return forced;
+ let gl: GL | null = null;
+ try {
+ gl = env.webgl();
+ } catch {
+ gl = null;
+ }
+ if (!gl) return true;
+ try {
+ return SOFTWARE_RENDERER.test(rendererOf(gl));
+ } finally {
+ // Give the context back now: browsers cap live WebGL contexts per page.
+ (gl.getExtension("WEBGL_lose_context") as { loseContext(): void } | null)?.loseContext();
+ }
+}
+
+function parseOverride(value: unknown): boolean | null {
+ if (value === true || value === "1" || value === "true") return true;
+ if (value === false || value === "0" || value === "false") return false;
+ return null;
+}
+
+export const browserCompositingEnv: CompositingEnv = {
+ webgl() {
+ if (typeof document === "undefined") return null;
+ const canvas = document.createElement("canvas");
+ return (canvas.getContext("webgl") ?? canvas.getContext("experimental-webgl")) as GL | null;
+ },
+ override() {
+ const flag = parseOverride((globalThis as Record<string, unknown>)[SOFTWARE_OVERRIDE_GLOBAL]);
+ if (flag !== null) return flag;
+ try {
+ return parseOverride(globalThis.localStorage?.getItem(SOFTWARE_OVERRIDE_KEY));
+ } catch {
+ return null;
+ }
+ },
+};
+
+let cached: boolean | undefined;
+
+/** Software compositing on this page; probed on the first call only. */
+export function softwareCompositing(env: CompositingEnv = browserCompositingEnv): boolean {
+ if (cached === undefined) cached = detectSoftwareCompositing(env);
+ return cached;
+}
+
+/** Forget the cached answer (tests). */
+export function resetSoftwareCompositing(): void {
+ cached = undefined;
+}
diff --git a/studio/frontend/src/index.css b/studio/frontend/src/index.css
index eb30b2e65d2..6ad6bce0d84 100644
--- a/studio/frontend/src/index.css
+++ b/studio/frontend/src/index.css
@@ -7500,6 +7500,67 @@ html[data-glass-clear] #root [data-slot="sidebar-inner"] :is(.bg-sidebar, .sideb
}
}
+/* Glass in motion, only with software compositing (data-glass-motion on <html>, set once by WindowMaterialMount
+ when the page has no GPU WebGL renderer; with a GPU nothing here applies and glass looks and moves as before).
+ data-glass-moving is set by glass-motion.ts on each surface while something opens, closes or
+ scrolls: every frame drawn then would compute every backdrop-filter on screen again, so for those frames the
+ moving surface and the standing glass (sidebar, composer) take a near-opaque fill of their own colour instead,
+ and the blur returns in one frame (data-glass-settling) once nothing has moved for 200 ms. A Radix surface
+ closing (data-state="closed") is in motion until it unmounts. Keyed on the surface, never on <html>, so the flag
+ restyles only the surface and its own sticky bars. No descendant rule keys on data-state: Chromium would then
+ search the subtree of every element whose data-state changes (the sidebar, collapsibles in the chat). */
+html[data-glass][data-glass-motion] [data-glass-moving],
+html[data-glass][data-glass-motion] [data-glass-moving]::before,
+html[data-glass][data-glass-motion] [data-glass-moving] .sticky,
+html[data-glass][data-glass-motion] [data-slot$="-content"][data-state="closed"],
+html[data-glass][data-glass-motion] [data-slot$="-content"][data-state="closed"]::before {
+ -webkit-backdrop-filter: none !important;
+ backdrop-filter: none !important;
+}
+/* A transition outranks !important, and Radix content transitions every property (duration-100 with the initial
+ transition-property: all), which would fade the blur out, and later back in, over the very frames this saves. */
+html[data-glass][data-glass-motion] [data-slot$="-content"]:is([data-glass-moving], [data-glass-settling], [data-state="closed"]) {
+ transition: none !important;
+}
+html[data-glass][data-glass-motion][data-chat-wallpaper-workspace-ready] [data-slot="sidebar-inner"][data-glass-moving],
+html[data-glass][data-glass-motion][data-chat-wallpaper-workspace-ready] [data-windows-glass-frame][data-glass-moving]::before {
+ background-color: color-mix(in srgb, var(--glass-sidebar-fill) 96%, transparent) !important;
+}
+html[data-glass][data-glass-motion] :is([data-wallpaper-workspace], [data-chat-content-root])[data-wallpaper-ready][data-wallpaper-ready] :is(.unsloth-composer-surface, .unsloth-files-panel)[data-glass-moving],
+html[data-glass="macos"][data-glass-motion] :is(.unsloth-composer-surface, .unsloth-files-panel)[data-glass-moving] {
+ background-color: color-mix(in srgb, var(--glass-composer-fill) 96%, transparent) !important;
+}
+html[data-glass][data-glass-menus][data-glass-motion] :is([data-slot$="menu-content"], [data-slot$="menu-sub-content"], [data-slot="select-content"], [data-slot="combobox-content"], [data-slot="popover-content"], [data-slot="hover-card-content"], .menu-soft-surface, .menu-soft-surface-up, .dropdown-surface):is([data-glass-moving], [data-slot$="-content"][data-state="closed"]) {
+ background-color: color-mix(in srgb, var(--glass-page-popover) 96%, transparent) !important;
+}
+html[data-glass][data-glass-menus][data-glass-motion] :is(.tooltip-compact, .tooltip-rich)[data-glass-moving] {
+ background-color: var(--tooltip-bg) !important;
+}
+html[data-glass][data-glass-menus][data-glass-motion] [data-slot="dialog-content"]:is([data-glass-moving], [data-state="closed"]),
+html[data-glass][data-glass-motion] [data-slot="dialog-content"][data-glass-moving] .sticky {
+ background-color: color-mix(in srgb, var(--glass-page-bg) 96%, transparent) !important;
+}
+html[data-glass][data-glass-motion] :is([data-slot$="menu-content"], [data-slot$="menu-sub-content"], [data-slot="select-content"], [data-slot="combobox-content"], [data-slot="popover-content"], [data-slot="hover-card-content"], .menu-soft-surface, .menu-soft-surface-up, .dropdown-surface)[data-glass-moving] .sticky {
+ background-color: var(--glass-page-popover) !important;
+}
+/* Liquid 3D's wide blurred inner glows are painted again with every repaint inside the surface (a Settings pane
+ scrolling); while it moves they give way to the 1 px rim, as on the WebKitGTK path. Set on the dialog directly,
+ so its large subtree is not restyled; menus pin their shadow in a layer, so there the rim variables change. */
+html[data-glass="liquid-3d"][data-glass-menus][data-glass-motion] [data-slot="dialog-content"]:is([data-glass-moving], [data-state="closed"]) {
+ box-shadow: inset 0 1px 1px rgb(255 255 255 / .347) !important;
+}
+html[data-glass="liquid-3d"][data-glass-menus][data-glass-motion].dark [data-slot="dialog-content"]:is([data-glass-moving], [data-state="closed"]) {
+ box-shadow: inset 0 1px 1px rgb(255 255 255 / .109) !important;
+}
+html[data-glass="liquid-3d"][data-glass-menus][data-glass-motion] :is([data-slot$="menu-content"], [data-slot$="menu-sub-content"], [data-slot="select-content"], [data-slot="combobox-content"], [data-slot="popover-content"], [data-slot="hover-card-content"], .menu-soft-surface, .menu-soft-surface-up, .dropdown-surface):is([data-glass-moving], [data-slot$="-content"][data-state="closed"]) {
+ --glass-rim: inset 0 1px 1px rgb(255 255 255 / .347);
+ --glass-lift: 0 6px 14px -8px rgb(0 0 0 / .19), 0 2px 6px -4px rgb(0 0 0 / .075);
+}
+html[data-glass="liquid-3d"][data-glass-menus][data-glass-motion].dark :is([data-slot$="menu-content"], [data-slot$="menu-sub-content"], [data-slot="select-content"], [data-slot="combobox-content"], [data-slot="popover-content"], [data-slot="hover-card-content"], .menu-soft-surface, .menu-soft-surface-up, .dropdown-surface):is([data-glass-moving], [data-slot$="-content"][data-state="closed"]) {
+ --glass-rim: inset 0 1px 1px rgb(255 255 255 / .109);
+ --glass-lift: 0 0 8px 0 color-mix(in srgb, var(--background) 75%, transparent);
+}
+
/* WebKitGTK only (data-glass-cpu, set by WindowMaterialMount): it runs every backdrop-filter again on
each composite, on the CPU, so a caret blink, a scrolled line or a menu frame re-blurred every glass
surface on screen and glass typing, scrolling and menus cost far more than solid. There only the
diff --git a/studio/frontend/tests/glass-motion.test.ts b/studio/frontend/tests/glass-motion.test.ts
new file mode 100644
index 00000000000..e2b09ae7268
--- /dev/null
+++ b/studio/frontend/tests/glass-motion.test.ts
@@ -0,0 +1,367 @@
+// 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 { mock, test } from "node:test";
+
+import postcss from "postcss";
+
+import { readSrc } from "./helpers/kit.ts";
+
+const CSS = readSrc("index.css");
+const MATERIAL = readSrc("features/chat-background/material.ts");
+
+// --- a DOM just big enough for glass-motion.ts -------------------------------------------------------
+
+type Listener = (event: { target: unknown }) => void;
+
+// Tags stand for the selectors glass-motion.ts asks about: "surface" (GLASS_MOTION_SURFACES), "tooltip",
+// "sidebar", "frame", "thread" (the chat viewport), "field", "huge" (must never be searched), "class:NAME".
+class FakeElement {
+ attrs = new Map<string, string>();
+ children: FakeElement[] = [];
+ parentElement: FakeElement | null = null;
+ writes = 0;
+ tags: string[];
+ constructor(tags: string[] = []) {
+ this.tags = tags;
+ }
+ append(...kids: FakeElement[]): this {
+ for (const kid of kids) {
+ kid.parentElement = this;
+ this.children.push(kid);
+ }
+ return this;
+ }
+ is(tag: string): boolean {
+ return this.tags.includes(tag);
+ }
+ get isConnected(): boolean {
+ let el: FakeElement = this;
+ while (el.parentElement) el = el.parentElement;
+ return el.is("root");
+ }
+ matches(selector: string): boolean {
+ if (selector === SURFACES) return this.is("surface");
+ if (selector.includes("tooltip-compact")) return this.is("tooltip");
+ if (selector.includes("sidebar-inner")) return this.is("sidebar");
+ if (selector.includes("windows-glass-frame")) return this.is("frame");
+ if (selector.includes("aui-thread-viewport")) return this.is("thread");
+ if (selector.includes("textarea")) return this.is("field");
+ throw new Error(`unexpected selector ${selector}`);
+ }
+ closest(selector: string): FakeElement | null {
+ for (let el: FakeElement | null = this; el; el = el.parentElement) if (el.matches(selector)) return el;
+ return null;
+ }
+ all(pred: (el: FakeElement) => boolean): FakeElement[] {
+ if (this.is("huge")) throw new Error("searched the chat subtree");
+ const out: FakeElement[] = [];
+ for (const kid of this.children) {
+ if (pred(kid)) out.push(kid);
+ if (!kid.is("huge")) out.push(...kid.all(pred));
+ }
+ return out;
+ }
+ querySelectorAll(selector: string): FakeElement[] {
+ return this.all((el) => el.matches(selector));
+ }
+ hasAttribute(name: string): boolean {
+ return this.attrs.has(name);
+ }
+ getAttribute(name: string): string | null {
+ return this.attrs.get(name) ?? null;
+ }
+ setAttribute(name: string, value: string): void {
+ this.writes++;
+ this.attrs.set(name, value);
+ }
+ removeAttribute(name: string): void {
+ this.writes++;
+ this.attrs.delete(name);
+ }
+}
+
+class FakeDocument {
+ listeners = new Map<string, Set<Listener>>();
+ documentElement = new FakeElement(["root"]);
+ body = new FakeElement();
+ scrollingElement = new FakeElement();
+ constructor() {
+ this.documentElement.append(this.body);
+ }
+ querySelector(selector: string): FakeElement | null {
+ return this.body.querySelectorAll(selector)[0] ?? null;
+ }
+ getElementsByClassName(name: string): FakeElement[] {
+ // A live collection in a browser; the fake walks past "huge" nodes like the engine's indexed lookup would.
+ return this.body.all((el) => el.is(`class:${name}`));
+ }
+ addEventListener(type: string, fn: Listener): void {
+ if (!this.listeners.has(type)) this.listeners.set(type, new Set());
+ this.listeners.get(type)!.add(fn);
+ }
+ removeEventListener(type: string, fn: Listener): void {
+ this.listeners.get(type)?.delete(fn);
+ }
+ fire(type: string, target: unknown): void {
+ for (const fn of this.listeners.get(type) ?? []) fn({ target });
+ }
+ count(): number {
+ return [...this.listeners.values()].reduce((n, s) => n + s.size, 0);
+ }
+}
+
+let observed: { cb: (records: unknown[]) => void; target: unknown; opts: unknown; live: boolean }[] = [];
+class FakeMutationObserver {
+ entry: (typeof observed)[number];
+ constructor(cb: (records: unknown[]) => void) {
+ this.entry = { cb, target: null, opts: null, live: false };
+ observed.push(this.entry);
+ }
+ observe(target: unknown, opts: unknown): void {
+ Object.assign(this.entry, { target, opts, live: true });
+ }
+ disconnect(): void {
+ this.entry.live = false;
+ }
+}
+
+Object.assign(globalThis, { Element: FakeElement, MutationObserver: FakeMutationObserver });
+mock.timers.enable({ apis: ["setTimeout", "Date"], now: 0 });
+let clock = 0;
+Object.defineProperty(globalThis, "performance", { value: { now: () => clock }, configurable: true });
+const tick = (ms: number) => {
+ clock += ms;
+ mock.timers.tick(ms);
+};
+
+const motion = await import("../src/features/chat-background/glass-motion.ts");
+const SURFACES = motion.GLASS_MOTION_SURFACES;
+const ATTR = motion.GLASS_MOVING_ATTR;
+const SETTLING = motion.GLASS_SETTLING_ATTR;
+
+/** A chat page: sidebar (in a Windows glass frame), thread viewport (huge) beside the composer dock. */
+function page(glass = "liquid-3d") {
+ observed = [];
+ const doc = new FakeDocument();
+ if (glass) doc.documentElement.setAttribute("data-glass", glass);
+ const sidebar = new FakeElement(["sidebar"]);
+ const frame = new FakeElement(["frame"]).append(sidebar);
+ const composer = new FakeElement(["surface", "class:unsloth-composer-surface"]);
+ const float = new FakeElement(["surface"]);
+ const dock = new FakeElement().append(composer, float);
+ const viewport = new FakeElement(["thread", "huge"]);
+ doc.body.append(frame, new FakeElement().append(viewport, dock));
+ const ctl = motion.startGlassMotion(doc as unknown as Document);
+ return { doc, ctl, sidebar, frame, composer, float, viewport };
+}
+const moving = (...els: FakeElement[]) => els.map((el) => el.hasAttribute(ATTR));
+
+// --- behaviour ------------------------------------------------------------------------------------
+
+test("scrolling the chat pauses the glass over it and the standing glass, then the blur returns in one step", () => {
+ const { doc, ctl, sidebar, frame, composer, float, viewport } = page();
+ doc.fire("scroll", viewport);
+ assert.deepEqual(moving(composer, float, sidebar, frame), [true, true, true, true]);
+ assert.ok(!viewport.hasAttribute(ATTR), "the chat itself is never flagged");
+ tick(motion.SETTLE_MS - 1);
+ doc.fire("scroll", viewport);
+ tick(motion.SETTLE_MS - 1);
+ assert.ok(sidebar.hasAttribute(ATTR), "each scroll event extends the hold");
+ tick(1);
+ assert.deepEqual(moving(composer, float, sidebar, frame), [false, false, false, false]);
+ assert.ok(composer.hasAttribute(SETTLING), "the blur returns with the surface's transitions off");
+ tick(motion.SETTLING_MS);
+ assert.ok(!composer.hasAttribute(SETTLING), "then its transitions are back");
+ assert.equal(sidebar.writes, 4, "set, settle + clear, unsettle: however many scroll events");
+ ctl.stop();
+});
+
+test("a scroll inside a dialog pauses it with the standing glass; typing in a field pauses nothing", () => {
+ const { doc, ctl, sidebar, composer } = page();
+ const pane = new FakeElement();
+ const dialog = new FakeElement(["surface"]).append(pane);
+ const field = new FakeElement(["field"]);
+ doc.body.append(dialog, new FakeElement(["surface"]).append(field));
+ doc.fire("scroll", field);
+ assert.deepEqual(moving(sidebar, composer), [false, false], "text scrolling inside a field is typing");
+ doc.fire("scroll", pane);
+ assert.deepEqual(moving(dialog, sidebar, composer), [true, true, true]);
+ doc.fire("scroll", doc);
+ ctl.stop();
+});
+
+test("a menu mounting is paused from its first frame with the standing glass; a tooltip only pauses itself", () => {
+ const { ctl, sidebar, composer } = page();
+ const [mo] = observed;
+ assert.deepEqual(mo.opts, { childList: true }, "body's own children only, never the chat subtree");
+ const tip = new FakeElement(["surface", "tooltip"]);
+ mo.cb([{ addedNodes: [new FakeElement().append(tip), "text node"] }]);
+ assert.ok(tip.hasAttribute(ATTR));
+ assert.deepEqual(moving(sidebar, composer), [false, false], "hovering must not flicker the sidebar");
+ const menu = new FakeElement(["surface"]);
+ mo.cb([{ addedNodes: [new FakeElement().append(menu)] }]);
+ assert.deepEqual(moving(menu, sidebar, composer), [true, true, true]);
+ tick(motion.MOUNT_HOLD_MS);
+ assert.deepEqual(moving(menu, sidebar, composer), [false, false, false]);
+ ctl.stop();
+});
+
+test("an animation holds its surface until it ends; the standing glass is never released early", () => {
+ const { doc, ctl, sidebar } = page();
+ const dialog = new FakeElement(["surface"]);
+ doc.fire("animationstart", dialog);
+ tick(motion.MOUNT_HOLD_MS + 10);
+ assert.ok(dialog.hasAttribute(ATTR), "a running animation holds it past the mount hold");
+ doc.fire("animationend", dialog);
+ tick(motion.SETTLE_MS);
+ assert.ok(!dialog.hasAttribute(ATTR));
+ const long = new FakeElement(["surface"]);
+ doc.fire("animationstart", long);
+ doc.fire("scroll", new FakeElement());
+ tick(motion.SETTLE_MS + 1);
+ assert.ok(sidebar.hasAttribute(ATTR), "a short scroll does not cut the animation's hold on the sidebar");
+ tick(motion.ANIMATION_HOLD_MS);
+ assert.ok(!long.hasAttribute(ATTR), "an animation whose end never arrives is released by ANIMATION_HOLD_MS");
+ const spinner = new FakeElement();
+ doc.fire("animationstart", spinner);
+ assert.ok(!spinner.hasAttribute(ATTR) && !sidebar.hasAttribute(ATTR), "only glass surfaces' animations count");
+ ctl.stop();
+});
+
+test("with the native macOS material the sidebar keeps its look", () => {
+ const { doc, ctl, sidebar, composer, viewport } = page("macos");
+ doc.fire("scroll", viewport);
+ assert.deepEqual(moving(sidebar, composer), [false, true]);
+ ctl.stop();
+});
+
+test("the standing glass is found again once it leaves the page", () => {
+ const { doc, ctl, composer, viewport } = page();
+ const dock = composer.parentElement!;
+ dock.children = dock.children.filter((el) => el !== composer);
+ composer.parentElement = null;
+ const fresh = new FakeElement(["surface", "class:unsloth-composer-surface"]);
+ dock.append(fresh);
+ doc.fire("scroll", new FakeElement());
+ tick(motion.SETTLE_MS + motion.SETTLING_MS);
+ doc.fire("scroll", viewport);
+ assert.ok(fresh.hasAttribute(ATTR));
+ ctl.stop();
+});
+
+test("stop() removes every listener, the observer and every flag, and is safe to call twice", () => {
+ const { doc, ctl, sidebar } = page();
+ assert.equal(doc.count(), 4);
+ const a = new FakeElement(["surface"]);
+ const c = new FakeElement(["surface"]);
+ ctl.hold(a as unknown as Element, 10_000);
+ ctl.hold(c as unknown as Element, 10);
+ doc.fire("scroll", new FakeElement());
+ tick(10);
+ assert.ok(c.hasAttribute(SETTLING));
+ ctl.stop();
+ assert.equal(doc.count(), 0);
+ assert.equal(observed[0].live, false);
+ assert.ok(!a.hasAttribute(ATTR) && !sidebar.hasAttribute(ATTR));
+ assert.ok(!c.hasAttribute(SETTLING), "a settling surface gets its transitions back");
+ assert.ok(!a.hasAttribute(SETTLING), "stop() restores the blur without a settle step");
+ ctl.stop();
+ tick(10_000);
+ assert.equal(a.writes, 2, "the cancelled timer never fires a late write");
+});
+
+// --- wiring and CSS contract -----------------------------------------------------------------------
+
+test("glass motion runs only with software compositing, where glass blurs: never solid, Transparent, out of scope or WebKitGTK", () => {
+ assert.match(MATERIAL, /import \{ startGlassMotion \} from "\.\/glass-motion";/);
+ assert.match(
+ MATERIAL,
+ /const on =\s*!WEBKIT_GTK &&\s*material !== "solid" &&\s*material !== "transparent" &&\s*here &&\s*softwareCompositing\(\);\s*document\.documentElement\.toggleAttribute\("data-glass-motion", on\);\s*return on \? startGlassMotion\(\)\.stop : undefined;\s*\}, \[material, here\]\);/,
+ );
+});
+
+const root = postcss.parse(CSS);
+const movingRules: postcss.Rule[] = [];
+root.walkRules((rule) => {
+ if (/data-glass-(moving|settling)|\[data-slot\$="-content"\]\[data-state="closed"\]/.test(rule.selector)) movingRules.push(rule);
+});
+
+test("the motion flag is keyed on the surface, never on html or body, and never inside :has()", () => {
+ assert.ok(movingRules.length >= 5);
+ for (const rule of movingRules) {
+ for (const sel of rule.selectors) {
+ assert.doesNotMatch(sel, /html\[[^\]]*data-glass-moving|body\[[^\]]*data-glass-moving/, sel);
+ assert.doesNotMatch(sel, /:has\(/, `${sel}: a :has() here would re-match on every DOM change`);
+ assert.match(sel, /^html(\.dark)?\[data-glass/, `${sel}: only with Glass on`);
+ assert.match(sel, /^html[^ ]*\[data-glass-motion\]/, `${sel}: only with software compositing; with a GPU nothing changes`);
+ }
+ assert.equal(rule.parent?.type, "root", `${rule.selector}: unlayered, outside @layer and @media`);
+ }
+ for (const rule of movingRules) {
+ for (const sel of rule.selectors) {
+ // Chromium indexes invalidation by attribute name: a descendant rule on data-state would search the
+ // subtree of every element whose data-state changes (the sidebar, collapsibles in the chat).
+ assert.doesNotMatch(sel, /\[data-state[^\]]*\][^,]*\s+[^\s]/, `${sel}: no descendant keyed on data-state`);
+ assert.ok(!/\[data-state/.test(sel) || /\[data-slot\$?="[^"]*-content"\]/.test(sel), `${sel}: only Radix content closing`);
+ }
+ }
+ assert.doesNotMatch(readSrc("features/chat-background/glass-motion.ts"), /(documentElement|body)\??\.(set|toggle|remove)Attribute/);
+});
+
+test("a moving or closing surface loses its blur at once and takes a near-opaque fill", () => {
+ const pause = movingRules.find((r) => r.selectors.includes("html[data-glass][data-glass-motion] [data-glass-moving]"));
+ assert.ok(pause);
+ for (const sel of [
+ "html[data-glass][data-glass-motion] [data-glass-moving]::before",
+ "html[data-glass][data-glass-motion] [data-glass-moving] .sticky",
+ 'html[data-glass][data-glass-motion] [data-slot$="-content"][data-state="closed"]',
+ 'html[data-glass][data-glass-motion] [data-slot$="-content"][data-state="closed"]::before',
+ ]) assert.ok(pause.selectors.includes(sel), sel);
+ const decl = (prop: string) => pause.nodes.find((n) => n.type === "decl" && n.prop === prop) as postcss.Declaration;
+ assert.equal(decl("backdrop-filter").value, "none");
+ assert.ok(decl("backdrop-filter").important);
+ assert.ok(decl("-webkit-backdrop-filter").important);
+ const still = movingRules.find(
+ (r) => r.selector === 'html[data-glass][data-glass-motion] [data-slot$="-content"]:is([data-glass-moving], [data-glass-settling], [data-state="closed"])',
+ );
+ assert.ok(still, "Radix content pauses, settles and closes with its transitions off");
+ assert.ok(
+ still.nodes.some((n) => n.type === "decl" && n.prop === "transition" && n.value === "none" && n.important),
+ "a running transition outranks !important, and transition-all would fade the blur over every frame saved",
+ );
+ assert.ok(!pause.nodes.some((n) => n.type === "decl" && n.prop === "transition"), "the sidebar keeps its own transitions");
+ const fills = movingRules.filter((r) => r.nodes.some((n) => n.type === "decl" && n.prop === "background-color"));
+ for (const surface of [".unsloth-composer-surface", '[data-slot$="menu-content"]', '[data-slot="dialog-content"]', ".tooltip-compact"]) {
+ assert.ok(fills.some((r) => r.selector.includes(surface)), `${surface} has a motion fill`);
+ }
+ for (const rule of fills) {
+ const bg = rule.nodes.find((n) => n.type === "decl" && n.prop === "background-color") as postcss.Declaration;
+ assert.ok(bg.important, rule.selector);
+ assert.match(bg.value, /96%|^var\(--(tooltip-bg|glass-page-popover)\)$/, `${rule.selector}: dense enough that nothing ghosts`);
+ }
+});
+
+test("no later important blur can win the cascade back from a moving surface", () => {
+ const at = CSS.indexOf("html[data-glass][data-glass-motion] [data-glass-moving],");
+ assert.ok(at > 0);
+ const tail = CSS.slice(at);
+ assert.doesNotMatch(tail, /backdrop-filter:\s*blur[^;]*!important/);
+});
+
+test("in motion, Liquid 3D drops its wide blurred inner glows on dialogs and menus", () => {
+ const rims = movingRules.filter((r) => r.selector.includes('[data-glass="liquid-3d"]'));
+ assert.equal(rims.length, 4, "dialog and menus, light and dark");
+ for (const rule of rims) {
+ for (const node of rule.nodes) {
+ if (node.type !== "decl" || !/^(box-shadow|--glass-rim)$/.test(node.prop)) continue;
+ for (const shadow of node.value.split(/,(?![^(]*\))/)) {
+ const blur = /inset\s+-?[\d.]+(?:px)?\s+-?[\d.]+(?:px)?\s+([\d.]+)px/.exec(shadow)?.[1];
+ assert.ok(!blur || Number(blur) <= 2, `${rule.selector}: no wide blurred inset (${shadow.trim()})`);
+ }
+ }
+ }
+ const dialog = rims.find((r) => r.selector.includes("dialog-content") && !r.selector.includes(".dark"));
+ assert.ok(dialog?.nodes.some((n) => n.type === "decl" && n.prop === "box-shadow" && n.important), "set on the dialog itself, not inherited by its subtree");
+});
diff --git a/studio/frontend/tests/software-compositing.test.ts b/studio/frontend/tests/software-compositing.test.ts
new file mode 100644
index 00000000000..f1285cb6c51
--- /dev/null
+++ b/studio/frontend/tests/software-compositing.test.ts
@@ -0,0 +1,115 @@
+// 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 {
+ SOFTWARE_OVERRIDE_GLOBAL,
+ SOFTWARE_OVERRIDE_KEY,
+ browserCompositingEnv,
+ detectSoftwareCompositing,
+ resetSoftwareCompositing,
+ softwareCompositing,
+} from "../src/features/chat-background/software-compositing.ts";
+
+const UNMASKED = 0x9246;
+const RENDERER = 0x1f01;
+
+function gl(renderer: string, unmasked = true) {
+ const state = { lost: 0 };
+ return {
+ state,
+ RENDERER,
+ getExtension(name: string) {
+ if (name === "WEBGL_debug_renderer_info") return unmasked ? { UNMASKED_RENDERER_WEBGL: UNMASKED } : null;
+ if (name === "WEBGL_lose_context") return { loseContext: () => void state.lost++ };
+ return null;
+ },
+ getParameter(p: number) {
+ if (p === UNMASKED) return renderer;
+ if (p === RENDERER) return unmasked ? "WebKit WebGL" : renderer;
+ return null;
+ },
+ };
+}
+const env = (context: ReturnType<typeof gl> | null, override: boolean | null = null) => ({
+ webgl: () => context as never,
+ override: () => override,
+});
+
+test("software rasterizers and a missing WebGL context mean software compositing", () => {
+ for (const name of [
+ "ANGLE (Google, Vulkan 1.3.0 (SwiftShader Device (Subzero) (0x0000C0DE)), SwiftShader driver)",
+ "llvmpipe (LLVM 17.0.6, 256 bits)",
+ "softpipe",
+ "ANGLE (Microsoft, Microsoft Basic Render Driver Direct3D11 vs_5_0 ps_5_0, D3D11)",
+ "Microsoft Basic Render Driver",
+ ]) {
+ assert.equal(detectSoftwareCompositing(env(gl(name))), true, name);
+ }
+ assert.equal(detectSoftwareCompositing(env(null)), true, "no WebGL at all");
+ assert.equal(
+ detectSoftwareCompositing({ webgl: () => { throw new Error("blocked"); }, override: () => null }),
+ true,
+ "a context that throws counts as none",
+ );
+});
+
+test("a GPU renderer is not software, masked or not, and the probe context is released", () => {
+ for (const name of [
+ "ANGLE (NVIDIA, NVIDIA GeForce RTX 4070 Direct3D11 vs_5_0 ps_5_0, D3D11)",
+ "ANGLE (Intel, Intel(R) UHD Graphics 620 Direct3D11 vs_5_0 ps_5_0, D3D11)",
+ "Apple GPU",
+ "Apple M2",
+ ]) {
+ const context = gl(name);
+ assert.equal(detectSoftwareCompositing(env(context)), false, name);
+ assert.equal(context.state.lost, 1, `${name}: context lost after the probe`);
+ }
+ assert.equal(detectSoftwareCompositing(env(gl("Apple GPU", false))), false, "no debug extension: RENDERER");
+ assert.equal(detectSoftwareCompositing(env(gl("llvmpipe", false))), true);
+});
+
+test("the override wins both ways", () => {
+ assert.equal(detectSoftwareCompositing(env(gl("Apple GPU"), true)), true);
+ assert.equal(detectSoftwareCompositing(env(null, false)), false);
+});
+
+test("the browser override reads the window flag first, then localStorage", () => {
+ const g = globalThis as Record<string, unknown>;
+ const store = new Map<string, string>();
+ const saved = Object.getOwnPropertyDescriptor(globalThis, "localStorage");
+ Object.defineProperty(globalThis, "localStorage", {
+ value: { getItem: (k: string) => store.get(k) ?? null },
+ configurable: true,
+ });
+ try {
+ assert.equal(browserCompositingEnv.override(), null);
+ store.set(SOFTWARE_OVERRIDE_KEY, "0");
+ assert.equal(browserCompositingEnv.override(), false);
+ store.set(SOFTWARE_OVERRIDE_KEY, "1");
+ assert.equal(browserCompositingEnv.override(), true);
+ g[SOFTWARE_OVERRIDE_GLOBAL] = false;
+ assert.equal(browserCompositingEnv.override(), false, "the window flag outranks localStorage");
+ store.set(SOFTWARE_OVERRIDE_KEY, "junk");
+ delete g[SOFTWARE_OVERRIDE_GLOBAL];
+ assert.equal(browserCompositingEnv.override(), null);
+ } finally {
+ delete g[SOFTWARE_OVERRIDE_GLOBAL];
+ if (saved) Object.defineProperty(globalThis, "localStorage", saved);
+ else delete g.localStorage;
+ }
+});
+
+test("the answer is probed once and cached until reset", () => {
+ resetSoftwareCompositing();
+ let probes = 0;
+ const counting = { webgl: () => (probes++, gl("Apple GPU") as never), override: () => null };
+ assert.equal(softwareCompositing(counting), false);
+ assert.equal(softwareCompositing(env(null)), false, "cached, the second environment is not asked");
+ assert.equal(probes, 1);
+ resetSoftwareCompositing();
+ assert.equal(softwareCompositing(env(null)), true);
+ resetSoftwareCompositing();
+});
diff --git a/tests/studio/_area_matrix.py b/tests/studio/_area_matrix.py
index bd912c3f6ce..59837ff21ea 100644
--- a/tests/studio/_area_matrix.py
+++ b/tests/studio/_area_matrix.py
@@ -65,20 +65,19 @@ CPU_BASE_FLOOR_MS = float(os.environ.get("LONG_THREAD_AREAS_CPU_BASE_FLOOR_MS",
RECHECKS = int(os.environ.get("LONG_THREAD_AREAS_RECHECKS", "2"))
# At most this many mode pages are measured again (each loads only its failing areas).
RECHECK_PAGES = int(os.environ.get("LONG_THREAD_AREAS_RECHECK_PAGES", "10"))
-# Costs main already has (origin/main 42489f20e2: highest settled reading of 3 Colab runs pinned
-# to 4 CPUs and 7 runs on a loaded 36-core host), as `mode:area=ratio`, `mode:*=ratio`,
-# `length:area=ratio` or `count:area=elements` (elements restyled at LONG turns, replacing the length
-# ratio for that area). Each ceiling is about 1.2-1.3x the highest reading, so these may not get
-# worse while a new mode or area meets MAX_RATIO / LENGTH_RATIO. Glass: CPU raster of the
-# backdrop-filter on every repaint (on GitHub runners, main reads up to 13.5x scrolling Settings and
-# 7.8x on small areas). No area needs a count ceiling. Lower or drop an entry when its cause is fixed;
+# Costs main already has, as `mode:area=ratio`, `mode:*=ratio`, `length:area=ratio` or
+# `count:area=elements` (elements restyled at LONG turns, replacing the length ratio for that area).
+# These may not get worse while a new mode or area meets MAX_RATIO / LENGTH_RATIO. Glass: with
+# software compositing (the gate's headless Chromium; these ceilings assume it) every frame redraws
+# the window, so the sidebar's blur costs on any repaint: small areas up to 7.8x on GitHub runners.
+# glass-motion.ts swaps the blur for a plain fill while anything moves, so scrolling Settings reads
+# 1.4-4.5x (main 7.8-14.0x) and the thread 1.8-4.9x (main 4.6-8.3x); 7x leaves runner margin.
# LONG_THREAD_AREAS_KNOWN="" holds main to the plain limits.
+_GLASS_MODES = ("frosted", "blurred", "liquid", GLASS)
KNOWN_DEFAULT = ",".join(
- [f"{m}:*={r}" for m, r in (("frosted", 10), ("blurred", 10), ("liquid", 10), (GLASS, 10))]
- + [
- f"{m}:settings_scroll={r}"
- for m, r in (("frosted", 18), ("blurred", 18), ("liquid", 18), (GLASS, 18))
- ]
+ [f"{m}:*=10" for m in _GLASS_MODES]
+ + [f"{m}:thread_scroll=7" for m in _GLASS_MODES]
+ + [f"{m}:settings_scroll=7" for m in _GLASS_MODES]
)
KNOWN = os.environ.get("LONG_THREAD_AREAS_KNOWN", KNOWN_DEFAULT)
diff --git a/tests/studio/test_area_matrix.py b/tests/studio/test_area_matrix.py
index 9275966a804..ed6a90ed191 100644
--- a/tests/studio/test_area_matrix.py
+++ b/tests/studio/test_area_matrix.py
@@ -131,11 +131,13 @@ def test_appearance_check(base, mode, fails, monkeypatch):
# Highest readings on the GitHub runners the gate runs on (identical code spans about 1.35x
# between runs; 25 runs, 2026-11-07).
+# Scrolls pause the Glass blur (glass-motion.ts), so their worst readings dropped from 8.3x (thread)
+# and 14.0x (Settings) to at most 4.9x (local and runner runs of that change).
RUNNER_READINGS = [
- ("blurred", "thread_scroll", 8.3),
+ ("blurred", "thread_scroll", 4.9),
(am.GLASS, "reasoning_toggle", 7.8),
- ("blurred", "settings_scroll", 14.0),
- ("frosted", "settings_scroll", 13.5),
+ ("blurred", "settings_scroll", 4.9),
+ ("frosted", "settings_scroll", 4.9),
]