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: toast icons centred on one line, top-aligned on longer toasts (#16050)
Michael Hanb5052abd2cd3
diff --git a/studio/frontend/src/components/ui/sonner.tsx b/studio/frontend/src/components/ui/sonner.tsxindex 5e175d54e83..3e2edae113f 100644--- a/studio/frontend/src/components/ui/sonner.tsx+++ b/studio/frontend/src/components/ui/sonner.tsx@@ -28,6 +28,56 @@ const handleToastPointerDownCapture = (event.stopPropagation();};+// Sonner has no line count: tag toasts whose text runs past one line, so CSS can+// centre a one-line toast's icon and top-align a longer one's.+function markMultilineToasts(scope: HTMLElement): () => void {+ const sized = new ResizeObserver((entries) => {+ for (const { target } of entries) {+ const toast = target.closest("[data-sonner-toast]");+ const text = target.querySelector("[data-title], [data-description]");+ if (!(toast && text)) continue;+ const line = Number.parseFloat(getComputedStyle(text).lineHeight);+ toast.toggleAttribute(+ "data-multiline",+ target.getBoundingClientRect().height > line * 1.5,+ );+ }+ });+ const observed = new Set<Element>();+ const watch = () => {+ for (const content of observed) {+ if (!scope.contains(content)) {+ sized.unobserve(content);+ observed.delete(content);+ }+ }+ for (const content of scope.querySelectorAll("[data-sonner-toast] [data-content]")) {+ if (!observed.has(content)) {+ sized.observe(content);+ observed.add(content);+ }+ }+ };+ watch();+ const added = new MutationObserver(watch);+ added.observe(scope, { childList: true, subtree: true });+ return () => {+ added.disconnect();+ sized.disconnect();+ observed.clear();+ };+}++function toasterScope(element: HTMLDivElement | null) {+ if (!element) return undefined;+ const releaseInsets = cornerInsetScope(element);+ const releaseLines = markMultilineToasts(element);+ return () => {+ releaseInsets?.();+ releaseLines();+ };+}+const Toaster = ({ ...props }: ToasterProps) => {// Use the resolved mode so data-sonner-theme matches the class on <html>.const { resolved } = useTheme();@@ -36,7 +86,7 @@ const Toaster = ({ ...props }: ToasterProps) => {// display:contents adds no box; only carries the selection-fix handler.// biome-ignore lint/a11y/noStaticElementInteractions: capture-only guard, not interactive<div- ref={cornerInsetScope}+ ref={toasterScope}style={{ display: "contents" }}onPointerDownCapture={handleToastPointerDownCapture}>diff --git a/studio/frontend/src/index.css b/studio/frontend/src/index.cssindex ffbacacf25a..0c182158585 100644--- a/studio/frontend/src/index.css+++ b/studio/frontend/src/index.css@@ -5052,14 +5052,20 @@ html[data-chat-font] .aui-root {box-shadow: var(--composer-shadow) !important;}-/* Icon centred on the first text line, so multi-line toasts keep it level with the title.- Title and description line heights are 1.5 and 1.4. */+/* Icon centred on the first text line; past one line (data-multiline, set in sonner.tsx) its top+ drops 0.08em to the title's cap height. Title and description line heights are 1.5 and 1.4. */[data-sonner-toast][data-styled='true'] [data-icon] {margin: calc((1.5em - var(--ui-icon-size)) / 2) 0 0 !important;}[data-sonner-toast][data-styled='true']:not(:has([data-title])) [data-icon] {margin-top: calc((1.4em - var(--ui-icon-size)) / 2) !important;}+[data-sonner-toast][data-styled='true'][data-multiline] [data-icon] {+ margin-top: calc((1.5em - var(--ui-icon-size)) / 2 + 0.08em) !important;+}+[data-sonner-toast][data-styled='true'][data-multiline]:not(:has([data-title])) [data-icon] {+ margin-top: calc((1.4em - var(--ui-icon-size)) / 2 + 0.08em) !important;+}[data-sonner-toast][data-styled='true'] [data-content] {min-width: 0;diff --git a/studio/frontend/tests/toast-offset.test.ts b/studio/frontend/tests/toast-offset.test.tsindex 04d73d6d4f9..65d7a0c0326 100644--- a/studio/frontend/tests/toast-offset.test.ts+++ b/studio/frontend/tests/toast-offset.test.ts@@ -286,11 +286,19 @@ test("the published corner card frame is re-read when the rail insets move the cassert.match(hook, /unsubscribe\(\);/);});+test("toasts that leave the toaster stop being observed", () => {+ const toaster = readSrc("components/ui/sonner.tsx");+ assert.match(toaster, /if \(!scope\.contains\(content\)\) \{\s*sized\.unobserve\(content\);\s*observed\.delete\(content\);/);+ assert.match(toaster, /if \(!observed\.has\(content\)\) \{\s*sized\.observe\(content\);\s*observed\.add\(content\);/);+});+test("panel insets are written to their consumers, never to <html>", () => {const sheet = readSrc("features/chat/chat-settings-sheet.tsx");assert.match(sheet, /return watchChatSettingsInset\(\s*cornerInsets,\s*asideRef\.current,/, "an inherited variable on <html> restyled the whole document on every drag frame");assert.match(readSrc("features/browser/native-view.ts"), /const style = cornerInsets\.style;/);- assert.match(readSrc("components/ui/sonner.tsx"), /<div\s+ref=\{cornerInsetScope\}\s+style=\{\{ display: "contents" \}\}/);+ const toaster = readSrc("components/ui/sonner.tsx");+ assert.match(toaster, /<div\s+ref=\{toasterScope\}\s+style=\{\{ display: "contents" \}\}/);+ assert.match(toaster, /function toasterScope\([\s\S]*?cornerInsetScope\(element\)/);assert.equal(readSrc("app/provider.tsx").match(/ref=\{cornerInsetScope\}\s*\/\/ Scrolls at the cap/g)?.length, 2, "both corner rails read the Run settings inset");for (const file of ["features/chat/chat-settings-sheet.tsx", "features/browser/native-view.ts", "lib/toast-offset.ts"]) {assert.equal(/documentElement\.style\.setProperty\((?:CHAT_SETTINGS_INSET_VAR|BROWSER_PAGE_INSET_VAR)/.test(readSrc(file)), false, file);