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: 12px code font, context usage ring and small sizing fixes (#12805)
Michael Hanede99a2a04ea
diff --git a/studio/frontend/src/components/assistant-ui/attachment.tsx b/studio/frontend/src/components/assistant-ui/attachment.tsxindex bb4addd2405..0acb7310d2c 100644--- a/studio/frontend/src/components/assistant-ui/attachment.tsx+++ b/studio/frontend/src/components/assistant-ui/attachment.tsx@@ -135,7 +135,7 @@ const FileCardBody: FC<{) : (<CardCenter>{center}</CardCenter>)}- <span className={cn("flex min-w-0 items-center gap-1.5 px-2.25 pb-1.75", preview && "pt-1.25")}>+ <span className={cn("flex min-w-0 items-center gap-1.5 px-2.25 pb-[calc(var(--spacing)*1.75-0.5px)]", preview && "pt-1.25")}>{icon ?? <AttachmentKindIcon kind={kind} className="size-3.25" />}<span className="min-w-0 truncate text-ui-11p5 leading-ui-15 text-foreground">{name}diff --git a/studio/frontend/src/components/assistant-ui/thread.tsx b/studio/frontend/src/components/assistant-ui/thread.tsxindex aa2117bd4b3..92d91bd0ebb 100644--- a/studio/frontend/src/components/assistant-ui/thread.tsx+++ b/studio/frontend/src/components/assistant-ui/thread.tsx@@ -8244,7 +8244,7 @@ const ForkMessageButton: FC = () => {disabled={forkDisabled}onClick={forkMessage}>- <HugeiconsIcon icon={ForkIcon} strokeWidth={1.75} className="size-icon" />+ <HugeiconsIcon icon={ForkIcon} strokeWidth={1.75} className="size-[calc(var(--icon-size)*0.97)]" /></TooltipIconButton>);};diff --git a/studio/frontend/src/features/browser/browser-toggle.tsx b/studio/frontend/src/features/browser/browser-toggle.tsxindex b0ec5aafdd4..072bebb64b2 100644--- a/studio/frontend/src/features/browser/browser-toggle.tsx+++ b/studio/frontend/src/features/browser/browser-toggle.tsx@@ -108,7 +108,7 @@ export function BrowserToggleButton({ active = true }: { active?: boolean }) {onClick={() => openTab()}className="flex size-[calc(30px*var(--ui-space-scale,1))] cursor-pointer items-center justify-center rounded-[10px] text-nav-fg transition-colors hover:bg-nav-surface-hover hover:text-black focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring aria-expanded:bg-nav-surface-hover aria-expanded:text-black dark:hover:text-white dark:aria-expanded:text-white">- <HugeiconsIcon icon={InternetIcon} strokeWidth={1.75} className="size-icon" />+ <HugeiconsIcon icon={InternetIcon} strokeWidth={1.75} className="size-[calc(var(--icon-size)*0.95)]" /></button></DropdownMenuTrigger><DropdownMenuContentdiff --git a/studio/frontend/src/features/chat/components/context-usage-bar.tsx b/studio/frontend/src/features/chat/components/context-usage-bar.tsxindex fa04e2285d6..2d42ae3ba26 100644--- a/studio/frontend/src/features/chat/components/context-usage-bar.tsx+++ b/studio/frontend/src/features/chat/components/context-usage-bar.tsx@@ -57,6 +57,49 @@ const UsageRing: FC<{ percent: number | null; stroke: string }> = ({</svg>);+const DOT_TRIM_CH = 0.15;++// Visible gap each side of the slash, less each glyph's side bearing (JetBrains Mono, in ch).+const SLASH_GAP_CH = 0.55;+function slashMargins(before: string, after: string): [number, number] {+ const beforeBearing = before === "k" ? 0.03 : before === "—" ? 0 : 0.11;+ const afterBearing = after === "1" ? 0.17 : 0.11;+ return [SLASH_GAP_CH - beforeBearing - 0.08, SLASH_GAP_CH - 0.12 - afterBearing];+}++// " / " becomes a slash with slashMargins either side, and each "." is pulled in by DOT_TRIM_CH.+function faceWidthCh(face: string): number {+ const dots = face.split(".").length - 1;+ const at = face.indexOf(" / ");+ const [left, right] = at >= 0 ? slashMargins(face[at - 1] ?? "", face[at + 3] ?? "") : [1, 1];+ return face.length + left + right - 2 - dots * 2 * DOT_TRIM_CH;+}++const TokenCount: FC<{ text: string }> = ({ text }) => (+ <>+ {text.split(".").map((part, i) => (+ <span key={i}>+ {/* 0.85em dot, margins in its own ch so it still takes 1 - 2 * DOT_TRIM_CH of the parent's. */}+ {i > 0 ? <span className="-mx-[0.088ch] text-[0.85em]">.</span> : null}+ {part}+ </span>+ ))}+ </>+);++const Face: FC<{ face: string }> = ({ face }) => {+ const slash = face.indexOf(" / ");+ if (slash < 0) return <span><TokenCount text={face} /></span>;+ const [left, right] = slashMargins(face[slash - 1] ?? "", face[slash + 3] ?? "");+ return (+ <span>+ <TokenCount text={face.slice(0, slash)} />+ <span style={{ marginLeft: `${left}ch`, marginRight: `${right}ch` }}>/</span>+ <TokenCount text={face.slice(slash + 3)} />+ </span>+ );+};+export const ContextUsageBar: FC<ContextUsageBarInput & { className?: string }> = ({ className, ...input }) => {@@ -68,10 +111,14 @@ export const ContextUsageBar: FC<: input;const { percent, advice, face, compactFace } = state;const severity = getSeverityColor(percent ?? 0);- // Mono text, so widths are exact in ch. Full: padding, face, and the gap and bar. Compact: an icon button.- const fullWidth = `calc(${face.length}ch + ${percent !== null ? 23 : 5} * var(--spacing))`;+ // The ring shows whenever there is a window to fill, even before anything is counted.+ const showRing = compactFace === null;+ // Mono text, so widths are exact in ch. Full: padding, face, and the gap and ring. Compact: an icon button.+ const fullWidth = showRing+ ? `calc(${faceWidthCh(face)}ch + var(--icon-size) + 7 * var(--spacing))`+ : `calc(${faceWidthCh(face)}ch + 5 * var(--spacing))`;const compactWidth =- compactFace === null ? "calc(30px * var(--ui-space-scale, 1))" : `calc(${compactFace.length}ch + 5 * var(--spacing))`;+ compactFace === null ? "calc(30px * var(--ui-space-scale, 1))" : `calc(${faceWidthCh(compactFace)}ch + 5 * var(--spacing))`;const hover = "rounded-[10px] transition-colors group-hover:bg-chat-icon-bg-hover";return (@@ -99,8 +146,8 @@ export const ContextUsageBar: FC<}}className={cn("group grid h-full items-center justify-self-end overflow-hidden rounded-[10px] text-chat-icon-fg tabular-nums whitespace-nowrap hover:text-chat-icon-fg-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",- // ring and bar track- "[--track:rgb(0_0_0_/_calc(0.1*var(--contrast-wash-gain,1)))] dark:[--track:rgb(255_255_255_/_calc(0.15*var(--contrast-wash-gain,1)))]",+ // ring track+ "[--track:rgb(0_0_0_/_calc(0.14*var(--contrast-wash-gain,1)))] dark:[--track:rgb(255_255_255_/_calc(0.2*var(--contrast-wash-gain,1)))]",)}>{/* Exactly one of these has width, matching the button's. */}@@ -113,7 +160,7 @@ export const ContextUsageBar: FC<<UsageRing percent={percent} stroke={severity.stroke} /></span>) : (- <span className={cn("flex h-full shrink-0 items-center px-2.5", hover)}>{compactFace}</span>+ <span className={cn("flex h-full shrink-0 items-center px-2.5", hover)}><Face face={compactFace} /></span>)}</span><span@@ -121,15 +168,8 @@ export const ContextUsageBar: FC<style={{ width: "clamp(0px, (100% - var(--full) + 1px) * 999, var(--full))" }}><span className={cn("flex h-full w-(--full) items-center gap-2 px-2.5", hover)}>- <span>{face}</span>- {percent !== null ? (- <span className="h-1.5 w-16 shrink-0 overflow-hidden rounded-full bg-(--track)">- <span- className={cn("block h-full rounded-full transition-all", severity.bar)}- style={{ width: `${percent}%` }}- />- </span>- ) : null}+ <Face face={face} />+ {showRing ? <UsageRing percent={percent} stroke={severity.stroke} /> : null}</span></span></button>diff --git a/studio/frontend/src/features/settings/stores/appearance-custom-store.ts b/studio/frontend/src/features/settings/stores/appearance-custom-store.tsindex 75b06f98ed3..ae086769c13 100644--- a/studio/frontend/src/features/settings/stores/appearance-custom-store.ts+++ b/studio/frontend/src/features/settings/stores/appearance-custom-store.ts@@ -292,7 +292,7 @@ export const DEFAULT_CUSTOMIZATION: AppearanceCustomization = {};export const UI_FONT_SIZE_RANGE = { min: 12, max: 20, default: 15 } as const;-export const CODE_FONT_SIZE_RANGE = { min: 10, max: 20, default: 13 } as const;+export const CODE_FONT_SIZE_RANGE = { min: 10, max: 20, default: 12 } as const;const UI_FONT_SIZE_CSS_BASE = 16;/**diff --git a/studio/frontend/src/index.css b/studio/frontend/src/index.cssindex a4e9ce235dc..2f871e8a08c 100644--- a/studio/frontend/src/index.css+++ b/studio/frontend/src/index.css@@ -4325,21 +4325,23 @@ html[data-chat-font] .aui-root {width: 0 !important;}- /* Chat thread: code slightly smaller by default; step up when the thread column is wide. */+ /* Chat code is 12px at any width (CODE_FONT_SIZE_RANGE.default); the header steps up when wide. */.aui-thread-root [data-streamdown="code-block"] {- font-size: calc(0.8125rem * var(--ui-font-scale, 1));+ 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"] {+ font-size: inherit;+ line-height: inherit;+ }+.aui-thread-root [data-streamdown="code-block-header"] {font-size: calc(0.6875rem * var(--ui-font-scale, 1));}@container (min-width: 36rem) {- .aui-thread-root [data-streamdown="code-block"] {- font-size: calc(0.875rem * var(--ui-font-scale, 1));- }-.aui-thread-root [data-streamdown="code-block-header"] {font-size: calc(0.75rem * var(--ui-font-scale, 1));}diff --git a/studio/frontend/tests/chat-code-font-size.test.ts b/studio/frontend/tests/chat-code-font-size.test.tsnew file mode 100644index 00000000000..c6a10dc66e7--- /dev/null+++ b/studio/frontend/tests/chat-code-font-size.test.ts@@ -0,0 +1,24 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0++// Chat code defaults to 12px, matching the Code font size setting's default.++import assert from "node:assert/strict";+import test from "node:test";++import { readSrc } from "./helpers/kit.ts";++test("chat code is 12px at any width, and the body's text-sm does not override it", () => {+ 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\)\);/,+ );+ // FenceShell and StreamingFenceBlock put text-sm on the body.+ 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*\}/,+ );+ assert.match(readSrc("features/settings/stores/appearance-custom-store.ts"), /CODE_FONT_SIZE_RANGE = \{[^}]*default: 12 \}/);+});diff --git a/studio/frontend/tests/context-usage-compact.test.ts b/studio/frontend/tests/context-usage-compact.test.tsindex 2e747caf5ef..1e758b4cf71 100644--- a/studio/frontend/tests/context-usage-compact.test.ts+++ b/studio/frontend/tests/context-usage-compact.test.ts@@ -1,7 +1,7 @@// SPDX-License-Identifier: AGPL-3.0-only// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0-// When the chat header is squeezed, the context bar shrinks to a ring.+// The context usage shows its counts beside a ring; squeezed, the ring alone.import assert from "node:assert/strict";import test from "node:test";@@ -29,3 +29,12 @@ test("the header shrinks the context bar before the model name", () => {assert.match(page, /"pointer-events-auto flex min-w-0 items-center gap-1"/);assert.match(page, /ml-auto flex min-w-min max-w-max grow basis-0 items-center gap-1 \*:shrink-0/);});++test("both faces draw the ring, not the line", () => {+ const bar = readSrc("features/chat/components/context-usage-bar.tsx");+ assert.match(bar, /\{compactFace === null \? \(\s*<span[^>]*>\s*<UsageRing /);+ // Empty before anything is counted, but still drawn.+ assert.match(bar, /const showRing = compactFace === null;/);+ assert.match(bar, /\{showRing \? <UsageRing percent=\{percent\} stroke=\{severity\.stroke\} \/> : null\}/);+ assert.doesNotMatch(bar, /style=\{\{ width: `\$\{percent\}%` \}\}/);+});