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: static dark dropdown glow, and stop modal opens restyling the page (#13013)

Michael Han9ced604c6e61
diff --git a/studio/frontend/src/features/browser/browser-panel.tsx b/studio/frontend/src/features/browser/browser-panel.tsx
index 341be6e08b0..8cdd5c48fa1 100644
--- a/studio/frontend/src/features/browser/browser-panel.tsx
+++ b/studio/frontend/src/features/browser/browser-panel.tsx
@@ -1678,7 +1678,7 @@ function BrowserFileToolbar({
<HugeiconsIcon icon={ArrowUpRight01Icon} strokeWidth={1.75} className="size-4" />
{t("browser.file.openIn")}
</DropdownMenuSubTrigger>
- <DropdownMenuSubContent className="min-w-52 rounded-[20px] p-1.5">
+ <DropdownMenuSubContent className="browser-menu min-w-52 rounded-[20px] p-1.5">
<DropdownMenuItem onSelect={openInNewChat}>
<HugeiconsIcon icon={BubbleChatAddIcon} strokeWidth={1.75} className="size-4.5" />
{t("browser.file.newChat")}
diff --git a/studio/frontend/src/features/browser/pinned-page-row.tsx b/studio/frontend/src/features/browser/pinned-page-row.tsx
index bd5bef64ac0..d0538fbbaf5 100644
--- a/studio/frontend/src/features/browser/pinned-page-row.tsx
+++ b/studio/frontend/src/features/browser/pinned-page-row.tsx
@@ -32,7 +32,8 @@ import {
usePinnedTab,
} from "./tab-menu";
-const MENU = "unsloth-plus-menu sidebar-row-menu sidebar-menu w-60";
+const SURFACE = "unsloth-plus-menu sidebar-row-menu sidebar-menu";
+const MENU = `${SURFACE} w-60`;
// As a chat row's: the pin and the kebab show on hover, and while the menu is open.
const ACTION =
"sidebar-row-action sidebar-touch-reveal group-hover/recent-item:opacity-100 group-hover/recent-item:pointer-events-auto focus-visible:opacity-100 focus-visible:pointer-events-auto group-has-[.sidebar-row-action[data-state=open]]/recent-item:opacity-100 group-has-[.sidebar-row-action[data-state=open]]/recent-item:pointer-events-auto";
@@ -158,12 +159,12 @@ export function PinnedPageRow({
</button>
)}
>
- <TabMenuItems P={DROPDOWN_TAB_MENU} tab={tab} pinned={page} onRename={startRename} />
+ <TabMenuItems P={DROPDOWN_TAB_MENU} tab={tab} pinned={page} subClassName={SURFACE} onRename={startRename} />
</NonModalDropdownMenu>
</SidebarMenuItem>
</ContextMenuTrigger>
<ContextMenuContent className={MENU} onCloseAutoFocus={keepMenuFocus}>
- <TabMenuItems P={CONTEXT_TAB_MENU} tab={tab} pinned={page} onRename={startRename} />
+ <TabMenuItems P={CONTEXT_TAB_MENU} tab={tab} pinned={page} subClassName={SURFACE} onRename={startRename} />
</ContextMenuContent>
</ContextMenu>
);
diff --git a/studio/frontend/src/features/browser/tab-menu.tsx b/studio/frontend/src/features/browser/tab-menu.tsx
index 1280e9cc53b..088061eb484 100644
--- a/studio/frontend/src/features/browser/tab-menu.tsx
+++ b/studio/frontend/src/features/browser/tab-menu.tsx
@@ -25,6 +25,7 @@ import { copyToClipboard } from "@/lib/copy-to-clipboard";
import { ForkIcon } from "@/lib/fork-icon";
import { openExternalLink } from "@/lib/open-link";
import { toast } from "@/lib/toast";
+import { cn } from "@/lib/utils";
import {
Add01Icon,
BubbleChatAddIcon,
@@ -181,12 +182,15 @@ export function TabMenuItems({
tab,
pinned,
strip = false,
+ subClassName = "browser-menu unsloth-plus-menu sidebar-row-menu",
onRename,
}: {
P: TabMenuParts;
tab?: BrowserTab;
pinned?: PinnedPage;
strip?: boolean;
+ /** Surface classes of the menu these items sit in, for its submenus. */
+ subClassName?: string;
onRename: () => void;
}) {
const t = useT();
@@ -238,7 +242,7 @@ export function TabMenuItems({
<HugeiconsIcon icon={ForkIcon} strokeWidth={1.75} className={ICON} />
<span>{t("browser.tabMenu.fork")}</span>
</P.SubTrigger>
- <P.SubContent className="browser-menu unsloth-plus-menu sidebar-row-menu w-48">
+ <P.SubContent className={cn(subClassName, "w-48")}>
<Row P={P} icon={BubbleChatAddIcon} onSelect={() => forkToChat(navigate, { tab, url }, false)}>
{t("browser.tabMenu.forkNewChat")}
</Row>
diff --git a/studio/frontend/src/index.css b/studio/frontend/src/index.css
index a582bb73eb9..d458b0b10a9 100644
--- a/studio/frontend/src/index.css
+++ b/studio/frontend/src/index.css
@@ -2192,6 +2192,11 @@ html[data-chat-font] .aui-root {
body[data-scroll-locked] {
margin-right: 0 !important;
}
+ /* The 0px react-remove-scroll sets on modal open. Preset so the lock
+ does not restyle the whole page. */
+ body {
+ --removed-body-scroll-bar-size: 0px;
+ }
/* Firefox makes scrollable containers keyboard focusable; swap the 3px
UA outline for the app's soft 1px indicator. :where keeps specificity
@@ -3103,8 +3108,8 @@ html[data-chat-font] .aui-root {
[data-slot="popover-content"] {
box-shadow: 0 2px 8px -2px rgba(0, 0, 0, 0.16) !important;
}
- /* Dark: glow in the darkest surface the menu touches, set per menu by
- lib/dropdown-surround.ts. .dropdown-surface marks bespoke dropdowns. */
+ /* Dark: glow in the page colour unless a context below sets --dropdown-glow.
+ .dropdown-surface marks bespoke dropdowns. */
.dark [data-slot="dropdown-menu-content"],
.dark [data-slot="dropdown-menu-sub-content"],
.dark [data-slot="context-menu-content"],
@@ -3113,7 +3118,7 @@ html[data-chat-font] .aui-root {
.dark [data-slot="combobox-content"],
.dark [data-slot="popover-content"],
.dark .dropdown-surface {
- box-shadow: 0 0 16px 0 var(--dropdown-surround-bg, var(--background)) !important;
+ box-shadow: 0 0 16px 0 var(--dropdown-glow, var(--background)) !important;
}
/* Sidebar and account menus stay flat in dark. */
.dark :is(.unsloth-plus-menu, .app-user-menu).sidebar-menu[data-slot],
@@ -3129,13 +3134,82 @@ html[data-chat-font] .aui-root {
background-color: var(--sidebar) !important;
}
- /* Menus that would blend into their surface get the Hub menu tone.
+ /* Menus portal after the dialog or picker they open from. There they glow
+ in its surface, and stock menus lift to the Hub tone. Sibling selectors,
+ as body:has() restyles the whole page on every <body> insert.
Defined on <html> so --accent can be reassigned without a cycle. */
.dark {
--dropdown-lift-surface: color-mix(in srgb, var(--accent) 60%, var(--popover));
--dropdown-lift-accent: color-mix(in srgb, var(--foreground) 6%, var(--accent));
}
- .dark [data-surround-blend] {
+ .dark
+ body
+ > :is([data-slot="dialog-content"], [data-slot="alert-dialog-content"])[data-state="open"]:is(
+ .dialog-soft-surface,
+ .settings-surface,
+ [class*="dark:bg-card"]
+ )
+ ~ *
+ :is(
+ [data-slot="dropdown-menu-content"],
+ [data-slot="dropdown-menu-sub-content"],
+ [data-slot="context-menu-content"],
+ [data-slot="context-menu-sub-content"],
+ [data-slot="select-content"],
+ [data-slot="combobox-content"],
+ [data-slot="popover-content"],
+ .dropdown-surface
+ ) {
+ --dropdown-glow: var(--card);
+ }
+ /* After the dialog rule, so a picker in a dialog wins. */
+ .dark
+ body
+ > [data-radix-popper-content-wrapper]:has(> .unsloth-model-selector-menu[data-state="open"])
+ ~ *
+ :is(
+ [data-slot="dropdown-menu-content"],
+ [data-slot="dropdown-menu-sub-content"],
+ [data-slot="context-menu-content"],
+ [data-slot="context-menu-sub-content"],
+ [data-slot="select-content"],
+ [data-slot="combobox-content"],
+ [data-slot="popover-content"],
+ .dropdown-surface
+ ) {
+ --dropdown-glow: var(--sidebar);
+ }
+ .dark
+ :is(
+ body
+ > :is([data-slot="dialog-content"], [data-slot="alert-dialog-content"])[data-state="open"]:is(
+ .dialog-soft-surface,
+ .settings-surface,
+ [class*="dark:bg-card"]
+ )
+ ~ *,
+ body
+ > [data-radix-popper-content-wrapper]:has(> .unsloth-model-selector-menu[data-state="open"])
+ ~ *
+ )
+ :is(
+ [data-slot="dropdown-menu-content"],
+ [data-slot="dropdown-menu-sub-content"],
+ [data-slot="context-menu-content"],
+ [data-slot="context-menu-sub-content"],
+ [data-slot="select-content"],
+ [data-slot="combobox-content"],
+ [data-slot="popover-content"],
+ .dropdown-surface
+ ):not(
+ .unsloth-model-selector-menu,
+ .sidebar-menu,
+ .sidebar-more-menu,
+ .library-menu,
+ .library-actions-menu,
+ .browser-menu,
+ .hub-menu-instant
+ ) {
--accent: var(--dropdown-lift-accent);
background-color: var(--dropdown-lift-surface) !important;
}
@@ -4388,8 +4462,9 @@ html[data-chat-font] .aui-root {
streamdown puts between two paragraphs. The parts themselves own no outer margin or
padding, so a header next to a paragraph reads the same as a paragraph next to a
paragraph. `:where()` keeps this at zero specificity so a part that does set its own
- `mt-*` still wins. The first real child follows a zero-height badge anchor and gets none. */
- :where(.aui-assistant-message-content > * + *) {
+ `mt-*` still wins. The first real child follows a zero-height badge anchor and gets none.
+ Not `* + *`: that restyles the whole page when Radix inserts its focus guard. */
+ :where(.aui-assistant-message-content > :not(:first-child)) {
margin-top: calc(1rem * var(--ui-space-scale, 1));
}
:where(.aui-assistant-message-content > .h-0 + *) {
diff --git a/studio/frontend/src/lib/dropdown-surround.ts b/studio/frontend/src/lib/dropdown-surround.ts
deleted file mode 100644
index 644e34c0a81..00000000000
--- a/studio/frontend/src/lib/dropdown-surround.ts
+++ /dev/null
@@ -1,326 +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
-
-/**
- * Dark dropdowns glow in the darkest surface they touch (--dropdown-surround-bg).
- * Menus that would blend into their surface get data-surround-blend.
- * Sub-menus copy their parent's fill. Model picker dropdowns glow in its colour.
- */
-
-const DROPDOWN_SELECTOR = [
- '[data-slot="dropdown-menu-content"]',
- '[data-slot="dropdown-menu-sub-content"]',
- '[data-slot="context-menu-content"]',
- '[data-slot="context-menu-sub-content"]',
- '[data-slot="select-content"]',
- '[data-slot="combobox-content"]',
- '[data-slot="popover-content"]',
- // Bespoke dropdowns not built on ui/ primitives.
- ".dropdown-surface",
-].join(",");
-
-const SUB_MENU_SELECTOR =
- '[data-slot="dropdown-menu-sub-content"], [data-slot="context-menu-sub-content"]';
-
-// Panels whose dropdowns glow in the panel's colour.
-const GLOW_HOST_SELECTOR = ".unsloth-model-selector-menu";
-
-const SURROUND_VAR = "--dropdown-surround-bg";
-const BLEND_ATTR = "data-surround-blend";
-// Max per-channel difference (0-255) that counts as the same surface.
-const BLEND_TOLERANCE = 6;
-// Probe distance outside the menu edge.
-const EDGE_PROBE_PX = 8;
-// Radix positions poppers after a few frames.
-const MAX_POSITION_FRAMES = 6;
-
-let canvasContext: CanvasRenderingContext2D | null | undefined;
-// Sub-menus whose fill this module set inline, so a theme switch can clear it.
-const inlineFills = new WeakSet<HTMLElement>();
-
-function getCanvasContext(doc: Document): CanvasRenderingContext2D | null {
- if (canvasContext === undefined) {
- const canvas = doc.createElement("canvas");
- canvas.width = 1;
- canvas.height = 1;
- canvasContext = canvas.getContext("2d", { willReadFrequently: true });
- }
- return canvasContext;
-}
-
-type Rgb = [number, number, number];
-
-function isTransparent(color: string): boolean {
- return color === "transparent" || color === "rgba(0, 0, 0, 0)";
-}
-
-/** Alpha of any CSS colour the canvas can parse (oklch, color-mix output, ...). */
-function alphaOf(ctx: CanvasRenderingContext2D, color: string): number {
- ctx.clearRect(0, 0, 1, 1);
- ctx.fillStyle = color;
- ctx.fillRect(0, 0, 1, 1);
- return ctx.getImageData(0, 0, 1, 1).data[3] / 255;
-}
-
-/**
- * Composited surface colour at (x, y) outside `dropdown`. Boxes smaller than
- * the menu are skipped so rows and chips do not tint the glow.
- */
-function surfaceColorAt(
- doc: Document,
- ctx: CanvasRenderingContext2D,
- dropdown: Element,
- minArea: number,
- x: number,
- y: number,
-): Rgb | null {
- const view = doc.defaultView;
- if (!view || x < 0 || y < 0 || x >= view.innerWidth || y >= view.innerHeight)
- return null;
- const layers: string[] = [];
- for (const el of doc.elementsFromPoint(x, y)) {
- if (dropdown.contains(el)) continue;
- const style = view.getComputedStyle(el);
- if (isTransparent(style.backgroundColor) || style.opacity === "0") continue;
- const box = el.getBoundingClientRect();
- if (box.width * box.height < minArea) continue;
- layers.push(style.backgroundColor);
- if (alphaOf(ctx, style.backgroundColor) >= 1) break;
- }
- if (layers.length === 0) return null;
- ctx.clearRect(0, 0, 1, 1);
- for (let i = layers.length - 1; i >= 0; i--) {
- ctx.fillStyle = layers[i];
- ctx.fillRect(0, 0, 1, 1);
- }
- const [r, g, b, a] = ctx.getImageData(0, 0, 1, 1).data;
- // No opaque floor; fall back to --background.
- if (a < 255) return null;
- return [r, g, b];
-}
-
-/** `dropdown`'s own fill as painted over `surround`. */
-function paintedFill(
- ctx: CanvasRenderingContext2D,
- dropdown: Element,
- surround: Rgb,
-): Rgb {
- const view = dropdown.ownerDocument.defaultView;
- ctx.clearRect(0, 0, 1, 1);
- ctx.fillStyle = `rgb(${surround.join(" ")})`;
- ctx.fillRect(0, 0, 1, 1);
- const fill = view?.getComputedStyle(dropdown).backgroundColor;
- if (fill && !isTransparent(fill)) {
- ctx.fillStyle = fill;
- ctx.fillRect(0, 0, 1, 1);
- }
- const [r, g, b] = ctx.getImageData(0, 0, 1, 1).data;
- return [r, g, b];
-}
-
-function luminance([r, g, b]: Rgb): number {
- return 0.2126 * r + 0.7152 * g + 0.0722 * b;
-}
-
-interface Surround {
- /** The surface the menu mostly sits on: decides whether it would vanish. */
- majority: Rgb;
- /** The deepest surface it touches: the glow's colour. */
- darkest: Rgb;
-}
-
-function measureSurround(
- doc: Document,
- ctx: CanvasRenderingContext2D,
- dropdown: HTMLElement,
-): Surround | null {
- const rect = dropdown.getBoundingClientRect();
- const minArea = rect.width * rect.height;
- const cx = rect.left + rect.width / 2;
- const cy = rect.top + rect.height / 2;
- const top = rect.top - EDGE_PROBE_PX;
- const right = rect.right + EDGE_PROBE_PX;
- const bottom = rect.bottom + EDGE_PROBE_PX;
- const left = rect.left - EDGE_PROBE_PX;
- // Ring just outside the menu.
- const points: [number, number][] = [
- [cx, top],
- [right, cy],
- [cx, bottom],
- [left, cy],
- [left, top],
- [right, top],
- [right, bottom],
- [left, bottom],
- ];
-
- // Modal layers set inline pointer-events: none, hiding them from
- // hit-testing. Lift it for this synchronous probe only.
- const disabled = [
- ...doc.querySelectorAll<HTMLElement>('[style*="pointer-events: none"]'),
- ];
- for (const el of disabled) el.style.pointerEvents = "auto";
- const votes = new Map<string, number>();
- const colors = new Map<string, Rgb>();
- let best: string | null = null;
- let darkest: Rgb | null = null;
- try {
- for (const [x, y] of points) {
- const color = surfaceColorAt(doc, ctx, dropdown, minArea, x, y);
- if (!color) continue;
- const key = color.join(" ");
- colors.set(key, color);
- const count = (votes.get(key) ?? 0) + 1;
- votes.set(key, count);
- if (best === null || count > (votes.get(best) ?? 0)) best = key;
- if (!darkest || luminance(color) < luminance(darkest)) darkest = color;
- }
- } finally {
- for (const el of disabled) el.style.pointerEvents = "none";
- }
- const majority = best === null ? undefined : colors.get(best);
- return majority && darkest ? { majority, darkest } : null;
-}
-
-/** The menu a sub-menu opened from. */
-function parentMenuOf(doc: Document, subMenu: HTMLElement): HTMLElement | null {
- return (
- triggerOf(doc, subMenu)?.closest<HTMLElement>(DROPDOWN_SELECTOR) ?? null
- );
-}
-
-/** The control that opened `dropdown`. */
-function triggerOf(doc: Document, dropdown: HTMLElement): Element | null {
- if (dropdown.id) {
- const direct = doc.querySelector(
- `[aria-controls="${CSS.escape(dropdown.id)}"]`,
- );
- if (direct) return direct;
- }
- // Some pickers point aria-controls at an inner listbox.
- for (const el of doc.querySelectorAll(
- '[aria-expanded="true"][aria-controls]',
- )) {
- const controlled = doc.getElementById(
- el.getAttribute("aria-controls") ?? "",
- );
- if (controlled && dropdown.contains(controlled)) return el;
- }
- return null;
-}
-
-function applySurround(
- win: Window,
- dropdown: HTMLElement,
- framesLeft = MAX_POSITION_FRAMES,
-): void {
- win.requestAnimationFrame(() => {
- if (!dropdown.isConnected) return;
- const rect = dropdown.getBoundingClientRect();
- const placed =
- rect.width > 0 &&
- rect.height > 0 &&
- rect.bottom > 0 &&
- rect.top < win.innerHeight;
- if (!placed) {
- if (framesLeft > 0) applySurround(win, dropdown, framesLeft - 1);
- return;
- }
- const ctx = getCanvasContext(win.document);
- const surround = ctx ? measureSurround(win.document, ctx, dropdown) : null;
- const host = triggerOf(win.document, dropdown)?.closest(GLOW_HOST_SELECTOR);
- if (host) {
- dropdown.style.setProperty(
- SURROUND_VAR,
- win.getComputedStyle(host).backgroundColor,
- );
- } else if (surround) {
- dropdown.style.setProperty(
- SURROUND_VAR,
- `rgb(${surround.darkest.join(" ")})`,
- );
- } else {
- dropdown.style.removeProperty(SURROUND_VAR);
- }
-
- // The parent was measured earlier, so its fill is final.
- const parent = dropdown.matches(SUB_MENU_SELECTOR)
- ? parentMenuOf(win.document, dropdown)
- : null;
- if (parent) {
- dropdown.toggleAttribute(BLEND_ATTR, parent.hasAttribute(BLEND_ATTR));
- // Important, so no menu class can override it.
- dropdown.style.setProperty(
- "background-color",
- win.getComputedStyle(parent).backgroundColor,
- "important",
- );
- inlineFills.add(dropdown);
- return;
- }
-
- if (!ctx || !surround) {
- dropdown.removeAttribute(BLEND_ATTR);
- return;
- }
- const fill = paintedFill(ctx, dropdown, surround.majority);
- const blends = fill.every(
- (channel, i) =>
- Math.abs(channel - surround.majority[i]) <= BLEND_TOLERANCE,
- );
- dropdown.toggleAttribute(BLEND_ATTR, blends);
- });
-}
-
-/** Drops everything applySurround set, for light mode. */
-function clearSurround(dropdown: HTMLElement): void {
- dropdown.style.removeProperty(SURROUND_VAR);
- dropdown.removeAttribute(BLEND_ATTR);
- if (inlineFills.delete(dropdown)) {
- dropdown.style.removeProperty("background-color");
- }
-}
-
-export function watchDropdownSurround(win: Window): void {
- const doc = win.document;
- const root = doc.documentElement;
- const observer = new MutationObserver((records) => {
- // Only dark-theme rules use these.
- if (!root.classList.contains("dark")) return;
- for (const record of records) {
- for (const node of record.addedNodes) {
- if (!(node instanceof HTMLElement)) continue;
- if (node.matches(DROPDOWN_SELECTOR)) applySurround(win, node);
- for (const el of node.querySelectorAll<HTMLElement>(
- DROPDOWN_SELECTOR,
- )) {
- applySurround(win, el);
- }
- }
- }
- });
- observer.observe(doc.body, { childList: true, subtree: true });
-
- // Menus left open across a theme switch: clear them for light, re-measure them for dark.
- let dark = root.classList.contains("dark");
- new MutationObserver(() => {
- const next = root.classList.contains("dark");
- if (next === dark) return;
- dark = next;
- const open = [...doc.querySelectorAll<HTMLElement>(DROPDOWN_SELECTOR)];
- if (!dark) {
- for (const el of open) clearSurround(el);
- return;
- }
- // Wait out the theme's colour fades, or the probe reads them halfway.
- const fades = doc
- .getAnimations()
- .filter((animation) => animation instanceof CSSTransition)
- .map((animation) => animation.finished);
- void Promise.allSettled(fades).then(() => {
- if (!root.classList.contains("dark")) return;
- // Document order puts a parent menu before its sub-menu.
- for (const el of open) applySurround(win, el);
- });
- }).observe(root, { attributes: true, attributeFilter: ["class"] });
-}
diff --git a/studio/frontend/src/main.tsx b/studio/frontend/src/main.tsx
index 216d0e1e0c5..af0249b8ac6 100644
--- a/studio/frontend/src/main.tsx
+++ b/studio/frontend/src/main.tsx
@@ -19,7 +19,6 @@ import {
import { initializeLocale } from "./i18n";
import { isTauri } from "./lib/api-base";
import { setHubSessionRefresh } from "./lib/hf-endpoint";
-import { watchDropdownSurround } from "./lib/dropdown-surround";
import { watchInputModality } from "./lib/input-modality";
import { watchOverlayScrollbarGutter } from "./lib/overlay-scrollbar";
@@ -60,7 +59,6 @@ watchMathBlockContainmentOverride();
// Keep right-edge controls clear of overlay scrollbars.
watchOverlayScrollbarGutter(window);
watchInputModality(window);
-watchDropdownSurround(window);
function renderApp(): void {
root.render(
diff --git a/studio/frontend/tests/browser-submenu-surface.test.ts b/studio/frontend/tests/browser-submenu-surface.test.ts
new file mode 100644
index 00000000000..c470b028ea8
--- /dev/null
+++ b/studio/frontend/tests/browser-submenu-surface.test.ts
@@ -0,0 +1,25 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+
+// Dark submenus no longer copy their parent's fill, so each one carries its
+// parent's surface class.
+
+import assert from "node:assert/strict";
+import test from "node:test";
+
+import { readSrcAsync } from "./helpers/kit.ts";
+
+test("every browser panel submenu uses the browser menu surface", async () => {
+ const panel = await readSrcAsync("features/browser/browser-panel.tsx");
+ const subs = [...panel.matchAll(/<DropdownMenuSubContent className="([^"]*)"/g)];
+ assert.ok(subs.length > 0);
+ for (const [, cls] of subs) assert.match(cls, /\bbrowser-menu\b/, cls);
+});
+
+test("pinned page menus hand their sidebar surface to the tab submenus", async () => {
+ const row = await readSrcAsync("features/browser/pinned-page-row.tsx");
+ const items = await readSrcAsync("features/browser/tab-menu.tsx");
+ assert.match(row, /const SURFACE = "unsloth-plus-menu sidebar-row-menu sidebar-menu";/);
+ assert.equal(row.match(/<TabMenuItems [^>]*subClassName=\{SURFACE\}/g)?.length, 2);
+ assert.match(items, /<P\.SubContent className=\{cn\(subClassName, "w-48"\)\}>/);
+});
diff --git a/studio/frontend/tests/modal-open-restyle.test.ts b/studio/frontend/tests/modal-open-restyle.test.ts
new file mode 100644
index 00000000000..e1c9b25de87
--- /dev/null
+++ b/studio/frontend/tests/modal-open-restyle.test.ts
@@ -0,0 +1,61 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+
+/**
+ * Radix writes to <body> on every modal open. Each rule pinned here turned
+ * one of those writes into a full page restyle (~160-185ms at ~15K elements).
+ */
+
+import assert from "node:assert/strict";
+import { existsSync } from "node:fs";
+import test from "node:test";
+
+import { readSrcAsync } from "./helpers/kit.ts";
+
+/** [selector, declarations] of each innermost rule. */
+function rules(css: string): [string, string][] {
+ const bare = css.replace(/\/\*[\s\S]*?\*\//g, "");
+ return [...bare.matchAll(/([^{}]+)\{([^{}]*)\}/g)].map((m) => [
+ m[1].replace(/\s+/g, " ").trim(),
+ m[2],
+ ]);
+}
+
+test("dark menus find their dialog or picker by sibling, not body:has()", async () => {
+ const css = rules(await readSrcAsync("index.css"));
+ const context = css.filter(
+ ([, body]) =>
+ /--dropdown-glow:/.test(body) || /var\(--dropdown-lift-surface\)/.test(body),
+ );
+ assert.ok(context.length >= 3, "the glow and lift context rules are present");
+ for (const [selector] of context) {
+ assert.doesNotMatch(selector, /body:has\(/, selector);
+ assert.match(selector, /~ \*/, selector);
+ }
+});
+
+test("no stylesheet uses a universal sibling selector", async () => {
+ for (const file of ["index.css", "features/hub/hub.css"]) {
+ for (const [selector] of rules(await readSrcAsync(file))) {
+ assert.doesNotMatch(selector, /(^|[\s>(,])\*\s*[+~]\s*\*/, `${file}: ${selector}`);
+ }
+ }
+});
+
+test("body already holds the value react-remove-scroll writes", async () => {
+ const css = rules(await readSrcAsync("index.css"));
+ assert.ok(
+ css.some(
+ ([selector, body]) =>
+ selector === "body" && /--removed-body-scroll-bar-size:\s*0px;/.test(body),
+ ),
+ );
+});
+
+test("the dark glow is static, with no per-menu probe", async () => {
+ assert.equal(
+ existsSync(new URL("../src/lib/dropdown-surround.ts", import.meta.url)),
+ false,
+ );
+ assert.doesNotMatch(await readSrcAsync("main.tsx"), /dropdown-surround|watchDropdownSurround/);
+});