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.

Stop the corner update toasts being cut off at the bottom (#9246)

Michael Han54de1e80537d
diff --git a/.github/workflows/studio-frontend-ci.yml b/.github/workflows/studio-frontend-ci.yml
index 1d4e52b44c3..62c28571d0a 100644
--- a/.github/workflows/studio-frontend-ci.yml
+++ b/.github/workflows/studio-frontend-ci.yml
@@ -25,6 +25,10 @@ on:
- 'tests/studio/probe_dismiss_guard.py'
- 'tests/studio/playwright_settings_tabs.py'
- 'tests/studio/playwright_stream_pacing.py'
+ # studio-ui-smoke.yml also triggers on tests/studio/**, but its step loops over
+ # firefox and webkit only, so without this a PR touching just this driver would
+ # never run it under Chromium.
+ - 'tests/studio/playwright_overlay_rail.py'
- 'tests/studio/playwright_code_block_flicker.py'
- 'tests/studio/_code_block_flicker_analysis.py'
- 'tests/studio/test_code_block_flicker_contract.py'
@@ -424,6 +428,23 @@ jobs:
working-directory: ${{ github.workspace }}
run: python3 tests/studio/playwright_settings_tabs.py
+ # The overlay rail's shadow gutter is block padding compensated for by two offsets and
+ # discounted back out of the measurement. Every part of that is a browser reading, so
+ # the node suite cannot see any of it, and the suites that boot Studio assert the
+ # horizontal gutter and the cap. Firefox and WebKit run it in studio-ui-smoke.yml,
+ # where they are already installed.
+ - name: Browser smoke for the overlay rail's shadow gutter
+ working-directory: ${{ github.workspace }}
+ env:
+ SMOKE_PORT: '5197'
+ # playwright-<name>, with the hyphen: the artifact step below uploads
+ # logs/playwright-* and an underscore would leave this gate's screenshot and
+ # failure report on the runner, which is the run where they are the whole point.
+ PW_ART_DIR: logs/playwright-overlay-rail
+ run: |
+ mkdir -p logs/playwright-overlay-rail
+ python3 tests/studio/playwright_overlay_rail.py
+
# A panel that cannot be fetched is new with lazy loading, and nothing above the
# root-mounted dialog catches, so unguarded it unmounts Studio, not one panel.
- name: Browser smoke for a settings panel that cannot load
diff --git a/.github/workflows/studio-ui-smoke.yml b/.github/workflows/studio-ui-smoke.yml
index 3adba96bb6a..b2f9f32bb34 100644
--- a/.github/workflows/studio-ui-smoke.yml
+++ b/.github/workflows/studio-ui-smoke.yml
@@ -601,6 +601,22 @@ jobs:
python tests/studio/playwright_update_banner_layout.py
done
+ # The rail's block gutter, in the two engines this runner has that the frontend CI
+ # does not. Serves its own vite rather than the Studio above it, so it needs no
+ # BASE_URL and does not care what state that Studio is in; it is here only because
+ # WebKit's install is already paid for on this shard.
+ - name: Overlay rail shadow gutter, other engines (Playwright)
+ if: matrix.shard == 'banner'
+ env:
+ SMOKE_PORT: '5197'
+ PW_ART_DIR: logs/playwright-overlay-rail
+ run: |
+ mkdir -p logs/playwright-overlay-rail
+ for engine in firefox webkit; do
+ STUDIO_PLAYWRIGHT_BROWSER="$engine" \
+ python tests/studio/playwright_overlay_rail.py
+ done
+
- name: Image model full-footprint selector regression (Playwright)
if: matrix.shard == 'extra'
env:
@@ -762,6 +778,7 @@ jobs:
logs/playwright_thread_settings
logs/playwright_fontscale
logs/playwright_update_banner
+ logs/playwright-overlay-rail
logs/playwright_image_footprint
logs/playwright_image_cancel_retry
logs/playwright_image_cancel_retry_cold
diff --git a/studio/frontend/smoke-overlay-rail-main.tsx b/studio/frontend/smoke-overlay-rail-main.tsx
new file mode 100644
index 00000000000..3d0965e3ce1
--- /dev/null
+++ b/studio/frontend/smoke-overlay-rail-main.tsx
@@ -0,0 +1,323 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+
+// Harness for tests/studio/playwright_overlay_rail.py, shaped like smoke-settings.html: a
+// vite entry with no backend and no auth, driving the real useStackGeometry.
+//
+// Everything the rail's geometry rests on -- the computed padding, both scrollHeight probes,
+// the clip, the hit box -- needs a DOM, and the node suite has none. The full app has one but
+// only behind a backend, a router and four polling cards.
+//
+// The rail below is a copy of the one in src/app/provider.tsx, className and style keys
+// included; playwright_overlay_rail.py pins the two against each other so it cannot drift.
+
+/* eslint-disable no-restricted-imports -- a harness entry point, not app code. */
+import {
+ STACK_SHADOW_GUTTER_BOTTOM,
+ STACK_SHADOW_GUTTER_TOP,
+ type MonitorFrame,
+ railBottomOffset,
+ railMaxHeight,
+ useMonitorFrameStore,
+ useStackGeometry,
+} from "@/features/settings/stores/monitor-frame-store";
+/* eslint-enable no-restricted-imports */
+import { Z_LAYER } from "@/lib/z-layers";
+import { cn } from "@/lib/utils";
+import { StrictMode, useSyncExternalStore } from "react";
+import { createRoot } from "react-dom/client";
+import "./src/index.css";
+
+/** One card in the rail, as the driver describes it. */
+type CardSpec = {
+ /** Natural height, the card's own `min-h-[...]` floor equivalent. */
+ height: number;
+ /** How far it may be squeezed. Equal to `height` models a card that cannot. */
+ floor?: number;
+ /** Transient banners carry this; the download and loaded-model cards do not. */
+ dismissible?: boolean;
+ /** Dragged out of the rail's flow, the way the loaded-models card can be. */
+ dragged?: boolean;
+};
+
+declare global {
+ interface Window {
+ // Optional: the app typechecks this entry, but only the harness page installs it.
+ __railSmoke?: {
+ setCards: (cards: CardSpec[]) => void;
+ publish: (who: string, frame: MonitorFrame) => void;
+ clear: (who: string) => void;
+ /** What the hook last handed the rail, before either offset is applied. */
+ geometry: () => { bottom: number; maxHeight: number; overflowing: boolean };
+ /** The reserved room, so the driver asserts against the source, not a copy. */
+ gutter: () => { top: number; bottom: number };
+ state: () => { cards: CardSpec[]; errors: string[] };
+ errors: () => string[];
+ };
+ }
+}
+
+const seenErrors: string[] = [];
+window.addEventListener("error", (e) => {
+ seenErrors.push(String(e.message));
+});
+window.addEventListener("unhandledrejection", (e) => {
+ seenErrors.push(String(e.reason));
+});
+
+// Publisher tokens are compared by identity and the store folds frames one at a time, so
+// each obstacle needs its own stable token; their union under one token is a different
+// input, and a wrong one.
+const publishers = new Map<string, object>();
+function publisherFor(who: string): object {
+ let token = publishers.get(who);
+ if (!token) {
+ token = {};
+ publishers.set(who, token);
+ }
+ return token;
+}
+
+// A store of one value, so setCards re-renders without pulling in any app state.
+let cards: CardSpec[] = [];
+const listeners = new Set<() => void>();
+function setCards(next: CardSpec[]): void {
+ cards = next;
+ for (const listener of listeners) listener();
+}
+function subscribe(listener: () => void): () => void {
+ listeners.add(listener);
+ return () => {
+ listeners.delete(listener);
+ };
+}
+
+function Card({ spec, index }: { spec: CardSpec; index: number }) {
+ const floor = spec.floor ?? spec.height;
+ return (
+ <div
+ className={cn(
+ "pointer-events-auto flex w-[calc(100vw-2rem)] max-w-[448px] flex-col",
+ spec.dragged && "fixed top-2 left-2 z-[9999] w-fit",
+ )}
+ data-overlay-dismissible={spec.dismissible ? "true" : undefined}
+ data-card-index={index}
+ style={{ minHeight: floor, flex: floor === spec.height ? "none" : "0 1 auto" }}
+ >
+ {/* The shadow the gutter is sized against: the same pair every rail surface carries. */}
+ <div
+ className="menu-soft-surface menu-soft-edgeless relative flex min-h-0 flex-col overflow-hidden rounded-[24px] bg-card"
+ data-card-surface={index}
+ style={{ height: spec.height, minHeight: floor }}
+ >
+ {/* Its own scroller, so the squeeze the rail probes for is a real one. */}
+ <div className="min-h-0 flex-1 overflow-y-auto p-4 text-sm">
+ {`card ${index}`}
+ <div style={{ height: spec.height * 2 }} />
+ </div>
+ </div>
+ </div>
+ );
+}
+
+// What the hook last returned, so the driver can compare the band the cards were given
+// against the box that was laid out.
+let lastGeometry = { bottom: 0, maxHeight: 0, overflowing: false };
+
+function Rail() {
+ const live = useSyncExternalStore(subscribe, () => cards);
+ const stack = useStackGeometry();
+ lastGeometry = {
+ bottom: stack.bottom,
+ maxHeight: stack.maxHeight,
+ overflowing: stack.overflowing,
+ };
+ return (
+ <div
+ ref={stack.ref}
+ data-testid="overlay-rail"
+ // Copied from src/app/provider.tsx. Keep both in step; the driver asserts it.
+ className={cn(
+ "fixed right-4 -mx-3 flex flex-col items-end gap-2 overflow-y-auto overflow-x-hidden overscroll-contain px-3",
+ stack.overflowing ? "pointer-events-auto" : "pointer-events-none",
+ )}
+ style={{
+ bottom: railBottomOffset(stack.bottom),
+ maxHeight: railMaxHeight(stack.maxHeight),
+ paddingTop: STACK_SHADOW_GUTTER_TOP,
+ paddingBottom: STACK_SHADOW_GUTTER_BOTTOM,
+ zIndex: Z_LAYER.OVERLAY_STACK,
+ }}
+ >
+ {live.map((spec, index) => (
+ <Card key={index} spec={spec} index={index} />
+ ))}
+ </div>
+ );
+}
+
+/**
+ * Stand-ins for the two surfaces that publish a frame: the Live monitor, which is a floating
+ * panel and so paints over the rail, and the chat composer, which does not.
+ */
+function Obstacles() {
+ const frames = useMonitorFrameStore((s) => s.frames);
+ const boxes: Array<[string, MonitorFrame]> = [];
+ for (const [token, frame] of frames) {
+ for (const [who, mine] of publishers) {
+ if (mine === token) boxes.push([who, frame]);
+ }
+ }
+ return (
+ <>
+ {boxes.map(([who, frame]) => (
+ <div
+ key={who}
+ data-testid={`obstacle-${who}`}
+ className="fixed rounded-xl border border-border/70 bg-muted"
+ style={{
+ left: frame.left,
+ top: frame.top,
+ width: Math.max(0, frame.right - frame.left),
+ height: Math.max(0, frame.bottom - frame.top),
+ // The Live monitor is a floating panel, which outranks the rail; the composer is
+ // in-page chrome and sits below it.
+ zIndex: who === "monitor" ? Z_LAYER.FLOATING_PANEL : 100,
+ resize: who === "monitor" ? "both" : "none",
+ overflow: who === "monitor" ? "auto" : "hidden",
+ }}
+ />
+ ))}
+ </>
+ );
+}
+
+/**
+ * All eight of the window's resize targets, copied from window-titlebar.tsx, so the driver
+ * can ask which ones the rail's box reaches rather than being told. A card is
+ * `w-[calc(100vw-2rem)]` up to its max, so a narrow window brings the left-hand ones in too.
+ */
+// Each carries the layer the app gives it, so the driver can separate which targets the
+// box reaches from which it takes: the difference is what a named layer is already covering.
+const RESIZE_TARGETS = [
+ ["resize-north", "fixed inset-x-2 top-0 h-1 cursor-n-resize"],
+ ["resize-south", "fixed inset-x-2 bottom-0 h-1 cursor-s-resize"],
+ ["resize-west", "fixed inset-y-2 left-0 w-1 cursor-w-resize"],
+ ["resize-east", "fixed inset-y-2 right-0 w-1 cursor-e-resize"],
+ ["resize-northwest", "fixed top-0 left-0 size-3 cursor-nw-resize"],
+ ["resize-northeast", "fixed top-0 right-0 size-3 cursor-ne-resize"],
+ ["resize-southwest", "fixed bottom-0 left-0 size-3 cursor-sw-resize"],
+ ["resize-southeast", "fixed right-0 bottom-0 size-3 cursor-se-resize"],
+] as const;
+
+// Overridable per load, so one run measures the shape this PR inherited as well as the one
+// it ships: `?gripz=70&headerz=70` is the titlebar before it was touched.
+const params = new URLSearchParams(window.location.search);
+function layerParam(name: string, fallback: number): number {
+ const raw = params.get(name);
+ if (raw === null) return fallback;
+ const parsed = Number(raw);
+ return Number.isFinite(parsed) ? parsed : fallback;
+}
+const GRIP_Z = layerParam("gripz", Z_LAYER.WINDOW_RESIZE_EDGE);
+// 70 is the app's own header, on Tailwind's scale with the rest of the in-page chrome.
+const HEADER_Z = layerParam("headerz", 70);
+// None by default: a z-index here cannot escape the header above it. `?toolbarz=` puts one
+// back so the driver can show it changes nothing.
+const TOOLBAR_Z = params.has("toolbarz")
+ ? layerParam("toolbarz", 0)
+ : undefined;
+
+function WindowResizeTargets() {
+ return (
+ <>
+ {RESIZE_TARGETS.map(([id, shape]) => (
+ <div
+ key={id}
+ aria-hidden="true"
+ data-testid={id}
+ className={cn("pointer-events-auto", shape)}
+ style={{ zIndex: GRIP_Z }}
+ />
+ ))}
+ </>
+ );
+}
+
+/**
+ * The window controls, whose corner the north-east grip lands on. Shaped like the toolbar in
+ * window-titlebar.tsx: `right-1` plus `px-1` leaves Close's right edge 8px in, and a 30px
+ * button centred in the band puts its top a couple of px down, so the grip's corner and the
+ * button's overlap.
+ *
+ * The `<header>` is not decoration. In the app the toolbar sits inside a positioned, numbered
+ * header, which by CSS is a stacking context and confines every z-index inside it. Without it
+ * the buttons compare against the grips directly, which is a more forgiving question than the
+ * one the app asks: it is the ancestor that has to out-rank a grip.
+ */
+function WindowControls() {
+ return (
+ <header
+ data-testid="titlebar-header"
+ className="pointer-events-none absolute inset-x-0 top-0 h-[34px] select-none"
+ style={{ zIndex: HEADER_Z }}
+ >
+ <div
+ className="pointer-events-auto absolute right-1 top-0 flex h-full items-center gap-0.5 px-1"
+ role="toolbar"
+ aria-label="Window controls"
+ style={TOOLBAR_Z === undefined ? undefined : { zIndex: TOOLBAR_Z }}
+ >
+ {["minimize", "maximize", "close"].map((name) => (
+ <button
+ key={name}
+ type="button"
+ data-testid={`control-${name}`}
+ aria-label={name}
+ className="relative z-[80] inline-flex size-[30px] items-center justify-center rounded-[10px]"
+ />
+ ))}
+ </div>
+ </header>
+ );
+}
+
+function Harness() {
+ return (
+ <>
+ <Obstacles />
+ {/* Header before grips, as window-titlebar.tsx renders them. Not cosmetic: equal
+ z-indexes are resolved by document order, so swapping these two hands the corner
+ to whichever comes last and the pre-PR control run measures the wrong titlebar. */}
+ <WindowControls />
+ <WindowResizeTargets />
+ <Rail />
+ </>
+ );
+}
+
+window.__railSmoke = {
+ setCards,
+ publish: (who, frame) =>
+ useMonitorFrameStore.getState().setFrame(publisherFor(who), frame),
+ clear: (who) => {
+ useMonitorFrameStore.getState().clearFrame(publisherFor(who));
+ publishers.delete(who);
+ },
+ geometry: () => ({ ...lastGeometry }),
+ gutter: () => ({
+ top: STACK_SHADOW_GUTTER_TOP,
+ bottom: STACK_SHADOW_GUTTER_BOTTOM,
+ }),
+ state: () => ({ cards, errors: [...seenErrors] }),
+ errors: () => [...seenErrors],
+};
+
+const rootElement = document.getElementById("root");
+if (!rootElement) throw new Error("Root element not found");
+const root = createRoot(rootElement);
+// StrictMode attaches the ref twice and its cleanup tears the observers down, so the driver
+// takes ?nostrict and never reads mid-remount.
+const strict = !new URLSearchParams(window.location.search).has("nostrict");
+const tree = <Harness />;
+root.render(strict ? <StrictMode>{tree}</StrictMode> : tree);
diff --git a/studio/frontend/smoke-overlay-rail.html b/studio/frontend/smoke-overlay-rail.html
new file mode 100644
index 00000000000..e330df64c26
--- /dev/null
+++ b/studio/frontend/smoke-overlay-rail.html
@@ -0,0 +1,15 @@
+<!doctype html>
+<html lang="en">
+ <head>
+ <meta charset="UTF-8" />
+ <script src="/crypto-boot.js"></script>
+ <!-- The dark --menu-soft-* values are the deeper shadow the bottom gutter is sized
+ against, so the theme has to be real here rather than left at the light default. -->
+ <script src="/theme-boot.js"></script>
+ <title>overlay rail smoke</title>
+ </head>
+ <body>
+ <div id="root"></div>
+ <script type="module" src="/smoke-overlay-rail-main.tsx"></script>
+ </body>
+</html>
diff --git a/studio/frontend/src/app/provider.tsx b/studio/frontend/src/app/provider.tsx
index 7bc2e5126f8..ed227bc4494 100644
--- a/studio/frontend/src/app/provider.tsx
+++ b/studio/frontend/src/app/provider.tsx
@@ -24,6 +24,10 @@ import { LoadedModelsIndicator } from "@/features/loaded-models";
import { NativeIntentDrain } from "@/features/native-intents/native-intent-drain";
import {
applyCustomizationToDocument,
+ STACK_SHADOW_GUTTER_BOTTOM,
+ STACK_SHADOW_GUTTER_TOP,
+ railBottomOffset,
+ railMaxHeight,
useAppearanceCustomStore,
useStackGeometry,
useTheme,
@@ -402,10 +406,10 @@ function TauriUpdateLayer({
// Capped like the browser stack: the download panel shares it, so both must fit.
<div
ref={stack.ref}
- // Scrolls when the cap is smaller than the cards, rather than spilling
- // them over the page. The gutter, cancelled by the margin, keeps the card
- // shadows out of the clip; horizontal only, since useStackGeometry reads
- // this node's scrollHeight and vertical padding would inflate it.
+ // Scrolls when the cap is smaller than the cards. The gutter keeps the
+ // card shadows out of the clip, cancelled by the negative margin across
+ // and by railBottomOffset and railMaxHeight underneath; useStackGeometry
+ // discounts it, so the placement still reads the cards alone.
// Click-through until it actually scrolls: pointer-events-none also
// costs it its scrollbar, and only the cards opt back in, so nothing
// would drag the ones below the fold into view.
@@ -413,9 +417,15 @@ function TauriUpdateLayer({
"fixed right-4 -mx-3 flex flex-col items-end gap-2 overflow-y-auto overflow-x-hidden overscroll-contain px-3",
stack.overflowing ? "pointer-events-auto" : "pointer-events-none",
)}
+ // The block gutter uses the same constants the two offsets compensate
+ // with, never a spacing utility: those are rem, so at any root size but
+ // 16px the padding and the compensation disagree. Across stays a utility,
+ // since px-3 and -mx-3 cancel whatever a rem is worth.
style={{
- bottom: stack.bottom,
- maxHeight: stack.maxHeight,
+ bottom: railBottomOffset(stack.bottom),
+ maxHeight: railMaxHeight(stack.maxHeight),
+ paddingTop: STACK_SHADOW_GUTTER_TOP,
+ paddingBottom: STACK_SHADOW_GUTTER_BOTTOM,
zIndex: Z_LAYER.OVERLAY_STACK,
}}
>
@@ -699,10 +709,10 @@ function TauriWrapper({ children }: { children: ReactNode }) {
<div
ref={stack.ref}
// Scrolls when the cap is smaller than the cards, rather than
- // spilling them over the page. The gutter, cancelled by the margin,
- // keeps the card shadows out of the clip; horizontal only, since
- // useStackGeometry reads this node's scrollHeight and vertical
- // padding would inflate it.
+ // The gutter keeps the card shadows out of the clip, cancelled by
+ // the negative margin across and by railBottomOffset and
+ // railMaxHeight underneath; useStackGeometry discounts it, so the
+ // placement still reads the cards alone.
// Click-through until it actually scrolls: pointer-events-none also
// costs it its scrollbar, and only the cards opt back in, so nothing
// would drag the ones below the fold into view.
@@ -710,9 +720,14 @@ function TauriWrapper({ children }: { children: ReactNode }) {
"fixed right-4 -mx-3 flex flex-col items-end gap-2 overflow-y-auto overflow-x-hidden overscroll-contain px-3",
stack.overflowing ? "pointer-events-auto" : "pointer-events-none",
)}
+ // The block gutter uses the same constants the two offsets
+ // compensate with, never a spacing utility: those are rem, so at any
+ // root size but 16px the padding and the compensation disagree.
style={{
- bottom: stack.bottom,
- maxHeight: stack.maxHeight,
+ bottom: railBottomOffset(stack.bottom),
+ maxHeight: railMaxHeight(stack.maxHeight),
+ paddingTop: STACK_SHADOW_GUTTER_TOP,
+ paddingBottom: STACK_SHADOW_GUTTER_BOTTOM,
zIndex: Z_LAYER.OVERLAY_STACK,
}}
>
diff --git a/studio/frontend/src/components/tauri/window-titlebar.tsx b/studio/frontend/src/components/tauri/window-titlebar.tsx
index f2091e9ecdf..08c20638c68 100644
--- a/studio/frontend/src/components/tauri/window-titlebar.tsx
+++ b/studio/frontend/src/components/tauri/window-titlebar.tsx
@@ -6,6 +6,7 @@ import { useSidebarPin } from "@/hooks/use-sidebar-pin";
import { useSidebarWidth } from "@/hooks/use-sidebar-width";
import { isTauri } from "@/lib/api-base";
import { cn } from "@/lib/utils";
+import { Z_LAYER } from "@/lib/z-layers";
import { CopyIcon, LayoutAlignLeftIcon } from "@hugeicons/core-free-icons";
import { HugeiconsIcon } from "@hugeicons/react";
import type { Window as TauriWindow } from "@tauri-apps/api/window";
@@ -413,6 +414,11 @@ export function WindowTitlebar({
/>
<div
className="pointer-events-auto absolute right-1 top-0 flex h-full items-center gap-0.5 px-1"
+ // No z-index here: the header above is positioned and numbered, so it is a
+ // stacking context and anything written here is compared inside it, never against
+ // the grips. The overlap that invites one costs Close 92px and the other two 60px
+ // each, and measures the same before and after this PR; see
+ // tests/studio/playwright_overlay_rail.py.
role="toolbar"
aria-label="Window controls"
>
@@ -458,42 +464,59 @@ export function WindowTitlebar({
</header>
<div
aria-hidden="true"
- className="pointer-events-auto fixed inset-x-2 top-0 z-[70] h-1 cursor-n-resize"
+ className="pointer-events-auto fixed inset-x-2 top-0 h-1 cursor-n-resize"
+ style={{ zIndex: Z_LAYER.WINDOW_RESIZE_EDGE }}
onPointerDown={handleResizePointerDown("North")}
/>
+ {/* All eight carry a named layer rather than z-[70], because the overlay stack out-
+ ranks that band and hit-tests its whole box while it scrolls. Anchored to the
+ bottom-right it still reaches five of them: `-mx-3` puts its border box 4px from
+ the right edge, the bottom gutter drops it to the floor, the top gutter lifts it
+ to 8px from the ceiling, and a card is `w-[calc(100vw-2rem)]`, so on a narrow
+ window it spans nearly the full width and the left-hand corners come into range
+ too. Measured, not reasoned: south-west 80 of 144px, north-east and north-west 32
+ of 144px each. The controls move up with them so the north-east corner does not
+ cost Close any of its own hit area. */}
<div
aria-hidden="true"
- className="pointer-events-auto fixed inset-x-2 bottom-0 z-[70] h-1 cursor-s-resize"
+ className="pointer-events-auto fixed inset-x-2 bottom-0 h-1 cursor-s-resize"
+ style={{ zIndex: Z_LAYER.WINDOW_RESIZE_EDGE }}
onPointerDown={handleResizePointerDown("South")}
/>
<div
aria-hidden="true"
- className="pointer-events-auto fixed inset-y-2 left-0 z-[70] w-1 cursor-w-resize"
+ className="pointer-events-auto fixed inset-y-2 left-0 w-1 cursor-w-resize"
+ style={{ zIndex: Z_LAYER.WINDOW_RESIZE_EDGE }}
onPointerDown={handleResizePointerDown("West")}
/>
<div
aria-hidden="true"
- className="pointer-events-auto fixed inset-y-2 right-0 z-[70] w-1 cursor-e-resize"
+ className="pointer-events-auto fixed inset-y-2 right-0 w-1 cursor-e-resize"
+ style={{ zIndex: Z_LAYER.WINDOW_RESIZE_EDGE }}
onPointerDown={handleResizePointerDown("East")}
/>
<div
aria-hidden="true"
- className="pointer-events-auto fixed left-0 top-0 z-[70] size-3 cursor-nw-resize"
+ className="pointer-events-auto fixed left-0 top-0 size-3 cursor-nw-resize"
+ style={{ zIndex: Z_LAYER.WINDOW_RESIZE_EDGE }}
onPointerDown={handleResizePointerDown("NorthWest")}
/>
<div
aria-hidden="true"
- className="pointer-events-auto fixed right-0 top-0 z-[70] size-3 cursor-ne-resize"
+ className="pointer-events-auto fixed right-0 top-0 size-3 cursor-ne-resize"
+ style={{ zIndex: Z_LAYER.WINDOW_RESIZE_EDGE }}
onPointerDown={handleResizePointerDown("NorthEast")}
/>
<div
aria-hidden="true"
- className="pointer-events-auto fixed bottom-0 left-0 z-[70] size-3 cursor-sw-resize"
+ className="pointer-events-auto fixed bottom-0 left-0 size-3 cursor-sw-resize"
+ style={{ zIndex: Z_LAYER.WINDOW_RESIZE_EDGE }}
onPointerDown={handleResizePointerDown("SouthWest")}
/>
<div
aria-hidden="true"
- className="pointer-events-auto fixed bottom-0 right-0 z-[70] size-3 cursor-se-resize"
+ className="pointer-events-auto fixed bottom-0 right-0 size-3 cursor-se-resize"
+ style={{ zIndex: Z_LAYER.WINDOW_RESIZE_EDGE }}
onPointerDown={handleResizePointerDown("SouthEast")}
/>
</>
diff --git a/studio/frontend/src/features/settings/index.ts b/studio/frontend/src/features/settings/index.ts
index c5f69da235c..9f50cb8b4fd 100644
--- a/studio/frontend/src/features/settings/index.ts
+++ b/studio/frontend/src/features/settings/index.ts
@@ -46,7 +46,12 @@ export type {
export { useMonitorOverlayStore } from "./stores/monitor-overlay-store";
export {
type MonitorFrame,
+ STACK_SHADOW_GUTTER_BOTTOM,
+ STACK_SHADOW_GUTTER_TOP,
type StackGeometry,
+ railBottomOffset,
+ railCardsHeight,
+ railMaxHeight,
stackBottomInset,
stackGeometry,
stackMaxHeight,
diff --git a/studio/frontend/src/features/settings/stores/monitor-frame-store.ts b/studio/frontend/src/features/settings/stores/monitor-frame-store.ts
index b7af2c6b984..49994115107 100644
--- a/studio/frontend/src/features/settings/stores/monitor-frame-store.ts
+++ b/studio/frontend/src/features/settings/stores/monitor-frame-store.ts
@@ -85,6 +85,15 @@ export const useMonitorFrameStore = create<MonitorFrameState>((set) => ({
// The corner stack's own inset, and the gap left between it and the monitor.
const STACK_INSET = 16;
const STACK_GAP = 8;
+// Room the rail keeps around its cards so its overflow clip does not cut their
+// shadows off. Sized off the rendered blur, not the radius: below, dark's
+// 0 8px 28px -6px is one level of #181818 by 16px and light's is one level of
+// white by 8px; above, light ends by 6px and dark is under a level by 8px.
+// railCardsHeight discounts both, and provider.tsx sets the rail's block
+// padding from them: a rem utility would drift at any root size but 16.
+export const STACK_SHADOW_GUTTER_BOTTOM = 16;
+export const STACK_SHADOW_GUTTER_TOP = 8;
+
// Widest overlay the stack holds: the update banners, at max-w-[448px].
const STACK_WIDTH = 448;
// Never lift so far that the stack itself is pushed off the top.
@@ -106,6 +115,49 @@ const MONITOR_HEADER = 64;
// STACK_INSET of clearance takes the stack off all of it.
const MONITOR_GRIP = 16;
+/**
+ * The rail's own `bottom`, given where its cards belong: its edge drops by the
+ * gutter and its padding carries the cards back up.
+ *
+ * The horizontal gutter's negative margin cannot do this. `bottom` anchors the
+ * margin edge, and with `top` and `height` auto the engine solves for `top`, so
+ * in Chromium the padding moved the card instead of the box.
+ *
+ * The dropped edge does reach into what `dodgeInset` reserves for the Live
+ * monitor's grip when the stack is seated inside a tall one, and costs nothing:
+ * the monitor is `FLOATING_PANEL` and the rail `OVERLAY_STACK`, so the panel
+ * hit-tests above it wherever they meet, which is what z-layers.ts states for
+ * this case. Measured down every row of the grip band in all three engines.
+ */
+export function railBottomOffset(cardsInset: number): number {
+ return cardsInset - STACK_SHADOW_GUTTER_BOTTOM;
+}
+
+/**
+ * The rail's `max-height`, given the band its cards may fill. Both gutters are
+ * added back so neither is spent on them, which also leaves slack: the clip is
+ * at the padding box, so a cap landing a few px short of a card shows it whole
+ * rather than taking its corners off.
+ *
+ * The slack is the room below only, since the cards sit against the top of the
+ * band, and it is spent rather than free: a cap short by k leaves `16 - k` for
+ * the shadow, and one short by more than 16 clips the card by the excess.
+ * Measured in all three engines. Growing the cap by k too would hand the cards
+ * more room than the placement allotted, which is the composer the cap exists
+ * to dodge, so this is the trade and not an oversight.
+ */
+export function railMaxHeight(cardsRoom: number): number {
+ return cardsRoom + STACK_SHADOW_GUTTER_BOTTOM + STACK_SHADOW_GUTTER_TOP;
+}
+
+/** The cards' own height, with the gutter the rail carries discounted. */
+export function railCardsHeight(
+ scrollHeight: number,
+ paddingY: number,
+): number {
+ return Math.max(0, scrollHeight - paddingY);
+}
+
/**
* How far above the bottom edge the overlay stack must sit to clear the Live
* monitor. The monitor defaults to the same corner, so without this the
@@ -155,9 +207,21 @@ function reachesStack(
return roomBelow(frame, viewportHeight, bottomInset) < Math.max(1, wanted);
}
+/**
+ * The clearance a lift leaves over the box it is dodging. The gap the cards want, or the
+ * room the rail carries under them, whichever is larger.
+ *
+ * `STACK_GAP` was enough while the rail's box ended where its cards did. It now hangs
+ * `STACK_SHADOW_GUTTER_BOTTOM` lower and a scrolling rail hit-tests all of it, so at a gap
+ * of 8 the lower 8px sat on the composer it had just dodged and took its top edge: 1088px2
+ * at 1280x800, measured. Nothing protects the composer the way `FLOATING_PANEL` protects
+ * the Live monitor, so the placement is what has to keep off it.
+ */
+const LIFT_CLEARANCE = Math.max(STACK_GAP, STACK_SHADOW_GUTTER_BOTTOM);
+
/** The inset that clears this box's top edge, whether or not it fits there. */
function liftOver(frame: MonitorFrame, viewportHeight: number): number {
- return viewportHeight - frame.top + STACK_GAP;
+ return viewportHeight - frame.top + LIFT_CLEARANCE;
}
/**
@@ -493,11 +557,17 @@ export function useStackGeometry(): StackPlacement {
const ref = useCallback((node: HTMLElement | null) => {
if (node === null || typeof ResizeObserver === "undefined") return;
const measure = () => {
- // An empty stack asks for nothing, so nothing is dodged for it.
+ // An empty stack asks for nothing. Every reading is cleared, the overflow one
+ // included: a rail whose last card goes while scrolling would stay latched to it, and
+ // `overflowing` decides whether the rail takes pointer input. That cost nothing while
+ // an empty rail was a zero-height box; it now has the gutter's height and would hold
+ // the corner.
if (node.childElementCount === 0) {
setNeededRoom((current) => (current === 0 ? current : 0));
setFloorRoom((current) => (current === 0 ? current : 0));
setCollapsedRoom((current) => (current === 0 ? current : 0));
+ setPersistentTail((current) => (current === 0 ? current : 0));
+ setDomOverflowing((current) => (current === false ? current : false));
return;
}
// Drop the cap and put it back in one synchronous block, so scrollHeight
@@ -514,6 +584,14 @@ export function useStackGeometry(): StackPlacement {
// inline style says otherwise: a rail with three whole cards laid out
// below a zero-height box, which is what the loaded models indicator
// turned up. Suppressed for the probe and restored with it.
+ // scrollHeight spans the padding box, so both probes below include the
+ // rail's gutter. Read off the node, not assumed, so a class change cannot
+ // leave them counting padding as cards.
+ const railStyle = getComputedStyle(node);
+ const paddingY =
+ Number.parseFloat(railStyle.paddingTop) +
+ Number.parseFloat(railStyle.paddingBottom);
+ const gutter = Number.isFinite(paddingY) ? paddingY : 0;
const eased = node.style.transition;
node.style.transition = "none";
const capped = node.style.maxHeight;
@@ -532,10 +610,12 @@ export function useStackGeometry(): StackPlacement {
}
const scrolled = node.scrollTop;
node.style.maxHeight = "none";
- const natural = node.scrollHeight;
+ const natural = railCardsHeight(node.scrollHeight, gutter);
// Card by card as well as in total, since a card is floored against its
// own height rather than the rail's. Same probe, so no extra layout, and
// one list for both readings so the two can never fall out of step.
+ // Card heights are their own border boxes, so only the totals above and
+ // below discount the gutter.
const cards = [...node.children].filter(inRailFlow);
const grown = cards.map(cardHeight);
// Taken here, uncapped, and not after the cap goes back on. The tail
@@ -559,7 +639,7 @@ export function useStackGeometry(): StackPlacement {
// hold `natural` when it only has to hold `floor` is what made a 3px
// shortfall at 1280x830 give up on dodging the composer entirely.
node.style.maxHeight = "0px";
- const collapsed = node.scrollHeight;
+ const collapsed = railCardsHeight(node.scrollHeight, gutter);
const floor = usableFloorRoom(
cards.map((child, index) => ({
squeezed: cardHeight(child),
diff --git a/studio/frontend/src/lib/z-layers.ts b/studio/frontend/src/lib/z-layers.ts
index 970a3e74ee9..9d0f8b8d1c7 100644
--- a/studio/frontend/src/lib/z-layers.ts
+++ b/studio/frontend/src/lib/z-layers.ts
@@ -12,6 +12,7 @@
* Ordered bottom to top:
*
* OVERLAY_STACK passive corner status, nothing to click through to
+ * WINDOW_RESIZE_EDGE the window's own bottom resize grips, under that stack
* FLOATING_PANEL windows the user drags, resizes and closes
* FLOATING_PANEL_TOP the one of those the user touched last
* STARTUP_SCREEN blocks the app while the backend comes up or quits
@@ -32,6 +33,20 @@ export const Z_LAYER = {
* loses.
*/
OVERLAY_STACK: 9000,
+ /**
+ * The custom titlebar's window-resize targets, which the notification stack
+ * reaches: `-mx-3` puts its border box 4px from the window edge and the
+ * shadow gutter drops it the last 16px to the floor, and a scrolling stack is
+ * pointer-active over the whole box. All eight, not just the bottom two: a
+ * card is `w-[calc(100vw-2rem)]` up to its max, so a narrow window brings the
+ * north and west targets into range as well.
+ *
+ * This does not move them relative to the window controls. Those sit inside a
+ * positioned, numbered `header`, so the grips are compared against that
+ * header rather than the buttons inside it, and they were already above it at
+ * equal z-index by document order.
+ */
+ WINDOW_RESIZE_EDGE: 9050,
/**
* Floating panels: the Live resource monitor and the API monitor overlay.
* Above the stack because a window the user is dragging, resizing and
diff --git a/studio/frontend/tests/monitor-stack-inset.test.ts b/studio/frontend/tests/monitor-stack-inset.test.ts
index 94198f3e8b3..d5d6a119b52 100644
--- a/studio/frontend/tests/monitor-stack-inset.test.ts
+++ b/studio/frontend/tests/monitor-stack-inset.test.ts
@@ -482,7 +482,7 @@ test("the height is measured with the hook's own cap lifted", async () => {
);
assert.match(
measure,
- /node\.scrollHeight;[\s\S]*node\.style\.maxHeight = capped;/,
+ /node\.scrollHeight[\s\S]*node\.style\.maxHeight = capped;/,
"the cap is not restored after the read",
);
});
diff --git a/studio/frontend/tests/overlay-shadow-gutter.test.ts b/studio/frontend/tests/overlay-shadow-gutter.test.ts
new file mode 100644
index 00000000000..fa2d073b8dd
--- /dev/null
+++ b/studio/frontend/tests/overlay-shadow-gutter.test.ts
@@ -0,0 +1,94 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+
+// The rail clips at its padding box, so with no padding under the bottom card
+// that card lost its shadow, all of which falls below it: the llama.cpp toast
+// was reported as "the bottom is cut off".
+//
+// Pinned here: the gutter is reserved under the cards and added on top of the
+// band they may fill, so they stay put and a cap a few px short no longer
+// slices one.
+
+import assert from "node:assert/strict";
+import test from "node:test";
+
+import {
+ STACK_SHADOW_GUTTER_BOTTOM,
+ STACK_SHADOW_GUTTER_TOP,
+ railBottomOffset,
+ railCardsHeight,
+ railMaxHeight,
+ stackGeometry,
+} from "../src/features/settings/stores/monitor-frame-store.ts";
+
+const GUTTER = STACK_SHADOW_GUTTER_BOTTOM + STACK_SHADOW_GUTTER_TOP;
+
+const INSET = 16;
+
+test("the gutters clear the shadows the rail carries", () => {
+ // Off the rendered blur: light is one level of white 8px below and gone 6px
+ // above; dark is one level of #181818 16px below and 8px above.
+ assert.ok(STACK_SHADOW_GUTTER_BOTTOM >= 16, "the shadow below is clipped");
+ assert.ok(STACK_SHADOW_GUTTER_TOP >= 8, "the shadow above is clipped");
+});
+
+test("the rail's edge drops by the gutter, so the cards keep their inset", () => {
+ // Offset plus padding is where the cards land.
+ assert.equal(
+ railBottomOffset(INSET) + STACK_SHADOW_GUTTER_BOTTOM,
+ INSET,
+ "the bottom card moved",
+ );
+ // A lifted placement keeps it too.
+ assert.equal(railBottomOffset(148) + STACK_SHADOW_GUTTER_BOTTOM, 148);
+});
+
+test("the cap grows by both gutters, so the cards' band is unchanged", () => {
+ for (const room of [0, 56, 137, 468]) {
+ assert.equal(
+ railMaxHeight(room) - GUTTER,
+ room,
+ "a gutter is being taken out of the cards",
+ );
+ }
+});
+
+test("the clip box holds a card the cap is a little short of", () => {
+ const card = 137;
+ // A cap a few px short of the card used to slice its bottom corners off.
+ assert.ok(
+ railMaxHeight(card - 10) >= card,
+ "the rail still slices a card the cap is 10px short of",
+ );
+ // Not a licence to overflow by any amount: a cramped rail still scrolls.
+ assert.ok(railMaxHeight(card - 40) < card);
+});
+
+test("the measured height discounts the gutters the rail carries", () => {
+ const card = 137;
+ assert.equal(railCardsHeight(card + GUTTER, GUTTER), card);
+ // An empty rail is padding alone, and asks for nothing.
+ assert.equal(railCardsHeight(GUTTER, GUTTER), 0);
+ // Never negative, whatever scrollHeight rounds to.
+ assert.equal(railCardsHeight(15, 16), 0);
+});
+
+test("a discounted measurement places the rail as an unpadded one did", () => {
+ const W = 1280;
+ const H = 720;
+ const card = 137;
+ // The composer, docked under a thread with turns.
+ const composer = {
+ left: 220,
+ top: H - 140,
+ right: 1180,
+ bottom: H,
+ coverable: true,
+ };
+ const measured = railCardsHeight(card + GUTTER, GUTTER);
+ assert.deepEqual(
+ stackGeometry([composer], W, H, measured, measured),
+ stackGeometry([composer], W, H, card, card),
+ "the gutter leaked into the placement",
+ );
+});
diff --git a/studio/frontend/tests/update-banner-flex-priority.test.ts b/studio/frontend/tests/update-banner-flex-priority.test.ts
index 1dd59dcc499..219ec2badb9 100644
--- a/studio/frontend/tests/update-banner-flex-priority.test.ts
+++ b/studio/frontend/tests/update-banner-flex-priority.test.ts
@@ -245,17 +245,99 @@ test("the rail scrolls rather than spilling its cards", () => {
// was.
assert.match(rules, /\bpx-3\b/);
assert.match(rules, /-mx-3/);
- // Sideways only. This node is the one useStackGeometry measures, so
- // vertical padding is counted into scrollHeight and the stack asks for room
- // it does not occupy: a card that fits under the composer then measures as
- // one that does not, and the rail lifts over it. The cap has to stay on
- // this same node too, since measure() lifts it here to read the natural
- // height; on a parent, the read would be the placement's own output.
- assert.ok(
- !/\bp-3\b/.test(rules) && !/\bpy-3\b/.test(rules),
- "vertical padding on the measured node inflates the measured height",
+ // scrollHeight spans that padding, so discount it or the stack asks for room
+ // it does not occupy and lifts over the composer for nothing.
+ assert.match(
+ STORE,
+ /const natural = railCardsHeight\(node\.scrollHeight, gutter\)/,
+ "the natural height counts the rail's own padding as cards",
+ );
+ // Both totals: the squeezed one is what `overflowing` compares against the
+ // cards' cap, and the per-card readings are border boxes.
+ assert.match(
+ STORE,
+ /const collapsed = railCardsHeight\(node\.scrollHeight, gutter\)/,
+ "the squeezed height counts the rail's own padding as cards",
+ );
+ }
+});
+
+// Reserved, not taken: the cards keep their band and the padding hangs below
+// it. A negative margin cannot do this -- `bottom` anchors the margin edge, so
+// the padding would move the cards instead.
+test("the rail's block gutter costs the cards no room", () => {
+ const rails = PROVIDER.split('"fixed right-4 ');
+ assert.equal(rails.length - 1, 2, "the rail count changed");
+ for (const rail of rails.slice(1)) {
+ const rules = rail.slice(0, rail.indexOf('"'));
+ const style = rail.slice(rail.indexOf("style={{"), rail.indexOf("}}"));
+ assert.match(
+ style,
+ /bottom: railBottomOffset\(stack\.bottom\)/,
+ "the rail's own edge is anchored where its cards belong",
+ );
+ assert.match(
+ style,
+ /maxHeight: railMaxHeight\(stack\.maxHeight\)/,
+ "the gutter is spent on the cards' cap",
+ );
+ // From the same constants, not pb-4/pt-2: those are rem, so at any root size
+ // but 16px the padding and the compensation drift apart.
+ assert.match(
+ style,
+ /paddingTop: STACK_SHADOW_GUTTER_TOP/,
+ "the top gutter can drift from the cap that pays for it",
+ );
+ assert.match(
+ style,
+ /paddingBottom: STACK_SHADOW_GUTTER_BOTTOM/,
+ "the bottom gutter can drift from the offset that pays for it",
+ );
+ // Every surface offsets its shadow downwards, so flush against the clip
+ // edge the bottom card loses all of it. A zero gutter is that bug again.
+ assert.doesNotMatch(rules, /\bp[byt]-/, "a rem gutter is back on the rail");
+ // The gutter drops the rail's box to the floor and `-mx-3` put it 4px from the right
+ // edge, so a scrolling rail lands on the window's resize grips, which are under it on
+ // Tailwind's scale. All eight: a narrow window spans the rail across the north and west
+ // targets too.
+ const TITLEBAR = read("components/tauri/window-titlebar.tsx");
+ // A z-index on the toolbar would read as protection and give none: it sits inside a
+ // positioned, numbered header, which is a stacking context.
+ const toolbar = TITLEBAR.slice(
+ TITLEBAR.lastIndexOf("<div", TITLEBAR.indexOf('aria-label="Window controls"')),
+ TITLEBAR.indexOf('aria-label="Window controls"'),
+ );
+ assert.doesNotMatch(
+ toolbar,
+ /zIndex:/,
+ "the window-controls toolbar carries a z-index, which its header traps",
+ );
+ for (const grip of [
+ "cursor-n-resize",
+ "cursor-s-resize",
+ "cursor-w-resize",
+ "cursor-e-resize",
+ "cursor-nw-resize",
+ "cursor-ne-resize",
+ "cursor-sw-resize",
+ "cursor-se-resize",
+ ]) {
+ const target = TITLEBAR.slice(
+ TITLEBAR.lastIndexOf("<div", TITLEBAR.indexOf(grip)),
+ TITLEBAR.indexOf("/>", TITLEBAR.indexOf(grip)),
+ );
+ assert.doesNotMatch(
+ target,
+ /z-\[70\]/,
+ `the ${grip} target is back under the overlay stack`,
+ );
+ assert.match(
+ target,
+ /zIndex: Z_LAYER\.WINDOW_RESIZE_EDGE/,
+ `the ${grip} target does not take the named layer, so a scrolling rail covers it`,
);
}
+ }
});
// pointer-events-none takes the rail's scrollbar with it, and only the cards
@@ -285,6 +367,30 @@ test("a scrolling rail takes pointer input, a fitting one stays click-through",
"the overflow flag is not derived from the placement",
);
assert.ok(!/setOverflowing/.test(STORE), "a latched DOM reading is back");
+ // The one place the flag can still latch is the empty-stack return, which
+ // publishes nothing and leaves. Before the rail carried a gutter that cost
+ // nothing: an empty rail was a zero-height box, so a stale "it scrolls"
+ // bought pointer input over no pixels. The gutter gives that box a height,
+ // so the corner would answer clicks with nothing in it. Every reading the
+ // branch leaves behind has to be cleared, the DOM one included.
+ const emptied = STORE.slice(
+ STORE.indexOf("node.childElementCount === 0"),
+ STORE.indexOf('node.style.transition = "none"'),
+ );
+ assert.ok(emptied.length > 0, "the empty-stack branch moved");
+ for (const cleared of [
+ "setNeededRoom",
+ "setFloorRoom",
+ "setCollapsedRoom",
+ "setPersistentTail",
+ "setDomOverflowing",
+ ]) {
+ assert.match(
+ emptied,
+ new RegExp(`${cleared}\\(`),
+ `an emptied rail keeps its ${cleared} reading, so it still holds the corner`,
+ );
+ }
// The probe writes max-height twice and reads scrollHeight between the
// writes. transition-property: all reaches the rail, so unsuppressed each
// write starts a transition, and a transition computes its start value
diff --git a/studio/frontend/tests/z-layers.test.ts b/studio/frontend/tests/z-layers.test.ts
index 61aefa40c27..885949c7343 100644
--- a/studio/frontend/tests/z-layers.test.ts
+++ b/studio/frontend/tests/z-layers.test.ts
@@ -14,6 +14,7 @@ import { Z_LAYER } from "../src/lib/z-layers.ts";
// The layers, bottom to top. Adding one belongs in this list.
const ORDER = [
"OVERLAY_STACK",
+ "WINDOW_RESIZE_EDGE",
"FLOATING_PANEL",
"FLOATING_PANEL_TOP",
"STARTUP_SCREEN",
@@ -41,6 +42,15 @@ test("floating panels paint over the notification stack", () => {
assert.ok(Z_LAYER.FLOATING_PANEL > Z_LAYER.OVERLAY_STACK);
});
+// The stack reaches the window's bottom edge once it reserves a gutter there,
+// and is pointer-active whenever it scrolls. A status card must not be what a
+// drag on the window's own grip lands on.
+test("the window's bottom resize grips outrank the notification stack", () => {
+ assert.ok(Z_LAYER.WINDOW_RESIZE_EDGE > Z_LAYER.OVERLAY_STACK);
+ // And stay under a panel being dragged, as they were before.
+ assert.ok(Z_LAYER.WINDOW_RESIZE_EDGE < Z_LAYER.FLOATING_PANEL);
+});
+
// Every in-page surface -- dialogs, sheets, dropdowns, the Tauri titlebar --
// is on Tailwind's own scale and tops out at 120. Nothing named here may drop
// into that band, or the numbers stop being comparable at a glance.
diff --git a/studio/frontend/tsconfig.app.json b/studio/frontend/tsconfig.app.json
index bdda66808bb..4dbea5ef86c 100644
--- a/studio/frontend/tsconfig.app.json
+++ b/studio/frontend/tsconfig.app.json
@@ -37,6 +37,7 @@
"smoke-thread-weight-main.tsx",
"smoke-settings-main.tsx",
"smoke-stream-pacing-main.tsx",
- "smoke-code-block-flicker-main.tsx"
+ "smoke-code-block-flicker-main.tsx",
+ "smoke-overlay-rail-main.tsx"
]
}
diff --git a/tests/studio/playwright_overlay_rail.py b/tests/studio/playwright_overlay_rail.py
new file mode 100644
index 00000000000..a0d0a2c6154
--- /dev/null
+++ b/tests/studio/playwright_overlay_rail.py
@@ -0,0 +1,963 @@
+# SPDX-License-Identifier: AGPL-3.0-only
+# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+
+"""The overlay rail's shadow gutter must cost the cards nothing.
+
+The rail reserves room around its cards so its `overflow-y-auto` clip does not cut their
+shadows off, and pays for it by dropping its box and growing its cap by the same amounts. All
+of that lives in the browser -- an inline style, arithmetic on the hook's output, and a
+`getComputedStyle` read -- so the node suite cannot reach it, and the suites that boot the app
+assert the horizontal gutter and the cap but never the block one.
+
+Drives the real `useStackGeometry` against a bare vite entry. What it holds:
+
+ - the reserved room is in pixels at any root font size, so a rem cannot move the cards;
+ - the rail's edge and cap carry the gutter, and the cards' band is unchanged by it;
+ - the clip really has that much room around the cards afterwards;
+ - both `scrollHeight` probes see the padding exactly once;
+ - a rail sized against a cap it overflows still says so, even where an engine leaves the
+ block-end padding out of its scrollable overflow;
+ - the taller pointer box takes no input that was not already the rail's.
+
+Run: SMOKE_PORT, SMOKE_BASE_URL, PW_ART_DIR and STUDIO_PLAYWRIGHT_BROWSER, as the other
+smokes take them.
+"""
+
+from __future__ import annotations
+
+import json
+import os
+import sys
+from pathlib import Path
+
+from playwright.sync_api import sync_playwright
+
+sys.path.insert(0, str(Path(__file__).resolve().parent))
+from _playwright_robust import ( # noqa: E402
+ chromium_launch_args,
+ echo_browser_errors,
+ start_vite,
+ stop_process,
+ wait_for_smoke_page,
+)
+
+PORT = int(os.environ.get("SMOKE_PORT", "5197"))
+BASE_URL = os.environ.get("SMOKE_BASE_URL", "").rstrip("/")
+ART = Path(os.environ.get("PW_ART_DIR", "logs/playwright-overlay-rail"))
+ENTRY = "smoke-overlay-rail.html"
+# Vite's SPA fallback answers 200 for a path it cannot resolve, so readiness is matched on
+# the module specifier, not the status.
+ENTRY_MODULE = "smoke-overlay-rail-main.tsx"
+PLAYWRIGHT_BROWSER = os.environ.get("STUDIO_PLAYWRIGHT_BROWSER", "chromium").lower()
+if PLAYWRIGHT_BROWSER not in ("chromium", "firefox", "webkit"):
+ raise SystemExit(f"unknown STUDIO_PLAYWRIGHT_BROWSER: {PLAYWRIGHT_BROWSER!r}")
+
+# `right-4` and `gap-2` resolve through `--spacing` in rem, so the driver reads both off the
+# node rather than mirroring them here: a root size other than 16 is measured, not assumed.
+STORE_STACK_GAP = 8
+# `STACK_GAP`, the clearance the placement leaves between the cards and a box it dodges.
+CARD_TO_MONITOR_GAP = 8
+# Layout is fractional under zoom and at DPR != 1, so equality is to within a CSS pixel.
+EPS = 1.0
+
+failures: list[str] = []
+
+
+def check(ok: bool, message: str) -> bool:
+ if not ok:
+ failures.append(message)
+ return ok
+
+
+def info(message: str) -> None:
+ print(f" {message}", flush = True)
+
+
+MEASURE = """
+() => {
+ const rail = document.querySelector('[data-testid="overlay-rail"]');
+ if (!rail) return null;
+ const style = getComputedStyle(rail);
+ const num = (v) => Number.parseFloat(v) || 0;
+ // The hook counts only the cards still in the rail's flow; a dragged one is not one.
+ const flow = [...rail.children].filter((c) => {
+ const p = getComputedStyle(c).position;
+ return p !== "fixed" && p !== "absolute";
+ });
+ const box = (el) => {
+ if (!el) return null;
+ const r = el.getBoundingClientRect();
+ return {
+ top: r.top, bottom: r.bottom, left: r.left, right: r.right,
+ width: r.width, height: r.height,
+ };
+ };
+ const surfaces = flow.map((c) => c.querySelector("[data-card-surface]") || c);
+ return {
+ padding: {
+ top: num(style.paddingTop), bottom: num(style.paddingBottom),
+ left: num(style.paddingLeft), right: num(style.paddingRight),
+ },
+ margin: { left: num(style.marginLeft), right: num(style.marginRight) },
+ // Both spacing utilities, read off the node rather than mirrored from a constant.
+ rowGap: num(style.rowGap),
+ rightInset: num(style.right),
+ maxHeight: num(style.maxHeight),
+ styleBottom: num(rail.style.bottom),
+ pointerEvents: style.pointerEvents,
+ rail: box(rail),
+ first: box(flow[0]),
+ last: box(flow[flow.length - 1]),
+ firstSurface: box(surfaces[0]),
+ lastSurface: box(surfaces[surfaces.length - 1]),
+ cardCount: flow.length,
+ cardHeights: flow.map((c) => c.offsetHeight),
+ scrollHeight: rail.scrollHeight,
+ clientHeight: rail.clientHeight,
+ scrollTop: rail.scrollTop,
+ geometry: window.__railSmoke.geometry(),
+ gutter: window.__railSmoke.gutter(),
+ innerHeight: window.innerHeight,
+ innerWidth: window.innerWidth,
+ dpr: window.devicePixelRatio,
+ rootFontSize: num(getComputedStyle(document.documentElement).fontSize),
+ dir: document.documentElement.dir || "ltr",
+ errors: window.__railSmoke.errors(),
+ };
+}
+"""
+
+# The rail measures itself and changes its own cap, so read after the observers go quiet
+# rather than after a fixed wait.
+SETTLE = """
+async () => {
+ const rail = document.querySelector('[data-testid="overlay-rail"]');
+ const frame = () => new Promise((r) => requestAnimationFrame(() => r()));
+ let last = "";
+ for (let i = 0; i < 40; i += 1) {
+ await frame();
+ const now = [rail.style.bottom, rail.style.maxHeight, rail.scrollHeight,
+ rail.clientHeight, rail.children.length].join("|");
+ if (now === last) return { settledAfter: i, state: now };
+ last = now;
+ }
+ return { settledAfter: -1, state: last };
+}
+"""
+
+
+def configure(
+ page,
+ *,
+ cards,
+ obstacles = None,
+ root_font = 16,
+ direction = "ltr",
+ theme = "dark",
+) -> dict:
+ """Put the page in one state of the matrix and wait for the rail to stop moving."""
+ page.evaluate(
+ """([opts]) => {
+ document.documentElement.dir = opts.direction;
+ document.documentElement.style.fontSize = opts.rootFont + "px";
+ document.documentElement.classList.toggle("dark", opts.theme === "dark");
+ document.documentElement.classList.toggle("light", opts.theme !== "dark");
+ for (const who of ["monitor", "composer"]) window.__railSmoke.clear(who);
+ for (const [who, frame] of Object.entries(opts.obstacles || {})) {
+ window.__railSmoke.publish(who, frame);
+ }
+ window.__railSmoke.setCards(opts.cards);
+ }""",
+ [
+ {
+ "cards": cards,
+ "obstacles": obstacles or {},
+ "rootFont": root_font,
+ "direction": direction,
+ "theme": theme,
+ }
+ ],
+ )
+ page.evaluate(SETTLE)
+ return page.evaluate(MEASURE)
+
+
+def report_gap(m: dict) -> None:
+ """The rail's own gap against the one the store's floor arithmetic assumes.
+
+ `gap-2` is a rem and `STACK_GAP` a literal 8, so they agree only at a 16px root. That
+ predates the gutter and is not gated here, but it is the drift the gutter was pinned in
+ pixels to avoid, so it is printed rather than left to be rediscovered.
+ """
+ if abs(m["rowGap"] - STORE_STACK_GAP) > 0.01:
+ info(
+ f"note: at a {m['rootFontSize']:.0f}px root the rail's gap is {m['rowGap']:.1f}px "
+ f"while STACK_GAP is {STORE_STACK_GAP}; pre-existing, unrelated to the gutter"
+ )
+
+
+def assert_invariants(m: dict, label: str, *, fitting: bool) -> None:
+ """The properties that must hold in every state, whatever else the case is testing."""
+ if not check(m is not None, f"{label}: the rail is not in the page"):
+ return
+ top, bottom = m["gutter"]["top"], m["gutter"]["bottom"]
+
+ # In pixels: a spacing utility would be a rem and disagree with the compensation.
+ check(
+ abs(m["padding"]["top"] - top) < 0.01 and abs(m["padding"]["bottom"] - bottom) < 0.01,
+ f"{label}: block padding is {m['padding']['top']}/{m['padding']['bottom']}, "
+ f"reserved {top}/{bottom}; a rem has got into the gutter",
+ )
+ # Across, the utility and its negative margin cancel whatever a rem is worth.
+ check(
+ abs(m["padding"]["left"] + m["margin"]["left"]) < 0.01
+ and abs(m["padding"]["right"] + m["margin"]["right"]) < 0.01,
+ f"{label}: the horizontal gutter no longer cancels: "
+ f"{m['padding']['left']}/{m['margin']['left']}",
+ )
+ # The rail gives up exactly what it takes back.
+ check(
+ abs((m["styleBottom"] + bottom) - m["geometry"]["bottom"]) < 0.01,
+ f"{label}: rail bottom {m['styleBottom']} + {bottom} is not the placed inset "
+ f"{m['geometry']['bottom']}; the cards have moved",
+ )
+ check(
+ abs((m["maxHeight"] - top - bottom) - m["geometry"]["maxHeight"]) < 0.01,
+ f"{label}: cap {m['maxHeight']} less the gutter is not the placed band "
+ f"{m['geometry']['maxHeight']}; the gutter is being taken out of the cards",
+ )
+ # The clip is at the padding box, so this is the room the shadows have. Only at rest: a
+ # scrolling rail has cards below the fold, and run_observer_and_scroll covers that end.
+ if fitting and m["cardCount"] > 0:
+ check(
+ m["rail"]["bottom"] - m["last"]["bottom"] >= bottom - 0.6,
+ f"{label}: {m['rail']['bottom'] - m['last']['bottom']:.2f}px under the bottom "
+ f"card, reserved {bottom}",
+ )
+ check(
+ m["first"]["top"] - m["rail"]["top"] >= top - 0.6,
+ f"{label}: {m['first']['top'] - m['rail']['top']:.2f}px over the top card, "
+ f"reserved {top}",
+ )
+ # A cap that grew by the gutter must not push the rail off the viewport.
+ check(
+ m["rail"]["top"] >= -0.5 and m["rail"]["bottom"] <= m["innerHeight"] + 0.5,
+ f"{label}: the rail is off screen: {m['rail']['top']:.1f}..{m['rail']['bottom']:.1f} "
+ f"in {m['innerHeight']}",
+ )
+ # Both probes read the padding box, so the cards' own total is what is left after it.
+ if m["cardCount"] > 0:
+ cards_total = sum(m["cardHeights"]) + m["rowGap"] * (m["cardCount"] - 1)
+ measured = m["scrollHeight"] - m["padding"]["top"] - m["padding"]["bottom"]
+ check(
+ abs(measured - cards_total) <= EPS,
+ f"{label}: discounted scrollHeight {measured} is not the cards' {cards_total}; "
+ f"the padding is counted a number of times other than once",
+ )
+ if fitting and m["cardCount"] > 0 and m["dir"] == "ltr":
+ # The block gutter may not touch where the cards sit across.
+ check(
+ abs((m["innerWidth"] - m["last"]["right"]) - m["rightInset"]) <= EPS,
+ f"{label}: the cards' right inset is "
+ f"{m['innerWidth'] - m['last']['right']:.2f}, but the rail's is "
+ f"{m['rightInset']:.2f}",
+ )
+ check(not m["errors"], f"{label}: page errors {m['errors']}")
+
+
+BANNER = {"height": 160, "floor": 160, "dismissible": True}
+PANEL = {"height": 120, "floor": 60}
+INDICATOR = {"height": 64, "floor": 64}
+
+VIEWPORTS = [
+ (1280, 800),
+ (1440, 900),
+ (1920, 1080),
+ (1024, 768),
+ (921, 534),
+ (768, 500),
+ (390, 844),
+ (640, 480),
+]
+ROOT_FONTS = [12, 14, 16, 20, 24]
+DECKS = {
+ "empty": [],
+ "one": [INDICATOR],
+ "banner+indicator": [BANNER, INDICATOR],
+ "full": [BANNER, dict(BANNER), PANEL, INDICATOR],
+ "dragged": [BANNER, PANEL, {**INDICATOR, "dragged": True}],
+}
+
+
+def obstacles_for(name: str, width: int, height: int) -> dict:
+ """The three shapes that publish a frame, in the stack's own column."""
+ if name == "none":
+ return {}
+ if name == "composer":
+ return {
+ "composer": {
+ "left": width // 2 - 300,
+ "right": width // 2 + 300,
+ "top": height - 180,
+ "bottom": height - 24,
+ "coverable": True,
+ }
+ }
+ if name == "monitor-short":
+ return {
+ "monitor": {
+ "left": width - 288,
+ "right": width - 16,
+ "top": height - 320,
+ "bottom": height - 200,
+ }
+ }
+ if name == "monitor-tall":
+ # Too tall to lift over, so the stack seats inside the panel instead.
+ return {
+ "monitor": {
+ "left": width - 288,
+ "right": width - 16,
+ "top": 20,
+ "bottom": height - 20,
+ }
+ }
+ if name == "both":
+ out = obstacles_for("monitor-short", width, height)
+ out.update(obstacles_for("composer", width, height))
+ return out
+ raise AssertionError(name)
+
+
+OBSTACLES = ["none", "composer", "monitor-short", "monitor-tall", "both"]
+
+
+def run_geometry_matrix(page) -> None:
+ """Every combination of viewport, root size, deck, obstacle and writing direction."""
+ print("[matrix] geometry", flush = True)
+ seen = 0
+ noted_gaps: set[int] = set()
+ for width, height in VIEWPORTS:
+ page.set_viewport_size({"width": width, "height": height})
+ for root_font in ROOT_FONTS:
+ for deck_name, deck in DECKS.items():
+ for obstacle in OBSTACLES:
+ for direction in ("ltr", "rtl"):
+ label = (
+ f"{width}x{height} root{root_font} {deck_name} "
+ f"{obstacle} {direction}"
+ )
+ m = configure(
+ page,
+ cards = deck,
+ obstacles = obstacles_for(obstacle, width, height),
+ root_font = root_font,
+ direction = direction,
+ )
+ fitting = bool(m) and not m["geometry"]["overflowing"]
+ assert_invariants(m, label, fitting = fitting)
+ if m and m["cardCount"] > 1 and root_font not in noted_gaps:
+ noted_gaps.add(root_font)
+ report_gap(m)
+ seen += 1
+ info(f"{seen} states")
+
+
+def run_cap_boundary(page) -> None:
+ """Crossing the cap must flip the rail's overflow state once, not oscillate over it."""
+ print("[matrix] cap boundary", flush = True)
+ page.set_viewport_size({"width": 1280, "height": 800})
+ probe = configure(page, cards = [INDICATOR])
+ room = probe["geometry"]["maxHeight"]
+ transitions = 0
+ previous = None
+ for step in range(-16, 17):
+ height = room + step * 0.25
+ m = configure(page, cards = [{"height": height, "floor": height}])
+ state = m["geometry"]["overflowing"]
+ if previous is not None and state != previous:
+ transitions += 1
+ previous = state
+ assert_invariants(m, f"cap{step * 0.25:+.2f}", fitting = not state)
+ check(
+ transitions <= 1,
+ f"the rail changed its mind about overflowing {transitions} times across the "
+ f"boundary; a fractional reading is flapping",
+ )
+ # And well past it, where it must certainly scroll and take input.
+ for over in (8, 10, 16, 24, 40):
+ height = room + over
+ m = configure(page, cards = [{"height": height, "floor": height}])
+ check(
+ m["geometry"]["overflowing"],
+ f"a card {over}px past the cap does not make the rail scroll",
+ )
+ check(
+ m["pointerEvents"] == "auto",
+ f"a scrolling rail is {m['pointerEvents']}, so its scrollbar cannot be reached",
+ )
+ info(f"{transitions} transition(s) across the boundary")
+
+
+def run_short_cap(page) -> None:
+ """A cap that lands a little short of a card must show it whole, not shear its corners.
+
+ The clip is at the padding box, so the gutter is slack: a card overrunning the band by
+ less than the room reserved under it is still painted in full. The sheared-corner half of
+ the report.
+ """
+ print("[matrix] a cap short of the card", flush = True)
+ # No obstacle, so the band is the viewport less both insets and the shortfall is exact.
+ height = 400
+ page.set_viewport_size({"width": 1280, "height": height})
+ band = height - 2 * 16
+ for short in (0, 4, 10, 16, 24, 40):
+ card = band + short
+ m = configure(page, cards = [{"height": card, "floor": card}])
+ sliced = page.evaluate(
+ """() => {
+ const rail = document.querySelector('[data-testid="overlay-rail"]');
+ const card = rail.querySelector("[data-card-index]");
+ const c = card.getBoundingClientRect();
+ const r = rail.getBoundingClientRect();
+ return {
+ sliced: Math.round((Math.max(0, r.top - c.top)
+ + Math.max(0, c.bottom - r.bottom)) * 100) / 100,
+ // What is left for the shadow once the card has spent the slack.
+ room: Math.round((r.bottom - c.bottom) * 100) / 100,
+ band: r.bottom - r.top,
+ };
+ }"""
+ )
+ # Cards sit against the top of the band, so the slack is the room under them only.
+ reserved = m["gutter"]["bottom"]
+ info(
+ f"cap short by {short:2d}: {sliced['sliced']:5.2f}px of the card is clipped, "
+ f"{sliced['room']:5.2f}px left under it "
+ f"(cap {m['geometry']['maxHeight']}, card {card}, {reserved}px reserved)"
+ )
+ # Spent, not free: overrunning the band by k eats k of the room under the card.
+ check(
+ abs(sliced["room"] - (reserved - short)) <= 0.6,
+ f"a cap {short}px short leaves {sliced['room']:.2f}px under the card, "
+ f"expected {reserved - short}",
+ )
+ if short <= reserved:
+ check(
+ sliced["sliced"] <= 0.6,
+ f"a cap {short}px short of the card slices {sliced['sliced']:.2f}px off it, "
+ f"with {reserved}px reserved under it",
+ )
+ else:
+ check(
+ abs(sliced["sliced"] - (short - reserved)) <= 0.6,
+ f"a cap {short}px short slices {sliced['sliced']:.2f}px, expected "
+ f"{short - reserved}",
+ )
+
+
+def run_stale_block_end_padding(page) -> None:
+ """An engine that leaves the block-end padding out of its scrollable overflow.
+
+ Chromium always reserved it and Gecko now does, but the CSSWG settled it after both had
+ shipped and a Linux build runs whatever WebKitGTK the distribution carries. Under that
+ reading `collapsed` is 16px short and the rail would stop scrolling, so the live
+ `scrollHeight > clientHeight` fallback beside it is what has to hold.
+ """
+ print("[matrix] block-end padding left out of the overflow region", flush = True)
+ page.set_viewport_size({"width": 1280, "height": 800})
+ room = configure(page, cards = [INDICATOR])["geometry"]["maxHeight"]
+ tall = room + 120
+ page.evaluate(
+ """() => {
+ const proto = Element.prototype;
+ const original = Object.getOwnPropertyDescriptor(proto, "scrollHeight");
+ window.__restoreScrollHeight = () =>
+ Object.defineProperty(proto, "scrollHeight", original);
+ Object.defineProperty(proto, "scrollHeight", {
+ configurable: true,
+ get() {
+ const raw = original.get.call(this);
+ if (this.dataset && this.dataset.testid === "overlay-rail") {
+ const pad = Number.parseFloat(getComputedStyle(this).paddingBottom) || 0;
+ return Math.max(0, raw - pad);
+ }
+ return raw;
+ },
+ });
+ }"""
+ )
+ try:
+ m = configure(page, cards = [{"height": tall, "floor": tall}])
+ check(
+ m["geometry"]["overflowing"],
+ "with the block-end padding out of scrollHeight the rail stops scrolling, so "
+ "the cards below the fold cannot be reached",
+ )
+ check(
+ m["pointerEvents"] == "auto",
+ "the rail lost its scrollbar under the older overflow reading",
+ )
+ finally:
+ page.evaluate("() => window.__restoreScrollHeight()")
+
+
+HIT = """
+([spec]) => {
+ const rail = document.querySelector('[data-testid="overlay-rail"]');
+ const r = rail.getBoundingClientRect();
+ const name = (el) => {
+ if (!el) return null;
+ if (el === rail) return "rail";
+ if (el.closest && el.closest('[data-testid="overlay-rail"]')) return "card";
+ if (el.dataset && el.dataset.testid) return el.dataset.testid;
+ return el.tagName;
+ };
+ const x = Math.round((r.left + r.right) / 2);
+ const rows = {};
+ // Every pixel row of both gutters, and the two rows just outside them.
+ for (let dy = -2; dy <= spec.top + 1; dy += 1) {
+ rows["top" + dy] = name(document.elementFromPoint(x, Math.round(r.top) + dy));
+ }
+ for (let dy = -1; dy <= spec.bottom + 2; dy += 1) {
+ rows["bottom" + dy] = name(document.elementFromPoint(x, Math.round(r.bottom) - dy));
+ }
+ return { x, rows, rail: {top: r.top, bottom: r.bottom, left: r.left, right: r.right} };
+}
+"""
+
+
+def run_hit_testing(page) -> None:
+ """The taller box must take no input a click-through rail would have let past."""
+ print("[matrix] hit testing", flush = True)
+ page.set_viewport_size({"width": 1280, "height": 800})
+ gutter = page.evaluate("() => window.__railSmoke.gutter()")
+
+ m = configure(page, cards = [INDICATOR])
+ check(
+ m["pointerEvents"] == "none",
+ f"a rail that fits is {m['pointerEvents']}, so it is taking clicks it should pass on",
+ )
+ hit = page.evaluate(HIT, [gutter])
+ check(
+ "rail" not in hit["rows"].values(),
+ f"a fitting rail answers a click in its gutter: {hit['rows']}",
+ )
+
+ # Seated inside a tall monitor: the panel outranks the rail, so however far down the
+ # box goes the gutter cannot reach the panel's grip.
+ room = configure(page, cards = [INDICATOR])["geometry"]["maxHeight"]
+ m = configure(
+ page,
+ cards = [{"height": room + 200, "floor": room + 200}],
+ obstacles = obstacles_for("monitor-tall", 1280, 800),
+ )
+ check(m["geometry"]["overflowing"], "the deck meant to overflow does not")
+ grip = page.evaluate(
+ """([grip]) => {
+ const rail = document.querySelector('[data-testid="overlay-rail"]');
+ const panel = document.querySelector('[data-testid="obstacle-monitor"]');
+ const p = panel.getBoundingClientRect();
+ const r = rail.getBoundingClientRect();
+ const x = Math.round(p.right - grip / 2);
+ const answers = [];
+ for (let y = Math.round(p.bottom) - grip; y < Math.round(p.bottom); y += 1) {
+ const el = document.elementFromPoint(x, y);
+ answers.push(el === rail ? "rail"
+ : el && el.dataset && el.dataset.testid ? el.dataset.testid
+ : el ? el.tagName : null);
+ }
+ return {
+ answers,
+ railOverlapsBand: r.bottom > Math.round(p.bottom) - grip && r.right > p.left,
+ };
+ }""",
+ [16],
+ )
+ check(
+ "rail" not in grip["answers"],
+ f"the rail's gutter answers over the monitor's resize grip: {grip['answers']}",
+ )
+ info(
+ f"gutter overlaps the grip band: {grip['railOverlapsBand']}, "
+ f"answers: {sorted(set(grip['answers']))}"
+ )
+
+ # Emptied after scrolling: its box is the gutter now, and must not hold the corner.
+ m = configure(page, cards = [])
+ hit = page.evaluate(HIT, [gutter])
+ check(
+ "rail" not in hit["rows"].values() and "card" not in hit["rows"].values(),
+ f"an emptied rail still answers clicks in the corner: {hit['rows']}",
+ )
+
+ run_reach_and_capture(page)
+
+
+# What the rail's box can land on unprotected: the eight resize targets and the composer.
+CAPTURE_TARGETS = [
+ "resize-north",
+ "resize-south",
+ "resize-west",
+ "resize-east",
+ "resize-northwest",
+ "resize-northeast",
+ "resize-southwest",
+ "resize-southeast",
+ "obstacle-composer",
+]
+# Measured the same way, but against the grips rather than against the rail.
+CONTROLS = ["control-minimize", "control-maximize", "control-close"]
+
+CONTROL_LOSS = """
+([ids]) => {
+ // Only pixels taken by a grip or by the rail count. A rounded button's own corners
+ // answer as its container, which is the button's shape rather than a lost hit area.
+ const stolen = (el) =>
+ Boolean(el) && (
+ el.closest('[data-testid="overlay-rail"]') !== null ||
+ (el.dataset && typeof el.dataset.testid === "string"
+ && el.dataset.testid.startsWith("resize-"))
+ );
+ const out = {};
+ for (const id of ids) {
+ const node = document.querySelector(`[data-testid="${id}"]`);
+ if (!node) continue;
+ const b = node.getBoundingClientRect();
+ let lost = 0, total = 0;
+ for (let x = Math.ceil(b.left); x < b.right; x += 1) {
+ for (let y = Math.ceil(b.top); y < b.bottom; y += 1) {
+ total += 1;
+ if (stolen(document.elementFromPoint(x, y))) lost += 1;
+ }
+ }
+ out[id] = { lost, total };
+ }
+ return out;
+}
+"""
+
+REACH = """
+([ids]) => {
+ const rail = document.querySelector('[data-testid="overlay-rail"]');
+ const r = rail.getBoundingClientRect();
+ const mine = (el) =>
+ el === rail || Boolean(el && el.closest && el.closest('[data-testid="overlay-rail"]'));
+ const out = {};
+ for (const id of ids) {
+ const node = document.querySelector(`[data-testid="${id}"]`);
+ if (!node) continue;
+ const g = node.getBoundingClientRect();
+ // Geometric reach first, so a target the rail lands on is visible in the report even
+ // when a layer above the rail is what stops it taking the pixels.
+ const overlapW = Math.max(0, Math.min(g.right, r.right) - Math.max(g.left, r.left));
+ const overlapH = Math.max(0, Math.min(g.bottom, r.bottom) - Math.max(g.top, r.top));
+ let taken = 0, total = 0;
+ for (let x = Math.ceil(g.left); x < g.right; x += 1) {
+ for (let y = Math.ceil(g.top); y < g.bottom; y += 1) {
+ total += 1;
+ if (mine(document.elementFromPoint(x, y))) taken += 1;
+ }
+ }
+ out[id] = {
+ reach: Math.round(overlapW * overlapH),
+ taken, total,
+ box: {top: g.top, bottom: g.bottom, left: g.left, right: g.right},
+ };
+ }
+ out.__rail = {top: r.top, bottom: r.bottom, left: r.left, right: r.right};
+ return out;
+}
+"""
+
+
+def report_capture(page, label: str) -> dict:
+ """Which unprotected surfaces the rail's box lands on, and which it actually takes."""
+ seen = page.evaluate(REACH, [CAPTURE_TARGETS])
+ rail = seen.pop("__rail")
+ reached = {k: v for k, v in seen.items() if v["reach"] > 0}
+ info(
+ f"[{label}] rail box "
+ f"{rail['left']:.0f},{rail['top']:.0f}..{rail['right']:.0f},{rail['bottom']:.0f}; "
+ f"reaches {sorted(reached) or 'nothing'}"
+ )
+ for name, v in sorted(reached.items()):
+ info(f" {name}: reach {v['reach']}px2, takes {v['taken']} of {v['total']}")
+ check(
+ v["taken"] == 0,
+ f"{label}: a scrolling rail takes {v['taken']} of the {name} target's "
+ f"{v['total']}px, so input started there lands on the rail",
+ )
+ return seen
+
+
+def run_reach_and_capture(page) -> None:
+ """The taller, pointer-active box must take nothing that is not already the rail's.
+
+ Three states, because reach depends on width and placement: a card is
+ `w-[calc(100vw-2rem)]` up to its max, so a narrow window spans the rail across nearly
+ everything, and a lifted placement puts its lower gutter over the box it just dodged.
+ """
+ room = configure(page, cards = [INDICATOR])["geometry"]["maxHeight"]
+ tall = {"height": room + 200, "floor": room + 200}
+
+ page.set_viewport_size({"width": 1280, "height": 800})
+ configure(page, cards = [tall])
+ report_capture(page, "1280x800, scrolling")
+
+ page.set_viewport_size({"width": 420, "height": 760})
+ narrow_room = configure(page, cards = [INDICATOR])["geometry"]["maxHeight"]
+ configure(
+ page,
+ cards = [{"height": narrow_room + 200, "floor": narrow_room + 200}],
+ )
+ report_capture(page, "420x760, scrolling")
+
+ # Lifted over the composer, so the gutter hangs below the cards and over its top edge.
+ page.set_viewport_size({"width": 1280, "height": 800})
+ lifted = configure(
+ page,
+ cards = [{"height": 300, "floor": 300}] * 3,
+ obstacles = obstacles_for("composer", 1280, 800),
+ )
+ check(
+ lifted["geometry"]["overflowing"],
+ "the lifted deck does not overflow, so the rail is click-through and the "
+ "composer check proves nothing",
+ )
+ info(
+ f" lifted: bottom={lifted['geometry']['bottom']} "
+ f"overflowing={lifted['geometry']['overflowing']}"
+ )
+ report_capture(page, "lifted over the composer")
+
+ # The controls lose nothing to the rail. What they lose to a grip belongs to the
+ # titlebar, and run_titlebar_stacking measures that against the pre-PR shape.
+ taken = page.evaluate(CONTROL_LOSS, [CONTROLS])
+ for name, v in sorted(taken.items()):
+ info(f" {name}: {v['lost']} of {v['total']}px taken by a grip or the rail")
+
+
+def run_titlebar_stacking(page, base: str) -> None:
+ """Whether the controls lose anything to the grips, and to whom the answer belongs.
+
+ The controls sit inside a positioned, numbered header, which by CSS is a stacking
+ context: every z-index inside it, the toolbar's included, is compared there and never
+ against the grips outside. A number on the toolbar therefore reads as protection and
+ gives none.
+
+ Three shapes, so the report can say who owns the overlap. The grips are later siblings of
+ the header, so the pre-PR pair at equal z-index already resolved in their favour by
+ document order; if the three agree, the Close corner is inherited, not moved by this PR.
+ """
+ print("[matrix] titlebar stacking", flush = True)
+ # Document order decides between equal z-indexes, so the comparison below holds only
+ # while the harness keeps the app's order: header first, grips after.
+ order = page.evaluate(
+ """() => {
+ const header = document.querySelector('[data-testid="titlebar-header"]');
+ const grip = document.querySelector('[data-testid="resize-northeast"]');
+ if (!header || !grip) return null;
+ // DOCUMENT_POSITION_FOLLOWING is 4: the grip comes after the header.
+ return Boolean(header.compareDocumentPosition(grip) & 4);
+ }"""
+ )
+ check(
+ order is True,
+ "the harness renders the resize grips before the titlebar header, which is not the "
+ "order window-titlebar.tsx uses; every equal-z result below would be backwards",
+ )
+ shapes = [
+ ("before this PR (grips 70, header 70)", "gripz=70&headerz=70"),
+ (
+ "toolbar number added (grips 9050, header 70, toolbar 9060)",
+ "gripz=9050&headerz=70&toolbarz=9060",
+ ),
+ ("at head (grips 9050, header 70, no toolbar number)", "gripz=9050&headerz=70"),
+ ]
+ losses = {}
+ for label, query in shapes:
+ page.goto(f"{base}/{ENTRY}?nostrict&{query}", wait_until = "domcontentloaded")
+ page.wait_for_function("() => Boolean(window.__railSmoke)", timeout = 30_000)
+ configure(page, cards = [INDICATOR])
+ taken = page.evaluate(CONTROL_LOSS, [CONTROLS])
+ losses[label] = {k: v["lost"] for k, v in taken.items()}
+ for name, v in sorted(taken.items()):
+ info(f" {label}: {name} loses {v['lost']} of {v['total']}px to a grip")
+
+ before = losses[shapes[0][0]]
+ numbered = losses[shapes[1][0]]
+ head = losses[shapes[2][0]]
+ check(
+ numbered == before,
+ f"a z-index on the toolbar changed what the controls keep, so it is not trapped "
+ f"after all: {before} -> {numbered}",
+ )
+ check(
+ head == before,
+ f"raising the grips cost the window controls hit area they had before this PR: "
+ f"{before} -> {head}",
+ )
+
+ page.goto(f"{base}/{ENTRY}?nostrict", wait_until = "domcontentloaded")
+ page.wait_for_function("() => Boolean(window.__railSmoke)", timeout = 30_000)
+
+
+def run_observer_and_scroll(page) -> None:
+ """The rail measures itself; that must terminate, and must not lose the scroll."""
+ print("[matrix] observers and scroll", flush = True)
+ page.set_viewport_size({"width": 1280, "height": 800})
+ loops: list[str] = []
+ page.on(
+ "console",
+ lambda msg: (loops.append(msg.text) if "ResizeObserver loop" in msg.text else None),
+ )
+ room = configure(page, cards = [INDICATOR])["geometry"]["maxHeight"]
+
+ for step in (-4, 4, -1, 1, -12, 12):
+ height = room + step
+ settle = page.evaluate(SETTLE)
+ configure(page, cards = [{"height": height, "floor": height}])
+ settle = page.evaluate(SETTLE)
+ check(
+ settle["settledAfter"] >= 0,
+ f"the rail never stopped moving at cap{step:+d}: {settle['state']}",
+ )
+ check(not loops, f"ResizeObserver loop errors: {loops[:3]}")
+
+ # The scroll position and the last card's reach must survive the none -> 0px -> cap
+ # probe.
+ tall = room + 240
+ configure(page, cards = [{"height": tall, "floor": tall}, INDICATOR])
+ state = page.evaluate(
+ """async () => {
+ const rail = document.querySelector('[data-testid="overlay-rail"]');
+ const frame = () => new Promise((r) => requestAnimationFrame(() => r()));
+ rail.scrollTop = rail.scrollHeight;
+ await frame();
+ const before = rail.scrollTop;
+ const max = rail.scrollHeight - rail.clientHeight;
+ // Anything that makes the hook remeasure without changing the deck.
+ window.dispatchEvent(new Event("resize"));
+ for (let i = 0; i < 10; i += 1) await frame();
+ const cards = [...rail.children];
+ const last = cards[cards.length - 1].getBoundingClientRect();
+ const r = rail.getBoundingClientRect();
+ return {
+ before, after: rail.scrollTop, max,
+ lastFullyInside: last.bottom <= r.bottom + 0.6 && last.top >= r.top - 0.6,
+ };
+ }"""
+ )
+ check(
+ abs(state["after"] - state["before"]) <= EPS,
+ f"the measurement moved the scroll from {state['before']} to {state['after']}",
+ )
+ check(
+ state["lastFullyInside"],
+ "scrolled to the end, the last card is not wholly inside the clip; the gutter is "
+ "not reachable",
+ )
+ info(f"scroll {state['before']:.1f} -> {state['after']:.1f} of {state['max']:.1f}")
+
+
+def run_shadow_pixels(page) -> None:
+ """The clip must no longer cut the card's shadow into a straight line."""
+ print("[matrix] shadow", flush = True)
+ page.set_viewport_size({"width": 1280, "height": 800})
+ m = configure(page, cards = [INDICATOR])
+ if not check(m is not None and m["cardCount"] == 1, "the shadow deck did not render"):
+ return
+ profile = page.evaluate(
+ """() => {
+ const rail = document.querySelector('[data-testid="overlay-rail"]');
+ const surface = rail.querySelector("[data-card-surface]");
+ const s = surface.getBoundingClientRect();
+ const r = rail.getBoundingClientRect();
+ return {
+ // How far below the card's own edge the clip lets anything paint at all.
+ room: r.bottom - s.bottom,
+ shadow: getComputedStyle(surface).boxShadow,
+ };
+ }"""
+ )
+ ART.mkdir(parents = True, exist_ok = True)
+ page.screenshot(
+ path = str(ART / f"rail-{PLAYWRIGHT_BROWSER}.png"),
+ clip = {
+ "x": max(0, m["rail"]["left"] - 8),
+ "y": m["rail"]["top"] - 8,
+ "width": min(m["rail"]["width"] + 16, m["innerWidth"] - m["rail"]["left"]),
+ "height": m["rail"]["height"] + 16,
+ },
+ )
+ check(
+ profile["room"] >= m["gutter"]["bottom"] - 0.6,
+ f"only {profile['room']:.2f}px of paintable room under the card, reserved "
+ f"{m['gutter']['bottom']}",
+ )
+ check(
+ "rgba" in profile["shadow"] or "rgb" in profile["shadow"],
+ f"the card carries no shadow to clip: {profile['shadow']}",
+ )
+ info(f"{profile['room']:.1f}px under the card, shadow {profile['shadow']}")
+
+
+def main() -> int:
+ server = None
+ base = BASE_URL
+ if not base:
+ server = start_vite(PORT)
+ base = f"http://127.0.0.1:{PORT}"
+ url = f"{base}/{ENTRY}?nostrict"
+ try:
+ with sync_playwright() as pw:
+ launcher = getattr(pw, PLAYWRIGHT_BROWSER)
+ browser = launcher.launch(
+ args = chromium_launch_args() if PLAYWRIGHT_BROWSER == "chromium" else [],
+ )
+ page = browser.new_page(viewport = {"width": 1280, "height": 800})
+ echo_browser_errors(page, info)
+ wait_for_smoke_page(url, ENTRY_MODULE, proc = server, info = info)
+ page.goto(url, wait_until = "domcontentloaded")
+ # Attached, not visible: an empty rail is a zero-height box, so waiting on
+ # visibility would hang.
+ page.wait_for_selector(
+ '[data-testid="overlay-rail"]',
+ state = "attached",
+ timeout = 30_000,
+ )
+ page.wait_for_function("() => Boolean(window.__railSmoke)", timeout = 30_000)
+
+ print(f"=== overlay rail, {PLAYWRIGHT_BROWSER} ===", flush = True)
+ run_geometry_matrix(page)
+ run_cap_boundary(page)
+ run_short_cap(page)
+ run_stale_block_end_padding(page)
+ run_hit_testing(page)
+ run_titlebar_stacking(page, base)
+ run_observer_and_scroll(page)
+ run_shadow_pixels(page)
+ browser.close()
+ finally:
+ if server is not None:
+ stop_process(server)
+
+ if failures:
+ print(f"\n{len(failures)} failure(s):", flush = True)
+ for line in failures[:40]:
+ print(f" - {line}", flush = True)
+ ART.mkdir(parents = True, exist_ok = True)
+ # Named, not the platform default: read back on the Windows shard, where a
+ # non-ASCII byte would otherwise not round-trip.
+ (ART / f"failures-{PLAYWRIGHT_BROWSER}.json").write_text(
+ json.dumps(failures, indent = 2),
+ encoding = "utf-8",
+ )
+ return 1
+ print("\noverlay rail: all checks passed", flush = True)
+ return 0
+
+
+if __name__ == "__main__":
+ raise SystemExit(main())