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: keep menus and popovers below the desktop titlebar (#12348)

Michael Hanf0af8596bde1
diff --git a/studio/frontend/src/app/provider.tsx b/studio/frontend/src/app/provider.tsx
index 41f23cf4fb9..b55038b1aa9 100644
--- a/studio/frontend/src/app/provider.tsx
+++ b/studio/frontend/src/app/provider.tsx
@@ -47,6 +47,7 @@ import { useTauriUpdate } from "@/hooks/use-tauri-update";
import { useUiSpaceScale } from "@/hooks/use-ui-space-scale";
import { isTauri } from "@/lib/api-base";
import { followDesktopUpdateScreen } from "@/lib/desktop-update-activity";
+import { refreshWindowChromeTop } from "@/lib/window-chrome";
import {
CHAT_SETTINGS_INSET_VAR,
getToastOffsets,
@@ -624,12 +625,19 @@ function DesktopChromeVarsEffect({
? NATIVE_MAC_TITLEBAR_HEIGHT_VAR
: null,
);
+ refreshWindowChromeTop();
+ // The macOS titlebar inset is divided by the zoom.
+ const stopZoom = usesNativeMacTitlebar
+ ? subscribeAppliedInterfaceZoom(refreshWindowChromeTop)
+ : null;
return () => {
+ stopZoom?.();
set("--studio-custom-titlebar-height", null);
set("--studio-mac-titlebar-height", null);
set("--studio-window-control-inset", null);
set("--studio-content-top-inset", null);
set("--studio-window-chrome-top", null);
+ refreshWindowChromeTop();
};
}, [usesCustomTitlebar, usesNativeMacTitlebar]);
return null;
diff --git a/studio/frontend/src/components/assistant-ui/thread.tsx b/studio/frontend/src/components/assistant-ui/thread.tsx
index 365b21867f2..6ee2df6aa3d 100644
--- a/studio/frontend/src/components/assistant-ui/thread.tsx
+++ b/studio/frontend/src/components/assistant-ui/thread.tsx
@@ -306,6 +306,7 @@ import { isTauri } from "@/lib/api-base";
import { InternetGlyph } from "@/lib/internet-icon";
import { copyToClipboard } from "@/lib/copy-to-clipboard";
import { MenuDismissGuard } from "@/lib/menu-dismiss-guard";
+import { useWindowChromeCollisionPadding } from "@/lib/window-chrome";
import { NonModalDropdownMenu } from "@/components/ui/non-modal-dropdown-menu";
import { MicIcon } from "@/lib/mic-icon";
import { downloadFile, isDownloadCancelled } from "@/lib/native-files";
@@ -8397,6 +8398,8 @@ async function exportMessageMarkdown(content: string): Promise<void> {
const AssistantActionBar: FC = () => {
const aui = useAui();
const moreMenuTriggerRef = useRef<HTMLButtonElement>(null);
+ // Not built on DropdownMenuContent, so clear the titlebar and cap the height here.
+ const moreMenuCollisionPadding = useWindowChromeCollisionPadding(undefined);
const { forkMessage, forkDisabled } = useForkMessageAction();
const researchRunId = useResearchMessageRunId();
const researchActive = useThreadResearchActive();
@@ -8480,8 +8483,9 @@ const AssistantActionBar: FC = () => {
<ActionBarMorePrimitive.Content
side="bottom"
align="start"
+ collisionPadding={moreMenuCollisionPadding}
onCloseAutoFocus={(e) => e.preventDefault()}
- className="aui-action-bar-more-content z-50 min-w-32 overflow-hidden rounded-[21px] bg-popover px-[calc(9px*var(--ui-space-scale,1))] py-2 text-popover-foreground shadow-[0_2px_8px_-2px_rgba(0,0,0,0.16)] dark:shadow-[0_8px_28px_-6px_var(--background)]"
+ className="aui-action-bar-more-content z-50 min-w-32 max-h-(--radix-dropdown-menu-content-available-height) overflow-x-hidden overflow-y-auto rounded-[21px] bg-popover px-[calc(9px*var(--ui-space-scale,1))] py-2 text-popover-foreground shadow-[0_2px_8px_-2px_rgba(0,0,0,0.16)] dark:shadow-[0_8px_28px_-6px_var(--background)]"
>
{/* Prevent an outside dismissal from triggering Delete. */}
<MenuDismissGuard triggerRef={moreMenuTriggerRef} />
diff --git a/studio/frontend/src/components/ui/combobox.tsx b/studio/frontend/src/components/ui/combobox.tsx
index 82b6303f4be..342a58e4990 100644
--- a/studio/frontend/src/components/ui/combobox.tsx
+++ b/studio/frontend/src/components/ui/combobox.tsx
@@ -21,6 +21,7 @@ import {
import { MenuTickIcon } from "@/lib/tick-icon";
import { ChevronDownStandardIcon } from "@/lib/chevron-icons";
import { useSnappedPaddingRef } from "@/lib/snap-padding";
+import { useWindowChromeCollisionPadding } from "@/lib/window-chrome";
import { cn } from "@/lib/utils";
import { Cancel01Icon } from "@hugeicons/core-free-icons";
import { HugeiconsIcon } from "@hugeicons/react";
@@ -166,6 +167,8 @@ function ComboboxContent({
align={align}
alignOffset={alignOffset}
anchor={anchor}
+ // Base UI's default padding is 5.
+ collisionPadding={useWindowChromeCollisionPadding(5)}
className="isolate z-[120] pointer-events-auto"
>
<ComboboxPrimitive.Popup
diff --git a/studio/frontend/src/components/ui/context-menu.tsx b/studio/frontend/src/components/ui/context-menu.tsx
index f26b5181bee..1fd0767893d 100644
--- a/studio/frontend/src/components/ui/context-menu.tsx
+++ b/studio/frontend/src/components/ui/context-menu.tsx
@@ -9,6 +9,7 @@ import type * as React from "react";
import { MenuChevronRightIcon } from "@/lib/chevron-icons";
import { MenuTickIcon } from "@/lib/tick-icon";
import { useSnappedPaddingRef } from "@/lib/snap-padding";
+import { useWindowChromeCollisionPadding } from "@/lib/window-chrome";
import { cn } from "@/lib/utils";
import { HugeiconsIcon } from "@hugeicons/react";
@@ -66,6 +67,7 @@ function ContextMenuRadioGroup({
function ContextMenuContent({
className,
+ collisionPadding,
ref,
...props
}: React.ComponentProps<typeof ContextMenuPrimitive.Content> & {
@@ -77,6 +79,7 @@ function ContextMenuContent({
<ContextMenuPrimitive.Content
ref={snappedRef}
data-slot="context-menu-content"
+ collisionPadding={useWindowChromeCollisionPadding(collisionPadding)}
className={cn(
"data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 ring-[color-mix(in_oklab,var(--foreground)_calc(5%*var(--contrast-edge-gain,1)),transparent)] bg-popover text-popover-foreground min-w-48 max-w-[calc(100vw-32px)] rounded-2xl p-1 shadow-2xl ring-1 duration-100 z-50 max-h-(--radix-context-menu-content-available-height) origin-(--radix-context-menu-content-transform-origin) overflow-x-hidden overflow-y-auto",
className,
@@ -140,6 +143,7 @@ function ContextMenuSubTrigger({
function ContextMenuSubContent({
className,
+ collisionPadding,
ref,
...props
}: React.ComponentProps<typeof ContextMenuPrimitive.SubContent>) {
@@ -152,8 +156,10 @@ function ContextMenuSubContent({
<ContextMenuPrimitive.SubContent
ref={snappedRef}
data-slot="context-menu-sub-content"
+ collisionPadding={useWindowChromeCollisionPadding(collisionPadding)}
+ // Capped and scrolled like ContextMenuContent, so a long list stays reachable.
className={cn(
- "data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 bg-popover text-popover-foreground min-w-32 max-w-[calc(100vw-32px)] rounded-md border p-1 shadow-lg duration-100 z-50 origin-(--radix-context-menu-content-transform-origin) overflow-hidden",
+ "data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 bg-popover text-popover-foreground min-w-32 max-w-[calc(100vw-32px)] rounded-md border p-1 shadow-lg duration-100 z-50 origin-(--radix-context-menu-content-transform-origin) max-h-(--radix-context-menu-content-available-height) overflow-x-hidden overflow-y-auto",
className,
)}
{...props}
diff --git a/studio/frontend/src/components/ui/dropdown-menu.tsx b/studio/frontend/src/components/ui/dropdown-menu.tsx
index 066333595a5..567241b8ba4 100644
--- a/studio/frontend/src/components/ui/dropdown-menu.tsx
+++ b/studio/frontend/src/components/ui/dropdown-menu.tsx
@@ -8,6 +8,7 @@ import { MenuTickIcon } from "@/lib/tick-icon";
import { MenuChevronRightIcon } from "@/lib/chevron-icons";
import { useIsMobile } from "@/hooks/use-mobile";
import { snapRowInsets, useSnappedPaddingRef } from "@/lib/snap-padding";
+import { useWindowChromeCollisionPadding } from "@/lib/window-chrome";
import { cn } from "@/lib/utils";
import { HugeiconsIcon } from "@hugeicons/react";
@@ -40,6 +41,7 @@ function DropdownMenuContent({
className,
align = "start",
sideOffset = 0,
+ collisionPadding,
children,
ref,
...props
@@ -51,6 +53,7 @@ function DropdownMenuContent({
ref={snappedRef}
data-slot="dropdown-menu-content"
sideOffset={sideOffset}
+ collisionPadding={useWindowChromeCollisionPadding(collisionPadding)}
align={align}
className={cn(
// Width in whole pixels: Firefox draws a row's hover pill a device pixel off centre in a
@@ -271,7 +274,9 @@ function DropdownMenuSubContent({
sideOffset,
alignOffset,
alignEnd,
+ collisionPadding,
style,
+ children,
ref,
...props
}: React.ComponentProps<typeof DropdownMenuPrimitive.SubContent> & {
@@ -341,19 +346,28 @@ function DropdownMenuSubContent({
data-slot="dropdown-menu-sub-content"
sideOffset={compactSideOffset}
alignOffset={resolvedAlignOffset}
+ collisionPadding={useWindowChromeCollisionPadding(collisionPadding)}
style={{
...style,
visibility:
isMobile && contentWidth === 0 ? "hidden" : style?.visibility,
}}
className={cn(
- "data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 bg-popover text-popover-foreground min-w-36 max-w-[calc(100vw-32px)] rounded-lg p-1 duration-100 z-50 origin-(--radix-dropdown-menu-content-transform-origin) overflow-hidden",
+ "data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 bg-popover text-popover-foreground min-w-36 max-w-[calc(100vw-32px)] max-h-(--radix-dropdown-menu-content-available-height) rounded-lg p-1 duration-100 z-50 origin-(--radix-dropdown-menu-content-transform-origin) flex flex-col overflow-hidden",
// !important so the fade-in animation cannot reveal it early.
measuring && "opacity-0!",
className,
)}
{...props}
- />
+ >
+ {/* Capped and scrolled like DropdownMenuContent, so a long list stays reachable. */}
+ <div
+ data-slot="dropdown-menu-viewport"
+ className="min-h-0 flex-1 overflow-x-hidden overflow-y-auto"
+ >
+ {children}
+ </div>
+ </DropdownMenuPrimitive.SubContent>
</DropdownMenuPrimitive.Portal>
);
}
diff --git a/studio/frontend/src/components/ui/hover-card.tsx b/studio/frontend/src/components/ui/hover-card.tsx
index 6786889457e..f081cd7aaff 100644
--- a/studio/frontend/src/components/ui/hover-card.tsx
+++ b/studio/frontend/src/components/ui/hover-card.tsx
@@ -5,6 +5,7 @@ import { HoverCard as HoverCardPrimitive } from "radix-ui";
import type * as React from "react";
import { cn } from "@/lib/utils";
+import { useWindowChromeCollisionPadding } from "@/lib/window-chrome";
function HoverCard({
...props
@@ -24,12 +25,14 @@ function HoverCardContent({
className,
align = "center",
sideOffset = 4,
+ collisionPadding,
...props
}: React.ComponentProps<typeof HoverCardPrimitive.Content>) {
return (
<HoverCardPrimitive.Portal data-slot="hover-card-portal">
<HoverCardPrimitive.Content
data-slot="hover-card-content"
+ collisionPadding={useWindowChromeCollisionPadding(collisionPadding)}
align={align}
sideOffset={sideOffset}
className={cn(
diff --git a/studio/frontend/src/components/ui/menubar.tsx b/studio/frontend/src/components/ui/menubar.tsx
index d46773dc65f..a6c5e14316d 100644
--- a/studio/frontend/src/components/ui/menubar.tsx
+++ b/studio/frontend/src/components/ui/menubar.tsx
@@ -8,6 +8,7 @@ import type * as React from "react";
import { Tick02Icon } from "@/lib/tick-icon";
import { useSnappedPaddingRef } from "@/lib/snap-padding";
+import { useWindowChromeCollisionPadding } from "@/lib/window-chrome";
import { cn } from "@/lib/utils";
import { MenuChevronRightIcon } from "@/lib/chevron-icons";
import { HugeiconsIcon } from "@hugeicons/react";
@@ -75,6 +76,7 @@ function MenubarContent({
align = "start",
alignOffset = -4,
sideOffset = 0,
+ collisionPadding,
ref,
...props
}: React.ComponentProps<typeof MenubarPrimitive.Content>) {
@@ -84,6 +86,7 @@ function MenubarContent({
<MenubarPrimitive.Content
ref={snappedRef}
data-slot="menubar-content"
+ collisionPadding={useWindowChromeCollisionPadding(collisionPadding)}
align={align}
alignOffset={alignOffset}
sideOffset={sideOffset}
@@ -255,6 +258,7 @@ function MenubarSubTrigger({
function MenubarSubContent({
className,
+ collisionPadding,
ref,
...props
}: React.ComponentProps<typeof MenubarPrimitive.SubContent>) {
@@ -263,6 +267,7 @@ function MenubarSubContent({
<MenubarPrimitive.SubContent
ref={snappedRef}
data-slot="menubar-sub-content"
+ collisionPadding={useWindowChromeCollisionPadding(collisionPadding)}
className={cn(
"bg-popover text-popover-foreground data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 ring-[color-mix(in_oklab,var(--foreground)_calc(5%*var(--contrast-edge-gain,1)),transparent)] min-w-32 rounded-2xl p-1 shadow-2xl ring-1 duration-100 z-50 origin-(--radix-menubar-content-transform-origin) overflow-hidden",
className,
diff --git a/studio/frontend/src/components/ui/popover.tsx b/studio/frontend/src/components/ui/popover.tsx
index 66b6b43d51d..7c250aa6fa1 100644
--- a/studio/frontend/src/components/ui/popover.tsx
+++ b/studio/frontend/src/components/ui/popover.tsx
@@ -8,6 +8,7 @@ import type * as React from "react";
import { useDialogPortalContainer } from "@/components/ui/dialog";
import { useSnappedPaddingRef } from "@/lib/snap-padding";
+import { useWindowChromeCollisionPadding } from "@/lib/window-chrome";
import { cn } from "@/lib/utils";
function Popover({
@@ -26,6 +27,7 @@ function PopoverContent({
className,
align = "center",
sideOffset = 0,
+ collisionPadding,
container,
ref,
...props
@@ -43,10 +45,12 @@ function PopoverContent({
<PopoverPrimitive.Content
ref={snappedRef}
data-slot="popover-content"
+ collisionPadding={useWindowChromeCollisionPadding(collisionPadding)}
align={align}
sideOffset={sideOffset}
+ // Padding alone doesn't shrink it, so cap it and scroll.
className={cn(
- "bg-popover text-popover-foreground data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 flex flex-col gap-4 rounded-lg p-4 text-sm duration-100 z-50 w-72 max-w-[calc(100vw-32px)] origin-(--radix-popover-content-transform-origin) outline-hidden",
+ "bg-popover text-popover-foreground data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 flex flex-col gap-4 rounded-lg p-4 text-sm duration-100 z-50 w-72 max-w-[calc(100vw-32px)] max-h-(--radix-popover-content-available-height) overflow-y-auto origin-(--radix-popover-content-transform-origin) outline-hidden",
className,
)}
{...props}
diff --git a/studio/frontend/src/components/ui/select.tsx b/studio/frontend/src/components/ui/select.tsx
index a2e93eec975..5cb8de8f1ea 100644
--- a/studio/frontend/src/components/ui/select.tsx
+++ b/studio/frontend/src/components/ui/select.tsx
@@ -13,6 +13,7 @@ import {
ChevronUpStandardIcon,
} from "@/lib/chevron-icons";
import { useSnappedPaddingRef } from "@/lib/snap-padding";
+import { useWindowChromeCollisionPadding } from "@/lib/window-chrome";
import { cn } from "@/lib/utils";
import { useDialogPortalContainer } from "@/components/ui/dialog";
import { HugeiconsIcon } from "@hugeicons/react";
@@ -115,6 +116,7 @@ function SelectContent({
children,
position = "popper",
align = "center",
+ collisionPadding,
container,
ref,
...props
@@ -128,6 +130,7 @@ function SelectContent({
<SelectPrimitive.Content
ref={snappedRef}
data-slot="select-content"
+ collisionPadding={useWindowChromeCollisionPadding(collisionPadding)}
data-align-trigger={position === "item-aligned"}
className={cn(
"bg-popover text-popover-foreground font-heading data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 min-w-36 max-w-[calc(100vw-32px)] rounded-xl p-1 corner-squircle duration-100 relative z-50 max-h-(--radix-select-content-available-height) origin-(--radix-select-content-transform-origin) flex flex-col overflow-hidden",
diff --git a/studio/frontend/src/lib/window-chrome.ts b/studio/frontend/src/lib/window-chrome.ts
new file mode 100644
index 00000000000..f4721f9e104
--- /dev/null
+++ b/studio/frontend/src/lib/window-chrome.ts
@@ -0,0 +1,75 @@
+// 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 { useSyncExternalStore } from "react";
+
+type Side = "top" | "right" | "bottom" | "left";
+export type CollisionPadding = number | Partial<Record<Side, number>>;
+
+// Height of the desktop titlebar, which paints over body-portaled surfaces. 0 in a browser.
+let chromeTop: number | null = null;
+const listeners = new Set<() => void>();
+
+function readChromeTop(): number {
+ if (
+ typeof document === "undefined" ||
+ typeof getComputedStyle !== "function"
+ ) {
+ return 0;
+ }
+ const value = Number.parseFloat(
+ getComputedStyle(document.documentElement).getPropertyValue(
+ "--studio-window-chrome-top",
+ ),
+ );
+ return Number.isFinite(value) && value > 0 ? value : 0;
+}
+
+export function getWindowChromeTop(): number {
+ chromeTop ??= readChromeTop();
+ return chromeTop;
+}
+
+/** Re-read after --studio-window-chrome-top or the value it references changes. */
+export function refreshWindowChromeTop(): void {
+ const next = readChromeTop();
+ if (next === chromeTop) {
+ return;
+ }
+ chromeTop = next;
+ for (const listener of listeners) {
+ listener();
+ }
+}
+
+function subscribe(listener: () => void): () => void {
+ listeners.add(listener);
+ return () => {
+ listeners.delete(listener);
+ };
+}
+
+export function useWindowChromeTop(): number {
+ return useSyncExternalStore(subscribe, getWindowChromeTop, () => 0);
+}
+
+/** Adds the titlebar to the top collision padding so popups size and flip below it. */
+export function clearOfWindowChrome(
+ padding: CollisionPadding | undefined,
+ top: number,
+): CollisionPadding | undefined {
+ if (top <= 0) {
+ return padding;
+ }
+ if (typeof padding === "object") {
+ return { ...padding, top: (padding.top ?? 0) + top };
+ }
+ const base = padding ?? 0;
+ return { top: base + top, right: base, bottom: base, left: base };
+}
+
+export function useWindowChromeCollisionPadding(
+ padding: CollisionPadding | undefined,
+): CollisionPadding | undefined {
+ return clearOfWindowChrome(padding, useWindowChromeTop());
+}
diff --git a/studio/frontend/tests/window-chrome-collision.test.ts b/studio/frontend/tests/window-chrome-collision.test.ts
new file mode 100644
index 00000000000..48631ee54f6
--- /dev/null
+++ b/studio/frontend/tests/window-chrome-collision.test.ts
@@ -0,0 +1,111 @@
+// 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 assert from "node:assert/strict";
+import test from "node:test";
+
+import { clearOfWindowChrome } from "../src/lib/window-chrome.ts";
+import { readSrcAsync } from "./helpers/kit.ts";
+
+test("popups stay below the desktop titlebar", () => {
+ assert.deepEqual(clearOfWindowChrome(16, 34), {
+ top: 50,
+ right: 16,
+ bottom: 16,
+ left: 16,
+ });
+ assert.deepEqual(clearOfWindowChrome(undefined, 34), {
+ top: 34,
+ right: 0,
+ bottom: 0,
+ left: 0,
+ });
+ assert.deepEqual(clearOfWindowChrome({ top: 8, left: 4 }, 34), {
+ top: 42,
+ left: 4,
+ });
+});
+
+test("a browser keeps the caller's padding untouched", () => {
+ assert.equal(clearOfWindowChrome(16, 0), 16);
+ assert.equal(clearOfWindowChrome(undefined, 0), undefined);
+ const padding = { top: 8 };
+ assert.equal(clearOfWindowChrome(padding, 0), padding);
+});
+
+test("every floating primitive clears the titlebar", async () => {
+ const uses = {
+ "dropdown-menu": 2,
+ "context-menu": 2,
+ menubar: 2,
+ popover: 1,
+ select: 1,
+ "hover-card": 1,
+ combobox: 1,
+ };
+ for (const [file, count] of Object.entries(uses)) {
+ const source = await readSrcAsync(`components/ui/${file}.tsx`);
+ assert.equal(
+ source.match(/collisionPadding=\{useWindowChromeCollisionPadding\(/g)
+ ?.length,
+ count,
+ file,
+ );
+ }
+});
+
+test("the message More menu clears the titlebar", async () => {
+ const thread = await readSrcAsync("components/assistant-ui/thread.tsx");
+ assert.match(
+ thread,
+ /const moreMenuCollisionPadding = useWindowChromeCollisionPadding\(undefined\);/,
+ );
+ assert.match(
+ thread,
+ /<ActionBarMorePrimitive\.Content[^>]*collisionPadding=\{moreMenuCollisionPadding\}/,
+ );
+ // Padding alone can't stop a flipped menu growing under the titlebar.
+ assert.match(
+ thread,
+ /aui-action-bar-more-content[^"]*max-h-\(--radix-dropdown-menu-content-available-height\)[^"]*overflow-y-auto/,
+ );
+});
+
+test("the titlebar height is re-read whenever it can change", async () => {
+ const provider = await readSrcAsync("app/provider.tsx");
+ assert.equal(provider.match(/refreshWindowChromeTop\(\);/g)?.length, 2);
+ assert.match(
+ provider,
+ /subscribeAppliedInterfaceZoom\(refreshWindowChromeTop\)/,
+ );
+});
+
+test("popovers stop at the titlebar and scroll", async () => {
+ const popover = await readSrcAsync("components/ui/popover.tsx");
+ assert.match(
+ popover,
+ /max-h-\(--radix-popover-content-available-height\) overflow-y-auto/,
+ );
+});
+
+test("dropdown submenus stop at the titlebar and scroll", async () => {
+ const menu = await readSrcAsync("components/ui/dropdown-menu.tsx");
+ const sub = menu.slice(menu.indexOf("function DropdownMenuSubContent"));
+ assert.match(
+ sub,
+ /max-h-\(--radix-dropdown-menu-content-available-height\)[^"]*flex flex-col overflow-hidden/,
+ );
+ assert.match(
+ sub,
+ /data-slot="dropdown-menu-viewport"\s+className="min-h-0 flex-1 overflow-x-hidden overflow-y-auto"\s*>\s*\{children\}/,
+ );
+});
+
+test("context submenus stop at the titlebar and scroll", async () => {
+ const menu = await readSrcAsync("components/ui/context-menu.tsx");
+ const sub = menu.slice(menu.indexOf("function ContextMenuSubContent"));
+ assert.match(
+ sub,
+ /max-h-\(--radix-context-menu-content-available-height\) overflow-x-hidden overflow-y-auto"/,
+ );
+});