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: register text-ui tokens with tailwind-merge so cn() keeps them (#7396)

Michael Han140b3fbe0573
diff --git a/studio/frontend/src/features/chat/chat-page.tsx b/studio/frontend/src/features/chat/chat-page.tsx
index c241607e28f..7452cf34477 100644
--- a/studio/frontend/src/features/chat/chat-page.tsx
+++ b/studio/frontend/src/features/chat/chat-page.tsx
@@ -2289,7 +2289,7 @@ export function ChatPage({
} else if (outcome === "conflict") {
toast.info("Resume this download from Models", {
description:
- "An earlier partial download used a different transport. Open the Models tab to resume or restart it.",
+ "An earlier partial download used a different transport. Open the Model hub tab to resume or restart it.",
});
} else if (outcome === "busy") {
toast.info("Download already in progress", {
@@ -2410,7 +2410,7 @@ export function ChatPage({
// surface's onComplete auto-loads, mirroring the "started" branch.
toast.info("Resume this download from Models", {
description:
- "An earlier partial download used a different transport. Open the Models tab to resume or restart it.",
+ "An earlier partial download used a different transport. Open the Model hub tab to resume or restart it.",
});
return;
}
diff --git a/studio/frontend/src/features/hub/catalog/models-header.tsx b/studio/frontend/src/features/hub/catalog/models-header.tsx
index f0e09508717..f844336d4a8 100644
--- a/studio/frontend/src/features/hub/catalog/models-header.tsx
+++ b/studio/frontend/src/features/hub/catalog/models-header.tsx
@@ -64,7 +64,7 @@ export function ModelsHeader({
return (
<header className="font-heading flex flex-col gap-3 sm:flex-row sm:flex-wrap sm:items-center sm:justify-between">
<PageHeading
- title={isDataset ? "Datasets" : "Models"}
+ title={isDataset ? "Datasets" : "Model hub"}
onTitleClick={onTitleClick}
subtitle={
isDataset
diff --git a/studio/frontend/src/i18n/locales/ar.ts b/studio/frontend/src/i18n/locales/ar.ts
index be641781df7..67029b7ad80 100644
--- a/studio/frontend/src/i18n/locales/ar.ts
+++ b/studio/frontend/src/i18n/locales/ar.ts
@@ -39,7 +39,7 @@ export const ar = {
returnToChat: "العودة إلى المحادثة",
compare: "مقارنة",
search: "بحث",
- hub: "النماذج",
+ hub: "مركز النماذج",
train: "تدريب",
recipes: "الوصفات",
export: "تصدير",
diff --git a/studio/frontend/src/i18n/locales/de.ts b/studio/frontend/src/i18n/locales/de.ts
index 42df1d5cd39..068563bfbad 100644
--- a/studio/frontend/src/i18n/locales/de.ts
+++ b/studio/frontend/src/i18n/locales/de.ts
@@ -39,7 +39,7 @@ export const de = {
returnToChat: "Zurück zum Chat",
compare: "Vergleichen",
search: "Suchen",
- hub: "Modelle",
+ hub: "Modell-Hub",
train: "Trainieren",
recipes: "Rezepte",
export: "Exportieren",
diff --git a/studio/frontend/src/i18n/locales/en.ts b/studio/frontend/src/i18n/locales/en.ts
index a0f9bfc1cd6..1c41cbdf38c 100644
--- a/studio/frontend/src/i18n/locales/en.ts
+++ b/studio/frontend/src/i18n/locales/en.ts
@@ -36,7 +36,7 @@ export const en = {
returnToChat: "Return to Chat",
compare: "Compare",
search: "Search",
- hub: "Models",
+ hub: "Model hub",
train: "Train",
recipes: "Recipes",
export: "Export",
diff --git a/studio/frontend/src/i18n/locales/es.ts b/studio/frontend/src/i18n/locales/es.ts
index dfbd98aca68..7494a154eb1 100644
--- a/studio/frontend/src/i18n/locales/es.ts
+++ b/studio/frontend/src/i18n/locales/es.ts
@@ -39,7 +39,7 @@ export const es = {
returnToChat: "Volver al chat",
compare: "Comparar",
search: "Buscar",
- hub: "Modelos",
+ hub: "Centro de modelos",
train: "Entrenar",
recipes: "Recetas",
export: "Exportar",
diff --git a/studio/frontend/src/i18n/locales/fr.ts b/studio/frontend/src/i18n/locales/fr.ts
index 59d01c7dae9..b2e5e87fe10 100644
--- a/studio/frontend/src/i18n/locales/fr.ts
+++ b/studio/frontend/src/i18n/locales/fr.ts
@@ -39,7 +39,7 @@ export const fr = {
returnToChat: "Retour à la discussion",
compare: "Comparer",
search: "Rechercher",
- hub: "Modèles",
+ hub: "Hub de modèles",
train: "Entraîner",
recipes: "Recettes",
export: "Exporter",
diff --git a/studio/frontend/src/i18n/locales/hi.ts b/studio/frontend/src/i18n/locales/hi.ts
index bb8cb70fea9..18e554802f3 100644
--- a/studio/frontend/src/i18n/locales/hi.ts
+++ b/studio/frontend/src/i18n/locales/hi.ts
@@ -39,7 +39,7 @@ export const hi = {
returnToChat: "चैट पर लौटें",
compare: "तुलना करें",
search: "खोजें",
- hub: "मॉडल",
+ hub: "मॉडल हब",
train: "ट्रेनिंग",
recipes: "रेसिपी",
export: "एक्सपोर्ट",
diff --git a/studio/frontend/src/i18n/locales/ja.ts b/studio/frontend/src/i18n/locales/ja.ts
index c0a8c627346..3a3f3017efb 100644
--- a/studio/frontend/src/i18n/locales/ja.ts
+++ b/studio/frontend/src/i18n/locales/ja.ts
@@ -40,7 +40,7 @@ export const ja = {
returnToChat: "チャットに戻る",
compare: "比較",
search: "検索",
- hub: "モデル",
+ hub: "モデルハブ",
train: "トレーニング",
recipes: "レシピ",
export: "エクスポート",
diff --git a/studio/frontend/src/i18n/locales/ko.ts b/studio/frontend/src/i18n/locales/ko.ts
index 16e27b50cdf..e9109784675 100644
--- a/studio/frontend/src/i18n/locales/ko.ts
+++ b/studio/frontend/src/i18n/locales/ko.ts
@@ -39,7 +39,7 @@ export const ko = {
returnToChat: "채팅으로 돌아가기",
compare: "비교",
search: "검색",
- hub: "모델",
+ hub: "모델 허브",
train: "학습",
recipes: "레시피",
export: "내보내기",
diff --git a/studio/frontend/src/i18n/locales/pt-br.ts b/studio/frontend/src/i18n/locales/pt-br.ts
index b46aea63217..2b43703f96e 100644
--- a/studio/frontend/src/i18n/locales/pt-br.ts
+++ b/studio/frontend/src/i18n/locales/pt-br.ts
@@ -39,7 +39,7 @@ export const ptBR = {
returnToChat: "Retornar ao Chat",
compare: "Comparar",
search: "Buscar",
- hub: "Modelos",
+ hub: "Hub de modelos",
train: "Treinar",
recipes: "Receitas",
export: "Exportar",
diff --git a/studio/frontend/src/i18n/locales/ru.ts b/studio/frontend/src/i18n/locales/ru.ts
index 1c0ac6f95ee..49c22f59e38 100644
--- a/studio/frontend/src/i18n/locales/ru.ts
+++ b/studio/frontend/src/i18n/locales/ru.ts
@@ -39,7 +39,7 @@ export const ru = {
returnToChat: "Вернуться к чату",
compare: "Сравнить",
search: "Поиск",
- hub: "Модели",
+ hub: "Хаб моделей",
train: "Обучение",
recipes: "Рецепты",
export: "Экспорт",
diff --git a/studio/frontend/src/i18n/locales/zh-CN.ts b/studio/frontend/src/i18n/locales/zh-CN.ts
index eb962cc8d4c..334e206ee73 100644
--- a/studio/frontend/src/i18n/locales/zh-CN.ts
+++ b/studio/frontend/src/i18n/locales/zh-CN.ts
@@ -39,7 +39,7 @@ export const zhCN = {
returnToChat: "返回聊天",
compare: "对比",
search: "搜索",
- hub: "模型",
+ hub: "模型中心",
train: "训练",
recipes: "配方",
export: "导出",
diff --git a/studio/frontend/src/lib/utils.ts b/studio/frontend/src/lib/utils.ts
index fcea359efda..7408fc4fe95 100644
--- a/studio/frontend/src/lib/utils.ts
+++ b/studio/frontend/src/lib/utils.ts
@@ -2,7 +2,21 @@
// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
import { type ClassValue, clsx } from "clsx";
-import { twMerge } from "tailwind-merge";
+import { extendTailwindMerge } from "tailwind-merge";
+
+// text-ui-* / leading-ui-* are the scaled typography tokens from index.css.
+// Register them as font-size / line-height so twMerge does not treat
+// text-ui-* as a text color and drop it when a color class follows.
+const isUiToken = (value: string) => /^ui-\d+(p5)?$/.test(value);
+
+const twMerge = extendTailwindMerge({
+ extend: {
+ classGroups: {
+ "font-size": [{ text: [isUiToken] }],
+ leading: [{ leading: [isUiToken] }],
+ },
+ },
+});
export function cn(...inputs: ClassValue[]): string {
return twMerge(clsx(inputs));
diff --git a/tests/studio/playwright_ui_font_scale.py b/tests/studio/playwright_ui_font_scale.py
index 89c7894929b..0f14c424221 100644
--- a/tests/studio/playwright_ui_font_scale.py
+++ b/tests/studio/playwright_ui_font_scale.py
@@ -193,6 +193,25 @@ def main():
page.set_viewport_size({"width": 1440, "height": 900})
page.wait_for_timeout(400)
+ step("cn keeps text-ui-* next to color classes (hub tabs)")
+ page.keyboard.press("Escape")
+ page.wait_for_timeout(400)
+ page.goto(f"{BASE}/hub", wait_until = "domcontentloaded")
+ page.wait_for_timeout(2000)
+ open_appearance(page)
+ set_input(page, "UI font size", 12)
+ page.keyboard.press("Escape")
+ page.wait_for_timeout(400)
+ tab = page.get_by_role("radio").filter(has_text = "Discover").first
+ tab.wait_for(state = "visible", timeout = 15000)
+ tab_font = tab.evaluate("el => parseFloat(getComputedStyle(el).fontSize)")
+ # text-ui-12p5 at scale 0.75; 16px means twMerge dropped the token.
+ if not near(tab_font, 12.5 * 12 / 16):
+ fail(f"hub tab font did not scale (twMerge drop?): {tab_font}")
+ page.goto(BASE, wait_until = "domcontentloaded")
+ page.wait_for_timeout(1500)
+ open_appearance(page)
+
step("default restores exactly")
page.get_by_role("dialog").get_by_role("button").filter(has_text = "Appearance").first.click()
page.wait_for_timeout(500)
diff --git a/tests/studio/test_ui_font_scale_contract.py b/tests/studio/test_ui_font_scale_contract.py
index 393c60dd6b6..1153eea6436 100644
--- a/tests/studio/test_ui_font_scale_contract.py
+++ b/tests/studio/test_ui_font_scale_contract.py
@@ -17,6 +17,7 @@ SRC = REPO / "studio/frontend/src"
INDEX_CSS = (SRC / "index.css").read_text(encoding = "utf-8")
STORE = (SRC / "features/settings/stores/appearance-custom-store.ts").read_text(encoding = "utf-8")
SELECT = (SRC / "components/ui/select.tsx").read_text(encoding = "utf-8")
+UTILS = (SRC / "lib/utils.ts").read_text(encoding = "utf-8")
# Raw numeric fontSize props are only allowed where a scaled stylesheet rule
# (.recharts-text) overrides the presentation attribute at render time.
@@ -87,6 +88,16 @@ def test_radix_select_viewport_owns_the_scroll_state():
assert "overflow-y-auto" not in content_cls.group(1)
+def test_cn_knows_the_ui_typography_tokens():
+ """Stock tailwind-merge classifies text-ui-* as a text color and deletes
+ it whenever a real color class follows in the same cn() call, so the
+ element falls back to the unscaled inherited font size."""
+ assert "extendTailwindMerge" in UTILS
+ assert '"font-size": [{ text: [isUiToken] }]' in UTILS
+ assert "leading: [{ leading: [isUiToken] }]" in UTILS
+ assert "/^ui-\\d+(p5)?$/.test(value)" in UTILS
+
+
def test_no_raw_pixel_text_utilities():
offenders = []
for path in _frontend_sources():