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: keep the memory row readable on a narrow panel (#9824)
Daniel Han7457e94dd67b
diff --git a/studio/frontend/src/features/model-picker/components/model-config-page.tsx b/studio/frontend/src/features/model-picker/components/model-config-page.tsxindex 5eacf085e48..12df88fb312 100644--- a/studio/frontend/src/features/model-picker/components/model-config-page.tsx+++ b/studio/frontend/src/features/model-picker/components/model-config-page.tsx@@ -80,6 +80,7 @@ import { resolveEstimateContext } from "../model-config/estimate-context";import {type MemoryFitVerdict,formatMemoryGb,+ glueNoteItems,resolveDraftCacheNote,resolveKvNote,resolveMemoryFit,@@ -955,7 +956,7 @@ function MemoryBreakdownLine({<span className="min-w-0 text-ui-11 leading-relaxed text-muted-foreground">{label}{note ? (- <span className="ml-1 text-muted-foreground/70">{note}</span>+ <span className="ml-1 text-muted-foreground/70">{glueNoteItems(note)}</span>) : null}</span><span@@ -1035,7 +1036,13 @@ function MemoryEstimateRow({);return (<div className="space-y-2">- <div className={ROW_CLASS}>+ {/* Wraps, unlike the other rows, because this one is the only header carrying a+ title AND two figures. The panel is w-[min(468px,...)], so under a ~460px+ window it shrinks with the viewport, and the figures do not shrink: the+ title absorbed the whole shortfall and truncated to "E..." at 320px. Letting+ the figures drop to their own line costs a line only where they would not+ have fitted anyway, and is identical above that width. */}+ <div className={`${ROW_CLASS} flex-wrap gap-y-1`}><buttontype="button"onClick={() => onExpandedChange(!expanded)}@@ -1053,8 +1060,10 @@ function MemoryEstimateRow({strokeWidth={1.75}/></button>+ {/* ml-auto so that on the wrapped line, where justify-between has nothing to+ push against, the figures still sit under the right edge they had. */}<div- className={`flex shrink-0 items-center gap-3 transition-opacity ${stale || loading ? "opacity-50" : ""}`}+ className={`ml-auto flex shrink-0 items-center gap-3 transition-opacity ${stale || loading ? "opacity-50" : ""}`}>{/* One pool: offloading a layer moves it within the same memory ratherthan out of it, so the honest single figure is the total. Reportingdiff --git a/studio/frontend/src/features/model-picker/model-config/memory-fit.ts b/studio/frontend/src/features/model-picker/model-config/memory-fit.tsindex 6b894b9e694..37fe141121b 100644--- a/studio/frontend/src/features/model-picker/model-config/memory-fit.ts+++ b/studio/frontend/src/features/model-picker/model-config/memory-fit.ts@@ -316,6 +316,38 @@ export function resolveMemoryAdvisory(return null;}+/** What `resolveKvNote` joins its items with, and what `glueNoteItems` splits on. */+export const NOTE_SEPARATOR = " · ";++/**+ * A separated caption, breakable only between its items.+ *+ * A caption like "f16 · 262,144 tokens · 4 slots" does not fit the panel once the+ * window is narrow enough to shrink it, and left to itself the browser breaks at the+ * last space that fits -- which put "slots" alone on a line under "... tokens · 4".+ * Gluing each item together with U+00A0 leaves exactly one break opportunity per+ * bullet, and gluing the bullet to the item that FOLLOWS it means the break lands+ * before the bullet rather than orphaning it at the end of the previous line.+ *+ * A note with NO separator is returned untouched. It has no items to keep apart, so+ * gluing it would buy nothing and cost every break opportunity it had: the Weights and+ * Draft cache notes are ordinary prose ("256 of 257 layers on GPU"), and glued they+ * became a single unbreakable run that overflows the caption column rather than+ * wrapping inside it, which is worse than the orphan this function exists to prevent.+ */+export function glueNoteItems(note: string): string {+ const items = note.split(NOTE_SEPARATOR);+ if (items.length < 2) {+ return note;+ }+ return items+ .map((item, index) => {+ const glued = item.replace(/ /g, "\u00a0");+ return index === 0 ? glued : `\u00b7\u00a0${glued}`;+ })+ .join(" ");+}+/** The KV line's caption: dtype, what was priced, and where it lives. */export function resolveKvNote(estimate: {cacheTypeKv: string | null;diff --git a/studio/frontend/tests/memory-estimate-narrow-panel.test.ts b/studio/frontend/tests/memory-estimate-narrow-panel.test.tsnew file mode 100644index 00000000000..ef64b93f18d--- /dev/null+++ b/studio/frontend/tests/memory-estimate-narrow-panel.test.ts@@ -0,0 +1,108 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0++// The Estimated Memory Usage header is the only row in the panel carrying a title AND+// two figures, and the panel is w-[min(468px,calc(100vw-1rem))] -- so under a ~460px+// window it shrinks while the figures do not. Measured on the merged build at 320px+// the title had been squeezed from 150px to 11px and rendered as "E...", which is what+// was reported. The layout half is asserted against the source, the idiom+// tensor-parallel-row-gating already uses for markup that cannot be imported; the note+// half is a pure function and is exercised directly.++import assert from "node:assert/strict";+import { readFileSync } from "node:fs";+import path from "node:path";+import test from "node:test";+import { fileURLToPath } from "node:url";++import {+ glueNoteItems,+ resolveDraftCacheNote,+ resolveKvNote,+} from "../src/features/model-picker/model-config/memory-fit.ts";++const HERE = path.dirname(fileURLToPath(import.meta.url));+const CONFIG_PAGE = readFileSync(+ path.join(+ HERE,+ "..",+ "src/features/model-picker/components/model-config-page.tsx",+ ),+ "utf8",+);++const NBSP = " ";++test("the memory header may wrap, so the figures drop rather than eat the title", () => {+ assert.match(CONFIG_PAGE, /\$\{ROW_CLASS\} flex-wrap gap-y-1/);+});++test("the wrapped figures still sit at the right edge", () => {+ // justify-between has nothing to push against on a line holding one item, so+ // without this the figures jump to the left margin when they wrap.+ assert.match(CONFIG_PAGE, /className=\{`ml-auto flex shrink-0 items-center gap-3/);+});++test("the header title is still allowed to truncate as a backstop", () => {+ // Wrapping is what keeps it whole at the widths that matter; truncation stays for a+ // locale whose title does not fit a line of its own. Dropping min-w-0 here would+ // overflow the panel instead.+ assert.match(+ CONFIG_PAGE,+ /className="flex min-w-0 items-center gap-1\.5 rounded-sm text-left/,+ );+});++test("breakdown notes are rendered glued", () => {+ assert.match(CONFIG_PAGE, /\{glueNoteItems\(note\)\}/);+});++test("an item's own spaces do not break", () => {+ const glued = glueNoteItems("f16 · 262,144 tokens · 4 slots");+ assert.equal(glued, `f16 ·${NBSP}262,144${NBSP}tokens ·${NBSP}4${NBSP}slots`);+ // The only ordinary spaces left are the ones a line may break at: one per bullet.+ assert.equal(glued.split(" ").length - 1, 2);+});++test("the bullet leads its item, so a break cannot orphan it", () => {+ for (const item of glueNoteItems("f16 · 4 slots").split(" ").slice(1)) {+ assert.ok(item.startsWith(`·${NBSP}`), `bullet detached from ${item}`);+ }+});++test("a note with no separator keeps every break opportunity it had", () => {+ // Only the KV caption is a list. Weights and Draft cache are ordinary prose, and+ // gluing those bought nothing while costing them the ability to wrap at all, so a+ // long one ran past the caption column into the value instead of wrapping inside it.+ for (const note of [+ "256 of 257 layers on GPU",+ "2.14 GB on GPU",+ "host RAM",+ "f16",+ ]) {+ assert.equal(glueNoteItems(note), note);+ assert.doesNotMatch(glueNoteItems(note), new RegExp(NBSP));+ }+});++test("the notes the row actually builds are left breakable", () => {+ // The two non-list note sources, at their real call sites in model-config-page.+ assert.match(CONFIG_PAGE, /layers on GPU`/);+ const hostNote = resolveDraftCacheNote(0, 1e9);+ assert.equal(hostNote, "host RAM");+ for (const note of ["256 of 257 layers on GPU", hostNote ?? ""]) {+ const spaces = (glueNoteItems(note).match(/ /g) || []).length;+ assert.ok(spaces > 0, `${note} has no break opportunity left`);+ }+});++test("gluing round-trips the note the row actually builds", () => {+ const note = resolveKvNote({+ cacheTypeKv: "q8_0",+ nCtx: 262144,+ nParallel: 4,+ kvOnGpu: false,+ });+ // Same text to a reader, and to anyone grepping the panel: only the spaces differ.+ assert.equal(glueNoteItems(note).replace(new RegExp(NBSP, "g"), " "), note);+});