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: Appearance > Code with a live preview, line numbers, word wrap and ligatures (#16299)

Michael Han6abeedca2cc6
diff --git a/studio/backend/routes/settings.py b/studio/backend/routes/settings.py
index a6acc0c24c9..b189212b12a 100644
--- a/studio/backend/routes/settings.py
+++ b/studio/backend/routes/settings.py
@@ -4754,6 +4754,9 @@ class PersonalizationCustomization(BaseModel):
pointerCursors: bool = False
reduceMotion: Literal["system", "on", "off"] = "system"
fontSmoothing: bool = True
+ codeLineNumbers: bool = False
+ codeWordWrap: bool = False
+ codeLigatures: bool = True
sidebarMenu: list[PersonalizationSidebarMenuItem] = Field(
default_factory = _default_sidebar_menu,
max_length = MAX_SIDEBAR_MENU_INPUT_ITEMS,
diff --git a/studio/backend/tests/test_personalization_settings.py b/studio/backend/tests/test_personalization_settings.py
index cd923b51f8b..321ec9caa91 100644
--- a/studio/backend/tests/test_personalization_settings.py
+++ b/studio/backend/tests/test_personalization_settings.py
@@ -85,6 +85,9 @@ def test_customization_defaults():
assert c.reduceMotion == "system"
assert c.fontSmoothing is True
assert c.pointerCursors is False
+ assert c.codeLineNumbers is False
+ assert c.codeWordWrap is False
+ assert c.codeLigatures is True
assert c.colors.light.accent is None
assert c.headingFont is None
assert c.chatFont is None
@@ -495,6 +498,9 @@ def test_personalization_route_roundtrip_real_shape(monkeypatch):
"pointerCursors": True,
"reduceMotion": "off",
"fontSmoothing": True,
+ "codeLineNumbers": True,
+ "codeWordWrap": True,
+ "codeLigatures": False,
"sidebarMenu": [
{"id": "darkMode", "visible": True},
{"id": "api", "visible": False},
diff --git a/studio/frontend/src/features/settings/components/api-example-parts.tsx b/studio/frontend/src/features/settings/components/api-example-parts.tsx
index 9fc99ea71ac..dbe67216225 100644
--- a/studio/frontend/src/features/settings/components/api-example-parts.tsx
+++ b/studio/frontend/src/features/settings/components/api-example-parts.tsx
@@ -207,13 +207,13 @@ export function HighlightedCode({
[code, language],
);
return (
- // Intrinsic code width keeps scrolling on the focusable section.
+ // Intrinsic code width keeps scrolling on the focusable section, unless Word wrap is on.
<section
// Safari never focuses a scroller on its own, so long examples need a tab stop.
// biome-ignore lint/a11y/noNoninteractiveTabindex: keyboard-scrollable region
tabIndex={0}
aria-label={label}
- className="max-h-96 max-w-full hover-scrollbar overflow-auto [mask-image:linear-gradient(to_bottom,transparent,#000_0.75rem)] p-3 pr-16 outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-inset text-ui-11 leading-relaxed [&_pre]:!m-0 [&_pre]:!whitespace-pre [&_pre]:!break-normal [&_pre]:!border-0 [&_pre]:!bg-transparent [&_pre]:!p-0 [&_pre]:!text-ui-11 [&_pre]:!leading-relaxed [&_code]:!text-ui-11 [&_[data-streamdown=code-block]]:!min-w-max [&_[data-streamdown=code-block]]:!my-0 [&_[data-streamdown=code-block]]:!border-0 [&_[data-streamdown=code-block]]:!bg-transparent [&_[data-streamdown=code-block]]:!p-0 [&_[data-streamdown=code-block]]:!text-ui-11"
+ className="max-h-96 max-w-full hover-scrollbar overflow-auto [mask-image:linear-gradient(to_bottom,transparent,#000_0.75rem)] p-3 pr-16 outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-inset text-ui-11 leading-relaxed [&_pre]:!m-0 [html:not([data-code-wrap])_&_pre]:!whitespace-pre [html:not([data-code-wrap])_&_pre]:!break-normal [&_pre]:!border-0 [&_pre]:!bg-transparent [&_pre]:!p-0 [&_pre]:!text-ui-11 [&_pre]:!leading-relaxed [&_code]:!text-ui-11 [html:not([data-code-wrap])_&_[data-streamdown=code-block]]:!min-w-max [&_[data-streamdown=code-block]]:!my-0 [&_[data-streamdown=code-block]]:!border-0 [&_[data-streamdown=code-block]]:!bg-transparent [&_[data-streamdown=code-block]]:!p-0 [&_[data-streamdown=code-block]]:!text-ui-11"
data-reload-snapshot-sensitive={redactFromReload ? "" : undefined}
>
<Streamdown
diff --git a/studio/frontend/src/features/settings/components/appearance-custom-controls.tsx b/studio/frontend/src/features/settings/components/appearance-custom-controls.tsx
index c5cb782447b..fac5237173f 100644
--- a/studio/frontend/src/features/settings/components/appearance-custom-controls.tsx
+++ b/studio/frontend/src/features/settings/components/appearance-custom-controls.tsx
@@ -846,6 +846,24 @@ export function CodeFontSizeRow() {
);
}
+export function CodeDisplaySwitch({
+ field,
+ label,
+}: {
+ field: "codeLineNumbers" | "codeWordWrap" | "codeLigatures";
+ label: string;
+}) {
+ const checked = useAppearanceCustomStore((s) => s.customization[field]);
+ const patch = useAppearanceCustomStore((s) => s.patch);
+ return (
+ <Switch
+ aria-label={label}
+ checked={checked}
+ onCheckedChange={(next) => patch({ [field]: next })}
+ />
+ );
+}
+
export function FontSmoothingSwitch() {
const fontSmoothing = useAppearanceCustomStore(
(s) => s.customization.fontSmoothing,
diff --git a/studio/frontend/src/features/settings/components/code-display-preview.tsx b/studio/frontend/src/features/settings/components/code-display-preview.tsx
new file mode 100644
index 00000000000..ae3cf5c5f40
--- /dev/null
+++ b/studio/frontend/src/features/settings/components/code-display-preview.tsx
@@ -0,0 +1,30 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+
+import { Streamdown } from "streamdown";
+import { unslothDarkTheme, unslothLightTheme } from "@/components/assistant-ui/code-themes";
+import { codePlugin } from "@/components/assistant-ui/shared-code-plugin";
+
+const SAMPLE = `\`\`\`ts
+const isActive = (user: User): boolean => user.visits >= 3 && user.status !== "banned";
+
+export function formatUser(user: User): string {
+ const tags = [user.role, user.team, user.location, user.timezone].filter((tag) => tag !== undefined).join(" · ");
+ return \`\${user.name} <\${user.email}>\${tags ? \` (\${tags})\` : ""}\`;
+}
+\`\`\``;
+
+export function CodeDisplayPreview() {
+ return (
+ <div data-code-preview="" className="min-w-0">
+ <Streamdown
+ mode="static"
+ plugins={{ code: codePlugin }}
+ controls={{ code: false }}
+ shikiTheme={[unslothLightTheme, unslothDarkTheme]}
+ >
+ {SAMPLE}
+ </Streamdown>
+ </div>
+ );
+}
diff --git a/studio/frontend/src/features/settings/settings-search.ts b/studio/frontend/src/features/settings/settings-search.ts
index f19334f1807..632bfd0468c 100644
--- a/studio/frontend/src/features/settings/settings-search.ts
+++ b/studio/frontend/src/features/settings/settings-search.ts
@@ -79,7 +79,11 @@ export const SETTINGS_SEARCH_INDEX: Record<SettingsTab, TranslationKey[]> = {
"settings.profile.greetingSloth",
"settings.chat.composerAtBottom",
"settings.appearance.custom.sentAttachments.label",
+ "settings.appearance.code.title",
"settings.appearance.custom.codeFont.label",
+ "settings.appearance.code.lineNumbers.label",
+ "settings.appearance.code.wordWrap.label",
+ "settings.appearance.code.ligatures.label",
"settings.appearance.custom.contrast.label",
"settings.appearance.custom.pointerCursors.label",
"settings.appearance.custom.reduceMotion.label",
diff --git a/studio/frontend/src/features/settings/stores/appearance-custom-store.ts b/studio/frontend/src/features/settings/stores/appearance-custom-store.ts
index 9bc3f722d21..f83c638773d 100644
--- a/studio/frontend/src/features/settings/stores/appearance-custom-store.ts
+++ b/studio/frontend/src/features/settings/stores/appearance-custom-store.ts
@@ -234,6 +234,9 @@ export type AppearanceCustomization = {
reduceMotion: ReduceMotionSetting;
/** true = the app default (antialiased). */
fontSmoothing: boolean;
+ codeLineNumbers: boolean;
+ codeWordWrap: boolean;
+ codeLigatures: boolean;
sidebarMenu: SidebarMenuItemPref[];
sidebarNav: SidebarNavItemPref[];
/** Rows still following their automatic rule; only Projects has one. */
@@ -261,6 +264,9 @@ export const DEFAULT_CUSTOMIZATION: AppearanceCustomization = {
pointerCursors: false,
reduceMotion: "system",
fontSmoothing: true,
+ codeLineNumbers: false,
+ codeWordWrap: false,
+ codeLigatures: true,
sidebarMenu: SIDEBAR_MENU_ITEM_IDS.map((id) => ({
id,
visible: SIDEBAR_MENU_DEFAULT_VISIBLE[id],
@@ -465,6 +471,9 @@ export function sanitizeCustomization(value: unknown): AppearanceCustomization {
? source.reduceMotion
: "system",
fontSmoothing: source.fontSmoothing !== false,
+ codeLineNumbers: source.codeLineNumbers === true,
+ codeWordWrap: source.codeWordWrap === true,
+ codeLigatures: source.codeLigatures !== false,
sidebarMenu: sanitizeSidebarMenu(source.sidebarMenu),
sidebarNav,
sidebarNavAuto: sanitizeSidebarNavAuto(source.sidebarNavAuto, sidebarNav),
@@ -1020,6 +1029,14 @@ export function applyCustomizationToDocument(
// "off" overrides OS reduced motion; index.css media rules skip html.force-motion.
el.classList.toggle("force-motion", c.reduceMotion === "off");
el.classList.toggle("no-font-smoothing", !c.fontSmoothing);
+ for (const [name, on] of [
+ ["data-code-line-numbers", c.codeLineNumbers],
+ ["data-code-wrap", c.codeWordWrap],
+ ["data-code-no-ligatures", !c.codeLigatures],
+ ] as const) {
+ if (on) el.setAttribute(name, "");
+ else el.removeAttribute(name);
+ }
}
/** For imperative motion (confetti, view transitions) CSS/MotionConfig cannot reach. */
diff --git a/studio/frontend/src/features/settings/tabs/appearance-tab.tsx b/studio/frontend/src/features/settings/tabs/appearance-tab.tsx
index 59bfbcec04e..e6a212c65c5 100644
--- a/studio/frontend/src/features/settings/tabs/appearance-tab.tsx
+++ b/studio/frontend/src/features/settings/tabs/appearance-tab.tsx
@@ -17,6 +17,7 @@ import {
ActiveColorControl,
ChatFontRow,
ChatWidthSelect,
+ CodeDisplaySwitch,
SentAttachmentsSelect,
CodeFontRow,
CodeFontSizeRow,
@@ -30,6 +31,7 @@ import {
UiFontRow,
UiFontSizeRow,
} from "../components/appearance-custom-controls";
+import { CodeDisplayPreview } from "../components/code-display-preview";
import { ColorThemeSelect } from "../components/color-theme-select";
import { GpuRenderingSegmented } from "../components/gpu-rendering-segmented";
import { SettingsRow } from "../components/settings-row";
@@ -43,6 +45,11 @@ import { useSettingsDialogStore } from "../stores/settings-dialog-store";
const FONT_CONTROL_CLASS = "flex w-76 max-w-full items-center gap-2";
const FONT_SELECT_CLASS = "w-auto min-w-0 flex-1";
+const CODE_SWITCHES = [
+ { field: "codeLineNumbers", key: "lineNumbers" },
+ { field: "codeWordWrap", key: "wordWrap" },
+ { field: "codeLigatures", key: "ligatures" },
+] as const;
const NOTE_CLASS =
"max-w-[calc(280px*var(--ui-space-scale,1))] text-right text-xs";
@@ -239,12 +246,6 @@ export function AppearanceTab() {
<ChatFontRow className={FONT_SELECT_CLASS} />
</div>
</SettingsRow>
- <SettingsRow label={t("settings.appearance.custom.codeFont.label")}>
- <div className={FONT_CONTROL_CLASS}>
- <CodeFontRow className={FONT_SELECT_CLASS} />
- <CodeFontSizeRow />
- </div>
- </SettingsRow>
<SettingsRow
label={t("settings.appearance.custom.interfaceScale.label")}
description={t(
@@ -312,6 +313,33 @@ export function AppearanceTab() {
</SettingsRow>
</SettingsSection>
+ <SettingsSection title={t("settings.appearance.code.title")}>
+ <SettingsRow
+ label={t("settings.appearance.custom.codeFont.label")}
+ description={t("settings.appearance.code.fontDescription")}
+ >
+ <div className={FONT_CONTROL_CLASS}>
+ <CodeFontRow className={FONT_SELECT_CLASS} />
+ <CodeFontSizeRow />
+ </div>
+ </SettingsRow>
+ <div className="pb-3">
+ <CodeDisplayPreview />
+ </div>
+ {CODE_SWITCHES.map(({ field, key }) => (
+ <SettingsRow
+ key={field}
+ label={t(`settings.appearance.code.${key}.label`)}
+ description={t(`settings.appearance.code.${key}.description`)}
+ >
+ <CodeDisplaySwitch
+ field={field}
+ label={t(`settings.appearance.code.${key}.label`)}
+ />
+ </SettingsRow>
+ ))}
+ </SettingsSection>
+
{isTauri ? (
<SettingsSection title={t("settings.appearance.gpuRendering.sectionTitle")}>
<GpuRenderingRow />
diff --git a/studio/frontend/src/i18n/locales/ar.ts b/studio/frontend/src/i18n/locales/ar.ts
index 387e19d7e74..ff8fbe9cb59 100644
--- a/studio/frontend/src/i18n/locales/ar.ts
+++ b/studio/frontend/src/i18n/locales/ar.ts
@@ -2340,6 +2340,22 @@ export const ar = {
description:
"سمات الهالوين وتحيات مخيفة حتى 1 نوفمبر.",
},
+ code: {
+ title: "الشيفرة",
+ fontDescription: "كتل الشيفرة في المحادثة ومعاينات الملفات وأمثلة API.",
+ lineNumbers: {
+ label: "أرقام الأسطر",
+ description: "ترقيم أسطر كتل الشيفرة في المحادثة.",
+ },
+ wordWrap: {
+ label: "التفاف الأسطر",
+ description: "التفاف الأسطر الطويلة في كتل الشيفرة بدل التمرير أفقيًا.",
+ },
+ ligatures: {
+ label: "الحروف المركّبة",
+ description: "دمج رموز مثل => و != في حرف واحد عندما يدعم خط الشيفرة ذلك.",
+ },
+ },
custom: {
chatWidth: {
label: "عرض المحادثة",
diff --git a/studio/frontend/src/i18n/locales/cs.ts b/studio/frontend/src/i18n/locales/cs.ts
index 335428a53dd..57dc1773f72 100644
--- a/studio/frontend/src/i18n/locales/cs.ts
+++ b/studio/frontend/src/i18n/locales/cs.ts
@@ -2554,6 +2554,22 @@ export const cs = {
description:
"Halloweenské motivy a strašidelné pozdravy, do 1. listopadu.",
},
+ code: {
+ title: "Kód",
+ fontDescription: "Bloky kódu v chatu, náhledy souborů a příklady API.",
+ lineNumbers: {
+ label: "Čísla řádků",
+ description: "Číslovat řádky bloků kódu v chatu.",
+ },
+ wordWrap: {
+ label: "Zalamování řádků",
+ description: "Zalamovat dlouhé řádky v blocích kódu místo vodorovného posouvání.",
+ },
+ ligatures: {
+ label: "Ligatury písma",
+ description: "Spojovat symboly jako => a != do jednoho znaku, pokud to písmo kódu podporuje.",
+ },
+ },
custom: {
chatWidth: {
label: "Šířka chatu",
diff --git a/studio/frontend/src/i18n/locales/de.ts b/studio/frontend/src/i18n/locales/de.ts
index 02287383897..7954a92f5be 100644
--- a/studio/frontend/src/i18n/locales/de.ts
+++ b/studio/frontend/src/i18n/locales/de.ts
@@ -2370,6 +2370,22 @@ export const de = {
description:
"Halloween-Designs und gruselige Begrüßungen, bis zum 1. November.",
},
+ code: {
+ title: "Code",
+ fontDescription: "Codeblöcke im Chat, Dateivorschauen und API-Beispiele.",
+ lineNumbers: {
+ label: "Zeilennummern",
+ description: "Zeilen von Codeblöcken im Chat nummerieren.",
+ },
+ wordWrap: {
+ label: "Zeilenumbruch",
+ description: "Lange Zeilen in Codeblöcken umbrechen statt seitlich zu scrollen.",
+ },
+ ligatures: {
+ label: "Schrift-Ligaturen",
+ description: "Zeichen wie => und != zu einer Glyphe verbinden, wenn die Codeschrift das unterstützt.",
+ },
+ },
custom: {
chatWidth: {
label: "Chatbreite",
diff --git a/studio/frontend/src/i18n/locales/en.ts b/studio/frontend/src/i18n/locales/en.ts
index 79317074b8c..578ee1615c8 100644
--- a/studio/frontend/src/i18n/locales/en.ts
+++ b/studio/frontend/src/i18n/locales/en.ts
@@ -2355,6 +2355,22 @@ export const en = {
description:
"Halloween themes and spooky greetings, until November 1.",
},
+ code: {
+ title: "Code",
+ fontDescription: "Code blocks in chat, file previews and API examples.",
+ lineNumbers: {
+ label: "Line numbers",
+ description: "Number the lines of code blocks in chat.",
+ },
+ wordWrap: {
+ label: "Word wrap",
+ description: "Wrap long lines in code blocks instead of scrolling sideways.",
+ },
+ ligatures: {
+ label: "Font ligatures",
+ description: "Join symbols such as => and != into one glyph when the code font supports it.",
+ },
+ },
custom: {
chatWidth: {
label: "Chat width",
diff --git a/studio/frontend/src/i18n/locales/es-419.ts b/studio/frontend/src/i18n/locales/es-419.ts
index 45786efae4d..b58e9aee883 100644
--- a/studio/frontend/src/i18n/locales/es-419.ts
+++ b/studio/frontend/src/i18n/locales/es-419.ts
@@ -2573,6 +2573,22 @@ export const es419 = {
description:
"Temas de Halloween y saludos terroríficos, hasta el 1 de noviembre.",
},
+ code: {
+ title: "Código",
+ fontDescription: "Bloques de código en el chat, vistas previas de archivos y ejemplos de la API.",
+ lineNumbers: {
+ label: "Números de línea",
+ description: "Numerar las líneas de los bloques de código en el chat.",
+ },
+ wordWrap: {
+ label: "Ajuste de línea",
+ description: "Ajustar las líneas largas en los bloques de código en lugar de desplazarse de lado.",
+ },
+ ligatures: {
+ label: "Ligaduras tipográficas",
+ description: "Unir símbolos como => y != en un solo glifo cuando la fuente de código lo admite.",
+ },
+ },
custom: {
chatWidth: {
label: "Ancho del chat",
diff --git a/studio/frontend/src/i18n/locales/es.ts b/studio/frontend/src/i18n/locales/es.ts
index fad368decee..dfa79cf2df5 100644
--- a/studio/frontend/src/i18n/locales/es.ts
+++ b/studio/frontend/src/i18n/locales/es.ts
@@ -2365,6 +2365,22 @@ export const es = {
description:
"Temas de Halloween y saludos terroríficos, hasta el 1 de noviembre.",
},
+ code: {
+ title: "Código",
+ fontDescription: "Bloques de código en el chat, vistas previas de archivos y ejemplos de la API.",
+ lineNumbers: {
+ label: "Números de línea",
+ description: "Numerar las líneas de los bloques de código en el chat.",
+ },
+ wordWrap: {
+ label: "Ajuste de línea",
+ description: "Ajustar las líneas largas en los bloques de código en lugar de desplazarse en horizontal.",
+ },
+ ligatures: {
+ label: "Ligaduras tipográficas",
+ description: "Unir símbolos como => y != en un solo glifo cuando la fuente de código lo admite.",
+ },
+ },
custom: {
chatWidth: {
label: "Ancho del chat",
diff --git a/studio/frontend/src/i18n/locales/fa.ts b/studio/frontend/src/i18n/locales/fa.ts
index 53c529f0e62..484427fe76e 100644
--- a/studio/frontend/src/i18n/locales/fa.ts
+++ b/studio/frontend/src/i18n/locales/fa.ts
@@ -2526,6 +2526,22 @@ export const fa = {
label: "حقه یا خوراکی",
description: "پوسته‌های هالووین و خوشامدگویی‌های ترسناک، تا 1 نوامبر.",
},
+ code: {
+ title: "کد",
+ fontDescription: "بلوک‌های کد در گفتگو، پیش‌نمایش فایل‌ها و نمونه‌های API.",
+ lineNumbers: {
+ label: "شمارهٔ خط",
+ description: "خط‌های بلوک‌های کد در گفتگو شماره‌گذاری شوند.",
+ },
+ wordWrap: {
+ label: "شکستن خط",
+ description: "خط‌های بلند در بلوک‌های کد به‌جای پیمایش افقی شکسته شوند.",
+ },
+ ligatures: {
+ label: "پیوندهای قلم",
+ description: "نمادهایی مانند => و != در صورت پشتیبانی قلم کد به یک نویسه تبدیل شوند.",
+ },
+ },
custom: {
chatWidth: {
label: "عرض گفتگو",
diff --git a/studio/frontend/src/i18n/locales/fr.ts b/studio/frontend/src/i18n/locales/fr.ts
index b1e572241fc..f0829bdc378 100644
--- a/studio/frontend/src/i18n/locales/fr.ts
+++ b/studio/frontend/src/i18n/locales/fr.ts
@@ -2368,6 +2368,22 @@ export const fr = {
description:
"Thèmes d’Halloween et salutations effrayantes, jusqu’au 1er novembre.",
},
+ code: {
+ title: "Code",
+ fontDescription: "Blocs de code dans le chat, aperçus de fichiers et exemples d’API.",
+ lineNumbers: {
+ label: "Numéros de ligne",
+ description: "Numéroter les lignes des blocs de code dans le chat.",
+ },
+ wordWrap: {
+ label: "Retour à la ligne",
+ description: "Renvoyer à la ligne les lignes longues des blocs de code au lieu de défiler horizontalement.",
+ },
+ ligatures: {
+ label: "Ligatures de police",
+ description: "Fusionner des symboles comme => et != en un seul glyphe quand la police de code le permet.",
+ },
+ },
custom: {
chatWidth: {
label: "Largeur du chat",
diff --git a/studio/frontend/src/i18n/locales/he.ts b/studio/frontend/src/i18n/locales/he.ts
index d7513130b41..e241648b8c5 100644
--- a/studio/frontend/src/i18n/locales/he.ts
+++ b/studio/frontend/src/i18n/locales/he.ts
@@ -2395,6 +2395,22 @@ export const he = {
description:
"ערכות נושא של ליל כל הקדושים וברכות מפחידות, עד 1 בנובמבר.",
},
+ code: {
+ title: "קוד",
+ fontDescription: "בלוקי קוד בצ׳אט, תצוגות מקדימות של קבצים ודוגמאות API.",
+ lineNumbers: {
+ label: "מספרי שורות",
+ description: "מספור השורות של בלוקי קוד בצ׳אט.",
+ },
+ wordWrap: {
+ label: "גלישת שורות",
+ description: "גלישת שורות ארוכות בבלוקי קוד במקום גלילה הצידה.",
+ },
+ ligatures: {
+ label: "ליגטורות גופן",
+ description: "איחוד סמלים כמו => ו-!= לגליף אחד כשגופן הקוד תומך בכך.",
+ },
+ },
custom: {
chatWidth: {
label: "רוחב הצ'אט",
diff --git a/studio/frontend/src/i18n/locales/hi.ts b/studio/frontend/src/i18n/locales/hi.ts
index 5fd51153802..36fafd3728b 100644
--- a/studio/frontend/src/i18n/locales/hi.ts
+++ b/studio/frontend/src/i18n/locales/hi.ts
@@ -2346,6 +2346,22 @@ export const hi = {
description:
"1 नवंबर तक हैलोवीन थीम और डरावने अभिवादन।",
},
+ code: {
+ title: "कोड",
+ fontDescription: "चैट में कोड ब्लॉक, फ़ाइल प्रीव्यू और API उदाहरण।",
+ lineNumbers: {
+ label: "लाइन नंबर",
+ description: "चैट में कोड ब्लॉक की लाइनों पर नंबर दिखाएँ।",
+ },
+ wordWrap: {
+ label: "वर्ड रैप",
+ description: "लंबी लाइनों को बगल में स्क्रॉल करने के बजाय कोड ब्लॉक में लपेटें।",
+ },
+ ligatures: {
+ label: "फ़ॉन्ट लिगेचर",
+ description: "कोड फ़ॉन्ट समर्थन करे तो => और != जैसे चिह्नों को एक ग्लिफ़ में जोड़ें।",
+ },
+ },
custom: {
chatWidth: {
label: "चैट की चौड़ाई",
diff --git a/studio/frontend/src/i18n/locales/id.ts b/studio/frontend/src/i18n/locales/id.ts
index e2cef0a3415..5fc0814a49d 100644
--- a/studio/frontend/src/i18n/locales/id.ts
+++ b/studio/frontend/src/i18n/locales/id.ts
@@ -2538,6 +2538,22 @@ export const id = {
label: "Trick or treat",
description: "Tema Halloween dan sapaan seram, hingga 1 November.",
},
+ code: {
+ title: "Kode",
+ fontDescription: "Blok kode di chat, pratinjau file, dan contoh API.",
+ lineNumbers: {
+ label: "Nomor baris",
+ description: "Beri nomor pada baris blok kode di chat.",
+ },
+ wordWrap: {
+ label: "Bungkus baris",
+ description: "Bungkus baris panjang di blok kode alih-alih menggulir ke samping.",
+ },
+ ligatures: {
+ label: "Ligatur font",
+ description: "Gabungkan simbol seperti => dan != menjadi satu glif jika font kode mendukungnya.",
+ },
+ },
custom: {
chatWidth: {
label: "Lebar chat",
diff --git a/studio/frontend/src/i18n/locales/it.ts b/studio/frontend/src/i18n/locales/it.ts
index d196802341f..6383cc948ed 100644
--- a/studio/frontend/src/i18n/locales/it.ts
+++ b/studio/frontend/src/i18n/locales/it.ts
@@ -2238,6 +2238,22 @@ export const it = {
description:
"Temi di Halloween e saluti spaventosi, fino al 1° novembre.",
},
+ code: {
+ title: "Codice",
+ fontDescription: "Blocchi di codice nella chat, anteprime dei file ed esempi API.",
+ lineNumbers: {
+ label: "Numeri di riga",
+ description: "Numera le righe dei blocchi di codice nella chat.",
+ },
+ wordWrap: {
+ label: "A capo automatico",
+ description: "Manda a capo le righe lunghe nei blocchi di codice invece di scorrere in orizzontale.",
+ },
+ ligatures: {
+ label: "Legature del carattere",
+ description: "Unisce simboli come => e != in un solo glifo se il carattere del codice lo supporta.",
+ },
+ },
custom: {
chatWidth: {
label: "Larghezza chat",
diff --git a/studio/frontend/src/i18n/locales/ja.ts b/studio/frontend/src/i18n/locales/ja.ts
index f58226619e6..3e933ac385c 100644
--- a/studio/frontend/src/i18n/locales/ja.ts
+++ b/studio/frontend/src/i18n/locales/ja.ts
@@ -2322,6 +2322,22 @@ export const ja = {
description:
"11月1日まで、ハロウィンのテーマと怖いあいさつを楽しめます。",
},
+ code: {
+ title: "コード",
+ fontDescription: "チャット内のコードブロック、ファイルのプレビュー、API の例。",
+ lineNumbers: {
+ label: "行番号",
+ description: "チャット内のコードブロックに行番号を表示します。",
+ },
+ wordWrap: {
+ label: "折り返し",
+ description: "コードブロックの長い行を横スクロールせずに折り返します。",
+ },
+ ligatures: {
+ label: "合字",
+ description: "コードフォントが対応していれば、=> や != などの記号を 1 つの字形で表示します。",
+ },
+ },
custom: {
chatWidth: {
label: "チャットの幅",
diff --git a/studio/frontend/src/i18n/locales/ko.ts b/studio/frontend/src/i18n/locales/ko.ts
index 48e9fff139b..f8cc4472418 100644
--- a/studio/frontend/src/i18n/locales/ko.ts
+++ b/studio/frontend/src/i18n/locales/ko.ts
@@ -2333,6 +2333,22 @@ export const ko = {
description:
"11월 1일까지 핼러윈 테마와 으스스한 인사말을 즐겨 보세요.",
},
+ code: {
+ title: "코드",
+ fontDescription: "채팅의 코드 블록, 파일 미리보기, API 예시.",
+ lineNumbers: {
+ label: "줄 번호",
+ description: "채팅 코드 블록의 줄에 번호를 붙입니다.",
+ },
+ wordWrap: {
+ label: "자동 줄바꿈",
+ description: "코드 블록의 긴 줄을 가로로 스크롤하지 않고 줄바꿈합니다.",
+ },
+ ligatures: {
+ label: "글꼴 합자",
+ description: "코드 글꼴이 지원하면 => 및 != 같은 기호를 하나의 글리프로 합칩니다.",
+ },
+ },
custom: {
chatWidth: {
label: "채팅 너비",
diff --git a/studio/frontend/src/i18n/locales/nl.ts b/studio/frontend/src/i18n/locales/nl.ts
index 1c316794900..e259bc1d7cd 100644
--- a/studio/frontend/src/i18n/locales/nl.ts
+++ b/studio/frontend/src/i18n/locales/nl.ts
@@ -2576,6 +2576,22 @@ export const nl = {
description:
"Halloweenthema's en griezelige begroetingen, tot 1 november.",
},
+ code: {
+ title: "Code",
+ fontDescription: "Codeblokken in de chat, bestandsvoorbeelden en API-voorbeelden.",
+ lineNumbers: {
+ label: "Regelnummers",
+ description: "Nummer de regels van codeblokken in de chat.",
+ },
+ wordWrap: {
+ label: "Regelterugloop",
+ description: "Lange regels in codeblokken laten teruglopen in plaats van horizontaal te scrollen.",
+ },
+ ligatures: {
+ label: "Ligaturen",
+ description: "Voeg tekens zoals => en != samen tot één glyph als het codelettertype dat ondersteunt.",
+ },
+ },
custom: {
chatWidth: {
label: "Chatbreedte",
diff --git a/studio/frontend/src/i18n/locales/pl.ts b/studio/frontend/src/i18n/locales/pl.ts
index 639774fdd87..dd012f1a284 100644
--- a/studio/frontend/src/i18n/locales/pl.ts
+++ b/studio/frontend/src/i18n/locales/pl.ts
@@ -2568,6 +2568,22 @@ export const pl = {
label: "Cukierek albo psikus",
description: "Motywy Halloween i upiorne powitania, do 1 listopada.",
},
+ code: {
+ title: "Kod",
+ fontDescription: "Bloki kodu na czacie, podglądy plików i przykłady API.",
+ lineNumbers: {
+ label: "Numery wierszy",
+ description: "Numeruj wiersze bloków kodu na czacie.",
+ },
+ wordWrap: {
+ label: "Zawijanie wierszy",
+ description: "Zawijaj długie wiersze w blokach kodu zamiast przewijać w poziomie.",
+ },
+ ligatures: {
+ label: "Ligatury czcionki",
+ description: "Łącz symbole takie jak => i != w jeden glif, jeśli czcionka kodu to obsługuje.",
+ },
+ },
custom: {
chatWidth: {
label: "Szerokość czatu",
diff --git a/studio/frontend/src/i18n/locales/pt-br.ts b/studio/frontend/src/i18n/locales/pt-br.ts
index 00d2a26b216..9502dffb7df 100644
--- a/studio/frontend/src/i18n/locales/pt-br.ts
+++ b/studio/frontend/src/i18n/locales/pt-br.ts
@@ -2356,6 +2356,22 @@ export const ptBR = {
description:
"Temas de Halloween e saudações assustadoras, até 1º de novembro.",
},
+ code: {
+ title: "Código",
+ fontDescription: "Blocos de código no chat, prévias de arquivos e exemplos da API.",
+ lineNumbers: {
+ label: "Números de linha",
+ description: "Numerar as linhas dos blocos de código no chat.",
+ },
+ wordWrap: {
+ label: "Quebra de linha",
+ description: "Quebrar linhas longas nos blocos de código em vez de rolar para o lado.",
+ },
+ ligatures: {
+ label: "Ligaduras da fonte",
+ description: "Unir símbolos como => e != em um único glifo quando a fonte de código oferece suporte.",
+ },
+ },
custom: {
chatWidth: {
label: "Largura do chat",
diff --git a/studio/frontend/src/i18n/locales/ru.ts b/studio/frontend/src/i18n/locales/ru.ts
index 37ebb716ed9..06d98fd18b2 100644
--- a/studio/frontend/src/i18n/locales/ru.ts
+++ b/studio/frontend/src/i18n/locales/ru.ts
@@ -2350,6 +2350,22 @@ export const ru = {
description:
"Темы Хэллоуина и жуткие приветствия до 1 ноября.",
},
+ code: {
+ title: "Код",
+ fontDescription: "Блоки кода в чате, предпросмотр файлов и примеры API.",
+ lineNumbers: {
+ label: "Номера строк",
+ description: "Нумеровать строки блоков кода в чате.",
+ },
+ wordWrap: {
+ label: "Перенос строк",
+ description: "Переносить длинные строки в блоках кода вместо горизонтальной прокрутки.",
+ },
+ ligatures: {
+ label: "Лигатуры шрифта",
+ description: "Объединять символы вроде => и != в один глиф, если шрифт кода это поддерживает.",
+ },
+ },
custom: {
chatWidth: {
label: "Ширина чата",
diff --git a/studio/frontend/src/i18n/locales/sv.ts b/studio/frontend/src/i18n/locales/sv.ts
index 0fde1ed3293..22dffe9cb09 100644
--- a/studio/frontend/src/i18n/locales/sv.ts
+++ b/studio/frontend/src/i18n/locales/sv.ts
@@ -2467,6 +2467,22 @@ export const sv = {
description:
"Halloweenteman och kusliga hälsningar, till 1 november.",
},
+ code: {
+ title: "Kod",
+ fontDescription: "Kodblock i chatten, filförhandsvisningar och API-exempel.",
+ lineNumbers: {
+ label: "Radnummer",
+ description: "Numrera raderna i kodblock i chatten.",
+ },
+ wordWrap: {
+ label: "Radbrytning",
+ description: "Bryt långa rader i kodblock i stället för att rulla i sidled.",
+ },
+ ligatures: {
+ label: "Ligaturer",
+ description: "Slå ihop tecken som => och != till ett tecken när kodtypsnittet stöder det.",
+ },
+ },
custom: {
chatWidth: {
label: "Chattbredd",
diff --git a/studio/frontend/src/i18n/locales/th.ts b/studio/frontend/src/i18n/locales/th.ts
index 4685031cedb..2ca45b120b6 100644
--- a/studio/frontend/src/i18n/locales/th.ts
+++ b/studio/frontend/src/i18n/locales/th.ts
@@ -2431,6 +2431,22 @@ export const th = {
label: "หลอกหรือเลี้ยง",
description: "ธีมฮาโลวีนและคำทักทายสยองขวัญ จนถึง 1 พฤศจิกายน",
},
+ code: {
+ title: "โค้ด",
+ fontDescription: "บล็อกโค้ดในแชท ตัวอย่างไฟล์ และตัวอย่าง API",
+ lineNumbers: {
+ label: "หมายเลขบรรทัด",
+ description: "แสดงหมายเลขบรรทัดของบล็อกโค้ดในแชท",
+ },
+ wordWrap: {
+ label: "ตัดบรรทัด",
+ description: "ตัดบรรทัดยาวในบล็อกโค้ดแทนการเลื่อนด้านข้าง",
+ },
+ ligatures: {
+ label: "อักษรควบ",
+ description: "รวมสัญลักษณ์อย่าง => และ != เป็นอักขระเดียวเมื่อฟอนต์โค้ดรองรับ",
+ },
+ },
custom: {
chatWidth: {
label: "ความกว้างของแชท",
diff --git a/studio/frontend/src/i18n/locales/tr.ts b/studio/frontend/src/i18n/locales/tr.ts
index a1595db62f2..88b07385ee4 100644
--- a/studio/frontend/src/i18n/locales/tr.ts
+++ b/studio/frontend/src/i18n/locales/tr.ts
@@ -2530,6 +2530,22 @@ export const tr = {
description:
"1 Kasım'a kadar Cadılar Bayramı temaları ve ürkütücü selamlamalar.",
},
+ code: {
+ title: "Kod",
+ fontDescription: "Sohbetteki kod blokları, dosya önizlemeleri ve API örnekleri.",
+ lineNumbers: {
+ label: "Satır numaraları",
+ description: "Sohbetteki kod bloklarının satırlarını numaralandırır.",
+ },
+ wordWrap: {
+ label: "Satır kaydırma",
+ description: "Kod bloklarındaki uzun satırları yana kaydırmak yerine alt satıra geçirir.",
+ },
+ ligatures: {
+ label: "Yazı tipi bitişik harfleri",
+ description: "Kod yazı tipi destekliyorsa => ve != gibi simgeleri tek bir karakterde birleştirir.",
+ },
+ },
custom: {
chatWidth: {
label: "Sohbet genişliği",
diff --git a/studio/frontend/src/i18n/locales/uk.ts b/studio/frontend/src/i18n/locales/uk.ts
index 65623a95ea1..4966c63ea8e 100644
--- a/studio/frontend/src/i18n/locales/uk.ts
+++ b/studio/frontend/src/i18n/locales/uk.ts
@@ -2561,6 +2561,22 @@ export const uk = {
description:
"Теми до Гелловіну та моторошні привітання до 1 листопада.",
},
+ code: {
+ title: "Код",
+ fontDescription: "Блоки коду в чаті, попередній перегляд файлів і приклади API.",
+ lineNumbers: {
+ label: "Номери рядків",
+ description: "Нумерувати рядки блоків коду в чаті.",
+ },
+ wordWrap: {
+ label: "Перенесення рядків",
+ description: "Переносити довгі рядки в блоках коду замість горизонтальної прокрутки.",
+ },
+ ligatures: {
+ label: "Лігатури шрифту",
+ description: "Об’єднувати символи на кшталт => і != в один гліф, якщо шрифт коду це підтримує.",
+ },
+ },
custom: {
chatWidth: {
label: "Ширина чату",
diff --git a/studio/frontend/src/i18n/locales/vi.ts b/studio/frontend/src/i18n/locales/vi.ts
index 7ed72e8b119..2b70d07e2b7 100644
--- a/studio/frontend/src/i18n/locales/vi.ts
+++ b/studio/frontend/src/i18n/locales/vi.ts
@@ -2543,6 +2543,22 @@ export const vi = {
description:
"Chủ đề Halloween và lời chào rùng rợn, đến hết ngày 1 tháng 11.",
},
+ code: {
+ title: "Mã",
+ fontDescription: "Khối mã trong trò chuyện, bản xem trước tệp và ví dụ API.",
+ lineNumbers: {
+ label: "Số dòng",
+ description: "Đánh số dòng cho khối mã trong trò chuyện.",
+ },
+ wordWrap: {
+ label: "Ngắt dòng",
+ description: "Ngắt các dòng dài trong khối mã thay vì cuộn ngang.",
+ },
+ ligatures: {
+ label: "Chữ ghép",
+ description: "Ghép các ký hiệu như => và != thành một ký tự khi phông chữ mã hỗ trợ.",
+ },
+ },
custom: {
chatWidth: {
label: "Độ rộng khung trò chuyện",
diff --git a/studio/frontend/src/i18n/locales/zh-CN.ts b/studio/frontend/src/i18n/locales/zh-CN.ts
index f6916e5d873..afd4ea5e0f1 100644
--- a/studio/frontend/src/i18n/locales/zh-CN.ts
+++ b/studio/frontend/src/i18n/locales/zh-CN.ts
@@ -2325,6 +2325,22 @@ export const zhCN = {
description:
"万圣节主题和惊悚问候,持续到 11 月 1 日。",
},
+ code: {
+ title: "代码",
+ fontDescription: "聊天中的代码块、文件预览和 API 示例。",
+ lineNumbers: {
+ label: "行号",
+ description: "为聊天中的代码块显示行号。",
+ },
+ wordWrap: {
+ label: "自动换行",
+ description: "代码块中的长行自动换行,而不是横向滚动。",
+ },
+ ligatures: {
+ label: "字体连字",
+ description: "代码字体支持时,将 => 和 != 等符号合成一个字形。",
+ },
+ },
custom: {
chatWidth: {
label: "聊天宽度",
diff --git a/studio/frontend/src/i18n/locales/zh-TW.ts b/studio/frontend/src/i18n/locales/zh-TW.ts
index 7fd06145c2b..d7bac0617a6 100644
--- a/studio/frontend/src/i18n/locales/zh-TW.ts
+++ b/studio/frontend/src/i18n/locales/zh-TW.ts
@@ -2417,6 +2417,22 @@ export const zhTW = {
label: "不給糖就搗蛋",
description: "萬聖節主題與詭異問候語,持續到 11 月 1 日。",
},
+ code: {
+ title: "程式碼",
+ fontDescription: "聊天中的程式碼區塊、檔案預覽和 API 範例。",
+ lineNumbers: {
+ label: "行號",
+ description: "為聊天中的程式碼區塊顯示行號。",
+ },
+ wordWrap: {
+ label: "自動換行",
+ description: "程式碼區塊中的長行自動換行,而不是水平捲動。",
+ },
+ ligatures: {
+ label: "字型連字",
+ description: "程式碼字型支援時,將 => 和 != 等符號合成一個字形。",
+ },
+ },
custom: {
chatWidth: {
label: "聊天寬度",
diff --git a/studio/frontend/src/index.css b/studio/frontend/src/index.css
index 5511d2d1c19..697b209efa2 100644
--- a/studio/frontend/src/index.css
+++ b/studio/frontend/src/index.css
@@ -2349,6 +2349,28 @@ html[data-code-font-size] .aui-reasoning-code-lines {
font-size: var(--custom-code-font-size) !important;
}
+html[data-code-wrap] [data-streamdown="code-block"] :is(pre, code) {
+ white-space: pre-wrap !important;
+ overflow-wrap: anywhere;
+}
+/* Wrapped lines hang past Streamdown's number column (w-6 + mr-4) wherever numbers show. */
+html[data-code-wrap] [data-streamdown="code-block"] code > span {
+ padding-inline-start: 2.5rem;
+ text-indent: -2.5rem;
+}
+html[data-code-wrap] [data-streamdown="code-block"] code > span::before {
+ text-indent: 0;
+}
+html[data-code-wrap]:not([data-code-line-numbers]) :is(.aui-thread-root, [data-code-preview]) [data-streamdown="code-block"] code > span {
+ padding-inline-start: 0;
+ text-indent: 0;
+}
+html[data-code-no-ligatures] :is(pre, code, kbd, samp),
+html[data-code-no-ligatures] .aui-reasoning-code-lines {
+ font-variant-ligatures: none;
+ font-feature-settings: "liga" 0, "calt" 0;
+}
+
html.pointer-cursors
:is(
button:not(:disabled),
@@ -4707,7 +4729,7 @@ html[data-chat-font] .aui-root {
padding-left: 0;
}
- .aui-thread-root [data-streamdown="code-block"] code > span::before {
+ html:not([data-code-line-numbers]) :is(.aui-thread-root, [data-code-preview]) [data-streamdown="code-block"] code > span::before {
content: none !important;
display: none !important;
margin: 0 !important;
@@ -4715,13 +4737,13 @@ html[data-chat-font] .aui-root {
}
/* Chat code is 12px at any width (CODE_FONT_SIZE_RANGE.default). */
- .aui-thread-root [data-streamdown="code-block"] {
+ :is(.aui-thread-root, [data-code-preview]) [data-streamdown="code-block"] {
font-size: calc(0.75rem * var(--ui-font-scale, 1));
line-height: 1.55;
}
/* The body's text-sm would otherwise override the size above. */
- .aui-thread-root [data-streamdown="code-block-body"] {
+ :is(.aui-thread-root, [data-code-preview]) [data-streamdown="code-block-body"] {
font-size: inherit;
line-height: inherit;
}
@@ -4939,8 +4961,7 @@ html[data-chat-font] .aui-root {
}
/* --custom-code-font when set, else Fira Code; not KaTeX. */
- .aui-thread-root [data-streamdown="code-block"] pre,
- .aui-thread-root [data-streamdown="code-block"] code {
+ :is(.aui-thread-root, [data-code-preview]) [data-streamdown="code-block"] :is(pre, code) {
font-family: var(--custom-code-font, "Fira Code", ui-monospace, monospace);
}
@@ -4960,7 +4981,7 @@ html[data-chat-font] .aui-root {
margin-right: calc(-1.25rem * var(--ui-space-scale, 1));
}
- .dark .aui-thread-root [data-streamdown="code-block"] {
+ .dark :is(.aui-thread-root, [data-code-preview]) [data-streamdown="code-block"] {
/* Streamdown `pre` sets its own dark bg; keep one surface on the outer shell. */
--shiki-dark-bg: transparent;
background: var(--color-code-block);
@@ -5020,6 +5041,10 @@ html[data-chat-font] .aui-root {
width: max-content;
}
+ html[data-code-wrap] .aui-thread-root [data-unsloth-fence-paint] pre {
+ width: auto;
+ }
+
html[data-code-block-containment="on"] .aui-thread-root [data-streamdown="code-block"]:not([data-incomplete]) > [data-unsloth-fence-windowed] {
content-visibility: auto;
contain-intrinsic-size: auto var(--unsloth-fence-height);
diff --git a/studio/frontend/tests/appearance-code-display.test.ts b/studio/frontend/tests/appearance-code-display.test.ts
new file mode 100644
index 00000000000..8c10debf784
--- /dev/null
+++ b/studio/frontend/tests/appearance-code-display.test.ts
@@ -0,0 +1,57 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+
+import assert from "node:assert/strict";
+import test from "node:test";
+
+import { readSrc } from "./helpers/kit.ts";
+
+const attributes = new Set<string>();
+(globalThis as { document?: unknown }).document = {
+ documentElement: {
+ style: { setProperty() {}, removeProperty() {} },
+ setAttribute: (name: string) => attributes.add(name),
+ removeAttribute: (name: string) => attributes.delete(name),
+ toggleAttribute: (name: string, on: boolean) => (on ? attributes.add(name) : attributes.delete(name)),
+ classList: { toggle() {} },
+ },
+};
+
+const { applyCustomizationToDocument, DEFAULT_CUSTOMIZATION, sanitizeCustomization } = await import(
+ "../src/features/settings/stores/appearance-custom-store.ts"
+);
+
+test("records from before the code settings keep today's code blocks", () => {
+ const c = sanitizeCustomization({});
+ assert.equal(c.codeLineNumbers, false);
+ assert.equal(c.codeWordWrap, false);
+ assert.equal(c.codeLigatures, true);
+ const odd = sanitizeCustomization({ codeLineNumbers: "yes", codeWordWrap: 1, codeLigatures: "no" });
+ assert.deepEqual([odd.codeLineNumbers, odd.codeWordWrap, odd.codeLigatures], [false, false, true]);
+});
+
+test("each code setting drives one root attribute the stylesheet keys on", () => {
+ applyCustomizationToDocument(
+ { ...DEFAULT_CUSTOMIZATION, codeLineNumbers: true, codeWordWrap: true, codeLigatures: false },
+ "light",
+ );
+ for (const name of ["data-code-line-numbers", "data-code-wrap", "data-code-no-ligatures"])
+ assert.ok(attributes.has(name), name);
+ applyCustomizationToDocument(DEFAULT_CUSTOMIZATION, "light");
+ for (const name of ["data-code-line-numbers", "data-code-wrap", "data-code-no-ligatures"])
+ assert.ok(!attributes.has(name), name);
+ const css = readSrc("index.css");
+ assert.match(css, /html\[data-code-wrap\] \[data-streamdown="code-block"\] :is\(pre, code\)/);
+ assert.match(css, /html\[data-code-no-ligatures\] :is\(pre, code, kbd, samp\)/);
+ assert.match(css, /html\[data-code-wrap\] \.aui-thread-root \[data-unsloth-fence-paint\] pre \{\s*width: auto;/);
+ assert.match(css, /html:not\(\[data-code-line-numbers\]\) :is\(\.aui-thread-root, \[data-code-preview\]\)/);
+});
+
+test("API examples drop their no-wrap overrides while Word wrap is on", () => {
+ const source = readSrc("features/settings/components/api-example-parts.tsx");
+ for (const utility of ["!whitespace-pre", "!break-normal", "!min-w-max"]) {
+ const uses = source.match(new RegExp(`\\S*:${utility.replace("!", "\\!")}(?=\\s|")`, "g")) ?? [];
+ assert.ok(uses.length > 0, utility);
+ for (const use of uses) assert.ok(use.startsWith("[html:not([data-code-wrap])_&"), use);
+ }
+});
diff --git a/studio/frontend/tests/chat-code-font-size.test.ts b/studio/frontend/tests/chat-code-font-size.test.ts
index c639226bd68..2043df3b2e5 100644
--- a/studio/frontend/tests/chat-code-font-size.test.ts
+++ b/studio/frontend/tests/chat-code-font-size.test.ts
@@ -10,12 +10,12 @@ test("chat code is 12px at any width, and the body's text-sm does not override i
const css = readSrc("index.css");
assert.match(
css,
- /\.aui-thread-root \[data-streamdown="code-block"\] \{\s*font-size: calc\(0\.75rem \* var\(--ui-font-scale, 1\)\);/,
+ /\.aui-thread-root(?:, \[data-code-preview\]\))? \[data-streamdown="code-block"\] \{\s*font-size: calc\(0\.75rem \* var\(--ui-font-scale, 1\)\);/,
);
assert.match(readSrc("components/assistant-ui/code-fence-defer.tsx"), /p-4 text-sm/);
assert.match(
css,
- /\.aui-thread-root \[data-streamdown="code-block-body"\] \{\s*font-size: inherit;\s*line-height: inherit;\s*\}/,
+ /\.aui-thread-root(?:, \[data-code-preview\]\))? \[data-streamdown="code-block-body"\] \{\s*font-size: inherit;\s*line-height: inherit;\s*\}/,
);
assert.match(readSrc("features/settings/stores/appearance-custom-store.ts"), /CODE_FONT_SIZE_RANGE = \{[^}]*default: 12 \}/);
});
diff --git a/studio/frontend/tests/settings-code-boxes.test.ts b/studio/frontend/tests/settings-code-boxes.test.ts
index 114debed97a..633cfab9820 100644
--- a/studio/frontend/tests/settings-code-boxes.test.ts
+++ b/studio/frontend/tests/settings-code-boxes.test.ts
@@ -50,9 +50,9 @@ test("long API examples are capped and scroll inside a keyboard-reachable region
// wrapped lines broke mid-token and ran back to the line-number gutter
const cls =
highlightedCode.match(/<section[\s\S]*?className="([^"]+)"/)?.[1] ?? "";
- assert.match(cls, /\[&_pre\]:!whitespace-pre(?!-)/);
+ assert.match(cls, /\[html:not\(\[data-code-wrap\]\)_&_pre\]:!whitespace-pre(?!-)/);
assert.doesNotMatch(cls, /break-words|break-all|whitespace-pre-wrap/);
- assert.match(cls, /\[&_\[data-streamdown=code-block\]\]:!min-w-max\b/);
+ assert.match(cls, /\[html:not\(\[data-code-wrap\]\)_&_\[data-streamdown=code-block\]\]:!min-w-max\b/);
// all three example sections share one code box
for (const caller of [USAGE, AUDIO, MEDIA]) {
assert.match(