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: clip every rounded scroller in Firefox, dropping the overflow watcher (#12438)
Michael Han2c72350ff578
diff --git a/studio/frontend/src/components/ui/alert-dialog.tsx b/studio/frontend/src/components/ui/alert-dialog.tsxindex 124cf57ce05..1cf45f19a16 100644--- a/studio/frontend/src/components/ui/alert-dialog.tsx+++ b/studio/frontend/src/components/ui/alert-dialog.tsx@@ -6,7 +6,6 @@ import { AlertDialog as AlertDialogPrimitive } from "radix-ui";import type * as React from "react";import { Button } from "@/components/ui/button";-import { useScrollOverflowRef } from "@/lib/scroll-overflow";import { cn } from "@/lib/utils";function AlertDialog({@@ -55,7 +54,6 @@ function AlertDialogContent({size = "default",overlayClassName,onOverlayClick,- ref,...props}: React.ComponentProps<typeof AlertDialogPrimitive.Content> & {size?: "default" | "sm";@@ -63,13 +61,10 @@ function AlertDialogContent({/** Alert dialogs ignore outside clicks; set this to cancel on backdrop click. */onOverlayClick?: () => void;}) {- // Clipped to its radius in Firefox only while it overflows, like DialogContent.- const contentRef = useScrollOverflowRef(ref);return (<AlertDialogPortal><AlertDialogOverlay className={overlayClassName} onClick={onOverlayClick} /><AlertDialogPrimitive.Content- ref={contentRef}data-slot="alert-dialog-content"data-size={size}className={cn(diff --git a/studio/frontend/src/components/ui/dialog.tsx b/studio/frontend/src/components/ui/dialog.tsxindex 8705f0f0b76..64c04dfe438 100644--- a/studio/frontend/src/components/ui/dialog.tsx+++ b/studio/frontend/src/components/ui/dialog.tsx@@ -10,7 +10,6 @@ import type * as React from "react";import { createContext, useContext } from "react";import { Button } from "@/components/ui/button";-import { useScrollOverflowRef } from "@/lib/scroll-overflow";import { cn } from "@/lib/utils";import { Cancel01Icon } from "@hugeicons/core-free-icons";import { HugeiconsIcon } from "@hugeicons/react";@@ -79,7 +78,6 @@ function DialogContent({overlayClassName,overlayPosition,onInteractOutside,- ref,...props}: React.ComponentProps<typeof DialogPrimitive.Content> & {showCloseButton?: boolean;@@ -89,8 +87,6 @@ function DialogContent({overlayPosition?: "fixed" | "absolute";}) {const resolvedContainer = container ?? null;- // Firefox clips a scrolling dialog to its radius only while it overflows, keeping its shadow.- const contentRef = useScrollOverflowRef(ref);return (<DialogPortalContainerContext.Provider value={resolvedContainer}><DialogPortal container={resolvedContainer ?? undefined}>@@ -99,7 +95,6 @@ function DialogContent({position={overlayPosition ?? position}/><DialogPrimitive.Content- ref={contentRef}data-slot="dialog-content"className={cn(// max-h + scroll keeps tall dialogs reachable on short viewports; a call sitediff --git a/studio/frontend/src/features/recipe-studio/dialogs/config-dialog.tsx b/studio/frontend/src/features/recipe-studio/dialogs/config-dialog.tsxindex 71d170de2b6..e76008493af 100644--- a/studio/frontend/src/features/recipe-studio/dialogs/config-dialog.tsx+++ b/studio/frontend/src/features/recipe-studio/dialogs/config-dialog.tsx@@ -2,7 +2,7 @@// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0import { Button } from "@/components/ui/button";-import { Dialog, DialogContent, DialogFooter } from "@/components/ui/dialog";+import { Dialog, DialogFooter } from "@/components/ui/dialog";import { Switch } from "@/components/ui/switch";import type { ReactElement } from "react";import { getBlockDefinitionForConfig } from "../blocks/definitions";@@ -10,6 +10,7 @@ import { renderBlockDialog } from "../blocks/registry";import type { NodeConfig, SamplerConfig } from "../types";import { DialogShell } from "./shared/dialog-shell";import { ValidationBanner } from "./shared/validation-banner";+import { RecipeDialogContent } from "./shared/recipe-dialog-content";type ConfigDialogProps = {open: boolean;@@ -51,13 +52,7 @@ export function ConfigDialog({return (<Dialog open={open} onOpenChange={onOpenChange}>- <DialogContent- container={container}- position="absolute"- overlayPosition="absolute"- overlayClassName="bg-transparent"- className="corner-squircle max-h-[min(calc(650px*var(--ui-space-scale,1)),calc(100dvh-var(--studio-window-chrome-top,0px)-2rem))] overflow-y-auto overflow-x-hidden sm:max-w-2xl shadow-border"- >+ <RecipeDialogContent container={container}><DialogShelltitle={blockDefinition ? blockDefinition.title : undefined}description={@@ -120,7 +115,7 @@ export function ConfigDialog({Done</Button></DialogFooter>- </DialogContent>+ </RecipeDialogContent></Dialog>);}diff --git a/studio/frontend/src/features/recipe-studio/dialogs/import-dialog.tsx b/studio/frontend/src/features/recipe-studio/dialogs/import-dialog.tsxindex f392846190a..3b5756ae9df 100644--- a/studio/frontend/src/features/recipe-studio/dialogs/import-dialog.tsx+++ b/studio/frontend/src/features/recipe-studio/dialogs/import-dialog.tsx@@ -4,7 +4,6 @@import { Button } from "@/components/ui/button";import {Dialog,- DialogContent,DialogFooter,DialogHeader,DialogTitle,@@ -12,6 +11,7 @@ import {import { Textarea } from "@/components/ui/textarea";import { type ReactElement, useState } from "react";import { FieldLabel } from "./shared/field-label";+import { RecipeDialogContent } from "./shared/recipe-dialog-content";type ImportDialogProps = {open: boolean;@@ -48,12 +48,9 @@ export function ImportDialog({return (<Dialog open={open} onOpenChange={handleOpenChange}>- <DialogContent+ <RecipeDialogContentcontainer={container}- position="absolute"- overlayPosition="absolute"- overlayClassName="bg-transparent"- className="corner-squircle max-h-[min(calc(650px*var(--ui-space-scale,1)),calc(100dvh-var(--studio-window-chrome-top,0px)-2rem))] overflow-auto sm:max-w-2xl shadow-border"+ viewportClassName="overflow-auto"><DialogHeader><DialogTitle>Import recipe</DialogTitle>@@ -82,7 +79,7 @@ export function ImportDialog({Import recipe</Button></DialogFooter>- </DialogContent>+ </RecipeDialogContent></Dialog>);}diff --git a/studio/frontend/src/features/recipe-studio/dialogs/preview-dialog.tsx b/studio/frontend/src/features/recipe-studio/dialogs/preview-dialog.tsxindex b9b8d3e0296..f9c234edb93 100644--- a/studio/frontend/src/features/recipe-studio/dialogs/preview-dialog.tsx+++ b/studio/frontend/src/features/recipe-studio/dialogs/preview-dialog.tsx@@ -10,7 +10,6 @@ import {} from "@/components/ui/collapsible";import {Dialog,- DialogContent,DialogFooter,DialogHeader,DialogTitle,@@ -30,6 +29,7 @@ import { type ReactElement, type ReactNode, useState } from "react";import type { RecipeExecutionKind } from "../execution-types";import type { RecipeRunSettings } from "../stores/recipe-executions";import { FieldLabel } from "./shared/field-label";+import { RecipeDialogContent } from "./shared/recipe-dialog-content";type RunDialogProps = {open: boolean;@@ -716,19 +716,16 @@ export function RunDialog({return (<Dialog open={open} onOpenChange={onOpenChange}>- <DialogContent+ <RecipeDialogContentcontainer={container}- position="absolute"- overlayPosition="absolute"- overlayClassName="bg-transparent"- className="corner-squircle max-h-[min(calc(650px*var(--ui-space-scale,1)),calc(100dvh-var(--studio-window-chrome-top,0px)-2rem))] overflow-y-auto overflow-x-hidden border-border/70 bg-background/95 sm:max-w-2xl shadow-border backdrop-blur-xl"+ className="border-border/70 bg-background/95 backdrop-blur-xl"><RunDialogBodykey={draftKey}{...contentProps}onClose={() => onOpenChange(false)}/>- </DialogContent>+ </RecipeDialogContent></Dialog>);}diff --git a/studio/frontend/src/features/recipe-studio/dialogs/processors-dialog.tsx b/studio/frontend/src/features/recipe-studio/dialogs/processors-dialog.tsxindex 15d89f5aac4..6b6246cd241 100644--- a/studio/frontend/src/features/recipe-studio/dialogs/processors-dialog.tsx+++ b/studio/frontend/src/features/recipe-studio/dialogs/processors-dialog.tsx@@ -2,7 +2,7 @@// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0import { Button } from "@/components/ui/button";-import { Dialog, DialogContent, DialogFooter, DialogTitle } from "@/components/ui/dialog";+import { Dialog, DialogFooter, DialogTitle } from "@/components/ui/dialog";import { Input } from "@/components/ui/input";import { Switch } from "@/components/ui/switch";import { Textarea } from "@/components/ui/textarea";@@ -12,6 +12,7 @@ import type { RecipeProcessorConfig } from "../types";import { buildDefaultSchemaTransform } from "../utils/processors";import { AvailableVariables } from "./shared/available-variables";import { FieldLabel } from "./shared/field-label";+import { RecipeDialogContent } from "./shared/recipe-dialog-content";type ProcessorsDialogProps = {open: boolean;onOpenChange: (open: boolean) => void;@@ -66,12 +67,9 @@ export function ProcessorsDialog({return (<Dialog open={open} onOpenChange={onOpenChange}>- <DialogContent+ <RecipeDialogContentcontainer={container}- position="absolute"- overlayPosition="absolute"- overlayClassName="bg-transparent"- className="corner-squircle max-h-[min(calc(650px*var(--ui-space-scale,1)),calc(100dvh-var(--studio-window-chrome-top,0px)-2rem))] overflow-auto sm:max-w-2xl shadow-border"+ viewportClassName="overflow-auto"><VisuallyHidden.Root><DialogTitle>Processors</DialogTitle>@@ -136,7 +134,7 @@ export function ProcessorsDialog({Done</Button></DialogFooter>- </DialogContent>+ </RecipeDialogContent></Dialog>);}diff --git a/studio/frontend/src/features/recipe-studio/dialogs/shared/recipe-dialog-content.tsx b/studio/frontend/src/features/recipe-studio/dialogs/shared/recipe-dialog-content.tsxnew file mode 100644index 00000000000..d6e1708862b--- /dev/null+++ b/studio/frontend/src/features/recipe-studio/dialogs/shared/recipe-dialog-content.tsx@@ -0,0 +1,41 @@+// 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 type { ComponentProps, ReactElement } from "react";++import { DialogContent } from "@/components/ui/dialog";+import { cn } from "@/lib/utils";++/** A recipe dialog over the canvas. The overlay is clear, so the shadow is its edge: Firefox's+ * .scroll-rounded clip would cut it, so an inner viewport scrolls instead of the shadowed box. */+export function RecipeDialogContent({+ className,+ viewportClassName,+ children,+ ...props+}: ComponentProps<typeof DialogContent> & {+ viewportClassName?: string;+}): ReactElement {+ return (+ <DialogContent+ position="absolute"+ overlayPosition="absolute"+ overlayClassName="bg-transparent"+ className={cn(+ "corner-squircle flex max-h-[min(calc(650px*var(--ui-space-scale,1)),calc(100dvh-var(--studio-window-chrome-top,0px)-2rem))] flex-col overflow-hidden p-0 sm:max-w-2xl shadow-border",+ className,+ )}+ {...props}+ >+ <div+ data-slot="recipe-dialog-viewport"+ className={cn(+ "grid min-h-0 gap-6 overflow-y-auto overflow-x-hidden scroll-rounded rounded-4xl px-7 pt-8 pb-7",+ viewportClassName,+ )}+ >+ {children}+ </div>+ </DialogContent>+ );+}diff --git a/studio/frontend/src/index.css b/studio/frontend/src/index.cssindex 56819171ef2..9a39d582863 100644--- a/studio/frontend/src/index.css+++ b/studio/frontend/src/index.css@@ -4958,11 +4958,11 @@ html.force-reduced-motion .sidebar-section-drop-line {margin-inline: var(--scroll-radius, 0px);}-/* Firefox has no track to inset, so clip the box back to its radius. 1px out keeps a ring-1.- The clip also cuts an outer shadow: dialogs, which carry one, are watched and clipped only while- they overflow (lib/scroll-overflow.ts), and shadowed menus and panels scroll an inner viewport. */+/* Firefox has no track to inset, so clip the box back to its radius. 1px out keeps a ring-1;+ an outer shadow would be clipped, so surfaces with one scroll an inner viewport instead.+ overflow-hidden has no scrollbar to clip: chat search and every CommandDialog keep their shadow. */@supports (-moz-appearance: none) {- :is(.scroll-rounded:not([data-overflow-watched]), .scroll-rounded[data-overflowing], .hub-readme-prose pre) {+ :is(.scroll-rounded:not(.overflow-hidden), .hub-readme-prose pre) {clip-path: inset(-1px round calc(var(--scroll-radius, 0px) + 1px));}}diff --git a/studio/frontend/src/lib/scroll-overflow.ts b/studio/frontend/src/lib/scroll-overflow.tsdeleted file mode 100644index d196a0ab6ff..00000000000--- a/studio/frontend/src/lib/scroll-overflow.ts+++ /dev/null@@ -1,72 +0,0 @@-// 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 type * as React from "react";-import { useCallback } from "react";--/**- * Marks a scroll container `data-overflowing` while it has something to scroll.- *- * Firefox drops a rounded scroller's radius on its scrollbar side, and `.scroll-rounded` clips the- * box back to it. The clip also cuts an outer shadow, so a surface that carries one (a dialog)- * takes it only while it overflows: with nothing to scroll there is no scrollbar to square it.- *- * Watches the box and each child in it, since content growing inside a capped box leaves the box- * itself the same size. Writes the DOM only on a change, never state. `data-overflow-watched` says- * the flag is live, so the clip can wait for it.- */-export function observeScrollOverflow(element: HTMLElement): () => void {- element.setAttribute("data-overflow-watched", "");- const sync = () => {- // No tolerance: a single pixel over is enough for overflow:auto to draw a scrollbar. A rounding- // false positive only clips a shadow; a miss squares the corners.- const overflowing =- element.scrollHeight > element.clientHeight ||- element.scrollWidth > element.clientWidth;- if (overflowing !== element.hasAttribute("data-overflowing")) {- element.toggleAttribute("data-overflowing", overflowing);- }- };- const sizes = new ResizeObserver(sync);- sizes.observe(element);- for (const child of element.children) sizes.observe(child);- const children = new MutationObserver((records) => {- for (const record of records) {- for (const node of record.removedNodes) {- if (node instanceof Element) sizes.unobserve(node);- }- for (const node of record.addedNodes) {- if (node instanceof Element) sizes.observe(node);- }- }- sync();- });- children.observe(element, { childList: true });- sync();- return () => {- sizes.disconnect();- children.disconnect();- element.removeAttribute("data-overflow-watched");- element.removeAttribute("data-overflowing");- };-}--/** A callback ref that forwards to `ref` and runs {@link observeScrollOverflow} while mounted. */-export function useScrollOverflowRef<T extends HTMLElement>(- ref: React.Ref<T> | undefined,-): (element: T | null) => (() => void) | undefined {- return useCallback(- (element: T | null) => {- if (typeof ref === "function") ref(element);- else if (ref) ref.current = element;- if (!element || typeof ResizeObserver === "undefined") return undefined;- const stop = observeScrollOverflow(element);- return () => {- stop();- if (typeof ref === "function") ref(null);- else if (ref) ref.current = null;- };- },- [ref],- );-}diff --git a/studio/frontend/tests/dialog-scrollbar-corners.test.ts b/studio/frontend/tests/dialog-scrollbar-corners.test.tsindex 3c7880c32e3..80bcaa9b50f 100644--- a/studio/frontend/tests/dialog-scrollbar-corners.test.ts+++ b/studio/frontend/tests/dialog-scrollbar-corners.test.ts@@ -35,36 +35,20 @@ test("scroll-rounded insets the track in Chromium and WebKit and clips in Firefo`${targets} \\{\\s*scrollbar-width: auto;\\s*scrollbar-color: auto;`,),);- // Watched surfaces (dialogs, which carry a shadow the clip would cut) take it only while they- // overflow; everything else always does.- assert.ok(- css.includes(- "@supports (-moz-appearance: none) {\n\t:is(.scroll-rounded:not([data-overflow-watched]), .scroll-rounded[data-overflowing], .hub-readme-prose pre) {\n\t\tclip-path: inset(-1px round calc(var(--scroll-radius, 0px) + 1px));",+ assert.match(+ css,+ new RegExp(+ String.raw`@supports \(-moz-appearance: none\) \{\s*` ++ String.raw`:is\(\.scroll-rounded:not\(\.overflow-hidden\), \.hub-readme-prose pre\) \{\s*` ++ String.raw`clip-path: inset\(-1px round calc\(var\(--scroll-radius, 0px\) \+ 1px\)\);`,),);+ // No watcher: every .scroll-rounded box that scrolls takes the clip, dialogs included.+ assert.doesNotMatch(css, /data-overflow-watched|data-overflowing/);// Phone-width dialogs go square, and the clip must follow.assert.ok(css.includes(String.raw`.scroll-rounded.max-sm\:rounded-none { --scroll-radius: 0px; }`));});-test("dialogs flag their overflow so Firefox clips them only while they scroll", () => {- for (const file of ["components/ui/dialog.tsx", "components/ui/alert-dialog.tsx"]) {- const source = readSrc(file);- assert.match(source, /const contentRef = useScrollOverflowRef\(ref\);/, file);- assert.match(source, /ref=\{contentRef\}/, file);- }- const lib = readSrc("lib/scroll-overflow.ts");- assert.match(lib, /element\.setAttribute\("data-overflow-watched", ""\);/);- assert.match(lib, /element\.toggleAttribute\("data-overflowing", overflowing\);/);- // Any overflow counts: one pixel over already draws a scrollbar.- assert.match(- lib,- /element\.scrollHeight > element\.clientHeight \|\|\s*element\.scrollWidth > element\.clientWidth;/,- );- // Content growing inside a capped box leaves the box the same size, so the children are watched.- assert.match(lib, /for \(const child of element\.children\) sizes\.observe\(child\);/);- assert.match(lib, /children\.observe\(element, \{ childList: true \}\);/);-});-test("dialogs and inline rounded scrollers use it", () => {for (const [file, needle] of [["components/ui/dialog.tsx", "overflow-y-auto scroll-rounded rounded-4xl"],@@ -80,6 +64,30 @@ test("dialogs and inline rounded scrollers use it", () => {}});+// Chat search is borderless with a clear overlay, so its shadow is its only edge. CommandDialog hides+// its overflow (the list scrolls inside), which keeps it out of the Firefox clip.+test("command dialogs keep their shadow in Firefox", () => {+ const command = readSrc("components/ui/command.tsx");+ assert.match(command, /rounded-4xl! max-sm:rounded-none! top-1\/3 translate-y-0 overflow-hidden p-0/);+ const search = readSrc("features/chat/components/chat-search-dialog.tsx");+ assert.match(search, /<CommandDialog[\s\S]*className="chat-search-surface /);+ assert.doesNotMatch(search, /className="chat-search-surface [^"]*overflow-(y-)?(auto|scroll)/);+});++// Recipe dialogs float over the canvas on a clear overlay with shadow-border, so they scroll an inner+// viewport too: the shadowed box hides its overflow and stays out of the Firefox clip.+test("recipe dialogs scroll an inner viewport, keeping their shadow", () => {+ const shared = readSrc("features/recipe-studio/dialogs/shared/recipe-dialog-content.tsx");+ assert.match(shared, /overlayClassName="bg-transparent"/);+ assert.match(shared, /"corner-squircle flex max-h-\[[^"]*\] flex-col overflow-hidden p-0 sm:max-w-2xl shadow-border"/);+ assert.match(shared, /"grid min-h-0 gap-6 overflow-y-auto overflow-x-hidden scroll-rounded rounded-4xl px-7 pt-8 pb-7"/);+ for (const file of ["config-dialog", "import-dialog", "processors-dialog", "preview-dialog"]) {+ const source = readSrc(`features/recipe-studio/dialogs/${file}.tsx`);+ assert.match(source, /<RecipeDialogContent\b/, file);+ assert.doesNotMatch(source, /<DialogContent\b/, file);+ }+});+test("shadowed menus scroll an inner viewport, not their rounded surface", () => {const contextMenu = readSrc("components/ui/context-menu.tsx");assert.equal(contextMenu.match(/data-slot="context-menu-viewport"/g)?.length, 2);diff --git a/studio/frontend/tests/dialog-toast-outside.test.ts b/studio/frontend/tests/dialog-toast-outside.test.tsindex c40d7ad77d5..63ac4aed972 100644--- a/studio/frontend/tests/dialog-toast-outside.test.ts+++ b/studio/frontend/tests/dialog-toast-outside.test.ts@@ -62,7 +62,6 @@ test("an interaction on a toast does not dismiss the dialog under it", () => {"@/components/app-readiness": { AppPortalGate: "AppPortalGate" },"@/components/ui/button": { Button: "Button" },"@/lib/utils": { cn: (...classes: unknown[]) => classes.join(" ") },- "@/lib/scroll-overflow": { useScrollOverflowRef: () => () => undefined },"@hugeicons/core-free-icons": { Cancel01Icon: {} },"@hugeicons/react": { HugeiconsIcon: "HugeiconsIcon" },});diff --git a/studio/frontend/tests/ui-font-size-scales-spacing.test.ts b/studio/frontend/tests/ui-font-size-scales-spacing.test.tsindex 918be707776..b4f64f0d5eb 100644--- a/studio/frontend/tests/ui-font-size-scales-spacing.test.ts+++ b/studio/frontend/tests/ui-font-size-scales-spacing.test.ts@@ -365,16 +365,20 @@ test("a scaled minimum never outgrows its own cap", () => {test("a scaled dialog keeps the viewport cap it replaces", () => {// A call-site max-h drops DialogContent's own viewport cap, so it restates it.const cap = "calc(100dvh-var(--studio-window-chrome-top,0px)-2rem)";+ // The recipe dialogs share RecipeDialogContent, which carries the cap.+ assert.ok(+ readSrc("features/recipe-studio/dialogs/shared/recipe-dialog-content.tsx").includes(+ `max-h-[min(calc(650px*var(--ui-space-scale,1)),${cap})]`,+ ),+ "recipe dialogs can outgrow the viewport",+ );for (const file of ["features/recipe-studio/dialogs/config-dialog.tsx","features/recipe-studio/dialogs/import-dialog.tsx","features/recipe-studio/dialogs/preview-dialog.tsx","features/recipe-studio/dialogs/processors-dialog.tsx",]) {- assert.ok(- readSrc(file).includes(`max-h-[min(calc(650px*var(--ui-space-scale,1)),${cap})]`),- `${file} can outgrow the viewport`,- );+ assert.match(readSrc(file), /<RecipeDialogContent\b/, file);}});