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.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
Studio: draw nothing for the glass lens when it is Off (glass 1.4 to 2.1x faster without GPU rendering) (#16852)
oobabooga767372b97a77
diff --git a/studio/frontend/src/features/chat-background/lens.tsx b/studio/frontend/src/features/chat-background/lens.tsxindex 9227391ded3..4efa22ab2d6 100644--- a/studio/frontend/src/features/chat-background/lens.tsx+++ b/studio/frontend/src/features/chat-background/lens.tsx@@ -4,7 +4,7 @@import { useEffect, useLayoutEffect, useRef, useState } from "react";import { createPortal } from "react-dom";import { useMaterialStore } from "./material";-import { LENS_SCALE } from "./model";+import { LENS_SCALE, lensDrawn } from "./model";const COMPOSER = ".unsloth-composer-surface";@@ -15,9 +15,10 @@ export function ComposerGlassLenses({wallpaper: HTMLElement | null;}) {const material = useMaterialStore((s) => s.material);+ const lens = useMaterialStore((s) => s.lens);const [hosts, setHosts] = useState<HTMLElement[]>([]);const workspace = wallpaper?.parentElement ?? null;- const on = Boolean(workspace) && material !== "solid";+ const on = Boolean(workspace) && lensDrawn(material, lens);useEffect(() => {if (!workspace || !on) return;let frame = 0;@@ -149,13 +150,11 @@ function Lens({}, [host, wallpaper, scale]);return (<div ref={root} aria-hidden="true" className="glass-lens" data-lens={lens}>- {lens !== "off" && (- <div className="glass-lens-fill">- <div data-lens-copy="" className="glass-lens-copy" />- <div data-lens-wash="" className="glass-lens-layer" />- <div data-lens-tint="" className="glass-lens-layer" />- </div>- )}+ <div className="glass-lens-fill">+ <div data-lens-copy="" className="glass-lens-copy" />+ <div data-lens-wash="" className="glass-lens-layer" />+ <div data-lens-tint="" className="glass-lens-layer" />+ </div><div className="glass-lens-rim"><div data-lens-copy="" className="glass-lens-copy" /></div>diff --git a/studio/frontend/src/features/chat-background/model.ts b/studio/frontend/src/features/chat-background/model.tsindex 02c92d400bd..77c9d47485b 100644--- a/studio/frontend/src/features/chat-background/model.ts+++ b/studio/frontend/src/features/chat-background/model.ts@@ -38,6 +38,10 @@ export const LENS_SCALE: Record<LensMode, number> = {export function sanitizeLens(value: unknown): LensMode {return LENS_MODES.includes(value as LensMode) ? (value as LensMode) : "off";}+// Off draws nothing: without GPU rendering, WebKitGTK repaints each wallpaper copy and its filter on every frame.+export function lensDrawn(material: WindowMaterial, lens: LensMode): boolean {+ return material !== "solid" && lens !== "off";+}export function sanitizeStrength(value: unknown, fallback = 50): number {return typeof value === "number" && Number.isFinite(value)? Math.max(0, Math.min(100, Math.round(value)))diff --git a/studio/frontend/tests/window-material.test.ts b/studio/frontend/tests/window-material.test.tsindex 1863f6f3276..02e6f9885f9 100644--- a/studio/frontend/tests/window-material.test.ts+++ b/studio/frontend/tests/window-material.test.ts@@ -4,6 +4,7 @@ import test from "node:test";import {MATERIALS,LENS_SCALE,+ lensDrawn,sanitizeLens,sanitizeMaterial,sanitizeStrength,@@ -113,6 +114,15 @@ test("glass lens modes repair malformed data and scale the right way", () => {assert.match(css, /\[data-outline="false"\]\) \.glass-lens \.glass-lens-rim,/);});+test("a glass lens set to off draws no wallpaper copies", () => {+ for (const material of MATERIALS) assert.equal(lensDrawn(material, "off"), false);+ for (const lens of ["magnify", "shrink"] as const) {+ assert.equal(lensDrawn("solid", lens), false);+ for (const material of MATERIALS.filter((m) => m !== "solid"))+ assert.equal(lensDrawn(material, lens), true);+ }+});+test("glass panes thicken over images that would wash out their text", async () => {const { glassReadability, toneOf } = await import("../src/features/chat-background/model.ts");const light = toneOf(Array.from({ length: 100 }, (_, i) => 0.6 + i * 0.003));