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: add configurable chat width (#10958)
Michael Hanf95ed7189ed1
diff --git a/studio/backend/routes/settings.py b/studio/backend/routes/settings.pyindex 47bb944ae13..c8ab526721a 100644--- a/studio/backend/routes/settings.py+++ b/studio/backend/routes/settings.py@@ -3406,6 +3406,7 @@ class PersonalizationCustomization(BaseModel):uiFontSize: Optional[int] = Field(None, ge = 12, le = 20)codeFontSize: Optional[int] = Field(None, ge = 10, le = 20)+ chatWidth: Literal["standard", "wide", "full"] = "standard"contrast: int = Field(50, ge = 0, le = 100)pointerCursors: bool = FalsereduceMotion: Literal["system", "on", "off"] = "system"@@ -3472,6 +3473,7 @@ class PersonalizationResponse(PersonalizationPayload):# False when the stored record predates a field, so the client keeps local# overrides instead of treating a server-filled default as an explicit value.customizationSaved: bool = False+ chatWidthSaved: bool = FalsepaletteSaved: bool = FalsegreetingSlothSaved: bool = False@@ -3484,8 +3486,10 @@ def get_personalization_settings(response = PersonalizationResponse.model_validate(stored or {})response.saved = bool(stored)appearance = stored.get("appearance") if isinstance(stored, dict) else None+ customization = appearance.get("customization") if isinstance(appearance, dict) else Noneprofile = stored.get("profile") if isinstance(stored, dict) else Noneresponse.customizationSaved = isinstance(appearance, dict) and "customization" in appearance+ response.chatWidthSaved = isinstance(customization, dict) and "chatWidth" in customizationresponse.paletteSaved = isinstance(appearance, dict) and "palette" in appearanceresponse.greetingSlothSaved = isinstance(profile, dict) and "showGreetingSloth" in profilereturn responsediff --git a/studio/backend/tests/test_personalization_settings.py b/studio/backend/tests/test_personalization_settings.pyindex f14ae177e8f..cd0c4271f16 100644--- a/studio/backend/tests/test_personalization_settings.py+++ b/studio/backend/tests/test_personalization_settings.py@@ -89,6 +89,7 @@ def test_customization_defaults():assert c.headingFont is Noneassert c.chatFont is Noneassert c.uiFontSize is None+ assert c.chatWidth == "standard"assert [(i.id, i.visible) for i in c.sidebarMenu] == [("api", True),("darkMode", True),@@ -102,6 +103,10 @@ def test_customization_defaults():def test_customization_invalid_values_rejected():+ with pytest.raises(ValidationError):+ PersonalizationPayload.model_validate(+ {"appearance": {"customization": {"chatWidth": "invalid"}}}+ )with pytest.raises(ValidationError):PersonalizationPayload.model_validate({"appearance": {"customization": {"colors": {"light": {"accent": "red"}}}}}@@ -447,6 +452,7 @@ def test_personalization_route_roundtrip_real_shape(monkeypatch):"uiFont": "SF Pro Text","headingFont": "Avenir Next","chatFont": "Georgia",+ "chatWidth": "full","codeFont": None,"importedFonts": [{"name": "SF Pro Text", "dataUrl": "data:font/woff2;base64,AAAA"}@@ -518,6 +524,55 @@ def test_personalization_get_flags_legacy_fields(monkeypatch):assert body["greetingSlothSaved"] is False+def test_personalization_legacy_chat_width_presence(monkeypatch):+ store = {+ pers.PERSONALIZATION_SETTING_KEY: {+ "appearance": {"customization": {"uiFont": "Georgia"}},+ }+ }+ client = _shared_setup_1(monkeypatch, store)+ body = client.get("/api/settings/personalization").json()+ assert body["customizationSaved"] is True+ assert body["chatWidthSaved"] is False+ assert body["appearance"]["customization"]["chatWidth"] == "standard"++ put = client.put(+ "/api/settings/personalization",+ json = {"appearance": {"customization": {"uiFont": "Arial"}}},+ )+ assert put.status_code == 200+ assert client.get("/api/settings/personalization").json()["chatWidthSaved"] is False+ assert "chatWidth" not in store[pers.PERSONALIZATION_SETTING_KEY]["appearance"]["customization"]++ put = client.put(+ "/api/settings/personalization",+ json = {"appearance": {"customization": {"chatWidth": "full"}}},+ )+ assert put.status_code == 200+ body = client.get("/api/settings/personalization").json()+ assert body["chatWidthSaved"] is True+ assert body["appearance"]["customization"]["chatWidth"] == "full"+ assert body["appearance"]["customization"]["uiFont"] == "Arial"++[email protected]("width", ["standard", "wide", "full"])+def test_personalization_saved_chat_width_survives_stale_write(monkeypatch, width):+ store = {+ pers.PERSONALIZATION_SETTING_KEY: {+ "appearance": {"customization": {"chatWidth": width}},+ }+ }+ client = _shared_setup_1(monkeypatch, store)+ put = client.put(+ "/api/settings/personalization",+ json = {"appearance": {"customization": {"uiFont": "Georgia"}}},+ )+ assert put.status_code == 200+ body = client.get("/api/settings/personalization").json()+ assert body["chatWidthSaved"] is True+ assert body["appearance"]["customization"]["chatWidth"] == width++def test_personalization_put_preserves_absent_fields(monkeypatch):# A stale client that omits palette/customization must not materialize them,# so the record stays legacy and GET keeps reporting those fields unsaved.diff --git a/studio/frontend/src/components/assistant-ui/thread.tsx b/studio/frontend/src/components/assistant-ui/thread.tsxindex 2084d833458..804e79fc564 100644--- a/studio/frontend/src/components/assistant-ui/thread.tsx+++ b/studio/frontend/src/components/assistant-ui/thread.tsx@@ -1868,7 +1868,7 @@ export const Thread: FC<{<ThreadPrimitive.RootclassName="aui-root aui-thread-root @container relative flex min-h-0 min-w-0 flex-1 basis-0 flex-col overflow-hidden"style={{- ["--thread-max-width" as string]: "48rem",+ ["--thread-max-width" as string]: "var(--custom-chat-max-width, 48rem)",["--thread-content-max-width" as string]:"calc(var(--thread-max-width) - 1.5rem)",}}@@ -2262,7 +2262,7 @@ const ThreadWelcome: FC<{<div className="aui-thread-welcome-root mx-auto my-auto flex w-full max-w-(--thread-max-width) grow flex-col"><div className="aui-thread-welcome-center flex w-full grow flex-col items-center justify-start pt-[27.5dvh]">{/* Matches the docked composer's gutter; index.css trims both. */}- <div className="aui-thread-welcome-message flex w-full flex-col justify-center gap-9 px-4">+ <div className="aui-thread-welcome-message flex w-full flex-col justify-center gap-9 px-[var(--custom-chat-welcome-padding,1rem)]">{/* Center the greeting (sloth + title) over the composer. */}<div className="unsloth-welcome-greeting flex flex-row items-center justify-center gap-[15px]">{/* Temporary chat keeps the title on its own, no mascot. */}@@ -2317,7 +2317,9 @@ const ComposerAnimated: FC<{// unsloth-composer-shell is the size container the tight (mobile) layout// in index.css queries. It sits outside the surface so those rules can// trim the surface's own padding.- <div className="unsloth-composer-shell relative mx-auto min-w-0 w-full max-w-[46rem]">+ // Its own width variable: every parent here is already capped by the width+ // setting, so re-reading that one would apply the cap twice.+ <div className="unsloth-composer-shell relative mx-auto min-w-0 w-full max-w-[var(--custom-chat-shell-max-width,46rem)]"><div className="relative z-10 w-full"><Composerdisabled={disabled}diff --git a/studio/frontend/src/features/chat/chat-page.tsx b/studio/frontend/src/features/chat/chat-page.tsxindex 9d791cc5efe..c2466dc5a48 100644--- a/studio/frontend/src/features/chat/chat-page.tsx+++ b/studio/frontend/src/features/chat/chat-page.tsx@@ -808,7 +808,7 @@ function CompareShell({{/* Symmetric: the extra right inset mirrored the viewport's one-sidedscrollbar gutter, which is now reserved on both edges. */}<div className="shrink-0 bg-background pl-5 pr-5 md:px-[30px] pb-2 pt-1">- <div className="mx-auto w-full max-w-[48rem]">{composer}</div>+ <div className="mx-auto w-full max-w-[var(--custom-chat-max-width,48rem)]">{composer}</div>{showModelDisclaimer && (<p className="composer-footer-note">LLMs can make mistakes. Double-check responses.diff --git a/studio/frontend/src/features/profile/hooks/use-personalization-sync.ts b/studio/frontend/src/features/profile/hooks/use-personalization-sync.tsindex 55ccfaf111d..ed781d0bc8c 100644--- a/studio/frontend/src/features/profile/hooks/use-personalization-sync.ts+++ b/studio/frontend/src/features/profile/hooks/use-personalization-sync.ts@@ -276,9 +276,17 @@ export function usePersonalizationSync(enabled: boolean): void {const keepLocalCustomization =remote.customizationSaved === false &&!isDefaultCustomization(localCustomization);+ const keepLocalChatWidth =+ remote.chatWidthSaved === false ||+ remote.appearance.customization?.chatWidth === undefined;const nextCustomization = keepLocalCustomization? localCustomization- : remoteCustomization;+ : keepLocalChatWidth+ ? {+ ...remoteCustomization,+ chatWidth: localCustomization.chatWidth,+ }+ : remoteCustomization;const remoteLanguage = remoteLanguagePreference(remote.version,remote.appearance.language,diff --git a/studio/frontend/src/features/settings/api/personalization.ts b/studio/frontend/src/features/settings/api/personalization.tsindex 7355b6fd0b9..81c53a5891f 100644--- a/studio/frontend/src/features/settings/api/personalization.ts+++ b/studio/frontend/src/features/settings/api/personalization.ts@@ -29,6 +29,7 @@ export type Personalization = {// False when the stored record predates these fields (legacy migration): the// client then keeps local values instead of the server-filled defaults.customizationSaved: boolean;+ chatWidthSaved?: boolean;paletteSaved: boolean;greetingSlothSaved: boolean;};@@ -46,7 +47,11 @@ export async function loadPersonalization(): Promise<Personalization> {export async function savePersonalization(data: Omit<Personalization,- "saved" | "customizationSaved" | "paletteSaved" | "greetingSlothSaved"+ | "saved"+ | "customizationSaved"+ | "chatWidthSaved"+ | "paletteSaved"+ | "greetingSlothSaved">,): Promise<void> {const res = await authFetch("/api/settings/personalization", {diff --git a/studio/frontend/src/features/settings/components/appearance-custom-controls.tsx b/studio/frontend/src/features/settings/components/appearance-custom-controls.tsxindex bb41b9b9a24..8e33e42f19a 100644--- a/studio/frontend/src/features/settings/components/appearance-custom-controls.tsx+++ b/studio/frontend/src/features/settings/components/appearance-custom-controls.tsx@@ -16,6 +16,13 @@ import {PopoverContent,PopoverTrigger,} from "@/components/ui/popover";+import {+ Select,+ SelectContent,+ SelectItem,+ SelectTrigger,+ SelectValue,+} from "@/components/ui/select";import { Slider } from "@/components/ui/slider";import { Switch } from "@/components/ui/switch";import { type TranslationKey, useT } from "@/i18n";@@ -881,6 +888,36 @@ export function FontSmoothingSwitch() {/* ------------------------------ Interface ------------------------------- */+export function ChatWidthSelect() {+ const t = useT();+ const chatWidth = useAppearanceCustomStore((s) => s.customization.chatWidth);+ const patch = useAppearanceCustomStore((s) => s.patch);+ return (+ <Select+ value={chatWidth}+ onValueChange={(value) => {+ if (value === "standard" || value === "wide" || value === "full") {+ patch({ chatWidth: value });+ }+ }}+ >+ <SelectTrigger+ className="w-40"+ aria-label={t("settings.appearance.custom.chatWidth.label")}+ >+ <SelectValue />+ </SelectTrigger>+ <SelectContent>+ {(["standard", "wide", "full"] as const).map((width) => (+ <SelectItem key={width} value={width}>+ {t(`settings.appearance.custom.chatWidth.${width}`)}+ </SelectItem>+ ))}+ </SelectContent>+ </Select>+ );+}+export function ContrastSliderRow() {const t = useT();const contrast = useAppearanceCustomStore((s) => s.customization.contrast);diff --git a/studio/frontend/src/features/settings/settings-search.ts b/studio/frontend/src/features/settings/settings-search.tsindex 998b6c8c2e2..7e2907b8d02 100644--- a/studio/frontend/src/features/settings/settings-search.ts+++ b/studio/frontend/src/features/settings/settings-search.ts@@ -60,6 +60,7 @@ export const SETTINGS_SEARCH_INDEX: Record<SettingsTab, TranslationKey[]> = {"settings.appearance.custom.uiFont.label","settings.appearance.custom.headingFont.label","settings.appearance.custom.chatFont.label",+ "settings.appearance.custom.chatWidth.label","settings.appearance.custom.codeFont.label","settings.appearance.custom.contrast.label","settings.appearance.custom.pointerCursors.label",diff --git a/studio/frontend/src/features/settings/stores/appearance-custom-store.ts b/studio/frontend/src/features/settings/stores/appearance-custom-store.tsindex ec44ea3a0ac..53a71aff023 100644--- a/studio/frontend/src/features/settings/stores/appearance-custom-store.ts+++ b/studio/frontend/src/features/settings/stores/appearance-custom-store.ts@@ -37,6 +37,7 @@ const guardedLocalStorage: StateStorage = {};export type ReduceMotionSetting = "system" | "on" | "off";+export type ChatWidthSetting = "standard" | "wide" | "full";export type CustomModeColors = {accent: string | null;@@ -195,6 +196,7 @@ export type AppearanceCustomization = {uiFont: string | null;headingFont: string | null;chatFont: string | null;+ chatWidth: ChatWidthSetting;codeFont: string | null;importedFonts: ImportedFont[];/** UI font size in px. null = app default (15). */@@ -224,6 +226,7 @@ export const DEFAULT_CUSTOMIZATION: AppearanceCustomization = {uiFont: null,headingFont: null,chatFont: null,+ chatWidth: "standard",codeFont: null,importedFonts: [],uiFontSize: null,@@ -385,6 +388,10 @@ export function sanitizeCustomization(value: unknown): AppearanceCustomization {uiFont: sanitizeFont(source.uiFont),headingFont: sanitizeFont(source.headingFont),chatFont: sanitizeFont(source.chatFont),+ chatWidth:+ source.chatWidth === "wide" || source.chatWidth === "full"+ ? source.chatWidth+ : "standard",codeFont: sanitizeFont(source.codeFont),importedFonts: sanitizeImportedFonts(source.importedFonts),uiFontSize: sanitizeSize(source.uiFontSize, UI_FONT_SIZE_RANGE),@@ -781,6 +788,25 @@ export function applyCustomizationToDocument(}setVar("--background", colors.background);setVar("--foreground", colors.foreground);+ // keep the full-width inset from making narrow panes smaller than wide.+ setVar(+ "--custom-chat-max-width",+ c.chatWidth === "full"+ ? "max(72rem, calc(100% - 6rem))"+ : c.chatWidth === "wide"+ ? "72rem"+ : null,+ );+ // The composer shell fills whatever its parent was capped to, so the cap is+ // never applied twice. Same result as before at every width.+ setVar(+ "--custom-chat-shell-max-width",+ c.chatWidth === "standard" ? null : "100%",+ );+ setVar(+ "--custom-chat-welcome-padding",+ c.chatWidth === "standard" ? null : "0px",+ );syncImportedFonts(c.importedFonts);diff --git a/studio/frontend/src/features/settings/tabs/appearance-tab.tsx b/studio/frontend/src/features/settings/tabs/appearance-tab.tsxindex c8fc01b382e..242bb9d358a 100644--- a/studio/frontend/src/features/settings/tabs/appearance-tab.tsx+++ b/studio/frontend/src/features/settings/tabs/appearance-tab.tsx@@ -9,6 +9,7 @@ import { isTauri } from "@/lib/api-base";import {ActiveColorControl,ChatFontRow,+ ChatWidthSelect,CodeFontRow,CodeFontSizeRow,ContrastSliderRow,@@ -82,6 +83,12 @@ export function AppearanceTab() {<InterfaceScaleRow /></SettingsRow>)}+ <SettingsRow+ label={t("settings.appearance.custom.chatWidth.label")}+ description={t("settings.appearance.custom.chatWidth.description")}+ >+ <ChatWidthSelect />+ </SettingsRow><SettingsRowlabel={t("settings.appearance.custom.pointerCursors.label")}description={t(diff --git a/studio/frontend/src/i18n/locales/ar.ts b/studio/frontend/src/i18n/locales/ar.tsindex 13b2d8cb1aa..48c9a0604e5 100644--- a/studio/frontend/src/i18n/locales/ar.ts+++ b/studio/frontend/src/i18n/locales/ar.ts@@ -1029,6 +1029,13 @@ export const ar = {minimal: "بسيطة",},custom: {+ chatWidth: {+ label: "عرض المحادثة",+ description: "حدّد عرض الرسائل وحقل الكتابة. يستخدم العرض الكامل المساحة بين الشريطين الجانبيين.",+ standard: "قياسي",+ wide: "واسع",+ full: "العرض الكامل",+ },reset: "إعادة تعيين",resetAll: "إعادة تعيين التخصيص",preferencesTitle: "التفضيلات",diff --git a/studio/frontend/src/i18n/locales/de.ts b/studio/frontend/src/i18n/locales/de.tsindex 65967021625..45354fc9aa6 100644--- a/studio/frontend/src/i18n/locales/de.ts+++ b/studio/frontend/src/i18n/locales/de.ts@@ -1053,6 +1053,13 @@ export const de = {minimal: "Minimal",},custom: {+ chatWidth: {+ label: "Chatbreite",+ description: "Breite von Nachrichten und Eingabefeld festlegen. Volle Breite nutzt den Platz zwischen den Seitenleisten.",+ standard: "Standard",+ wide: "Breit",+ full: "Volle Breite",+ },reset: "Zurücksetzen",resetAll: "Anpassungen zurücksetzen",preferencesTitle: "Weitere Optionen",diff --git a/studio/frontend/src/i18n/locales/en.ts b/studio/frontend/src/i18n/locales/en.tsindex 1599432da02..af11423983b 100644--- a/studio/frontend/src/i18n/locales/en.ts+++ b/studio/frontend/src/i18n/locales/en.ts@@ -1023,6 +1023,13 @@ export const en = {minimal: "Minimal",},custom: {+ chatWidth: {+ label: "Chat width",+ description: "Set the width of messages and the composer. Full width uses the space between sidebars.",+ standard: "Standard",+ wide: "Wide",+ full: "Full width",+ },reset: "Reset",resetAll: "Reset customization",preferencesTitle: "Preferences",diff --git a/studio/frontend/src/i18n/locales/es.ts b/studio/frontend/src/i18n/locales/es.tsindex 40396f23d1c..14596851b1c 100644--- a/studio/frontend/src/i18n/locales/es.ts+++ b/studio/frontend/src/i18n/locales/es.ts@@ -1048,6 +1048,13 @@ export const es = {minimal: "Minimalista",},custom: {+ chatWidth: {+ label: "Ancho del chat",+ description: "Ajusta el ancho de los mensajes y del cuadro de texto. El ancho completo usa el espacio entre las barras laterales.",+ standard: "Estándar",+ wide: "Amplio",+ full: "Ancho completo",+ },reset: "Restablecer",resetAll: "Restablecer la personalización",preferencesTitle: "Preferencias",diff --git a/studio/frontend/src/i18n/locales/fr.ts b/studio/frontend/src/i18n/locales/fr.tsindex ed517ab13a3..1e540f31445 100644--- a/studio/frontend/src/i18n/locales/fr.ts+++ b/studio/frontend/src/i18n/locales/fr.ts@@ -1052,6 +1052,13 @@ export const fr = {minimal: "Minimale",},custom: {+ chatWidth: {+ label: "Largeur du chat",+ description: "Réglez la largeur des messages et de la zone de saisie. La pleine largeur utilise l’espace entre les barres latérales.",+ standard: "Standard",+ wide: "Large",+ full: "Pleine largeur",+ },reset: "Réinitialiser",resetAll: "Réinitialiser la personnalisation",preferencesTitle: "Préférences",diff --git a/studio/frontend/src/i18n/locales/hi.ts b/studio/frontend/src/i18n/locales/hi.tsindex 78217f8b98c..a147636f098 100644--- a/studio/frontend/src/i18n/locales/hi.ts+++ b/studio/frontend/src/i18n/locales/hi.ts@@ -1032,6 +1032,13 @@ export const hi = {minimal: "मिनिमल",},custom: {+ chatWidth: {+ label: "चैट की चौड़ाई",+ description: "संदेशों और इनपुट बॉक्स की चौड़ाई तय करें। पूरी चौड़ाई साइडबार के बीच की जगह का उपयोग करती है।",+ standard: "मानक",+ wide: "चौड़ा",+ full: "पूरी चौड़ाई",+ },reset: "रीसेट करें",resetAll: "कस्टमाइज़ेशन रीसेट करें",preferencesTitle: "प्राथमिकताएं",diff --git a/studio/frontend/src/i18n/locales/it.ts b/studio/frontend/src/i18n/locales/it.tsindex 37d88a9b17f..239b6725f3c 100644--- a/studio/frontend/src/i18n/locales/it.ts+++ b/studio/frontend/src/i18n/locales/it.ts@@ -1017,6 +1017,13 @@ export const it = {minimal: "Minimale",},custom: {+ chatWidth: {+ label: "Larghezza chat",+ description: "Imposta la larghezza dei messaggi e del campo di testo. La larghezza piena usa lo spazio tra le barre laterali.",+ standard: "Standard",+ wide: "Ampia",+ full: "Larghezza piena",+ },reset: "Ripristina",resetAll: "Ripristina la personalizzazione",preferencesTitle: "Preferenze",diff --git a/studio/frontend/src/i18n/locales/ja.ts b/studio/frontend/src/i18n/locales/ja.tsindex 36bf59aaa9c..ce95332aa72 100644--- a/studio/frontend/src/i18n/locales/ja.ts+++ b/studio/frontend/src/i18n/locales/ja.ts@@ -1012,6 +1012,13 @@ export const ja = {minimal: "ミニマル",},custom: {+ chatWidth: {+ label: "チャットの幅",+ description: "メッセージと入力欄の幅を設定します。全幅ではサイドバーの間のスペースを使います。",+ standard: "標準",+ wide: "広い",+ full: "全幅",+ },reset: "リセット",resetAll: "カスタマイズをリセット",preferencesTitle: "環境設定",diff --git a/studio/frontend/src/i18n/locales/ko.ts b/studio/frontend/src/i18n/locales/ko.tsindex c526982a7dd..1dd7182f114 100644--- a/studio/frontend/src/i18n/locales/ko.ts+++ b/studio/frontend/src/i18n/locales/ko.ts@@ -1025,6 +1025,13 @@ export const ko = {minimal: "미니멀",},custom: {+ chatWidth: {+ label: "채팅 너비",+ description: "메시지와 입력창의 너비를 설정합니다. 전체 너비는 사이드바 사이의 공간을 사용합니다.",+ standard: "표준",+ wide: "넓게",+ full: "전체 너비",+ },reset: "초기화",resetAll: "사용자 지정 초기화",preferencesTitle: "환경설정",diff --git a/studio/frontend/src/i18n/locales/pt-br.ts b/studio/frontend/src/i18n/locales/pt-br.tsindex 8235addae7c..4dcfcfb325a 100644--- a/studio/frontend/src/i18n/locales/pt-br.ts+++ b/studio/frontend/src/i18n/locales/pt-br.ts@@ -1040,6 +1040,13 @@ export const ptBR = {minimal: "Minimalista",},custom: {+ chatWidth: {+ label: "Largura do chat",+ description: "Defina a largura das mensagens e do campo de texto. A largura total usa o espaço entre as barras laterais.",+ standard: "Padrão",+ wide: "Ampla",+ full: "Largura total",+ },reset: "Redefinir",resetAll: "Redefinir personalização",preferencesTitle: "Preferências",diff --git a/studio/frontend/src/i18n/locales/ru.ts b/studio/frontend/src/i18n/locales/ru.tsindex 8ad738db99c..d535dc47ecd 100644--- a/studio/frontend/src/i18n/locales/ru.ts+++ b/studio/frontend/src/i18n/locales/ru.ts@@ -1033,6 +1033,13 @@ export const ru = {minimal: "Минималистичная",},custom: {+ chatWidth: {+ label: "Ширина чата",+ description: "Задайте ширину сообщений и поля ввода. Полная ширина использует пространство между боковыми панелями.",+ standard: "Стандартная",+ wide: "Широкая",+ full: "Полная ширина",+ },reset: "Сбросить",resetAll: "Сбросить настройки оформления",preferencesTitle: "Параметры",diff --git a/studio/frontend/src/i18n/locales/zh-CN.ts b/studio/frontend/src/i18n/locales/zh-CN.tsindex 6814f78c929..4488959018b 100644--- a/studio/frontend/src/i18n/locales/zh-CN.ts+++ b/studio/frontend/src/i18n/locales/zh-CN.ts@@ -1013,6 +1013,13 @@ export const zhCN = {minimal: "极简",},custom: {+ chatWidth: {+ label: "聊天宽度",+ description: "设置消息和输入框的宽度。全宽会使用侧边栏之间的可用空间。",+ standard: "标准",+ wide: "宽",+ full: "全宽",+ },reset: "重置",resetAll: "重置自定义",preferencesTitle: "偏好设置",diff --git a/studio/frontend/tests/personalization-locale-hydration.test.ts b/studio/frontend/tests/personalization-locale-hydration.test.tsindex 492ea53f756..1e0cf2b4ee1 100644--- a/studio/frontend/tests/personalization-locale-hydration.test.ts+++ b/studio/frontend/tests/personalization-locale-hydration.test.ts@@ -10,6 +10,7 @@ import assert from "node:assert/strict";import test from "node:test";import { loadWithStubs } from "./helpers/module-stubs.ts";+import { sanitizeCustomization } from "../src/features/settings/stores/appearance-custom-store.ts";type Slot = {value?: unknown;@@ -182,11 +183,31 @@ function remotePersonalization(language: string) {};}-function setup(localeResult: "superseded" | "cancelled" | "stalled") {+function setup(+ localeResult: "superseded" | "cancelled" | "stalled",+ options: {+ localCustomization?: Record<string, unknown>;+ remote?: ReturnType<typeof remotePersonalization> & {+ chatWidthSaved?: boolean;+ };+ } = {},+) {const runTimers = installWindow();const host = createReact();const saves: SavedPayload[] = [];const localeCalls: unknown[] = [];+ let customization = sanitizeCustomization(options.localCustomization);+ const appearanceStore = Object.assign(+ (select: (state: unknown) => unknown) => select({ customization }),+ {+ getState: () => ({+ customization,+ replaceAll: (next: unknown) => {+ customization = sanitizeCustomization(next);+ },+ }),+ },+ );let profile: Profile = {displayName: "",nickname: "",@@ -220,17 +241,17 @@ function setup(localeResult: "superseded" | "cancelled" | "stalled") {isDefaultCustomization: (value: unknown) =>Object.keys(value as object).length === 0,isPalette: (value: unknown) => typeof value === "string",- loadPersonalization: () => Promise.resolve(remotePersonalization("de")),+ loadPersonalization: () =>+ Promise.resolve(options.remote ?? remotePersonalization("de")),migrateShippedSidebarNavDefault: (value: unknown) => value,- sanitizeCustomization: (value: unknown) => value ?? {},+ sanitizeCustomization,savePersonalization: (data: SavedPayload) => {saves.push(data);return Promise.resolve();},setPalette: () => undefined,setTheme: () => undefined,- useAppearanceCustomStore: (select: (state: unknown) => unknown) =>- select({ customization: {} }),+ useAppearanceCustomStore: appearanceStore,usePalette: () => ({ palette: "standard" }),useTheme: () => ({ theme: "system" }),},@@ -268,6 +289,7 @@ function setup(localeResult: "superseded" | "cancelled" | "stalled") {releaseLocale,runTimers,saves,+ customization: () => customization,rename(displayName: string) {profile = { ...profile, displayName };},@@ -338,3 +360,74 @@ test("a stalled locale catalog does not pause personalization saves", async () =assert.equal(app.saves.length, 1);assert.equal(app.saves[0]?.profile.displayName, "Ada");});++function widthRemote(chatWidthSaved?: boolean, chatWidth?: string) {+ const remote = remotePersonalization("auto");+ return {+ ...remote,+ version: 4,+ chatWidthSaved,+ appearance: {+ ...remote.appearance,+ customization: {+ uiFont: "Georgia",+ ...(chatWidth === undefined ? {} : { chatWidth }),+ },+ },+ };+}++for (const localWidth of ["wide", "full"]) {+ test(`legacy chat width preserves and uploads local ${localWidth}`, async () => {+ const app = setup("stalled", {+ localCustomization: { chatWidth: localWidth, uiFont: "Arial" },+ remote: widthRemote(false, "standard"),+ });+ app.render();+ await settle();+ app.render();++ assert.equal(app.customization().chatWidth, localWidth);+ assert.equal(app.customization().uiFont, "Georgia");+ app.runTimers();+ await settle();+ assert.equal(app.saves.length, 1);+ assert.equal(app.saves[0]?.appearance.customization.chatWidth, localWidth);+ app.host.unmount();+ });+}++for (const remoteWidth of ["standard", "wide", "full"]) {+ test(`saved chat width ${remoteWidth} overrides local without another save`, async () => {+ const app = setup("stalled", {+ localCustomization: {+ chatWidth: remoteWidth === "full" ? "wide" : "full",+ },+ remote: widthRemote(true, remoteWidth),+ });+ app.render();+ await settle();+ app.render();+ assert.equal(app.customization().chatWidth, remoteWidth);+ app.runTimers();+ await settle();+ assert.equal(app.saves.length, 0);+ app.host.unmount();+ });+}++test("an older server without chat width metadata preserves local width", async () => {+ const app = setup("stalled", {+ localCustomization: { chatWidth: "wide" },+ remote: widthRemote(),+ });+ app.render();+ await settle();+ app.render();+ assert.equal(app.customization().chatWidth, "wide");+ app.runTimers();+ await settle();+ assert.equal(app.saves.length, 1);+ assert.equal(app.saves[0]?.appearance.customization.chatWidth, "wide");+ app.host.unmount();+});diff --git a/tests/studio/playwright_chat_width.py b/tests/studio/playwright_chat_width.pynew file mode 100644index 00000000000..06810be7b00--- /dev/null+++ b/tests/studio/playwright_chat_width.py@@ -0,0 +1,71 @@+# SPDX-License-Identifier: AGPL-3.0-only+# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0++"""Check width presets against a running Studio with a saved conversation.++BASE_URL, STUDIO_PW and CHAT_THREAD_ID identify the disposable test instance.+Run with: python tests/studio/playwright_chat_width.py+"""++import os++from playwright.sync_api import sync_playwright+++def check_widths(page):+ """Full must preserve the space available in Wide, including narrow panes."""+ thread_url = page.url+ measurements = {}+ for preset in ("Standard", "Wide", "Full width"):+ page.set_viewport_size({"width": 1440, "height": 900})+ page.keyboard.press("Control+,")+ page.get_by_role("dialog").get_by_role("button", name = "Appearance", exact = True).click()+ page.get_by_role("combobox", name = "Chat width").click()+ page.get_by_role("option", name = preset, exact = True).click()+ page.keyboard.press("Escape")+ measurements[preset] = {}+ for width in (390, 768, 900, 1280, 1536, 1920, 2560):+ page.set_viewport_size({"width": width, "height": 900})+ page.wait_for_timeout(300)+ measurements[preset][width] = page.evaluate(+ """() => {+ const width = selector => document.querySelector(selector).getBoundingClientRect().width;+ return {+ message: width('.aui-assistant-message-root'),+ composer: width('.unsloth-composer-shell'),+ overflow: document.documentElement.scrollWidth > innerWidth,+ };+ }"""+ )+ if preset == "Wide":+ page.set_viewport_size({"width": 1920, "height": 900})+ page.goto(thread_url.split("?")[0] + "?new=width-transition")+ shell = page.locator(".unsloth-composer-shell")+ shell.wait_for()+ page.wait_for_timeout(300)+ welcome_width = shell.bounding_box()["width"]+ assert abs(welcome_width - measurements[preset][1920]["composer"]) <= 1+ page.goto(thread_url)+ page.locator(".aui-assistant-message-root").wait_for()+ for width, full in measurements["Full width"].items():+ standard = measurements["Standard"][width]+ wide = measurements["Wide"][width]+ for surface in ("message", "composer"):+ assert full[surface] >= wide[surface] - 1, (width, surface, full, wide)+ assert wide[surface] >= standard[surface] - 1, (width, surface, wide, standard)+ assert not any(measurements[preset][width]["overflow"] for preset in measurements)+ return measurements+++if __name__ == "__main__":+ with sync_playwright() as playwright:+ browser = playwright.chromium.launch()+ page = browser.new_page(viewport = {"width": 1440, "height": 900}, reduced_motion = "reduce")+ page.goto(os.environ["BASE_URL"])+ page.locator("input[type=password]").fill(os.environ["STUDIO_PW"])+ page.keyboard.press("Enter")+ page.locator(".aui-thread-root").wait_for()+ page.goto(f"{os.environ['BASE_URL']}/chat?thread={os.environ['CHAT_THREAD_ID']}")+ page.locator(".aui-assistant-message-root").wait_for()+ print(check_widths(page))+ browser.close()