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: pause Glass blur through bursts of keys and presses under software compositing (#17237)

Daniel Hane36630f3bcf9
diff --git a/studio/frontend/src/features/chat-background/glass-motion.ts b/studio/frontend/src/features/chat-background/glass-motion.ts
index dfe895837e8..800dd4bae93 100644
--- a/studio/frontend/src/features/chat-background/glass-motion.ts
+++ b/studio/frontend/src/features/chat-background/glass-motion.ts
@@ -3,7 +3,7 @@
/*
* 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
+ * still sidebar's included. So while something moves, or keys and presses arrive, 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.
*/
@@ -39,6 +39,9 @@ const PAGE_REFRESH_MS = 2000;
const THREAD_SCROLLER = ".aui-thread-viewport";
const TEXT_FIELDS = 'textarea, input, [contenteditable]:not([contenteditable="false"])';
+/** Keys, presses and edits (paste, IME, autocomplete) each draw frames: the glass pauses through a burst of them. */
+export const INTERACTION_EVENTS = ["keydown", "pointerdown", "input"] as const;
+
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. */
@@ -166,6 +169,15 @@ export function startGlassMotion(doc: Document = document): GlassMotion {
holdMotion(null, SETTLE_MS);
};
+ // A key or a press redraws the window like any motion: typing a character, pasting, an IME step or a click
+ // that opens a reasoning block would otherwise compute every blur on screen again for each of its frames.
+ // The standing glass, and the surface the event lands in (a dialog's search field, a menu), pause with it.
+ const onInteraction = (event: Event) => {
+ const target = event.target;
+ const own = isElement(target) ? target.closest(GLASS_MOTION_SURFACES) : null;
+ holdMotion(own, 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);
@@ -195,6 +207,7 @@ export function startGlassMotion(doc: Document = document): GlassMotion {
const opts = { capture: true, passive: true } as const;
doc.addEventListener("scroll", onScroll, opts);
+ for (const type of INTERACTION_EVENTS) doc.addEventListener(type, onInteraction, opts);
doc.addEventListener("animationstart", onAnimationStart, opts);
doc.addEventListener("animationend", onAnimationEnd, opts);
doc.addEventListener("animationcancel", onAnimationEnd, opts);
@@ -202,6 +215,7 @@ export function startGlassMotion(doc: Document = document): GlassMotion {
const stop = () => {
observer?.disconnect();
doc.removeEventListener("scroll", onScroll, opts);
+ for (const type of INTERACTION_EVENTS) doc.removeEventListener(type, onInteraction, opts);
doc.removeEventListener("animationstart", onAnimationStart, opts);
doc.removeEventListener("animationend", onAnimationEnd, opts);
doc.removeEventListener("animationcancel", onAnimationEnd, opts);
diff --git a/studio/frontend/src/index.css b/studio/frontend/src/index.css
index fb7c1f0b891..d4870246809 100644
--- a/studio/frontend/src/index.css
+++ b/studio/frontend/src/index.css
@@ -7505,7 +7505,7 @@ 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
+ scrolls, and through a burst of keys or presses: 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
diff --git a/studio/frontend/tests/glass-motion.test.ts b/studio/frontend/tests/glass-motion.test.ts
index e2b09ae7268..915276d8e76 100644
--- a/studio/frontend/tests/glass-motion.test.ts
+++ b/studio/frontend/tests/glass-motion.test.ts
@@ -192,6 +192,28 @@ test("a scroll inside a dialog pauses it with the standing glass; typing in a fi
ctl.stop();
});
+test("keys, presses and edits pause the standing glass and the surface they land in through the burst", () => {
+ const { doc, ctl, sidebar, frame, composer, float } = page();
+ const field = new FakeElement(["field"]);
+ composer.append(field);
+ for (const type of motion.INTERACTION_EVENTS) {
+ doc.fire(type, field);
+ assert.deepEqual(moving(sidebar, frame, composer), [true, true, true], type);
+ assert.ok(!float.hasAttribute(ATTR), "glass the event did not land in and that does not stand stays blurred");
+ tick(motion.SETTLE_MS - 1);
+ }
+ assert.ok(sidebar.hasAttribute(ATTR), "each key extends the hold, so a burst of typing stays on the fill");
+ tick(1);
+ assert.deepEqual(moving(sidebar, frame, composer), [false, false, false], "the blur returns once the keys stop");
+ const button = new FakeElement();
+ const dialog = new FakeElement(["surface"]).append(button);
+ doc.body.append(dialog);
+ doc.fire("pointerdown", button);
+ assert.deepEqual(moving(dialog, sidebar, composer), [true, true, true], "a press in a dialog pauses the dialog too");
+ doc.fire("keydown", 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;
@@ -253,7 +275,7 @@ test("the standing glass is found again once it leaves the page", () => {
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);
+ assert.equal(doc.count(), 4 + motion.INTERACTION_EVENTS.length);
const a = new FakeElement(["surface"]);
const c = new FakeElement(["surface"]);
ctl.hold(a as unknown as Element, 10_000);
diff --git a/tests/studio/_area_matrix.py b/tests/studio/_area_matrix.py
index 59837ff21ea..22c5508cd17 100644
--- a/tests/studio/_area_matrix.py
+++ b/tests/studio/_area_matrix.py
@@ -72,12 +72,15 @@ RECHECK_PAGES = int(os.environ.get("LONG_THREAD_AREAS_RECHECK_PAGES", "10"))
# 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.
+# It also pauses through bursts of keys and presses: typing reads 1.3-1.7x locally (main 3.1-3.6x,
+# runners 4.1-4.9x before it); a message click 1.3-2.3x (main 2.9-3.7x) but noisy, so it keeps 10x.
# LONG_THREAD_AREAS_KNOWN="" holds main to the plain limits.
_GLASS_MODES = ("frosted", "blurred", "liquid", GLASS)
KNOWN_DEFAULT = ",".join(
[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]
+ + [f"{m}:type=6" 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 ed6a90ed191..d1bad6742fd 100644
--- a/tests/studio/test_area_matrix.py
+++ b/tests/studio/test_area_matrix.py
@@ -138,6 +138,8 @@ RUNNER_READINGS = [
(am.GLASS, "reasoning_toggle", 7.8),
("blurred", "settings_scroll", 4.9),
("frosted", "settings_scroll", 4.9),
+ # Before keys and presses paused the blur (main runner, Frontend CI 42610880257).
+ ("liquid", "type", 4.9),
]