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.

Follow #11648's UI-scale layout and #11628's Code placement in the studio contracts (#11673)

Daniel Hana4faad030da2
diff --git a/tests/studio/playwright_chat_ui.py b/tests/studio/playwright_chat_ui.py
index 2a71fe980ac..7778cfbd3aa 100644
--- a/tests/studio/playwright_chat_ui.py
+++ b/tests/studio/playwright_chat_ui.py
@@ -1590,9 +1590,11 @@ with sync_playwright() as p:
return {
// The scale the size tokens are multiplied by: index.css sets the 15px
// product default, and the appearance store overrides it inline as
- // preference / 16 for any other size.
- uiFontScale: getComputedStyle(root)
- .getPropertyValue('--ui-font-scale').trim(),
+ // preference / 16 for any other size. Resolved through a length rather
+ // than read as a property: since #11648 it is a calc() of the size and
+ // interface scales, and an unregistered custom property reads back as
+ // that expression, not a number.
+ uiFontScale: (() => { const probe = document.createElement('div'); probe.style.cssText = 'position:absolute;visibility:hidden;width:calc(10000px * var(--ui-font-scale, 1))'; document.body.appendChild(probe); const px = parseFloat(getComputedStyle(probe).width); probe.remove(); return String(px / 10000); })(),
actualRenderLinux: root.classList.contains('render-linux'),
isDesktopLinux: ua.includes('linux') && !ua.includes('android'),
isDark: root.classList.contains('dark'),
diff --git a/tests/studio/playwright_update_banner_layout.py b/tests/studio/playwright_update_banner_layout.py
index 95b125722e6..7e916579b0f 100644
--- a/tests/studio/playwright_update_banner_layout.py
+++ b/tests/studio/playwright_update_banner_layout.py
@@ -364,6 +364,8 @@ FONT_SCALE_VIEWPORTS = [(921, 534), (390, 500), (320, 480)]
UI_FONT_SIZE_MAX = 20
UI_FONT_SIZE_DEFAULT = 15
UI_FONT_SIZE_CSS_BASE = 16
+# --ui-font-scale as a number, read through a length since the property itself is a calc().
+UI_FONT_SCALE_JS = "(() => { const probe = document.createElement('div'); probe.style.cssText = 'position:absolute;visibility:hidden;width:calc(10000px * var(--ui-font-scale, 1))'; document.body.appendChild(probe); const px = parseFloat(getComputedStyle(probe).width); probe.remove(); return String(px / 10000); })()"
APPEARANCE_STORE_VERSION = 5
failures: list[str] = []
@@ -1281,14 +1283,14 @@ def main() -> int:
context.route(pattern, stub(payload))
page = context.new_page()
boot(page, "/")
- scale = page.evaluate(
- "() => getComputedStyle(document.documentElement)"
- ".getPropertyValue('--ui-font-scale').trim()"
- )
+ # Resolved through a length: since #11648 --ui-font-scale is a calc() of the size and interface
+ # scales, which reads back as that expression, so comparing the raw string to the default always
+ # said "scaled" and this check could not fail.
+ scale = float(page.evaluate("() => " + UI_FONT_SCALE_JS))
check(
f"{width}x{height} at {UI_FONT_SIZE_MAX}px: the type is actually scaled",
- scale not in ("", str(UI_FONT_SIZE_DEFAULT / UI_FONT_SIZE_CSS_BASE)),
- f"--ui-font-scale={scale!r}, so the rest of this pass proves nothing",
+ abs(scale - UI_FONT_SIZE_DEFAULT / UI_FONT_SIZE_CSS_BASE) > 1e-3,
+ f"--ui-font-scale resolved to {scale!r}, the default, so the rest of this pass proves nothing",
)
measure(page, f"{width}x{height} at {UI_FONT_SIZE_MAX}px")
page.screenshot(path = str(ART / f"{width}x{height}-font{UI_FONT_SIZE_MAX}.png"))
diff --git a/tests/studio/test_chat_response_details_ui_contract.py b/tests/studio/test_chat_response_details_ui_contract.py
index c3b89b2e4b3..63c4a68fb3d 100644
--- a/tests/studio/test_chat_response_details_ui_contract.py
+++ b/tests/studio/test_chat_response_details_ui_contract.py
@@ -713,7 +713,6 @@ def test_response_details_metadata_is_persisted_without_backend_schema_change():
assert "responseDetails: buildResponseDetails(finishedAt)" in src
assert "toolCalls: Array.from(" in src
assert "!isExternalRequest && supportsTools && toolsEnabled" in src
- assert "!isExternalRequest && supportsTools && codeToolsEnabled" in src
assert re.search(r"selectedModelSummary\?\.name\s*\|\|\s*responseModelId", src)
assert "providerName" in src
assert "cancelId" in src
@@ -723,6 +722,14 @@ def test_response_details_metadata_is_persisted_without_backend_schema_change():
builder_block = src[
src.find("const buildResponseDetails") : src.find("const externalCapabilities")
]
+ # #11628: Code is recorded from the placement the request actually sends, a hosted sandbox or Studio's local
+ # python/terminal/edit_file, so an external connection without a sandbox still reports Code when it runs locally.
+ # Read inside the builder: the request payload further down tests studioLocalCodeTools too.
+ assert re.search(
+ r"code:\s*hostedCodeToolsForThisTurn\.length > 0\s*\|\|\s*"
+ r"\(\s*supportsStudioToolsForThisTurn\s*&&\s*studioLocalCodeTools\.length > 0\s*\)",
+ builder_block,
+ ), "Response details no longer record Code from the hosted sandbox or Studio's local tools"
for forbidden in [
"encrypted_api_key",
"externalApiKey",
diff --git a/tests/studio/test_chat_thinking_compact_layout.py b/tests/studio/test_chat_thinking_compact_layout.py
index a44be880272..44b8609b5cc 100644
--- a/tests/studio/test_chat_thinking_compact_layout.py
+++ b/tests/studio/test_chat_thinking_compact_layout.py
@@ -13,7 +13,11 @@ def test_thinking_control_has_compact_hooks_in_both_composers():
for path in (THREAD_TSX, SHARED_TSX):
source = path.read_text(encoding = "utf-8")
assert 'className="unsloth-thinking-label"' in source
- assert "unsloth-thinking-caret size-[15px]" in source
+ # 15px at the default UI scale, wrapped in the space scale since #11648 so it grows with the
+ # rest of the composer. A bare 15px would stay put while the controls around it scale.
+ assert (
+ "unsloth-thinking-caret size-[calc(15px*var(--ui-space-scale,1))]" in source
+ ), f"{path.name}: the Thinking caret lost its hook or its scaled 15px size"
assert 'data-pill-label="Thinking settings"' in source
diff --git a/tests/studio/test_desktop_reliability_frontend_contract.py b/tests/studio/test_desktop_reliability_frontend_contract.py
index c7794a75040..4ba65944934 100644
--- a/tests/studio/test_desktop_reliability_frontend_contract.py
+++ b/tests/studio/test_desktop_reliability_frontend_contract.py
@@ -1054,6 +1054,12 @@ def _at_default_scale(source: str) -> str:
return _SCALED_AMOUNT.sub(lambda m: _resolve_amount(resolved, m), resolved)
+# The Create rail on Images and Audio at the default UI scale, as `_ui_source` reads it.
+RAIL_WIDTH = "@[50rem]:w-[min(408px,calc(100%-13rem))]"
+# The same class as written: `_ui_source` reads a bare 408px identically, so the scale is pinned raw.
+RAIL_WIDTH_SCALED = "@[50rem]:w-[min(calc(408px*var(--ui-space-scale,1)),calc(100%-13rem))]"
+
+
def _ui_source(path) -> str:
"""A checked-in source, read at the default UI scale.
@@ -2359,7 +2365,10 @@ def test_image_page_structural_panes_share_the_container_breakpoint():
assert "@container" in shell
assert "@[50rem]:flex-row @[50rem]:overflow-hidden" in section
- assert "@[50rem]:w-[408px]" in section
+ # 408px at the default scale, clamped since #11648 so the canvas keeps the 13rem its header column
+ # reserves (`minmax(13rem,1fr)`) when the scaled rail would otherwise eat it.
+ assert RAIL_WIDTH in section
+ assert RAIL_WIDTH_SCALED in IMAGES_PAGE.read_text(encoding = "utf-8"), "the rail stopped scaling"
assert "md:flex-row" not in section
# pb-6, not the old pb-20: the action is an in-flow footer now, so the rail no longer
# reserves 80px for an overlay to sit in. The crossfade into that footer is the
@@ -2396,7 +2405,8 @@ def test_audio_page_matches_the_image_rail_header_and_action_footer():
assert "absolute" not in header.split("<PillTabs", 1)[0]
assert "@[50rem]:flex-row @[50rem]:overflow-hidden" in layout
- assert "@[50rem]:w-[408px]" in layout
+ assert RAIL_WIDTH in layout
+ assert RAIL_WIDTH_SCALED in AUDIO_PAGE.read_text(encoding = "utf-8"), "the rail stopped scaling"
assert "@[50rem]:border-r @[50rem]:border-b-0" in layout
assert "gap-4 px-10 pt-9 pb-6 @[50rem]:overflow-y-auto" in layout
assert 'mode === "speak"' in layout
diff --git a/tests/studio/test_settings_compact_overflow_contract.py b/tests/studio/test_settings_compact_overflow_contract.py
index ce0dda426da..7d147b31622 100644
--- a/tests/studio/test_settings_compact_overflow_contract.py
+++ b/tests/studio/test_settings_compact_overflow_contract.py
@@ -15,7 +15,16 @@ SETTINGS = REPO / "studio/frontend/src/features/settings"
def test_dialog_content_can_shrink_inside_the_dialog_grid():
source = SETTINGS_DIALOG.read_text(encoding = "utf-8")
- assert "flex h-full min-h-0 min-w-0 w-full max-sm:flex-col" in source
+ assert "flex h-full min-h-0 min-w-0 w-full" in source
+ # Stacks on the dialog's measured width (`data-stacked`), not a viewport breakpoint: #11648 made the
+ # interface scale work in the browser, and `max-sm:` reads the viewport, which a larger UI does not change.
+ # Tailwind's data variant reads the attribute on the element carrying the class, so both sit in one tag.
+ at = source.index("min-w-0 w-full data-stacked:flex-col")
+ tag = source[source.rindex("<div", 0, at) : source.index(">", at)]
+ assert (
+ "data-stacked={stacked || undefined}" in tag
+ ), "the stacking attribute left the flex container"
+ assert "group/settings" in tag, "the stacked children read group/settings off this container"
assert "relative flex min-h-0 min-w-0 flex-1 flex-col" in source
diff --git a/tests/studio/test_ui_font_scale_contract.py b/tests/studio/test_ui_font_scale_contract.py
index eeb654571f8..b24cb650f15 100644
--- a/tests/studio/test_ui_font_scale_contract.py
+++ b/tests/studio/test_ui_font_scale_contract.py
@@ -71,7 +71,16 @@ def test_css_default_scale_matches_the_store_default():
assert "effectiveUiFontSize !== UI_FONT_SIZE_RANGE.default" in STORE
assert "effectiveUiFontSize / UI_FONT_SIZE_CSS_BASE" in STORE
scale = int(rng.group(3)) / int(base.group(1))
- assert f"--ui-font-scale: {scale:g};" in INDEX_CSS
+ # Since #11648 the store writes --ui-font-size-scale and index.css derives --ui-font-scale from it and the
+ # browser-only interface scale, so the default lives in the fallback of that derivation.
+ assert (
+ f"--ui-font-scale: calc(var(--ui-font-size-scale, {scale:g}) * var(--ui-interface-scale, 1));"
+ ) in INDEX_CSS
+ # One setter call: the default branch's `setVar("--ui-font-size-scale", null)` must not stand in for it.
+ assert re.search(
+ r'setVar\(\s*"--ui-font-size-scale",\s*String\(effectiveUiFontSize / UI_FONT_SIZE_CSS_BASE\),?\s*\)',
+ STORE,
+ ), "a custom font size no longer writes --ui-font-size-scale"
def test_named_text_tokens_scale():
@@ -127,16 +136,12 @@ def test_cn_knows_the_ui_typography_tokens():
def test_icons_follow_the_ui_font_size_itself():
"""Standard glyphs render at --ui-icon-size, which follows the UI font
- size itself: matches it below the 16px CSS scale base and grows at half the
- change above it (setting 20 gives 18px icons), so icons track the text
- when shrinking and read slightly smaller than it when growing. Sub 16px
- glyphs keep their proportions through the same curve as a factor.
- Sonner toast text and action labels are text, so they follow at full
- rate everywhere."""
- assert (
- "--ui-icon-size: min(calc(1rem * var(--ui-font-scale, 1)), "
- "calc(0.5rem + 0.5rem * var(--ui-font-scale, 1)));"
- ) in INDEX_CSS
+ size itself. Since #11648 icons scale linearly with --ui-font-scale, the
+ same factor as the text (setting 20 gives 20px icons), where they used to
+ grow at half the rate above the 16px base. Sub 16px and oversized glyphs
+ keep their proportions through the same factor. Sonner toast text and
+ action labels are text, so they follow at full rate everywhere."""
+ assert "--ui-icon-size: calc(1rem * var(--ui-font-scale, 1));" in INDEX_CSS
assert "--icon-size: var(--ui-icon-size);" in INDEX_CSS
assert "& svg.size-4 { width: var(--ui-icon-size); height: var(--ui-icon-size); }" in INDEX_CSS
assert "font-size: calc(13px * var(--ui-font-scale, 1)) !important;" in INDEX_CSS
@@ -145,7 +150,7 @@ def test_icons_follow_the_ui_font_size_itself():
assert "width: var(--ui-icon-size) !important;" in INDEX_CSS
assert "svg:not(.unsloth-tick) {" in INDEX_CSS
# Oversized art glyphs stay proportional instead of uniform.
- assert "& svg.size-6 { width: min(calc(1.5rem" in INDEX_CSS
+ assert "& svg.size-6 { width: calc(1.5rem * var(--ui-font-scale, 1));" in INDEX_CSS
for scope in (
"[data-slot='dropdown-menu-content']",
"[data-slot='select-content']",
diff --git a/tests/studio/test_update_release_notes.py b/tests/studio/test_update_release_notes.py
index 10aa3438c94..295bb4bc7c5 100644
--- a/tests/studio/test_update_release_notes.py
+++ b/tests/studio/test_update_release_notes.py
@@ -1005,15 +1005,36 @@ def test_preview_highlights_the_leading_sentence():
assert "item.rest" in panel
+def _max_widths(source: str) -> set[str]:
+ """Every `max-w-[...]` in *source*, read at the default UI scale.
+
+ #11648 wrapped these lengths in `calc(Npx*var(--ui-space-scale,1))` so they follow the interface size, which is
+ Npx at the default scale. Read back that way, the contract stays about the width rather than its spelling.
+ """
+ return {_SCALED_PX.sub(r"\1", width) for width in re.findall(r"max-w-\[([^\]\s\"]+)\]", source)}
+
+
+_SCALED_PX = re.compile(r"calc\((\d+(?:\.\d+)?px)\*var\(--ui-space-scale,1\)\)")
+# The notes width as written: `_max_widths` reads a bare 448px identically, so the scale is pinned raw.
+_NOTES_WIDTH_SCALED = "max-w-[calc(448px*var(--ui-space-scale,1))]"
+
+
@pytest.mark.parametrize("banner", [WEB_BANNER, TAURI_BANNER])
def test_update_popups_share_the_notes_width(banner):
"""Every update popup uses the same width for its notes and action rows."""
- assert "max-w-[448px]" in banner.read_text(encoding = "utf-8")
+ source = banner.read_text(encoding = "utf-8")
+ assert "448px" in _max_widths(source)
+ assert (
+ _NOTES_WIDTH_SCALED in source and "max-w-[448px]" not in source
+ ), "the notes width stopped scaling"
provider = (FRONTEND / "app/provider.tsx").read_text(encoding = "utf-8")
- assert "max-w-[400px]" not in provider, "stack must not cap overlay width"
+ assert "400px" not in _max_widths(provider), "stack must not cap overlay width"
llama = (FRONTEND / "components/llama-update-banner.tsx").read_text(encoding = "utf-8")
- assert "max-w-[448px]" in llama
- assert "max-w-[400px]" not in llama
+ assert "448px" in _max_widths(llama)
+ assert (
+ _NOTES_WIDTH_SCALED in llama and "max-w-[448px]" not in llama
+ ), "the notes width stopped scaling"
+ assert "400px" not in _max_widths(llama)
@pytest.mark.parametrize("banner", [WEB_BANNER, TAURI_BANNER])