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: blur modal titlebar background while keeping window controls sharp (#12433)

Lee Jackson1d4727cf2ff5
diff --git a/.github/workflows/studio-frontend-ci.yml b/.github/workflows/studio-frontend-ci.yml
index ef6d21f0e9b..b6ff2f3e8ad 100644
--- a/.github/workflows/studio-frontend-ci.yml
+++ b/.github/workflows/studio-frontend-ci.yml
@@ -20,6 +20,7 @@ on:
- 'tests/studio/playwright_strip_ansi_smoke.py'
- 'tests/studio/playwright_composer_icons.py'
+ - 'tests/studio/playwright_titlebar_blur.py'
- 'tests/studio/playwright_chat_autoscroll.py'
- 'tests/studio/playwright_research_freeze.py'
- 'tests/studio/playwright_research_review.py'
@@ -59,6 +60,7 @@ on:
- 'tests/studio/test_frontend_dep_removal.py'
- 'tests/studio/playwright_strip_ansi_smoke.py'
- 'tests/studio/playwright_composer_icons.py'
+ - 'tests/studio/playwright_titlebar_blur.py'
- 'tests/studio/playwright_chat_autoscroll.py'
- 'tests/studio/playwright_research_freeze.py'
- 'tests/studio/playwright_research_review.py'
@@ -446,6 +448,11 @@ jobs:
timeout-minutes: 3
run: python3 tests/studio/playwright_composer_icons.py chromium
+ - name: Titlebar modal blur and window controls (Chromium)
+ working-directory: ${{ github.workspace }}
+ timeout-minutes: 5
+ run: python3 tests/studio/playwright_titlebar_blur.py
+
# Each harness owns its vite server: starting one here backgrounds npm, so $! is the
# wrapper and killing it orphans the node child.
- name: Browser smoke for chat autoscroll
diff --git a/studio/frontend/smoke-titlebar-blur-main.tsx b/studio/frontend/smoke-titlebar-blur-main.tsx
new file mode 100644
index 00000000000..b4b122a95d7
--- /dev/null
+++ b/studio/frontend/smoke-titlebar-blur-main.tsx
@@ -0,0 +1,188 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+
+// Production chrome and overlays; deterministic media, no inference or desktop backend.
+import { useState, type CSSProperties } from "react";
+import { createRoot } from "react-dom/client";
+import { WindowTitlebar } from "@/components/tauri/window-titlebar";
+import { MediaViewer } from "@/components/media-viewer";
+import {
+ Dialog,
+ DialogContent,
+ DialogTitle,
+ DialogDescription,
+} from "@/components/ui/dialog";
+import {
+ AlertDialog,
+ AlertDialogContent,
+ AlertDialogTitle,
+ AlertDialogDescription,
+ AlertDialogCancel,
+} from "@/components/ui/alert-dialog";
+import {
+ Sheet,
+ SheetContent,
+ SheetTitle,
+ SheetDescription,
+} from "@/components/ui/sheet";
+import {
+ DropdownMenu,
+ DropdownMenuTrigger,
+ DropdownMenuContent,
+ DropdownMenuItem,
+} from "@/components/ui/dropdown-menu";
+import { TooltipProvider } from "@/components/ui/tooltip";
+import { Button } from "@/components/ui/button";
+import { GuidedTour } from "@/features/tour/components/guided-tour";
+import "./src/index.css";
+
+const art =
+ "data:image/svg+xml," +
+ encodeURIComponent(
+ `<svg xmlns="http://www.w3.org/2000/svg" width="960" height="540" viewBox="0 0 960 540"><rect width="960" height="540" fill="#cce8e5"/><circle cx="725" cy="130" r="65" fill="#f2cb7e"/><path d="M0 360L235 95L510 380L700 200L960 400V540H0Z" fill="#739f8e"/><path d="M0 430L290 265L535 450L770 330L960 450V540H0Z" fill="#345f55"/><path d="M0 480Q250 440 480 485T960 485V540H0Z" fill="#90bbba"/></svg>`,
+ );
+function Scene() {
+ const [kind, setKind] = useState("");
+ const [nested, setNested] = useState(false);
+ const [container, setContainer] = useState<HTMLDivElement | null>(null);
+ return (
+ <TooltipProvider>
+ <div
+ className="relative h-dvh overflow-hidden bg-background text-foreground"
+ style={
+ {
+ "--studio-custom-titlebar-height": "40px",
+ "--studio-window-chrome-top": "40px",
+ "--studio-window-control-inset": "138px",
+ } as CSSProperties
+ }
+ >
+ <WindowTitlebar showSidebarSurface />
+ <div className="flex h-full pt-10">
+ <aside className="w-60 shrink-0 bg-sidebar px-5 py-7">
+ <strong className="text-xl">unsloth</strong>
+ <div className="mt-8 space-y-5 text-sm">
+ <p>New chat</p>
+ <p>Model Hub</p>
+ <p>Library</p>
+ <p>Images</p>
+ <p className="rounded-lg bg-accent p-2">Create</p>
+ </div>
+ </aside>
+ <main className="flex-1 p-8">
+ <h1 className="mb-2 text-2xl font-medium">Create images</h1>
+ <p className="mb-6 text-muted-foreground">
+ Deterministic preview fixture · production title bar and media
+ viewer
+ </p>
+ <div className="mb-6 flex gap-3">
+ {["media", "dialog", "alert", "sheet", "tour", "scoped"].map((k) => (
+ <Button key={k} onClick={() => setKind(k)}>
+ Open {k}
+ </Button>
+ ))}
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <Button>Open menu</Button>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent>
+ <DropdownMenuItem>Menu item</DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ </div>
+ <img
+ data-tour="preview"
+ src={art}
+ alt="Illustrated mountain lake"
+ className="max-h-[60vh] rounded-xl"
+ />
+ </main>
+ </div>
+ <div
+ ref={setContainer}
+ className="absolute inset-x-60 top-48 bottom-8 pointer-events-none"
+ />
+ <MediaViewer
+ open={kind === "media"}
+ onOpenChange={(o) => !o && setKind("")}
+ title="Illustrated mountain lake"
+ meta="Test fixture · 960 × 540"
+ noun="image"
+ media
+ actions={{ onDownload: () => {} }}
+ >
+ <img
+ src={art}
+ width={960}
+ height={540}
+ alt="Illustrated mountain lake preview"
+ />
+ </MediaViewer>
+ <Dialog
+ open={kind === "dialog" || kind === "scoped"}
+ onOpenChange={(o) => !o && setKind("")}
+ >
+ <DialogContent
+ container={kind === "scoped" ? container : undefined}
+ position={kind === "scoped" ? "absolute" : "fixed"}
+ >
+ <DialogTitle>Example dialog</DialogTitle>
+ <DialogDescription>
+ Check the title bar while this dialog is open.
+ </DialogDescription>
+ <Button onClick={() => setNested(true)}>Open nested</Button>
+ </DialogContent>
+ </Dialog>
+ <AlertDialog
+ open={kind === "alert" || nested}
+ onOpenChange={(o) => {
+ if (!o) {
+ setNested(false);
+ if (kind === "alert") setKind("");
+ }
+ }}
+ >
+ <AlertDialogContent>
+ <AlertDialogTitle>Confirm action</AlertDialogTitle>
+ <AlertDialogDescription>
+ Nested modals keep the title bar blurred.
+ </AlertDialogDescription>
+ <AlertDialogCancel>Cancel</AlertDialogCancel>
+ </AlertDialogContent>
+ </AlertDialog>
+ <Sheet open={kind === "sheet"} onOpenChange={(o) => !o && setKind("")}>
+ <SheetContent>
+ <SheetTitle>Example sheet</SheetTitle>
+ <SheetDescription>
+ A viewport backdrop covers the page.
+ </SheetDescription>
+ </SheetContent>
+ </Sheet>
+ <GuidedTour
+ open={kind === "tour"}
+ onOpenChange={(o) => !o && setKind("")}
+ steps={[
+ {
+ id: "preview",
+ target: "preview",
+ title: "Preview tour",
+ body: "The viewport tour backdrop must also cover the titlebar.",
+ },
+ ]}
+ onSkip={() => {}}
+ onComplete={() => {}}
+ />
+ </div>
+ </TooltipProvider>
+ );
+}
+// App provider normally publishes these for dialogs portaled to document.body.
+document.documentElement.style.setProperty(
+ "--studio-custom-titlebar-height",
+ "40px",
+);
+document.documentElement.style.setProperty(
+ "--studio-window-chrome-top",
+ "40px",
+);
+createRoot(document.getElementById("root")!).render(<Scene />);
diff --git a/studio/frontend/smoke-titlebar-blur.html b/studio/frontend/smoke-titlebar-blur.html
new file mode 100644
index 00000000000..9e12fa35aac
--- /dev/null
+++ b/studio/frontend/smoke-titlebar-blur.html
@@ -0,0 +1,12 @@
+<!doctype html>
+<html lang="en">
+ <head>
+ <meta charset="UTF-8" />
+ <script src="/crypto-boot.js"></script>
+ <title>Titlebar modal blur</title>
+ </head>
+ <body>
+ <div id="root"></div>
+ <script type="module" src="/smoke-titlebar-blur-main.tsx"></script>
+ </body>
+</html>
diff --git a/studio/frontend/src/components/tauri/window-titlebar.tsx b/studio/frontend/src/components/tauri/window-titlebar.tsx
index 1387c5f66e6..8e51acd70d3 100644
--- a/studio/frontend/src/components/tauri/window-titlebar.tsx
+++ b/studio/frontend/src/components/tauri/window-titlebar.tsx
@@ -458,6 +458,7 @@ export function WindowTitlebar({
showSidebarSurface && "bg-sidebar text-sidebar-foreground",
)}
data-titlebar-live-width-scope=""
+ data-slot="window-titlebar"
aria-label="Window titlebar"
>
{showSidebarSurface && (
@@ -487,7 +488,8 @@ export function WindowTitlebar({
/>
<div
className={cn(
- "pointer-events-auto absolute right-0 top-0 flex h-full",
+ // Keep native window actions crisp above the visual modal backdrop.
+ "pointer-events-auto absolute right-0 top-0 z-[100] flex h-full",
focused ? "text-foreground" : "text-muted-foreground",
)}
role="toolbar"
diff --git a/studio/frontend/src/components/ui/alert-dialog.tsx b/studio/frontend/src/components/ui/alert-dialog.tsx
index 50e4d8c9218..124cf57ce05 100644
--- a/studio/frontend/src/components/ui/alert-dialog.tsx
+++ b/studio/frontend/src/components/ui/alert-dialog.tsx
@@ -40,6 +40,7 @@ function AlertDialogOverlay({
return (
<AlertDialogPrimitive.Overlay
data-slot="alert-dialog-overlay"
+ data-viewport-backdrop={true}
className={cn(
"data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 bg-black/30 duration-100 supports-backdrop-filter:backdrop-blur-[2px] fixed inset-0 z-50",
className,
diff --git a/studio/frontend/src/components/ui/dialog.tsx b/studio/frontend/src/components/ui/dialog.tsx
index ef081388087..8705f0f0b76 100644
--- a/studio/frontend/src/components/ui/dialog.tsx
+++ b/studio/frontend/src/components/ui/dialog.tsx
@@ -59,6 +59,7 @@ function DialogOverlay({
return (
<DialogPrimitive.Overlay
data-slot="dialog-overlay"
+ data-viewport-backdrop={position === "fixed" ? true : undefined}
className={cn(
"data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 bg-black/30 supports-backdrop-filter:backdrop-blur-[2px] duration-100 inset-0 isolate z-50",
position === "fixed" ? "fixed" : "absolute",
diff --git a/studio/frontend/src/components/ui/sheet.tsx b/studio/frontend/src/components/ui/sheet.tsx
index 7d66504a0c4..b68fef7d92f 100644
--- a/studio/frontend/src/components/ui/sheet.tsx
+++ b/studio/frontend/src/components/ui/sheet.tsx
@@ -69,6 +69,7 @@ function SheetOverlay({
return (
<SheetPrimitive.Overlay
data-slot="sheet-overlay"
+ data-viewport-backdrop={position === "fixed" ? true : undefined}
className={cn(
"data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 bg-black/30 duration-100 data-ending-style:opacity-0 data-starting-style:opacity-0 supports-backdrop-filter:backdrop-blur-[2px] inset-0 z-50",
position === "fixed" ? "fixed" : "absolute",
diff --git a/studio/frontend/src/features/tour/components/guided-tour.tsx b/studio/frontend/src/features/tour/components/guided-tour.tsx
index fe6d39b7d0e..e29874b12a5 100644
--- a/studio/frontend/src/features/tour/components/guided-tour.tsx
+++ b/studio/frontend/src/features/tour/components/guided-tour.tsx
@@ -245,6 +245,7 @@ export function GuidedTour({
<motion.div
// The shared slot, so modal checks see the tour.
data-slot="dialog-overlay"
+ data-viewport-backdrop={true}
className="fixed inset-0 z-50"
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
diff --git a/studio/frontend/src/index.css b/studio/frontend/src/index.css
index b13684b066e..811e8c82e0f 100644
--- a/studio/frontend/src/index.css
+++ b/studio/frontend/src/index.css
@@ -16,6 +16,30 @@
@custom-variant dark (&:is(.dark *));
@layer components {
+ /* The custom Windows/Linux titlebar stays above modal backdrops so native
+ window actions remain usable. Repeat the standard backdrop over the surface
+ and page navigation. Window controls paint above it, keeping their glyphs
+ and hover feedback sharp without changing hit testing.
+ Only viewport backdrops participate; a panel-local dialog or a menu must
+ not dim the window chrome. :has also keeps stacked modals correct without
+ a separate counter or document-wide MutationObserver. */
+ [data-slot="window-titlebar"]::after {
+ content: "";
+ position: absolute;
+ inset: 0;
+ z-index: 90;
+ pointer-events: none;
+ background: rgb(0 0 0 / 30%);
+ -webkit-backdrop-filter: blur(2px);
+ backdrop-filter: blur(2px);
+ opacity: 0;
+ transition: opacity 100ms;
+ }
+ body:has(> [data-viewport-backdrop="true"][data-state="open"])
+ [data-slot="window-titlebar"]::after {
+ opacity: 1;
+ }
+
/* The surface the sidebar panel actually paints. The collapsed icon rail
repaints it, so gradients fading into the panel must read this rather
than --sidebar, or they render as a block instead of a fade. */
diff --git a/studio/frontend/tests/titlebar-modal-layering.test.ts b/studio/frontend/tests/titlebar-modal-layering.test.ts
index 5795785630a..6b4ccc594c0 100644
--- a/studio/frontend/tests/titlebar-modal-layering.test.ts
+++ b/studio/frontend/tests/titlebar-modal-layering.test.ts
@@ -21,6 +21,12 @@ const CLOSED_DECORATION_PATTERN = /<\/div>\s*\)\}\s*$/;
const DIALOG_SURFACE_CLASSES =
/<(?:DialogContent|AlertDialogContent|CommandDialog)\b(?:[^>]|=>)*?\bclassName="([^"]*)"/g;
const WHOLE_WINDOW_CENTRE = /(?:^|\s)(?:max-sm:)?top-1\/2(?:\s|$)/;
+const DIRECT_VIEWPORT_BACKDROP_PATTERN =
+ /body:has\(> \[data-viewport-backdrop="true"\]\[data-state="open"\]\)/;
+const DESCENDANT_VIEWPORT_BACKDROP_PATTERN =
+ /body:has\(\[data-viewport-backdrop="true"\]\[data-state="open"\]\)/;
+const TOUR_VIEWPORT_BACKDROP_PATTERN =
+ /data-slot="dialog-overlay"[\s\S]*?data-viewport-backdrop=\{true\}/;
/** Every component under src, so a new dialog cannot slip past. */
const COMPONENTS = readdirSync(join(import.meta.dirname, "../src"), {
@@ -93,3 +99,14 @@ test("dialogs that set their own top still centre below the window chrome", () =
}
assert.ok(checked > 10, `only ${checked} dialog surfaces matched`);
});
+
+test("viewport titlebar effects stay mutation-scoped and cover custom modal chrome", async () => {
+ const [styles, tour] = await Promise.all([
+ readSrc("index.css"),
+ readSrc("features/tour/components/guided-tour.tsx"),
+ ]);
+
+ assert.match(styles, DIRECT_VIEWPORT_BACKDROP_PATTERN);
+ assert.doesNotMatch(styles, DESCENDANT_VIEWPORT_BACKDROP_PATTERN);
+ assert.match(tour, TOUR_VIEWPORT_BACKDROP_PATTERN);
+});
diff --git a/studio/frontend/tsconfig.app.json b/studio/frontend/tsconfig.app.json
index a189a89b9b3..5e35a2b3391 100644
--- a/studio/frontend/tsconfig.app.json
+++ b/studio/frontend/tsconfig.app.json
@@ -32,6 +32,7 @@
"src",
"smoke-ansi-main.tsx",
"smoke-composer-icons-main.tsx",
+ "smoke-titlebar-blur-main.tsx",
"smoke-find-in-page-main.tsx",
"smoke-autoscroll-main.tsx",
"smoke-research-main.tsx",
diff --git a/tests/studio/playwright_titlebar_blur.py b/tests/studio/playwright_titlebar_blur.py
new file mode 100644
index 00000000000..6e706bd8b96
--- /dev/null
+++ b/tests/studio/playwright_titlebar_blur.py
@@ -0,0 +1,240 @@
+# SPDX-License-Identifier: AGPL-3.0-only
+# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+"""Production chrome/overlay regression scene, with Tauri IPC stubbed.
+
+Runs its own Vite server, or uses SMOKE_URL when supplied.
+Set SMOKE_EVIDENCE_DIR to keep screenshots and measured facts.
+SMOKE_EXPECT_BLUR=0 captures the same scene against the unmodified base.
+No backend, inference, or real native window actions are used.
+"""
+
+import json
+import os
+import re
+import sys
+import tempfile
+from pathlib import Path
+from playwright.sync_api import sync_playwright, expect
+
+sys.path.insert(0, str(Path(__file__).resolve().parent))
+from _playwright_robust import chromium_launch_args, start_vite, stop_process
+
+PORT = int(os.environ.get("SMOKE_PORT", "5491"))
+URL = os.environ.get("SMOKE_URL", f"http://127.0.0.1:{PORT}/smoke-titlebar-blur.html")
+EXPECTED = os.environ.get("SMOKE_EXPECT_BLUR", "1") == "1"
+OUT = Path(
+ os.environ.get(
+ "SMOKE_EVIDENCE_DIR", str(Path(tempfile.gettempdir()) / "titlebar-blur-evidence")
+ )
+)
+OUT.mkdir(parents = True, exist_ok = True)
+INIT = r"""
+Object.defineProperty(navigator, 'platform', {get: () => 'Win32'});
+Object.defineProperty(navigator, 'userAgentData', {get: () => ({platform: 'Windows'})});
+window.__windowActions = [];
+window.__TAURI_INTERNALS__ = {
+ metadata: {currentWindow: {label: 'main'}, currentWebview: {label: 'main'}},
+ transformCallback: () => 1, unregisterCallback: () => {},
+ invoke: async (cmd, args) => {
+ window.__windowActions.push({cmd, args});
+ if (cmd.endsWith('is_maximized')) return false;
+ if (cmd.endsWith('is_resizable') || cmd.endsWith('is_focused')) return true;
+ if (cmd === 'plugin:event|listen') return 1;
+ return null;
+ }
+};
+window.__TAURI_EVENT_PLUGIN_INTERNALS__ = {unregisterListener: () => {}};
+"""
+
+
+def run():
+ with sync_playwright() as p:
+ browser = p.chromium.launch(args = chromium_launch_args())
+ context = browser.new_context(
+ viewport = {"width": 1440, "height": 900}, device_scale_factor = 1
+ )
+ context.add_init_script(INIT)
+ page = context.new_page()
+ errors = []
+ page.on("pageerror", lambda e: (errors.append(str(e)), print("PAGE ERROR:", e)))
+ page.route(
+ re.compile(r"^http://127\.0\.0\.1:\d+/api/"), lambda route: route.fulfill(json = [])
+ )
+ print("Loading", URL)
+ page.on(
+ "response",
+ lambda response: errors.append(f"{response.status}: {response.url}")
+ if response.status >= 400
+ and response.request.resource_type in ("script", "stylesheet", "font")
+ else None,
+ )
+ page.goto(URL)
+ titlebar = page.locator('header[aria-label="Window titlebar"]')
+ expect(titlebar).to_be_visible(timeout = 60000)
+ page.get_by_role("button", name = "Open media", exact = True).click()
+ expect(page.get_by_role("dialog")).to_be_visible()
+ page.wait_for_timeout(500)
+ print("Media open")
+
+ def facts():
+ return titlebar.evaluate("""e => {const s = getComputedStyle(e, '::after'); return {
+ titlebarZ: getComputedStyle(e).zIndex, content: s.content,
+ opacity: s.opacity, blur: s.backdropFilter, pointerEvents: s.pointerEvents,
+ backdropZ: s.zIndex,
+ controlsZ: getComputedStyle(e.querySelector('[aria-label="Window controls"]')).zIndex,
+ overlayZ: getComputedStyle(document.querySelector('[data-slot="dialog-overlay"]')).zIndex
+ }}""")
+
+ def blurred(want):
+ # Wait for the transition rather than assuming a fixed frame budget.
+ # Compositors can report an epsilon near zero on the final frame.
+ if not EXPECTED:
+ page.wait_for_timeout(180)
+ return
+ page.wait_for_function(
+ """want => {
+ const e = document.querySelector('header[aria-label="Window titlebar"]');
+ const value = Number(getComputedStyle(e, '::after').opacity);
+ return Math.abs(value - (want ? 1 : 0)) < 0.0001;
+ }""",
+ arg = want,
+ timeout = 5000,
+ )
+
+ blurred(True)
+ media_facts = facts()
+ if EXPECTED:
+ assert media_facts["blur"] == "blur(2px)", media_facts
+ assert media_facts["pointerEvents"] == "none", media_facts
+ assert int(media_facts["controlsZ"]) > int(media_facts["backdropZ"]), media_facts
+ else:
+ assert media_facts["content"] == "none", media_facts
+ page.evaluate("document.fonts.ready")
+ page.screenshot(path = str(OUT / "media-light.png"))
+ page.screenshot(
+ path = str(OUT / "titlebar-light.png"),
+ clip = {"x": 0, "y": 0, "width": 1440, "height": 150},
+ )
+ page.evaluate("document.documentElement.classList.add('dark')")
+ page.wait_for_timeout(180)
+ page.screenshot(path = str(OUT / "media-dark.png"))
+ page.evaluate("document.documentElement.classList.remove('dark')")
+ page.keyboard.press("Escape")
+ blurred(False)
+ expect(page.get_by_role("dialog")).to_have_count(0)
+ print("Starting modal checks")
+ tour_facts = None
+ for kind in ["dialog", "alert", "sheet", "tour", "scoped"]:
+ print("Checking", kind)
+ page.get_by_role("button", name = f"Open {kind}", exact = True).click()
+ blurred(kind != "scoped")
+ if kind == "dialog":
+ page.get_by_role("button", name = "Open nested", exact = True).click()
+ blurred(True)
+ page.get_by_role("button", name = "Cancel", exact = True).click()
+ blurred(True)
+ if kind == "alert":
+ page.get_by_role("button", name = "Cancel", exact = True).click()
+ elif kind == "tour":
+ tour_facts = facts()
+ if EXPECTED:
+ assert tour_facts["blur"] == "blur(2px)", tour_facts
+ assert tour_facts["opacity"] == "1", tour_facts
+ else:
+ assert tour_facts["content"] == "none", tour_facts
+ page.screenshot(path = str(OUT / "tour-light.png"))
+ page.get_by_role("button", name = "Skip", exact = True).click()
+ elif kind in ("dialog", "scoped"):
+ page.locator("[data-slot=dialog-close]").click()
+ else:
+ page.keyboard.press("Escape")
+ blurred(False)
+ page.get_by_role("button", name = "Open menu", exact = True).click()
+ expect(page.get_by_role("menu")).to_be_visible()
+ blurred(False)
+ page.keyboard.press("Escape")
+ commands = []
+ for label, command in [
+ ("Minimize window", "minimize"),
+ ("Maximize window", "toggle_maximize"),
+ ("Close window", "close"),
+ ]:
+ page.get_by_role("button", name = "Open media", exact = True).click()
+ blurred(True)
+ # Native controls are intentionally pointer-accessible even while Radix hides the background from AT.
+ page.locator(f'button[aria-label="{label}"]').click()
+ page.wait_for_function(
+ "c => window.__windowActions.some(a => a.cmd === 'plugin:window|' + c)", arg = command
+ )
+ commands.append(command)
+ page.keyboard.press("Escape")
+ blurred(False)
+ page.get_by_role("button", name = "Open media", exact = True).click()
+ blurred(True)
+ page.mouse.move(600, 20)
+ page.mouse.down()
+ page.mouse.move(640, 25)
+ page.mouse.up()
+ page.wait_for_function(
+ "() => window.__windowActions.some(a => a.cmd === 'plugin:window|start_dragging')"
+ )
+ page.keyboard.press("Escape")
+ blurred(False)
+ page.set_viewport_size({"width": 640, "height": 700})
+ page.get_by_role("button", name = "Open media", exact = True).click()
+ blurred(True)
+ page.screenshot(path = str(OUT / "media-narrow.png"))
+ # Web and native macOS chrome do not acquire the custom titlebar effect.
+ for platform in ("web", "macOS"):
+ other = browser.new_context()
+ if platform == "macOS":
+ other.add_init_script(INIT.replace("Win32", "MacIntel").replace("Windows", "macOS"))
+ web = other.new_page()
+ web.route(
+ re.compile(r"^http://127\.0\.0\.1:\d+/api/"), lambda route: route.fulfill(json = [])
+ )
+ web.goto(URL)
+ web.get_by_role("button", name = "Open media", exact = True).click()
+ expect(web.get_by_role("dialog")).to_be_visible()
+ expect(web.locator('header[aria-label="Window titlebar"]')).to_have_count(0)
+ other.close()
+ assert not errors, errors
+ (OUT / "facts.json").write_text(
+ json.dumps(
+ {
+ "url": URL,
+ "expected_blur": EXPECTED,
+ "media": media_facts,
+ "tour": tour_facts,
+ "commands": commands + ["start_dragging"],
+ "checks": [
+ "media",
+ "dialog",
+ "alert",
+ "sheet",
+ "tour",
+ "scoped excluded",
+ "menu excluded",
+ "nested",
+ "close cleanup",
+ "dark",
+ "narrow",
+ "web",
+ "macOS",
+ ],
+ "page_errors": errors,
+ },
+ indent = 2,
+ )
+ )
+ browser.close()
+ print(json.dumps({"passed": True, "facts": media_facts, "output": str(OUT)}))
+
+
+if __name__ == "__main__":
+ server = None if os.environ.get("SMOKE_URL") else start_vite(PORT)
+ try:
+ run()
+ finally:
+ if server is not None:
+ stop_process(server)