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
Long-chat gate: measure every appearance setting or allowlist it with a reason (#17262)
Daniel Han655b309ad62f
diff --git a/.github/workflows/studio-frontend-ci.yml b/.github/workflows/studio-frontend-ci.ymlindex 74cd3927792..9ca55097561 100644--- a/.github/workflows/studio-frontend-ci.yml+++ b/.github/workflows/studio-frontend-ci.yml@@ -46,6 +46,8 @@ on:- 'tests/studio/test_css_culprit.py'- 'tests/studio/_area_matrix.py'- 'tests/studio/test_area_matrix.py'+ - 'tests/studio/_appearance_coverage.py'+ - 'tests/studio/test_appearance_coverage.py'- 'tests/studio/_has_lint.py'- 'tests/studio/test_has_lint.py'- 'tests/studio/has_subject_allowlist.txt'@@ -103,6 +105,8 @@ on:- 'tests/studio/test_css_culprit.py'- 'tests/studio/_area_matrix.py'- 'tests/studio/test_area_matrix.py'+ - 'tests/studio/_appearance_coverage.py'+ - 'tests/studio/test_appearance_coverage.py'- 'tests/studio/_has_lint.py'- 'tests/studio/test_has_lint.py'- 'tests/studio/has_subject_allowlist.txt'@@ -427,6 +431,7 @@ jobs:tests/studio/test_code_block_flicker_contract.py \tests/studio/test_css_culprit.py \tests/studio/test_area_matrix.py \+ tests/studio/test_appearance_coverage.py \tests/studio/test_has_lint.py -q# Keep data settings separate from the shorter checks. Each group owns its cache.diff --git a/tests/studio/_appearance_coverage.py b/tests/studio/_appearance_coverage.pynew file mode 100644index 00000000000..764a54c3086--- /dev/null+++ b/tests/studio/_appearance_coverage.py@@ -0,0 +1,375 @@+# SPDX-License-Identifier: AGPL-3.0-only+# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0+"""Every appearance setting the app has, read from its source, is either measured by the long-chat+gate (a mode in _area_matrix.modes) or listed here with the reason it cannot slow an area down.++Glass shipped as a new look that was itself several times slower than the default; the gate only+caught it because MATERIALS happened to be measured. This module closes the gap for every other+appearance setting: a new key in DEFAULT_CUSTOMIZATION or DEFAULT_ADJUSTMENTS, a new value of an+enum setting, a new palette outside the shared palette rule, or a new <html> attribute or class that+switches on costly CSS (backdrop-filter, filter, animation, box-shadow, ...) fails+test_appearance_coverage.py until it is measured or allowlisted with a reason. No browser needed.+"""++from __future__ import annotations++import re+from pathlib import Path++SRC = Path(__file__).resolve().parents[2] / "studio" / "frontend" / "src"+MODEL_TS = SRC / "features" / "chat-background" / "model.ts"+CUSTOM_TS = SRC / "features" / "settings" / "stores" / "appearance-custom-store.ts"+THEMES_TS = SRC / "features" / "settings" / "lib" / "color-themes.ts"++# Measured by the `+custom` modes: the costliest value of each setting.+CUSTOM_MEASURED = {+ "contrast": 100,+ "composerOutline": 100,+ "elementOutline": 100,+ "pointerCursors": True,+ "fontSmoothing": False,+ "codeLineNumbers": True,+ "codeWordWrap": True,+ "codeLigatures": False,+ "chatWidth": "full",+ "uiFontSize": 20,+ "codeFontSize": 20,+}+# Root attributes / classes the `+custom` modes must show, so a renamed key cannot measure nothing.+CUSTOM_EXPECT = [+ "data-contrast-adjust",+ "data-element-outline",+ "data-composer-outline",+ "data-code-wrap",+ "data-code-line-numbers",+ "data-code-no-ligatures",+ "data-ui-font-size",+ "data-code-font-size",+ "pointer-cursors",+ "no-font-smoothing",+]+CUSTOM_ALLOW = {+ "colors": "custom colour tokens (CSS variables only, no effect properties)",+ "uiFont": "font-family variable only",+ "headingFont": "font-family variable only",+ "chatFont": "font-family variable only",+ "codeFont": "font-family variable only",+ "importedFonts": "@font-face list for the font settings above",+ "sentAttachments": "layout of sent attachment rows only",+ "reduceMotion": "default 'off' (forced motion) is what every mode measures; 'on' and 'system' only remove motion",+ "sidebarMenu": "which sidebar menu items show",+ "sidebarNav": "which sidebar items are pinned",+ "sidebarNavAuto": "which sidebar items auto-show",+}+# Enum settings: every value must be the default, measured, or listed here.+ENUM_ALLOW = {+ ("chatWidth", "wide"): "between standard and the measured full width",+ ("reduceMotion", "on"): "removes motion",+ ("reduceMotion", "system"): "follows the OS; no more than forced motion",+ ("sentAttachments", "list"): "attachment row layout",+ ("sentAttachments", "chips"): "attachment row layout",+}++# Measured by solid+palette: the only palette with its own effect rules (composer glow).+PALETTE_MEASURED = "neon-cyberpunk"++# Measured: the `+wallpaper` modes seed a stored chat wallpaper with these adjustments.+WALLPAPER_MEASURED = {"scope": "all", "conversation": 100, "blur": 20}+WALLPAPER_EXPECT = ["data-chat-wallpaper-ready", "data-chat-wallpaper-workspace-ready"]+WALLPAPER_ALLOW = {+ "effect": "pixel effects are rendered once into the image off the main thread (render.ts worker)",+ "visibility": "opacity of the static image",+ "fade": "static gradient over the image",+ "outline": "outline strength of the static image frame",+ "sizing": "background-size of the static image",+ "zoom": "scale of the static image",+ "position": "background-position of the static image",+ "glassLightVisibility": "opacity of the static image on Glass",+ "glassDarkVisibility": "opacity of the static image on Glass",+ "glassFade": "static gradient over the image on Glass",+}++# <html> attributes / classes that switch on costly CSS: what measures each, or why it needs nothing.+# A value naming a mode must be one of _area_matrix.app_modes() (checked by the test).+ROOT_FLAGS = {+ "data-glass": "liquid-3d",+ "data-glass=liquid-3d": "liquid-3d",+ "data-glass=macos": "macos",+ "data-glass-clear": "transparent",+ "data-glass-menus": "liquid-3d",+ "data-glass-plain": "liquid-3d",+ "data-glass-layers": "allow: WebKit only (layers for Glass surfaces); the Chromium gate cannot run it",+ "data-glass-cpu": "allow: WebKitGTK only (cheaper Glass); the Chromium gate cannot run it",+ "data-glass-motion": "allow: set only while scrolling under software compositing; scroll areas measure it",+ "data-chat-wallpaper-ready": "solid+wallpaper",+ "data-chat-wallpaper-workspace-ready": "liquid-3d+wallpaper",+ "data-chat-welcome": "allow: the empty new-chat screen, not a long chat",+ "data-browser-overlay-open": "allow: set while the browser pane is open; browser_pane measures it",+ "data-input-modality": "allow: keyboard vs pointer focus rings, set by every area",+ "data-input-modality=pointer": "allow: pointer focus rings, set by every clicked area",+ "data-palette": "solid+palette",+ "data-palette=neon-cyberpunk": "solid+palette",+ "data-contrast-adjust": "solid+custom",+ "data-element-outline": "solid+custom",+ "data-composer-outline": "solid+custom",+ "data-code-wrap": "solid+custom",+ "data-interface-zooming": "allow: set only during a zoom gesture",+ "dark": "solid+dark",+ "force-motion": "default",+ "force-reduced-motion": "allow: removes motion",+ "pointer-cursors": "solid+custom",+ "no-font-smoothing": "solid+custom",+ "theme-switching": "allow: set for one frame while the theme changes",+ "tauri": "allow: desktop app shell, not reachable from the browser gate",+ "render-linux": "allow: Linux desktop renderer, not reachable from the browser gate",+ "client-windows": "allow: Windows desktop shell, not reachable from the browser gate",+}++# Persisted Glass settings (useMaterialStore partialize in material.ts): what measures each.+MATERIAL_KEYS = {+ "material": "every MATERIALS entry is its own mode",+ "style": "follows material for every Glass mode",+ "menus": "liquid-3d+menus-off",+ "strength": "liquid-3d+strength-max",+ "lens": "every LENS_MODES entry is its own mode",+ "scope": "allow: 'all' (measured) shows Glass everywhere; other scopes show it on fewer pages",+}+MATERIAL_TS = SRC / "features" / "chat-background" / "material.ts"++COSTLY = re.compile(+ r"(?<![-\w])(?:-webkit-)?(?:backdrop-filter|filter|animation(?:-name)?|will-change|mix-blend-mode"+ r"|mask(?:-image)?|box-shadow)\s*:"+)+++def object_keys(source: str, name: str) -> list[str]:+ """Top-level keys of `export const NAME ... = { ... }` in a TS module."""+ m = re.search(rf"export const {name}\b[^=]*=\s*\{{", source)+ if not m:+ raise ValueError(f"{name} not found")+ i, depth, start, keys = m.end(), 1, m.end(), []+ while depth:+ c = source[i]+ if c in "{[(":+ depth += 1+ elif c in "}])":+ depth -= 1+ i += 1+ body = source[start : i - 1]+ depth, line = 0, ""+ for c in body:+ if c in "{[(":+ depth += 1+ elif c in "}])":+ depth -= 1+ if depth == 0 and c == "\n":+ line = ""+ continue+ line += c+ km = re.match(r"\s*(\w+)\s*:", line)+ if depth == 0 and km and line.rstrip().endswith(":"):+ keys.append(km.group(1))+ return list(dict.fromkeys(keys))+++def string_registry(source: str, name: str) -> list[str]:+ m = re.search(rf"export const {name}\s*=\s*\[(.*?)\]\s*as const", source, re.S)+ if not m:+ raise ValueError(f"{name} registry not found")+ return re.findall(r"""["']([^"']+)["']""", m.group(1))+++def union_values(source: str, type_name: str) -> list[str]:+ m = re.search(rf"export type {type_name}\s*=([^;]+);", source)+ if not m:+ raise ValueError(f"type {type_name} not found")+ return re.findall(r'"([^"]+)"', m.group(1))+++def enum_settings(source: str) -> dict[str, list[str]]:+ """Customization keys typed by an exported string-literal union: {key: values}."""+ body = re.search(r"export type AppearanceCustomization\s*=\s*\{(.*?)\n\};", source, re.S)+ if not body:+ raise ValueError("AppearanceCustomization type not found")+ out = {}+ for key, typ in re.findall(r"^\s*(\w+)\s*:\s*(\w+Setting)\s*;", body.group(1), re.M):+ out[key] = union_values(source, typ)+ return out+++def palettes() -> tuple[list[str], set[str]]:+ """Every palette id, and the ids listed in the shared palette rule of index.css."""+ themes = THEMES_TS.read_text(encoding = "utf-8")+ ids = []+ for name in ("UNSLOTH_THEME_IDS", "FLAVOR_THEME_IDS"):+ m = re.search(rf"(?:export )?const {name}\s*=\s*\[(.*?)\]", themes, re.S)+ if m:+ ids += re.findall(r'"([^"]+)"', m.group(1))+ css = (SRC / "index.css").read_text(encoding = "utf-8")+ shared = re.search(+ r":root:where\(((?:\[data-palette=\"[^\"]+\"\],?\s*)+)\)\[data-palette\]\s*\{", css+ )+ listed = set(re.findall(r'data-palette="([^"]+)"', shared.group(1))) if shared else set()+ return [i for i in ids if i != "standard"], listed+++def _split_top(selector: str) -> list[str]:+ out, depth, cur = [], 0, ""+ for c in selector:+ if c in "([":+ depth += 1+ elif c in ")]":+ depth -= 1+ if c == "," and depth == 0:+ out.append(cur)+ cur = ""+ else:+ cur += c+ return out + [cur]+++def _root_compound(part: str) -> str | None:+ """The first compound of a selector when it targets <html> / :root, else None."""+ part = part.strip()+ if not re.match(r"(html|:root)(?![\w-])", part):+ return None+ depth, out = 0, ""+ for c in part:+ if c in "([":+ depth += 1+ elif c in ")]":+ depth -= 1+ if depth == 0 and (c.isspace() or c in ">+~"):+ break+ out += c+ return out+++def _flags(compound: str) -> set[str]:+ """Attribute names (`name=value` when the selector pins an exact value) and classes."""+ out = set(re.findall(r"\.([\w-]+)", compound))+ for name, op, value in re.findall(+ r"\[([\w-]+)(?:\s*([~|^$*]?=)\s*\"?([^\]\"]*)\"?)?\]", compound+ ):+ out.add(f"{name}={value}" if op == "=" else name)+ return out+++def root_flags(css: str) -> dict[str, list[str]]:+ """{flag: [selector, ...]} for <html> attributes / classes on rules that set costly properties,+ nested rules included (a flag on an enclosing rule applies to its children)."""+ css = re.sub(r"/\*.*?\*/", "", css, flags = re.S)+ out: dict[str, list[str]] = {}++ def walk(i: int, inherited: set[str]) -> int:+ text = ""+ while i < len(css):+ c = css[i]+ if c == "{":+ selector = text.split(";")[-1].strip()+ flags = set(inherited)+ if not selector.startswith("@"):+ for part in _split_top(selector):+ compound = _root_compound(part.replace("&", ""))+ if compound:+ flags |= _flags(compound)+ j, body = i + 1, ""+ depth = 1+ # direct declarations of this block (nested blocks are walked separately)+ k = j+ while k < len(css) and depth:+ if css[k] == "{":+ depth += 1+ elif css[k] == "}":+ depth -= 1+ elif depth == 1:+ body += css[k]+ k += 1+ if COSTLY.search(body):+ for f in flags:+ out.setdefault(f, []).append(selector[:120])+ walk(j, flags)+ i, text = k, ""+ continue+ if c == "}":+ return i + 1+ text += c+ i += 1+ return i++ walk(0, set())+ return out+++def css_root_flags() -> dict[str, list[str]]:+ out: dict[str, list[str]] = {}+ for f in sorted(SRC.rglob("*.css")):+ for flag, sels in root_flags(f.read_text(encoding = "utf-8")).items():+ out.setdefault(flag, []).extend(f"{f.relative_to(SRC)}: {s}" for s in sels)+ return out+++def uncovered(mode_names: set[str]) -> list[str]:+ """Problems, one sentence each telling the author what to add; empty when covered."""+ problems = []+ custom = CUSTOM_TS.read_text(encoding = "utf-8")+ for key in object_keys(custom, "DEFAULT_CUSTOMIZATION"):+ if key not in CUSTOM_MEASURED and key not in CUSTOM_ALLOW:+ problems.append(+ f"appearance setting {key!r} (DEFAULT_CUSTOMIZATION) is not measured by the long-chat gate: "+ f"add its costliest value to CUSTOM_MEASURED (and its root flag to CUSTOM_EXPECT), or list it in "+ f"CUSTOM_ALLOW with why it cannot slow an area down (tests/studio/_appearance_coverage.py)"+ )+ defaults = dict(+ re.findall(+ r'^\s*(\w+):\s*"([^"]+)"', custom.split("DEFAULT_CUSTOMIZATION", 1)[1][:3000], re.M+ )+ )+ for key, values in enum_settings(custom).items():+ for v in values:+ if v == defaults.get(key) or CUSTOM_MEASURED.get(key) == v or (key, v) in ENUM_ALLOW:+ continue+ problems.append(+ f"appearance setting {key}={v!r} is not measured: set it in CUSTOM_MEASURED or list "+ f"({key!r}, {v!r}) in ENUM_ALLOW with a reason (tests/studio/_appearance_coverage.py)"+ )+ material = MATERIAL_TS.read_text(encoding = "utf-8")+ part = re.search(r"partialize:\s*\(s\)\s*=>\s*\(\{(.*?)\}\)", material, re.S)+ for key in re.findall(r"(\w+)\s*:", part.group(1) if part else ""):+ target = MATERIAL_KEYS.get(key)+ if target is None:+ problems.append(+ f"persisted Glass setting {key!r} (useMaterialStore) is not measured: add a mode for its costliest "+ f"value in _area_matrix.modes and map it in MATERIAL_KEYS, or map it to 'allow: <reason>'"+ )+ elif "+" in target and target not in mode_names:+ problems.append(+ f"MATERIAL_KEYS maps {key!r} to mode {target!r}, which the gate does not run"+ )+ model = MODEL_TS.read_text(encoding = "utf-8")+ for key in object_keys(model, "DEFAULT_ADJUSTMENTS"):+ if key not in WALLPAPER_MEASURED and key not in WALLPAPER_ALLOW:+ problems.append(+ f"chat wallpaper setting {key!r} (DEFAULT_ADJUSTMENTS) is not measured: add its costliest value "+ f"to WALLPAPER_MEASURED or list it in WALLPAPER_ALLOW with a reason (tests/studio/_appearance_coverage.py)"+ )+ ids, shared = palettes()+ for p in ids:+ if p not in shared:+ problems.append(+ f"palette {p!r} is not in the shared palette rule of index.css that solid+palette measures: "+ f"add it there, or measure it as its own mode"+ )+ for flag, where in sorted(css_root_flags().items()):+ target = ROOT_FLAGS.get(flag)+ if target is None:+ problems.append(+ f"<html> flag {flag!r} switches on costly CSS ({where[0]}) but no gate mode measures it: map it in "+ f"ROOT_FLAGS to the mode that sets it (add one in _area_matrix.modes if none does), or to "+ f"'allow: <reason>' (tests/studio/_appearance_coverage.py)"+ )+ elif not target.startswith("allow:") and target not in mode_names:+ problems.append(+ f"ROOT_FLAGS maps {flag!r} to mode {target!r}, which the gate does not run"+ )+ return problemsdiff --git a/tests/studio/_area_matrix.py b/tests/studio/_area_matrix.pyindex 4802ccc8e46..6e486062a4e 100644--- a/tests/studio/_area_matrix.py+++ b/tests/studio/_area_matrix.py@@ -41,11 +41,14 @@ import reimport threadingimport timefrom pathlib import Path++import _appearance_coverage as covfrom urllib.parse import urlparseREPO = Path(__file__).resolve().parents[2]SRC = REPO / "studio" / "frontend" / "src"MODEL_TS = SRC / "features" / "chat-background" / "model.ts"+CUSTOM_TS = SRC / "features" / "settings" / "stores" / "appearance-custom-store.ts"SHORTCUTS_TS = SRC / "features" / "settings" / "lib" / "keyboard-shortcuts.ts"SETTINGS_STORE_TS = SRC / "features" / "settings" / "stores" / "settings-dialog-store.ts"@@ -124,6 +127,40 @@ def modes(materials: list[str], lens_modes: list[str]) -> list[dict]:out.append({"name": f"{GLASS}+menus-off", "base": GLASS, "set": {**on_glass, "menus": False}})out.append({"name": "solid+dark", "base": "default", "set": {**DEFAULT, "theme": "dark"}})out.append({"name": f"{GLASS}+dark", "base": GLASS, "set": {**on_glass, "theme": "dark"}})+ # Costliest value of every other appearance setting (_appearance_coverage.py keeps this complete).+ for name, base, setting in (("solid", "default", DEFAULT), (GLASS, GLASS, on_glass)):+ out.append(+ {+ "name": f"{name}+custom",+ "base": base,+ "set": {**setting, "custom": dict(cov.CUSTOM_MEASURED)},+ "expect": cov.CUSTOM_EXPECT,+ }+ )+ out.append(+ {+ "name": f"{name}+wallpaper",+ "base": base,+ "set": {**setting, "wallpaper": dict(cov.WALLPAPER_MEASURED)},+ "expect": cov.WALLPAPER_EXPECT,+ }+ )+ out.append(+ {+ "name": "solid+palette",+ "base": "default",+ "set": {**DEFAULT, "palette": cov.PALETTE_MEASURED},+ "expect": [f"data-palette={cov.PALETTE_MEASURED}"],+ }+ )+ out.append(+ {+ "name": f"{GLASS}+strength-max",+ "base": GLASS,+ "set": {**on_glass, "strength": {"light": 100, "dark": 100}},+ "expect": ["--glass-strength=2.000"],+ }+ )return out@@ -888,9 +925,54 @@ def material_storage(mode: dict) -> str:"lens": mode["lens"],"scope": "all",}+ if mode.get("strength"):+ state["strength"] = mode["strength"]return json.dumps({"state": state, "version": 0})+def custom_storage(custom: dict) -> str:+ """unsloth_appearance_customization at the store's current version, so no migration rewrites it."""+ version = int(+ re.search(+ r'name: "unsloth_appearance_customization",\s*version: (\d+)',+ CUSTOM_TS.read_text(encoding = "utf-8"),+ ).group(1)+ )+ return json.dumps({"state": {"customization": custom}, "version": version})+++# Seeds a wallpaper into the app's chat-background database; a reload then hydrates it like an upload.+SEED_WALLPAPER = """async (adjust) => {+ const dbs = await indexedDB.databases();+ const hit = dbs.find((d) => d.name && d.name.startsWith('unsloth-chat-background'));+ if (!hit) return 'no chat-background database';+ const canvas = new OffscreenCanvas(1600, 1000);+ const ctx = canvas.getContext('2d');+ const g = ctx.createLinearGradient(0, 0, 1600, 1000);+ g.addColorStop(0, '#3b6fd8'); g.addColorStop(0.5, '#e7a34b'); g.addColorStop(1, '#2a9d6f');+ ctx.fillStyle = g; ctx.fillRect(0, 0, 1600, 1000);+ for (let i = 0; i < 400; i++) {+ ctx.fillStyle = `hsla(${(i * 37) % 360}, 70%, ${30 + (i % 50)}%, 0.5)`;+ ctx.beginPath(); ctx.arc((i * 97) % 1600, (i * 61) % 1000, 10 + (i % 60), 0, 7); ctx.fill();+ }+ const blob = await canvas.convertToBlob({ type: 'image/png' });+ const db = await new Promise((ok, no) => { const r = indexedDB.open(hit.name); r.onsuccess = () => ok(r.result); r.onerror = () => no(r.error); });+ await new Promise((ok, no) => {+ const tx = db.transaction('backgrounds', 'readwrite');+ tx.objectStore('backgrounds').put({ id: 'current', value: { ...adjust, blob }, sha256: null });+ tx.oncomplete = ok; tx.onerror = () => no(tx.error);+ });+ db.close();+ return 'ok';+}"""+ROOT_STATE = """() => { const r = document.documentElement; const out = {};+ for (const a of r.getAttributeNames()) out[a + (a === 'class' ? '' : '=' + r.getAttribute(a))] = 1;+ for (const c of r.classList) out[c] = 1;+ for (const a of r.getAttributeNames()) out[a] = 1;+ const v = r.style.getPropertyValue('--glass-strength').trim(); if (v) out['--glass-strength=' + v] = 1;+ return Object.keys(out); }"""++class Page:"""One app page at one chat length and one appearance mode."""@@ -905,6 +987,10 @@ class Page:"unsloth_window_material": material_storage(mode["set"]),"theme": mode["set"]["theme"],}+ if mode["set"].get("custom"):+ init["unsloth_appearance_customization"] = custom_storage(mode["set"]["custom"])+ if mode["set"].get("palette"):+ init["palette"] = mode["set"]["palette"]self.ctx.add_init_script("(() => { const v = %s; for (const k in v) localStorage.setItem(k, v[k]); })()"% json.dumps(init)@@ -920,12 +1006,53 @@ class Page:self.attr_before = Noneself.focusins_before = 0page.on("pageerror", lambda e: self.errors.append(str(e)[:200]))- page.goto(f"{base}/chat?thread={self.api.rec['id']}", wait_until = "load", timeout = 120_000)- page.wait_for_function(- "(n) => document.querySelectorAll('[data-role]').length >= n",- arg = 2 * turns,- timeout = 120_000,- )++ def load():+ page.goto(+ f"{base}/chat?thread={self.api.rec['id']}", wait_until = "load", timeout = 120_000+ )+ page.wait_for_function(+ "(n) => document.querySelectorAll('[data-role]').length >= n",+ arg = 2 * turns,+ timeout = 120_000,+ )++ load()+ if mode["set"].get("wallpaper"):+ seeded = page.evaluate(SEED_WALLPAPER, mode["set"]["wallpaper"])+ if seeded != "ok":+ raise RuntimeError(f"wallpaper not seeded: {seeded}")+ load()+ if mode["set"]["wallpaper"].get("blur"):+ # Fail if the bake (artwork.tsx) never replaces the live, per-frame blur.+ try:+ page.wait_for_function(+ "() => { const a = [...document.querySelectorAll('.chat-wallpaper-artwork')]"+ ".filter((e) => !e.classList.contains('glass-backdrop'));"+ " return a.length > 0 && a.every((e) => e.hasAttribute('data-baked') && !e.style.filter); }",+ timeout = 15_000,+ )+ except Exception as exc: # noqa: BLE001+ raise RuntimeError(+ f"mode {mode['name']}: the blurred wallpaper never baked (live filter still on the artwork)"+ ) from exc+ if mode.get("expect"):+ # A setting that did not reach the page would measure the default look and pass silently.+ want = list(mode["expect"])+ try:+ page.wait_for_function(+ "(want) => { const r = document.documentElement;"+ " return want.every((w) => w.startsWith('--') ? r.style.getPropertyValue(w.split('=')[0]).trim() === w.split('=')[1]"+ " : w.includes('=') ? r.getAttribute(w.split('=')[0]) === w.split('=')[1]"+ " : r.hasAttribute(w) || r.classList.contains(w)); }",+ arg = want,+ timeout = 30_000,+ )+ except Exception as exc: # noqa: BLE001+ have = page.evaluate(ROOT_STATE)+ raise RuntimeError(+ f"mode {mode['name']} did not apply: want {want}, <html> has {sorted(have)}"+ ) from excpage.evaluate(PROBE)page.wait_for_timeout(600)self.mac = page.evaluate(diff --git a/tests/studio/test_appearance_coverage.py b/tests/studio/test_appearance_coverage.pynew file mode 100644index 00000000000..8a2209cd774--- /dev/null+++ b/tests/studio/test_appearance_coverage.py@@ -0,0 +1,75 @@+# SPDX-License-Identifier: AGPL-3.0-only+# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0+"""Every appearance setting is measured by the long-chat gate or allowlisted with a reason (no browser)."""++import sys+from pathlib import Path++sys.path.insert(0, str(Path(__file__).resolve().parent))++import _appearance_coverage as cov # noqa: E402+import _area_matrix as am # noqa: E402++MODES = {m["name"] for m in am.app_modes()}+++def test_every_appearance_setting_is_measured_or_allowlisted():+ problems = cov.uncovered(MODES)+ assert not problems, "\n".join(problems)+++def test_the_enumeration_reads_the_real_stores():+ custom = cov.CUSTOM_TS.read_text(encoding = "utf-8")+ keys = cov.object_keys(custom, "DEFAULT_CUSTOMIZATION")+ assert {"contrast", "elementOutline", "reduceMotion", "chatWidth"} <= set(keys)+ assert set(cov.enum_settings(custom)["chatWidth"]) == {"standard", "wide", "full"}+ assert {"blur", "effect", "scope"} <= set(+ cov.object_keys(cov.MODEL_TS.read_text(encoding = "utf-8"), "DEFAULT_ADJUSTMENTS")+ )+ flags = cov.css_root_flags()+ assert "data-glass" in flags and "data-chat-wallpaper-workspace-ready" in flags+ ids, shared = cov.palettes()+ assert cov.PALETTE_MEASURED in ids and len(shared) >= 10+++def test_each_measured_setting_is_a_gate_mode_with_an_applied_check():+ by_name = {m["name"]: m for m in am.app_modes()}+ for name in (+ "solid+custom",+ f"{am.GLASS}+custom",+ "solid+wallpaper",+ f"{am.GLASS}+wallpaper",+ "solid+palette",+ f"{am.GLASS}+strength-max",+ ):+ mode = by_name[name]+ assert am.is_variant(mode), name+ assert mode.get("expect"), f"{name} must check that its setting reached <html>"+ assert by_name[mode["base"]]["base"] in (None, "default")+++def test_a_new_costly_root_flag_or_setting_fails(monkeypatch):+ css = "html[data-new-sparkle] .thread { backdrop-filter: blur(30px); }\nhtml[data-quiet] { color: red; }"+ flags = cov.root_flags(css)+ assert "data-new-sparkle" in flags and "data-quiet" not in flags+ nested = "html[data-glow] { .x { & .y { filter: blur(2px); } } }"+ assert "data-glow" in cov.root_flags(nested)+ monkeypatch.setattr(+ cov,+ "css_root_flags",+ lambda: {"data-new-sparkle": ["index.css: html[data-new-sparkle] .thread"]},+ )+ assert any("data-new-sparkle" in p for p in cov.uncovered(MODES))+ monkeypatch.setattr(+ cov, "CUSTOM_ALLOW", {k: v for k, v in cov.CUSTOM_ALLOW.items() if k != "colors"}+ )+ assert any("'colors'" in p for p in cov.uncovered(MODES))+++def test_new_modes_run_only_at_the_short_length_on_the_variant_areas():+ jobs = am.plan(am.app_modes(), long_modes = f"default,{am.GLASS}", full = False)+ long_names = {m["name"] for turns, m, _ in jobs if turns == am.LONG}+ assert long_names == {"default", am.GLASS}+ for turns, m, areas in jobs:+ if m["name"].endswith(("+custom", "+wallpaper", "+palette", "+strength-max")):+ assert turns == am.SHORT and set(areas) <= set(am.with_deps(am.VARIANT_AREAS))