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: put the notification rail back in its bottom-right corner (#9547)

Michael Han27434480f7d8
diff --git a/.github/workflows/studio-frontend-ci.yml b/.github/workflows/studio-frontend-ci.yml
index 62c28571d0a..1d4e52b44c3 100644
--- a/.github/workflows/studio-frontend-ci.yml
+++ b/.github/workflows/studio-frontend-ci.yml
@@ -25,10 +25,6 @@ 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'
@@ -428,23 +424,6 @@ 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 beac3268194..3adba96bb6a 100644
--- a/.github/workflows/studio-ui-smoke.yml
+++ b/.github/workflows/studio-ui-smoke.yml
@@ -601,48 +601,6 @@ jobs:
python tests/studio/playwright_update_banner_layout.py
done
- # The overlay rail harness below serves its own vite, and this job has no
- # node_modules to serve it with. Installing Studio is not enough: setup.sh installs
- # the frontend dev dependencies only when it has to build the frontend, and the
- # frontend-dist cache above exists precisely to stop that build (the restore action
- # asserts the installer reported the frontend up to date). So on a cache hit there is
- # no vite and `npm run dev` exits 127, while a cache miss builds and passes, which is
- # why this step looked green when it landed and red on every run since.
- #
- # Conditional on the binary rather than unconditional: on the cold-cache path
- # setup.sh has already installed these, and `npm ci` would delete and refetch them.
- - name: Frontend dev dependencies for the overlay rail harness
- if: matrix.shard == 'banner'
- working-directory: studio/frontend
- run: |
- if [ -x node_modules/.bin/vite ]; then
- echo "vite already present from the frontend build; not reinstalling"
- else
- npm ci --no-fund --no-audit
- fi
- # A silent install is worse than a loud one: without this the next step fails as
- # a Playwright timeout rather than as a missing toolchain.
- if [ ! -x node_modules/.bin/vite ]; then
- echo "::error::npm ci finished but studio/frontend/node_modules/.bin/vite is still missing"
- exit 1
- fi
-
- # 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:
@@ -804,7 +762,6 @@ 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
deleted file mode 100644
index 3d0965e3ce1..00000000000
--- a/studio/frontend/smoke-overlay-rail-main.tsx
+++ /dev/null
@@ -1,323 +0,0 @@
-// SPDX-License-Identifier: AGPL-3.0-only
-// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
-
-// 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
deleted file mode 100644
index e330df64c26..00000000000
--- a/studio/frontend/smoke-overlay-rail.html
+++ /dev/null
@@ -1,15 +0,0 @@
-<!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 ed227bc4494..8d028ff9685 100644
--- a/studio/frontend/src/app/provider.tsx
+++ b/studio/frontend/src/app/provider.tsx
@@ -24,12 +24,7 @@ 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,
} from "@/features/settings";
import { SttDownloadPrompt } from "@/features/settings/components/stt-download-prompt";
@@ -38,7 +33,6 @@ import { type BackendStatus, useTauriBackend } from "@/hooks/use-tauri-backend";
import { useTauriUpdate } from "@/hooks/use-tauri-update";
import { isTauri } from "@/lib/api-base";
import { getToastOffsets } from "@/lib/toast-offset";
-import { cn } from "@/lib/utils";
import { Z_LAYER } from "@/lib/z-layers";
import { useRouterState } from "@tanstack/react-router";
import { MotionConfig } from "motion/react";
@@ -80,6 +74,15 @@ type TauriMonitor = NonNullable<
// Keep in step with MOBILE_BREAKPOINT in hooks/use-mobile.ts.
const MIN_DESKTOP_LAYOUT_WIDTH = 768;
+// Room the corner rail keeps around its cards so its overflow clip does not cut
+// their shadows off (#9246). 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. The rail sits on `bottom-0` and its bottom padding carries the cards
+// back up, so they still land 16px off the corner.
+const STACK_SHADOW_GUTTER_BOTTOM = 16;
+const STACK_SHADOW_GUTTER_TOP = 8;
+
// Logical px per CSS px: webview zoom above the display scale (Windows text
// scaling); 1 if none.
function logicalPerCssPx(monitorScale: number): number {
@@ -385,7 +388,6 @@ function TauriUpdateLayer({
appContent: ReactNode;
}) {
const update = useTauriUpdate(isExternalServer);
- const stack = useStackGeometry();
const isUpdating =
update.status === "updating-backend" ||
update.status === "downloading" ||
@@ -405,25 +407,19 @@ 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. 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.
- 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",
- )}
- // 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.
+ // Scrolls at the cap rather than spilling cards off screen: at a large
+ // type size the banner floors alone exceed it. Wheel over a card scrolls
+ // this box and focus scrolls into it, so the fold is reachable while the
+ // rail stays click-through.
+ // The gutter keeps the card shadows out of that clip: across, cancelled
+ // by the negative margin; below and above, by the block padding. The
+ // cards still land on 16px, since the box sits on the floor and the
+ // bottom gutter carries them back up.
+ className="pointer-events-none fixed bottom-0 right-4 -mx-3 flex max-h-[calc(100dvh_-_8px)] flex-col items-end gap-2 overflow-y-auto overflow-x-hidden overscroll-contain px-3"
+ // Block gutter in px, never a spacing utility: those are rem, and at any
+ // root but 16px the cards would drift off the corner. Across stays a
+ // utility, since px-3 and -mx-3 cancel whatever a rem is worth.
style={{
- bottom: railBottomOffset(stack.bottom),
- maxHeight: railMaxHeight(stack.maxHeight),
paddingTop: STACK_SHADOW_GUTTER_TOP,
paddingBottom: STACK_SHADOW_GUTTER_BOTTOM,
zIndex: Z_LAYER.OVERLAY_STACK,
@@ -539,7 +535,6 @@ function DesktopChromeVarsEffect({
function TauriWrapper({ children }: { children: ReactNode }) {
const pathname = useRouterState({ select: (s) => s.location.pathname });
- const stack = useStackGeometry();
const {
status,
logs,
@@ -707,25 +702,18 @@ function TauriWrapper({ children }: { children: ReactNode }) {
{/* Capped to the viewport, or a long download list plus expanded notes
pushes the top of the stack off screen. */}
<div
- ref={stack.ref}
- // Scrolls when the cap is smaller than the cards, rather than
- // 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.
- 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",
- )}
- // 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.
+ // Scrolls at the cap rather than spilling cards off screen: at a
+ // large type size the banner floors alone exceed it. Wheel over a
+ // card scrolls this box and focus scrolls into it, so the fold is
+ // reachable while the rail stays click-through.
+ // The gutter keeps the card shadows out of that clip: across,
+ // cancelled by the negative margin; below and above, by the block
+ // padding. The cards still land on 16px, since the box sits on the
+ // floor and the bottom gutter carries them back up.
+ className="pointer-events-none fixed bottom-0 right-4 -mx-3 flex max-h-[calc(100dvh_-_8px)] flex-col items-end gap-2 overflow-y-auto overflow-x-hidden overscroll-contain px-3"
+ // Block gutter in px, never a spacing utility: those are rem, and at
+ // any root but 16px the cards would drift off the corner.
style={{
- 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/assistant-ui/thread.tsx b/studio/frontend/src/components/assistant-ui/thread.tsx
index 106652fffd8..dc33f6ef125 100644
--- a/studio/frontend/src/components/assistant-ui/thread.tsx
+++ b/studio/frontend/src/components/assistant-ui/thread.tsx
@@ -4214,15 +4214,10 @@ const Composer: FC<{
formRef.current = node;
setComposerEl(node);
}, []);
- // The composer docks to the bottom of the viewport once a thread has turns,
- // in the same column the corner overlay stack occupies. Published so the
- // stack lifts above it rather than covering the Send button.
- //
- // Coverable, though: in a window too short to hold the update cards above it
- // there is no arrangement that dodges the composer AND shows them whole, and
- // a card clipped at the rail's edge looks like it has slid behind the page.
- // The stack takes the corner and paints over the composer there instead.
- usePublishedFrame(composerEl, { coverable: true });
+ // Docked under a thread, the composer sits in the corner the API monitor
+ // panel opens in. Published so that panel opens clear of Send. The
+ // notification rail does not read this; it is anchored in CSS.
+ usePublishedFrame(composerEl);
const dictationBaseTextRef = useRef("");
const dictationComposerRef = useRef("");
// Thread switches reuse this composer, so the send has to know where it
diff --git a/studio/frontend/src/components/floating-monitor.tsx b/studio/frontend/src/components/floating-monitor.tsx
index 45a0e22a534..68fb69d9e01 100644
--- a/studio/frontend/src/components/floating-monitor.tsx
+++ b/studio/frontend/src/components/floating-monitor.tsx
@@ -479,13 +479,10 @@ function FloatingMonitorPanel({
const hasGpu = (displayedGpu?.available ?? false) && devices.length > 0;
// The container sits on the floating panel layer, above the bottom-right
- // overlay stack. That stack normally dodges this monitor, but the dodge has a
- // floor: drag the monitor to the corner and resize it to fill the viewport and
- // there is nowhere left to dodge to, so stackBottomInset clamps at
- // MIN_STACK_ROOM and parks the stack at the top of the screen, directly over
- // this monitor's title bar and Close button. The stack is passive status; this
- // is a window the user is dragging, resizing and closing, so it wins. Still
- // below the startup screen and tooltips. See lib/z-layers.
+ // overlay stack. The stack is anchored to that same corner and does not move
+ // for this monitor, so the two can overlap. The stack is passive status; this
+ // is a window being dragged, resized and closed, so it wins. Still below the
+ // startup screen and tooltips. See lib/z-layers.
//
// The API monitor panel shares this layer rather than sitting under it, and
// whichever of the two the user touched last is the one in front.
diff --git a/studio/frontend/src/components/llama-update-banner.tsx b/studio/frontend/src/components/llama-update-banner.tsx
index ffa08345c7e..0ba9ae6dcbc 100644
--- a/studio/frontend/src/components/llama-update-banner.tsx
+++ b/studio/frontend/src/components/llama-update-banner.tsx
@@ -138,11 +138,6 @@ export function LlamaUpdateBanner({
// stack squeezing it only prints its text over its own buttons.
"pointer-events-auto w-[calc(100vw-2rem)] max-w-[400px] shrink-0",
)}
- // See the app update card: dismissible, so it may cover the composer.
- // Only while it actually is. The dismiss button goes away for the length
- // of an update, and the licence has to go with it: a card the reader
- // cannot get rid of is one the stack must never park on Send.
- data-overlay-dismissible={applying ? undefined : "true"}
data-testid="llama-update-banner"
>
<div className="relative overflow-hidden rounded-[24px] bg-white px-5 pb-4 pt-5 shadow-[0_2px_8px_-2px_rgba(0,0,0,0.16)] dark:bg-card dark:shadow-[0_8px_28px_-6px_rgba(0,0,0,0.28)]">
diff --git a/studio/frontend/src/components/tauri/update-banner.tsx b/studio/frontend/src/components/tauri/update-banner.tsx
index 04ef5e0b3e6..c6edacfe50f 100644
--- a/studio/frontend/src/components/tauri/update-banner.tsx
+++ b/studio/frontend/src/components/tauri/update-banner.tsx
@@ -134,8 +134,6 @@ export function UpdateBanner({
: "min-h-[calc(117px+93px*var(--ui-font-scale,1))] max-[383px]:min-h-[calc(24px+224px*var(--ui-font-scale,1))]",
),
)}
- // See the browser card: dismissible, so it may cover the composer.
- data-overlay-dismissible="true"
data-testid="tauri-update-banner"
>
<div className="relative flex max-h-[calc(100dvh_-_2rem)] min-h-0 flex-col overflow-hidden rounded-[24px] bg-white px-5 pb-4 pt-5 shadow-[0_2px_8px_-2px_rgba(0,0,0,0.16)] dark:bg-card dark:shadow-[0_8px_28px_-6px_rgba(0,0,0,0.28)]">
diff --git a/studio/frontend/src/components/tauri/window-titlebar.tsx b/studio/frontend/src/components/tauri/window-titlebar.tsx
index 08c20638c68..fb8bad1a0ea 100644
--- a/studio/frontend/src/components/tauri/window-titlebar.tsx
+++ b/studio/frontend/src/components/tauri/window-titlebar.tsx
@@ -417,8 +417,7 @@ export function WindowTitlebar({
// 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.
+ // each, and is unchanged by the grips taking the named layer.
role="toolbar"
aria-label="Window controls"
>
diff --git a/studio/frontend/src/components/web/update-banner.tsx b/studio/frontend/src/components/web/update-banner.tsx
index 51ec46a22b6..fb9de93cc99 100644
--- a/studio/frontend/src/components/web/update-banner.tsx
+++ b/studio/frontend/src/components/web/update-banner.tsx
@@ -108,10 +108,6 @@ export function WebUpdateBanner({
// 259) and are exact from 17px up, where the extra wrap starts.
"pointer-events-auto flex min-h-[calc(109px+80px*var(--ui-font-scale,1))] w-[calc(100vw-2rem)] max-w-[448px] flex-col max-[383px]:min-h-[calc(139px+96px*var(--ui-font-scale,1))]",
)}
- // Dismissible, so the stack may cover the composer to show it
- // whole. See useStackGeometry: a card that cannot be got rid of
- // does not get that licence.
- data-overlay-dismissible="true"
data-testid="web-update-banner"
>
<div className="relative flex max-h-[calc(100dvh_-_2rem)] min-h-0 flex-col overflow-hidden rounded-[24px] bg-white px-5 pb-4 pt-5 shadow-[0_2px_8px_-2px_rgba(0,0,0,0.16)] dark:bg-card dark:shadow-[0_8px_28px_-6px_rgba(0,0,0,0.28)]">
diff --git a/studio/frontend/src/features/api-monitor/panel-placement.ts b/studio/frontend/src/features/api-monitor/panel-placement.ts
index 37513e5b873..fb54228551a 100644
--- a/studio/frontend/src/features/api-monitor/panel-placement.ts
+++ b/studio/frontend/src/features/api-monitor/panel-placement.ts
@@ -9,11 +9,11 @@
* this one, which put this panel's header, its Close button and its drag
* handle underneath a window the user can resize across the whole viewport.
*
- * Avoidance rather than a z-index, because it is what Studio already does in
- * this corner: the notification stack does not outrank the monitor, it steps
- * over it (monitor-frame-store's stackGeometry, whose gap and inset this file
- * matches so the three surfaces line up on one grid). This panel reads the same
- * published boxes and does the same thing one rung further in.
+ * Avoidance rather than a z-index, because both are windows the user drags,
+ * resizes and closes, and the one underneath loses controls it needs. The
+ * notification rail is the opposite case, settled by z-order: it is passive
+ * status, it never moves, and the panels paint over it. The gap and inset here
+ * match the rail's so the three surfaces line up on one grid.
*
* Pure, and separate from the component, because the interesting part is what
* happens when there is nowhere clear to go.
diff --git a/studio/frontend/src/features/settings/hooks/use-published-frame.ts b/studio/frontend/src/features/settings/hooks/use-published-frame.ts
index ae0beed43ba..5c9049f506e 100644
--- a/studio/frontend/src/features/settings/hooks/use-published-frame.ts
+++ b/studio/frontend/src/features/settings/hooks/use-published-frame.ts
@@ -1,34 +1,25 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
-// Publish an element's box to the overlay-frame store, so the bottom-right
-// stack keeps clear of it. The Live monitor does this by hand inside its own
-// layout effect; anything else that must not be covered uses this.
+// Publish an element's box to the overlay-frame store, so the API monitor
+// panel opens somewhere it is not. The Live monitor does this by hand inside
+// its own layout effect; anything else uses this.
import { useEffect, useMemo } from "react";
import { useMonitorFrameStore } from "../stores/monitor-frame-store";
/**
- * Keep the corner stack off `element` for as long as it is mounted.
+ * Keep the floating panels off `element` for as long as it is mounted.
*
* The chat composer is the case this exists for: it docks to the bottom of the
- * viewport once a thread has turns, in the same column the stack occupies, and
- * the loaded models card is the first overlay there that is persistent rather
- * than transient. It sat over the Send button and swallowed the click.
+ * viewport once a thread has turns, in the same corner the API monitor panel
+ * opens in, and a panel landing on it covers Send.
*
* Re-measured on resize and through a ResizeObserver, because the composer
* grows with its input and moves from centred to docked with no resize event.
- *
- * `coverable` says the stack may paint over this box rather than clip itself,
- * for the windows too short to do both. Off by default: the Live monitor's
- * controls have to stay clickable, and anything else that publishes here should
- * decide deliberately rather than inherit the composer's answer.
*/
-export function usePublishedFrame(
- element: HTMLElement | null,
- { coverable = false }: { coverable?: boolean } = {},
-): void {
+export function usePublishedFrame(element: HTMLElement | null): void {
// This caller's claim on the store, stable for the life of the component.
const publisher = useMemo(() => ({}), []);
const setFrame = useMonitorFrameStore((state) => state.setFrame);
@@ -41,8 +32,8 @@ export function usePublishedFrame(
}
const measure = () => {
const box = element.getBoundingClientRect();
- // A hidden composer measures 0x0; publishing that would pin the stack to
- // the top-left corner rather than leave it where it belongs.
+ // A hidden composer measures 0x0; publishing that would push the panels
+ // out of the top-left corner for an obstacle that is not there.
if (box.width === 0 && box.height === 0) {
clearFrame(publisher);
return;
@@ -52,7 +43,6 @@ export function usePublishedFrame(
top: box.top,
right: box.right,
bottom: box.bottom,
- coverable,
});
};
measure();
@@ -65,5 +55,5 @@ export function usePublishedFrame(
observer?.disconnect();
clearFrame(publisher);
};
- }, [element, publisher, coverable, setFrame, clearFrame]);
+ }, [element, publisher, setFrame, clearFrame]);
}
diff --git a/studio/frontend/src/features/settings/index.ts b/studio/frontend/src/features/settings/index.ts
index 9f50cb8b4fd..168139eb0c5 100644
--- a/studio/frontend/src/features/settings/index.ts
+++ b/studio/frontend/src/features/settings/index.ts
@@ -46,17 +46,7 @@ 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,
useMonitorFrameStore,
- useStackGeometry,
} from "./stores/monitor-frame-store";
export type {
Personalization,
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 49994115107..95d3acb511b 100644
--- a/studio/frontend/src/features/settings/stores/monitor-frame-store.ts
+++ b/studio/frontend/src/features/settings/stores/monitor-frame-store.ts
@@ -1,18 +1,16 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
-// What the bottom-right overlay stack has to keep clear of, in viewport
-// coordinates. The Live monitor is draggable and resizable and defaults to that
-// same corner; the chat composer docks to the bottom of the same column once a
-// thread has turns; the API monitor panel opens in that corner on its own. Each
-// publishes its box here while it is mounted.
+// Where the floating panels are, in viewport coordinates. The Live monitor,
+// the chat composer and the API monitor panel each publish their box here
+// while mounted.
//
-// Read as well as written: the API monitor panel places itself against every
-// box but its own (api-monitor/panel-placement), so the three surfaces resolve
-// in one direction -- the monitor is placed by the user, the API panel steps
-// around the monitor, and the stack steps around both.
+// Read only by api-monitor/panel-placement, which opens the API panel clear of
+// the others. The notification rail is not a reader: it is anchored in CSS.
+// Placing it from these boxes is what moved it out of its corner, since every
+// input to that placement (composer height, download rows, release notes)
+// changes on its own.
-import { useCallback, useEffect, useMemo, useState } from "react";
import { create } from "zustand";
export type MonitorFrame = {
@@ -20,17 +18,6 @@ export type MonitorFrame = {
top: number;
right: number;
bottom: number;
- /**
- * Whether the stack may paint over this box when there is nowhere left to
- * put itself. Off by default, because the box that started this store is the
- * Live monitor and its Close button and resize grip have to stay clickable.
- *
- * The chat composer opts in. In a short window there is no arrangement that
- * both dodges it and shows the cards whole, and the two ways to lose are not
- * equal: a clipped card reads as broken, a card over the composer reads as a
- * card over the composer and has a dismiss button on it.
- */
- coverable?: boolean;
};
/**
@@ -45,8 +32,7 @@ interface MonitorFrameState {
/** Every published box, kept apart. Deliberately not merged into one: the
* rectangle around a left-hand monitor and a bottom-right composer spans
* the empty space between them, and reading that as a single obstacle
- * lifted the stack to its cap for a monitor nowhere near its column.
- * `stackGeometry` folds them one at a time. */
+ * would have the API panel dodge a corner nothing is in. */
frames: ReadonlyMap<MonitorFramePublisher, MonitorFrame>;
setFrame: (publisher: MonitorFramePublisher, frame: MonitorFrame) => void;
/** Drops only this publisher's box; the others still count. */
@@ -59,15 +45,14 @@ function sameFrame(a: MonitorFrame | null, b: MonitorFrame | null): boolean {
a.left === b.left &&
a.top === b.top &&
a.right === b.right &&
- a.bottom === b.bottom &&
- Boolean(a.coverable) === Boolean(b.coverable)
+ a.bottom === b.bottom
);
}
export const useMonitorFrameStore = create<MonitorFrameState>((set) => ({
frames: new Map(),
// Written from a layout effect on every reconcile, so no-op writes must not
- // notify: the overlay stack re-renders on this.
+ // notify: the API monitor panel re-places itself on this.
setFrame: (publisher, frame) =>
set((state) => {
if (sameFrame(state.frames.get(publisher) ?? null, frame)) return state;
@@ -81,701 +66,3 @@ export const useMonitorFrameStore = create<MonitorFrameState>((set) => ({
return { frames };
}),
}));
-
-// 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.
-const MIN_STACK_ROOM = 120;
-// Keep the download header and one row visible when a collapsible card reports
-// only its borders to the squeeze probe.
-const MIN_CARD_ROOM = 128;
-// Room the stack asks for before it has been measured. Deliberately small: guessing
-// high is what parked the loaded models card mid-window with the corner underneath it
-// empty. The real height arrives from the stack's ResizeObserver on the next frame.
-const ASSUMED_STACK_HEIGHT = 56;
-// The monitor's own controls, measured from its top edge: 12px of panel
-// padding, a 24px control row (the drag handle and the size-6 Close button),
-// an 8px rule and an 8px margin come to 54. Rounded up so a font or a border
-// cannot eat the margin.
-const MONITOR_HEADER = 64;
-// Its native `resize` grip, in the opposite corner. Chromium's hit area
-// reaches 15px in from the bottom-right corner and Firefox's 12px, so one
-// 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
- * update banners, the download panel and the loaded models card all land
- * underneath it.
- */
-/** Whether the monitor overlaps the column the stack's overlays occupy. */
-function inStackColumn(frame: MonitorFrame, viewportWidth: number): boolean {
- const columnLeft = viewportWidth - STACK_INSET - STACK_WIDTH;
- return frame.right > columnLeft && frame.left < viewportWidth - STACK_INSET;
-}
-
-/**
- * Whether the box leaves the stack too little room to sit under it, in which
- * case the stack has to go over it instead. Anything higher leaves the corner
- * usable, however far down the screen it starts.
- *
- * This is the whole difference between the two composer layouts. Docked under a
- * thread it crowds the corner and has to be dodged, or the card covers Send. On
- * an empty chat it sits well clear of the bottom, and lifting over it there
- * strands the stack mid-page with the corner underneath it empty.
- *
- * So the room is measured, never guessed: `neededRoom` is the stack's own
- * ResizeObserver height (see useStackGeometry). A fixed 120 once lifted an 80px
- * card out of an 83px gap it fit in.
- *
- * Asked against the inset in force, never a fixed one: lifting over one box
- * moves the stack up into the next, and a box that had room at the corner may
- * have none there.
- *
- * A box that may be covered is asked against the floor instead. It has already
- * said the stack outranks it, so a band holding every card whole is enough, and
- * the height the cards would prefer is not worth leaving the corner for: a rail
- * taller than the welcome composer's band was being parked mid-window for room
- * it scrolls anyway.
- */
-function reachesStack(
- frame: MonitorFrame,
- viewportHeight: number,
- bottomInset: number,
- neededRoom: number,
- floorRoom: number = neededRoom,
-): boolean {
- const wanted = frame.coverable ? floorRoom : neededRoom;
- // At least a pixel: a needed room of 0 lets the capped branch hand back a
- // max-height of 0, which browsers honour, leaving the stack invisible.
- 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 + LIFT_CLEARANCE;
-}
-
-/**
- * Whether the stack still has its floor above the box once lifted clear of it.
- * A box reaching the top of the viewport has nothing above it to lift into.
- */
-function liftFits(frame: MonitorFrame, viewportHeight: number): boolean {
- return liftOver(frame, viewportHeight) <= viewportHeight - MIN_STACK_ROOM;
-}
-
-/**
- * The inset that dodges this box: over its top edge while the stack still fits
- * there, and otherwise inside it, above its own resize grip.
- *
- * Bounding the lift to the stack's floor rather than giving it up is what the
- * second branch replaces. That parked the stack across the box's own top edge,
- * over the very controls it was dodging: a monitor resized to fill the viewport
- * had its Close button swallowed by the loaded models card. Only the Live
- * monitor is ever tall enough to get here, and its native `resize` grip is in
- * the opposite corner, so the one place left for the stack is inside it with
- * that grip kept clear. `stackMaxHeight` holds the other edge.
- */
-function dodgeInset(frame: MonitorFrame, viewportHeight: number): number {
- if (liftFits(frame, viewportHeight)) {
- return Math.max(STACK_INSET, liftOver(frame, viewportHeight));
- }
- return Math.max(
- STACK_INSET,
- viewportHeight - frame.bottom + MONITOR_GRIP + STACK_GAP,
- );
-}
-
-/** Height available between the box and the stack sitting on `bottomInset`. */
-function roomBelow(
- frame: MonitorFrame,
- viewportHeight: number,
- bottomInset: number,
-): number {
- return viewportHeight - bottomInset - frame.bottom - STACK_GAP;
-}
-
-export function stackBottomInset(
- frame: MonitorFrame | null,
- viewportWidth: number,
- viewportHeight: number,
- neededRoom: number = ASSUMED_STACK_HEIGHT,
- floorRoom: number = neededRoom,
-): number {
- if (!frame) return STACK_INSET;
- // Only dodge a box that is in the stack's column and crowds its corner; one
- // parked anywhere else, or one leaving room underneath itself, leaves that
- // corner free.
- const inTheWay =
- inStackColumn(frame, viewportWidth) &&
- reachesStack(frame, viewportHeight, STACK_INSET, neededRoom, floorRoom);
- return inTheWay ? dodgeInset(frame, viewportHeight) : STACK_INSET;
-}
-
-/**
- * How tall the stack may grow while sitting on `bottomInset`, keeping its own
- * margin at the top. Lifting the stack over the monitor shortens it by the same
- * amount, or a long download list plus the card runs off the top of the screen.
- *
- * A monitor parked high in the same column is not lifted over, because the free
- * space is underneath it. It still has to be dodged: the stack grows upwards
- * from the bottom, and a full download list plus the card is easily tall enough
- * to reach it. Cap the height at the gap below it instead.
- *
- * A monitor too tall to lift over needs the same treatment from the other side.
- * The stack is seated inside it, and the inset alone only holds its bottom
- * edge: an expanded download list plus the loaded models card grows from there
- * back over the monitor's header, which is what the inset was dodging.
- */
-export function stackMaxHeight(
- frame: MonitorFrame | null,
- viewportWidth: number,
- viewportHeight: number,
- bottomInset: number,
- neededRoom: number = ASSUMED_STACK_HEIGHT,
- floorRoom: number = neededRoom,
-): number {
- const ownMargin = viewportHeight - bottomInset - STACK_INSET;
- if (!frame || !inStackColumn(frame, viewportWidth)) return ownMargin;
- if (reachesStack(frame, viewportHeight, bottomInset, neededRoom, floorRoom)) {
- // Lifted over: bottomInset already cleared it.
- if (liftFits(frame, viewportHeight)) return ownMargin;
- // Seated inside it instead. Stop below its header, or the Close button goes
- // back under the stack the inset has just moved off it. Floored, because a
- // box taller than the room the header leaves would ask for a negative cap
- // and browsers drop one of those, taking the limit with it.
- const belowHeader =
- viewportHeight - bottomInset - frame.top - MONITOR_HEADER - STACK_GAP;
- return Math.max(MIN_STACK_ROOM, Math.min(ownMargin, belowHeader));
- }
- // At least MIN_STACK_ROOM, since anything tighter reaches at this inset.
- return Math.min(ownMargin, roomBelow(frame, viewportHeight, bottomInset));
-}
-
-/** What one card will not give up: its own floor, or a usable slice of it. */
-function cardFloorRoom(squeezed: number, natural: number): number {
- return Math.max(squeezed, Math.min(natural, MIN_CARD_ROOM));
-}
-
-/**
- * A card's height as the layout has it, not as it is painted. `offsetHeight`
- * and not a rect, for the reason `use-panel-anchor` has it: the update cards
- * animate in from `scale: 0.96`, a rect is read through that transform, and
- * finishing a transform resizes nothing, so no observer comes back with the
- * settled figure. It also matches `scrollHeight`, the total it is summed for.
- */
-function cardHeight(child: Element): number {
- return (child as HTMLElement).offsetHeight;
-}
-
-/**
- * Whether the card is part of the rail's own layout. Dragged, the loaded models
- * card pins itself `position: fixed` and is painted wherever the reader left
- * it; `scrollHeight` has already dropped it, so the floor and the tail have to
- * drop it too, or the rail asks for room to hold a card that is not in it.
- */
-function inRailFlow(child: Element): boolean {
- const { position } = getComputedStyle(child);
- return position !== "fixed" && position !== "absolute";
-}
-
-/**
- * How short the rail can be and still show every card in it.
- *
- * Per card, never over their sum. The update banner's own min-height, 189px,
- * answers any minimum asked of the rail as a whole while the min-h-0 download
- * panel beside it still measures its borders: floored as one number the rail
- * accepted the 200px band the welcome composer leaves at 1366x640, and the
- * panel came back an 8px strip, the same hairline as the docked case below.
- *
- * Bounded by the rail's natural height, so a card shorter than the minimum is
- * asked for what it has rather than for room it would not fill.
- */
-export function usableFloorRoom(
- cards: readonly { squeezed: number; natural: number }[],
- natural: number,
-): number {
- const floor = cards.reduce(
- (total, card) => total + cardFloorRoom(card.squeezed, card.natural),
- STACK_GAP * Math.max(0, cards.length - 1),
- );
- return Math.min(Math.round(floor), natural);
-}
-
-export type StackGeometry = { bottom: number; maxHeight: number };
-
-/**
- * Where the overlay stack sits and how tall it may be, given everything it has
- * to keep clear of.
- *
- * Folded per box, never over their union: a tall monitor and the wide docked
- * composer share almost no area, and the rectangle around the pair covers most
- * of the viewport. Reading that as one obstacle pinned the stack to the top of
- * the screen and put it back over the monitor it was dodging. Each box asks for
- * the lift it needs; the stack takes the largest, and the shortest height.
- */
-export function stackGeometry(
- frames: MonitorFrame | null | readonly MonitorFrame[],
- viewportWidth: number,
- viewportHeight: number,
- neededRoom: number = ASSUMED_STACK_HEIGHT,
- // What the stack cannot give up, as opposed to what it would like. Defaults
- // to `neededRoom` so a caller that knows only one number keeps the stricter
- // reading of it.
- floorRoom: number = neededRoom,
- // Height of the run of cards at the bottom of the stack that the reader
- // cannot dismiss. Covering is refused when that run would land on a box.
- persistentTail = 0,
-): StackGeometry {
- const list = frames === null ? [] : Array.isArray(frames) ? frames : [frames];
- const placed = place(
- list,
- viewportWidth,
- viewportHeight,
- neededRoom,
- floorRoom,
- );
- if (placed.maxHeight >= floorRoom || !list.some((f) => f.coverable)) {
- return placed;
- }
- // Nowhere to put the stack even at its floor while dodging everything. Drop
- // the boxes that said they may be covered and try again: the stack takes the
- // corner and paints over the composer, which is what the cards being on top
- // means. Clipping them instead is what the report was about, and a card
- // sliced off at the rail's edge looks like it has slid behind the page.
- //
- // Tested against the floor and not the natural height on purpose. The cards
- // are allowed to give up their notes, so a placement 3px short of the height
- // they would prefer is still a placement that shows all of them, and covering
- // the composer to win those 3px is a worse answer than a slightly shorter
- // notes preview.
- const uncoverable = list.filter((f) => !f.coverable);
- const covering = place(
- uncoverable,
- viewportWidth,
- viewportHeight,
- neededRoom,
- floorRoom,
- );
- // Where the run the reader cannot dismiss would actually land, measured from
- // the placement being considered rather than from the corner. Dropping the
- // composer does not always leave the stack at the bottom: an uncoverable
- // monitor can still lift it, which carries the tail up onto the very box the
- // corner-based reading had just cleared.
- const tailTop = viewportHeight - covering.bottom - persistentTail;
- const safeToCover = list.every(
- (frame) => !frame.coverable || frame.bottom <= tailTop,
- );
- // Covering has to buy the thing it is for. A placement that takes the
- // composer and STILL cannot show the cards at their floor has paid the whole
- // price for nothing: the rail scrolls either way, so the one that leaves Send
- // reachable is the better of two bad answers.
- if (!safeToCover || covering.maxHeight < floorRoom) {
- return placed;
- }
- return covering.maxHeight > placed.maxHeight ? covering : placed;
-}
-
-/** `stackGeometry` for one set of boxes, all of which must be dodged. */
-function place(
- list: readonly MonitorFrame[],
- viewportWidth: number,
- viewportHeight: number,
- neededRoom: number,
- floorRoom: number = neededRoom,
-): StackGeometry {
- if (list.length === 0) {
- const bottom = stackBottomInset(
- null,
- viewportWidth,
- viewportHeight,
- neededRoom,
- );
- return {
- bottom,
- maxHeight: stackMaxHeight(
- null,
- viewportWidth,
- viewportHeight,
- bottom,
- neededRoom,
- ),
- };
- }
- // Settled, not summed. Lifting over one box moves the stack up into the next,
- // which may then need a lift of its own, so keep going until nothing more
- // asks. Each pass can only promote a box once, so this bounds at their count.
- const column = list.filter((f) => inStackColumn(f, viewportWidth));
- let bottom = STACK_INSET;
- for (let pass = 0; pass <= column.length; pass += 1) {
- let next = bottom;
- for (const frame of column) {
- if (reachesStack(frame, viewportHeight, bottom, neededRoom, floorRoom)) {
- next = Math.max(next, dodgeInset(frame, viewportHeight));
- }
- }
- if (next === bottom) break;
- bottom = next;
- }
- return {
- bottom,
- maxHeight: Math.min(
- ...list.map((f) =>
- stackMaxHeight(
- f,
- viewportWidth,
- viewportHeight,
- bottom,
- neededRoom,
- floorRoom,
- ),
- ),
- ),
- };
-}
-
-export type StackPlacement = StackGeometry & {
- /** Attach to the stack container so its height feeds back into the placement. */
- ref: (node: HTMLElement | null) => void;
- /**
- * The cards need more room than the cap allows, so the stack is scrolling.
- * It is click-through the rest of the time, which also costs it its
- * scrollbar, and a scroller nobody can drag hides the cards below the fold.
- */
- overflowing: boolean;
-};
-
-/**
- * `stackGeometry` in px, recomputed as the monitor moves or resizes, and as the
- * stack's own content grows.
- *
- * The measurement has to be taken with this hook's own `maxHeight` off. The
- * overlays are `min-h-0` flex items with inner scrollers, so under the cap they
- * shrink to it and `scrollHeight` reports the cap, not the content: 83px of
- * content reads back as 40 under a 40px cap. Fed back in that is the placement
- * reading its own output, so a stack taller than the gap under an obstacle would
- * measure as exactly the gap, never ask to be lifted, and sit there clipped.
- */
-export function useStackGeometry(): StackPlacement {
- const frames = useMonitorFrameStore((state) => state.frames);
- // Every published box, not their union: see stackGeometry.
- const published = useMemo(() => [...frames.values()], [frames]);
- const [viewport, setViewport] = useState(() => ({
- width: typeof window === "undefined" ? 0 : window.innerWidth,
- height: typeof window === "undefined" ? 0 : window.innerHeight,
- }));
- const [neededRoom, setNeededRoom] = useState(ASSUMED_STACK_HEIGHT);
- const [floorRoom, setFloorRoom] = useState(ASSUMED_STACK_HEIGHT);
- // How far the rail can be squeezed, as opposed to how far it may be: a card
- // clipped inside its own min-h-0 box takes the cap without the rail
- // overflowing. The placement asks `floorRoom`, the scroll reading asks this.
- const [collapsedRoom, setCollapsedRoom] = useState(ASSUMED_STACK_HEIGHT);
- const [persistentTail, setPersistentTail] = useState(0);
- // Whether the rail is ACTUALLY scrolling, read off the node at its real cap.
- // The derived answer below is a prediction, and a prediction can be wrong: the
- // cards are only assumed to collapse to `collapsedRoom`, so whenever they stop
- // short of it the box overflows a cap that `collapsedRoom > maxHeight` says it
- // fits inside. That combination is a rail that scrolls while it is still
- // click-through, which costs it its scrollbar and strands every card above the
- // fold where no pointer can reach them.
- const [domOverflowing, setDomOverflowing] = useState(false);
- useEffect(() => {
- const onResize = () =>
- setViewport({ width: window.innerWidth, height: window.innerHeight });
- onResize();
- window.addEventListener("resize", onResize);
- return () => window.removeEventListener("resize", onResize);
- }, []);
- const ref = useCallback((node: HTMLElement | null) => {
- if (node === null || typeof ResizeObserver === "undefined") return;
- const measure = () => {
- // 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
- // sees the unconstrained layout but nothing else ever sees the uncapped
- // box. Through style, not state: React rewrites the same value next render.
- // An uncapped box does not overflow, so lifting the cap clamps scrollTop
- // to 0 and putting it back does not undo that: every descendant resize
- // would throw a reader back to the first card. Restore it with the cap.
- // `transition-property: all` reaches this box, so each write below starts
- // a transition on max-height, and a transition's computed value is its
- // *start* value until the timeline advances. Reading scrollHeight flushes
- // style within the same frame, so the probe would read the cap it just
- // replaced, and the restore would leave the box computing 0px while its
- // 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;
- // The rail's own scroll position is not the only one at stake. Uncapping
- // it grows every scroller inside it, which shortens their scrollable
- // range and clamps any that were scrolled past the new end: read the
- // release notes to the bottom, let a download tick, and the list the
- // reader was in jumps. The rail's cap comes back, but a clamped
- // descendant does not come back with it, so each one is noted here and
- // put back below.
- const scrollers: Array<[Element, number]> = [];
- for (const child of node.querySelectorAll("*")) {
- if (child.scrollTop > 0) {
- scrollers.push([child, child.scrollTop]);
- }
- }
- const scrolled = node.scrollTop;
- node.style.maxHeight = "none";
- 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
- // panels are min-h-0 with their own scrollers, so under a tight cap they
- // measure as almost nothing, the placement reads that as a tail it can
- // safely put in the corner, the corner's larger cap lets them grow, and
- // the next measurement says the opposite: the two placements would swap
- // back and forth for as long as a download and an update card share the
- // rail. One size that does not depend on the answer, as with the two
- // heights above.
- let tail = 0;
- for (let i = cards.length - 1; i >= 0; i -= 1) {
- const child = cards[i];
- if (child.hasAttribute("data-overlay-dismissible")) break;
- tail += cardHeight(child) + STACK_GAP;
- }
- const persistent = Math.round(tail);
- // And the other end of the same measurement: squeezed to nothing, what is
- // left is what the cards refuse to give up. The difference between the two
- // is the height the stack can donate to a dodge, and asking a placement to
- // 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 = railCardsHeight(node.scrollHeight, gutter);
- const floor = usableFloorRoom(
- cards.map((child, index) => ({
- squeezed: cardHeight(child),
- natural: grown[index],
- })),
- natural,
- );
- node.style.maxHeight = capped;
- if (node.scrollTop !== scrolled) {
- node.scrollTop = scrolled;
- }
- for (const [child, top] of scrollers) {
- if (child.scrollTop !== top) {
- child.scrollTop = top;
- }
- }
- // Flush the restore under the suppression, or putting `transition` back
- // hands the pending max-height change to a transition after all.
- void node.scrollHeight;
- node.style.transition = eased;
- // Taken here, with the real cap back on and the layout already flushed by
- // the line above, so it describes the box the reader has rather than
- // either probe. After the `transition` restore, not between it and the
- // flush: the cap change is already committed under the suppression, and
- // `transition` is not itself a transitionable property, so no reflow this
- // read forces can hand that cap to an animation.
- //
- // Read every time this runs, never latched: the observers below watch the
- // rail AND every descendant, and a placement change moves the rail's own
- // border box, so a cap that grows to fit clears this on the same pass that
- // applied it. That is what the derived value was protecting against, and
- // it is still true when the reading is refreshed rather than remembered.
- const overflows = node.scrollHeight > node.clientHeight;
- setDomOverflowing((current) =>
- current === overflows ? current : overflows,
- );
- setNeededRoom((current) => (current === natural ? current : natural));
- setFloorRoom((current) => (current === floor ? current : floor));
- setCollapsedRoom((current) =>
- current === collapsed ? current : collapsed,
- );
- // How much of the stack, measured up from the corner, the reader cannot
- // dismiss. The loaded models indicator and the download panel are last,
- // so a covering placement puts them nearest the bottom edge: over Send
- // that is #8210 again and permanently, rather than until a dismiss. The
- // indicator ships off by default (#8346), which makes this whoever turned
- // it on rather than nobody.
- //
- // A height rather than a flag, because whether it is a problem depends on
- // where the composer is. Docked under a thread it sits on the bottom edge
- // and the tail lands on it; on an empty chat it is centred and the corner
- // below it is free, so the cards that reach it are the dismissible ones
- // and there is nothing to protect.
- setPersistentTail((current) =>
- current === persistent ? current : persistent,
- );
- };
- measure();
- // Every box inside the stack, not just the stack itself. At its cap the container's
- // border box does not move when its content grows, so a root-only observer never
- // fires for a release-note image finishing its load, and childList says nothing
- // either: the stack would keep the pre-load height and stay clipped.
- // Height only. The llama.cpp update banner animates its progress bar's width on every
- // frame, and that bar is inside this stack, so an unfiltered observer would remeasure
- // at ~60Hz for a stack whose height never moved, each one forcing a synchronous layout
- // to read scrollHeight with the cap lifted.
- const heights = new WeakMap<Element, number>();
- const observer = new ResizeObserver((entries) => {
- let moved = false;
- for (const entry of entries) {
- const height =
- entry.borderBoxSize?.[0]?.blockSize ?? entry.contentRect.height;
- if (heights.get(entry.target) !== height) {
- heights.set(entry.target, height);
- moved = true;
- }
- }
- if (moved) measure();
- });
- const observed = new Set<Element>();
- const syncObserved = () => {
- const wanted = new Set<Element>([node, ...node.querySelectorAll("*")]);
- for (const element of observed) {
- if (!wanted.has(element)) {
- observer.unobserve(element);
- observed.delete(element);
- }
- }
- for (const element of wanted) {
- if (!observed.has(element)) {
- observer.observe(element);
- observed.add(element);
- }
- }
- };
- syncObserved();
- // A 0-height stack stays 0 as children come and go, so watch the child list too, and
- // observe whatever just arrived.
- const mutations = new MutationObserver(() => {
- syncObserved();
- measure();
- });
- mutations.observe(node, { childList: true, subtree: true });
- return () => {
- observer.disconnect();
- observed.clear();
- mutations.disconnect();
- };
- }, []);
- const geometry = stackGeometry(
- published,
- viewport.width,
- viewport.height,
- neededRoom,
- floorRoom,
- persistentTail,
- );
- return {
- ...geometry,
- ref,
- // Derived from the placement, not read back off the node. A DOM reading
- // latches: the stack is capped and scrolling for a frame, the placement
- // then changes to one that fits, and nothing resizes afterwards to correct
- // the flag, so a rail with nothing to scroll to keeps the pointer input it
- // took. The cards absorb everything down to the height they collapse at, so
- // a cap below that is exactly when the rail has to scroll. A pixel of slack,
- // since the reading is a rounded scrollHeight and the cap is not.
- //
- // `collapsedRoom` and not `floorRoom`: a card that gives up more than its
- // floor is clipped, not scrolled, so asking the floor here would hand the
- // rail pointer input, and the clicks crossing its gutter, for no fold.
- //
- // Or the box is simply scrolling, whatever the prediction says. The two
- // agree wherever the cards do collapse to the height they measured, so this
- // only ever adds the case the prediction misses; it cannot take pointer
- // input away from a rail that the derived reading already claimed.
- overflowing: collapsedRoom > geometry.maxHeight + 1 || domOverflowing,
- };
-}
diff --git a/studio/frontend/tests/monitor-frame-ownership.test.ts b/studio/frontend/tests/monitor-frame-ownership.test.ts
index 905074a894d..23904b6d681 100644
--- a/studio/frontend/tests/monitor-frame-ownership.test.ts
+++ b/studio/frontend/tests/monitor-frame-ownership.test.ts
@@ -160,7 +160,7 @@ test("two publishers are dodged together, not one at a time", () => {
assert.deepEqual(
published(),
[corner(300), { left: 300, top: 780, right: 1100, bottom: 860 }],
- "both are kept, apart, for stackGeometry to fold one at a time",
+ "both are kept, apart, for panel-placement to dodge one at a time",
);
});
diff --git a/studio/frontend/tests/monitor-stack-inset.test.ts b/studio/frontend/tests/monitor-stack-inset.test.ts
deleted file mode 100644
index d5d6a119b52..00000000000
--- a/studio/frontend/tests/monitor-stack-inset.test.ts
+++ /dev/null
@@ -1,972 +0,0 @@
-// SPDX-License-Identifier: AGPL-3.0-only
-// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
-
-import assert from "node:assert/strict";
-import { readFile } from "node:fs/promises";
-import test from "node:test";
-
-import {
- type MonitorFrame,
- stackBottomInset,
- stackGeometry,
- usableFloorRoom,
-} from "../src/features/settings/stores/monitor-frame-store.ts";
-
-const W = 1440;
-const H = 900;
-
-/** The Live monitor where it opens by default: bottom-right, w-64, inset-4. */
-function corner(height = 300): MonitorFrame {
- return {
- left: W - 16 - 256,
- top: H - 16 - height,
- right: W - 16,
- bottom: H - 16,
- };
-}
-
-test("with no monitor open the stack keeps its own inset", () => {
- assert.equal(stackBottomInset(null, W, H), 16);
-});
-
-// The reported overlap: both default to the same corner.
-test("a monitor in its default corner lifts the stack clear of it", () => {
- const frame = corner(300);
- const inset = stackBottomInset(frame, W, H);
- // The stack's bottom edge now sits above the monitor's top edge.
- assert.ok(inset > 16, "the stack must move");
- assert.ok(H - inset <= frame.top, "no vertical overlap remains");
-});
-
-test("a monitor dragged to the left is not dodged", () => {
- const frame: MonitorFrame = {
- left: 16,
- top: H - 316,
- right: 272,
- bottom: H - 16,
- };
- assert.equal(stackBottomInset(frame, W, H), 16);
-});
-
-test("a monitor dragged to the top right is not dodged", () => {
- const frame: MonitorFrame = {
- left: W - 272,
- top: 16,
- right: W - 16,
- bottom: 316,
- };
- assert.equal(stackBottomInset(frame, W, H), 16);
-});
-
-// The update banners are max-w-[448px], wider than the download panel, so the
-// column has to be measured from them.
-test("a monitor beside the download panel but under a banner is dodged", () => {
- const frame: MonitorFrame = {
- left: W - 16 - 430,
- top: H - 316,
- right: W - 16 - 410,
- bottom: H - 16,
- };
- assert.ok(stackBottomInset(frame, W, H) > 16);
-});
-
-// Lifting the stack without shortening it pushes its top off the screen.
-test("lifting the stack shortens it by the same amount", () => {
- assert.equal(stackGeometry(null, W, H).maxHeight, H - 32);
- const lifted = stackGeometry(corner(300), W, H);
- assert.ok(lifted.bottom > 16);
- assert.equal(lifted.maxHeight, H - lifted.bottom - 16);
-});
-
-// A monitor parked high is not lifted over, since the room is beneath it, but
-// the stack grows upwards and would still run into it.
-test("a monitor high in the column caps the stack instead of lifting it", () => {
- const frame: MonitorFrame = {
- left: W - 272,
- top: 16,
- right: W - 16,
- bottom: 316,
- };
- const geometry = stackGeometry(frame, W, H);
- // Nothing to lift over: the free space is below it.
- assert.equal(geometry.bottom, 16);
- // The stack's top edge stays clear of the monitor's bottom edge.
- assert.ok(H - geometry.bottom - geometry.maxHeight >= frame.bottom);
- assert.ok(geometry.maxHeight < H - 32, "it must actually be capped");
-});
-
-test("a monitor high but outside the column does not cap the stack", () => {
- const frame: MonitorFrame = { left: 16, top: 16, right: 272, bottom: 316 };
- assert.equal(stackGeometry(frame, W, H).maxHeight, H - 32);
-});
-
-// A monitor filling almost the whole column would otherwise leave no stack.
-test("the cap never shrinks the stack below its floor", () => {
- const frame: MonitorFrame = {
- left: W - 272,
- top: 0,
- right: W - 16,
- bottom: H / 2 - 1,
- };
- assert.ok(stackGeometry(frame, W, H).maxHeight >= 120);
-});
-
-// Clamping the lift to the stack's floor was worse than not lifting: it put
-// the stack across the monitor's own top edge, which is where its Close and
-// collapse controls are. The chat UI suite maximises the monitor and then
-// clicks Close, and the card swallowed the click.
-//
-// Nothing above such a monitor is free, so the stack goes inside it, and the
-// two things it may not bury are the header at the top and the native resize
-// grip in the bottom-right corner (Chromium's hit area reaches 15px in from
-// that corner, Firefox's 12px). Both edges are checked, because the inset
-// alone does not hold the top: an expanded download list plus the loaded
-// models card grows from the bottom right back over the header.
-/** Where the stack's own edges land, given everything it dodges. */
-function stackEdges(frame: MonitorFrame) {
- const { bottom, maxHeight } = stackGeometry(frame, W, H);
- return { bottom, top: H - bottom - maxHeight, edge: H - bottom };
-}
-
-test("a monitor too tall to lift over keeps its header and grip clear", () => {
- const frame: MonitorFrame = {
- left: W - 272,
- top: 16,
- right: W - 16,
- bottom: H - 16,
- };
- const { top, edge } = stackEdges(frame);
- assert.ok(
- edge <= frame.bottom - 16,
- "the stack sits clear of the resize grip",
- );
- assert.ok(top >= frame.top + 64, "and stops below the header controls");
-});
-
-test("a monitor resized to fill the viewport keeps its header and grip clear", () => {
- const frame: MonitorFrame = {
- left: 16,
- top: 16,
- right: W - 16,
- bottom: H - 16,
- };
- const { bottom, top, edge } = stackEdges(frame);
- assert.ok(
- edge <= frame.bottom - 16,
- "the stack sits clear of the resize grip",
- );
- assert.ok(top >= frame.top + 64, "and stops below the header controls");
- // Seated inside the monitor near its foot, not lifted to the stack's floor,
- // which is the whole of the difference and the only place both edges fit.
- assert.ok(bottom < H / 2, "the stack stays at the bottom of the screen");
-});
-
-// Tall enough that a lift over it would not fit, but it stops short of the
-// bottom edge, so it never crowds the stack's corner to begin with. The stack
-// keeps that corner and is capped to the room underneath rather than being
-// pushed up inside the monitor.
-test("a monitor too tall to lift over but clear of the bottom is sat under", () => {
- const frame: MonitorFrame = {
- left: W - 272,
- top: 16,
- right: W - 16,
- bottom: H / 2 + 100,
- };
- const { bottom, top } = stackEdges(frame);
- assert.equal(bottom, 16, "the corner is free, so stay in it");
- assert.ok(top >= frame.bottom, "and the stack stays underneath the monitor");
-});
-
-// The lift is dropped only when it cannot clear; one that fits still applies.
-test("a tall monitor that can still be cleared is lifted over", () => {
- const frame: MonitorFrame = {
- left: W - 272,
- top: 200,
- right: W - 16,
- bottom: H - 16,
- };
- const inset = stackBottomInset(frame, W, H);
- assert.ok(inset > 16, "the stack must move");
- assert.ok(H - inset <= frame.top, "no vertical overlap remains");
- assert.ok(H - inset - 16 >= 120, "and it keeps its floor");
-});
-
-// The union was the trap. A tall monitor and the wide docked composer share
-// almost no area, so the rectangle around the pair covers most of the viewport;
-// reading that as one obstacle lifted the stack to the top of the screen and
-// dropped it back onto the monitor it was meant to dodge, which the chat UI
-// suite caught as the card swallowing the monitor's Close button.
-test("two obstacles are folded one at a time, not as their bounding box", () => {
- // The monitor dragged up the column, as the chat UI suite does before it
- // clicks Close: too high to be lifted over, so on its own it asks for
- // nothing. The composer, docked, asks for a modest lift.
- const monitor = { left: W - 16 - 256, top: 40, right: W - 16, bottom: 340 };
- const composer = { left: 300, top: H - 120, right: W - 340, bottom: H - 40 };
- const both = stackGeometry([monitor, composer], W, H);
- const monitorOnly = stackGeometry(monitor, W, H);
- const composerOnly = stackGeometry(composer, W, H);
- assert.equal(
- both.bottom,
- Math.max(monitorOnly.bottom, composerOnly.bottom),
- "the stack takes the largest lift either one asks for",
- );
- // The union's own answer, which is what went wrong.
- const unioned = stackGeometry(
- {
- left: Math.min(monitor.left, composer.left),
- top: Math.min(monitor.top, composer.top),
- right: Math.max(monitor.right, composer.right),
- bottom: Math.max(monitor.bottom, composer.bottom),
- },
- W,
- H,
- );
- assert.notEqual(
- both.bottom,
- unioned.bottom,
- "folding must not agree with the bounding box, or nothing was fixed",
- );
- // The union is wrong in whichever direction its own answer happens to go: it
- // used to lift to the cap and land on the monitor, and a box that tall is now
- // seated inside itself, which asks for less than the composer does on its own
- // and puts the card back over the Send button. Folding gives each box what it
- // asked for.
- assert.equal(
- both.bottom,
- composerOnly.bottom,
- "the composer still gets the lift it asked for",
- );
-});
-
-test("an empty list behaves exactly like nothing published", () => {
- assert.deepEqual(stackGeometry([], W, H), stackGeometry(null, W, H));
-});
-
-test("one box in a list matches passing it on its own", () => {
- const frame = corner(300);
- assert.deepEqual(stackGeometry([frame], W, H), stackGeometry(frame, W, H));
-});
-
-// The two composer layouts, which are what this gate exists for. Boxes taken
-// from a 1280x830 window: the docked one has to be dodged, or the card covers
-// Send, which below a 1584px viewport it does. The welcome one must not be,
-// because it sits high on the page and lifting over it stranded the banners in
-// the middle of the screen with the corner underneath them empty.
-const CHAT_W = 1280;
-const CHAT_H = 830;
-
-test("a docked composer is dodged, so the card cannot cover Send", () => {
- const docked = { left: 412, top: 664, right: 1148, bottom: 814 };
- const inset = stackBottomInset(docked, CHAT_W, CHAT_H);
- assert.ok(inset > 16, "it reaches the stack's strip, so the stack lifts");
- assert.ok(
- inset >= CHAT_H - docked.top,
- "and lifts clear of it, not part way",
- );
- // Still the bottom of the screen, which is the point: above the composer,
- // not adrift in the middle.
- assert.ok(inset < CHAT_H / 2);
-});
-
-test("the welcome composer is left alone, and the stack stays in the corner", () => {
- const welcome = { left: 412, top: 435, right: 1148, bottom: 660 };
- assert.equal(stackBottomInset(welcome, CHAT_W, CHAT_H), 16);
-});
-
-// The reported case: a 921x534 window, where the welcome composer leaves 83px
-// under it and the 80px card fits in the corner it was being lifted out of.
-// Asking for a fixed 120 parked it in the middle of the screen instead.
-const SHORT_W = 921;
-const SHORT_H = 534;
-const SHORT_WELCOME = { left: 316, top: 308, right: 877, bottom: 427 };
-
-test("a card that fits under the welcome composer keeps the corner", () => {
- const geometry = stackGeometry(SHORT_WELCOME, SHORT_W, SHORT_H, 80);
- assert.equal(geometry.bottom, 16, "the card belongs in the corner");
- const stackTop = SHORT_H - geometry.bottom - geometry.maxHeight;
- assert.ok(stackTop >= SHORT_WELCOME.bottom, "and still clears the composer");
- assert.ok(geometry.maxHeight >= 80, "with room for the card it measured");
-});
-
-test("a stack too tall for that gap is still lifted over", () => {
- const inset = stackBottomInset(SHORT_WELCOME, SHORT_W, SHORT_H, 200);
- assert.ok(inset > 16, "200px cannot fit in 83px, so it has to move");
- assert.ok(SHORT_H - inset <= SHORT_WELCOME.top, "and clears it fully");
-});
-
-// Two active downloads on the welcome screen of a 1600x891 window. The rail is
-// taller than the 163px band under the composer but its cards scroll, so the
-// height it would PREFER is not worth the corner: dodging for it left the panel
-// mid-window with the corner under it empty.
-const WIDE_W = 1600;
-const WIDE_H = 891;
-const WIDE_WELCOME = {
- left: 532,
- top: 524,
- right: 1520,
- bottom: 704,
- coverable: true,
-};
-
-test("a rail that scrolls into the welcome composer's band keeps the corner", () => {
- const geometry = stackGeometry(WIDE_WELCOME, WIDE_W, WIDE_H, 328, 140);
- assert.equal(geometry.bottom, 16, "the panel belongs in the corner");
- assert.ok(geometry.maxHeight >= 140, "and holds the cards at their floor");
- const stackTop = WIDE_H - geometry.bottom - geometry.maxHeight;
- assert.ok(stackTop >= WIDE_WELCOME.bottom, "without reaching the composer");
-});
-
-test("a rail whose floor will not fit that band is still lifted over", () => {
- const geometry = stackGeometry(WIDE_WELCOME, WIDE_W, WIDE_H, 328, 300);
- assert.ok(geometry.bottom > 16, "300px cannot fit in 163px, so it moves");
- assert.ok(
- WIDE_H - geometry.bottom <= WIDE_WELCOME.top,
- "and clears the composer fully",
- );
-});
-
-test("the docked composer is dodged however little the rail insists on", () => {
- const docked = {
- left: 412,
- top: 664,
- right: 1148,
- bottom: 814,
- coverable: true,
- };
- for (const floor of [1, 40, 120]) {
- assert.ok(
- stackBottomInset(docked, CHAT_W, CHAT_H, 260, floor) > 16,
- `a rail with a ${floor}px floor must still clear Send`,
- );
- }
-});
-
-// The published form leaves a 5px strip above the footnote. A border-only floor
-// used to accept that strip and clip the download panel into a hairline.
-const NOTE_H = 800;
-const NOTE_DOCKED: MonitorFrame = {
- left: 407,
- top: 658.53,
- right: 1143,
- bottom: 770.53,
- coverable: true,
-};
-// One download row under the panel's header, measured in the same window.
-const ONE_CARD = 121;
-// The download panel alone in the rail, which is what the report had.
-const alone = (squeezed: number, natural: number) =>
- usableFloorRoom([{ squeezed, natural }], natural);
-
-test("the strip the composer's footnote leaves is not room for the rail", () => {
- const geometry = stackGeometry(
- NOTE_DOCKED,
- CHAT_W,
- NOTE_H,
- ONE_CARD,
- alone(2, ONE_CARD),
- );
- assert.ok(geometry.bottom > 16, "5px under the note is not a placement");
- assert.ok(
- NOTE_H - geometry.bottom <= NOTE_DOCKED.top,
- "so the rail clears the composer",
- );
- assert.ok(geometry.maxHeight >= ONE_CARD, "and the card fits where it lands");
-});
-
-test("the floor is a card the reader can see, not what the rail can shrink to", () => {
- assert.equal(alone(2, ONE_CARD), ONE_CARD);
- assert.equal(alone(2, 40), 40);
- assert.equal(alone(300, 480), 300);
- // Long lists still scroll rather than asking for their full height.
- assert.ok(alone(2, 480) < 480);
-});
-
-// The same window with the app update card up. Its min-height is its own floor,
-// so a rail floored as one number is already past the minimum while the panel
-// beside it is still measuring its borders.
-const BANNER_FLOOR = 189;
-const BANNER_NATURAL = 196;
-const PANEL_BORDERS = 2;
-const RAIL_CARDS = [
- { squeezed: BANNER_FLOOR, natural: BANNER_NATURAL },
- { squeezed: PANEL_BORDERS, natural: ONE_CARD },
-];
-const RAIL_NATURAL = BANNER_NATURAL + 8 + ONE_CARD;
-
-test("a banner's own floor does not answer for the panel beside it", () => {
- const floor = usableFloorRoom(RAIL_CARDS, RAIL_NATURAL);
- assert.ok(
- floor > BANNER_FLOOR + 8 + PANEL_BORDERS,
- "the panel is asked for as well as the banner",
- );
- // Shorter than the minimum, so it is asked for whole rather than for room it
- // could not fill.
- assert.equal(floor, BANNER_FLOOR + 8 + ONE_CARD);
-});
-
-// A 1366x768 laptop, where the browser leaves a 640px viewport: the welcome
-// composer sits with exactly 200px under it, which holds the banner and left
-// the download panel an 8px strip with no scrollbar to reach it by.
-const NOTE_W = 1366;
-const NOTE_WELCOME_H = 640;
-const NOTE_WELCOME: MonitorFrame = {
- left: 450,
- top: 304,
- right: 1186,
- bottom: 416,
- coverable: true,
-};
-
-test("a band that only holds the banner is not room for the rail", () => {
- const geometry = stackGeometry(
- NOTE_WELCOME,
- NOTE_W,
- NOTE_WELCOME_H,
- RAIL_NATURAL,
- usableFloorRoom(RAIL_CARDS, RAIL_NATURAL),
- ONE_CARD + 8,
- );
- assert.ok(
- NOTE_WELCOME_H - geometry.bottom - geometry.maxHeight >= 0,
- "the rail stays on the page",
- );
- assert.ok(
- geometry.maxHeight - BANNER_FLOOR - 8 >= ONE_CARD,
- "and the panel is more than its borders",
- );
-});
-
-// Preserve #8462: the 163px welcome-screen band still keeps the corner.
-test("the welcome band still keeps the corner under a real floor", () => {
- const geometry = stackGeometry(
- WIDE_WELCOME,
- WIDE_W,
- WIDE_H,
- 328,
- alone(2, 328),
- );
- assert.equal(geometry.bottom, 16, "the panel belongs in the corner");
-});
-
-test("a docked composer is dodged whatever the stack measures", () => {
- const docked = { left: 412, top: 664, right: 1148, bottom: 814 };
- for (const height of [40, 80, 120, 260]) {
- assert.ok(
- stackBottomInset(docked, CHAT_W, CHAT_H, height) > 16,
- `a ${height}px stack must still clear Send`,
- );
- }
-});
-
-// The measurement feeds the cap, and the cap is on the element measured. The
-// overlays are min-h-0 flex items, so under the cap they shrink to it and
-// scrollHeight reports the cap: a stack taller than the gap would measure as
-// the gap, never ask for a lift, and sit clipped. So read with the cap off.
-test("the height is measured with the hook's own cap lifted", async () => {
- const source = await readFile(
- new URL(
- "../src/features/settings/stores/monitor-frame-store.ts",
- import.meta.url,
- ),
- "utf8",
- );
- const measure = source.slice(
- source.indexOf("const measure = () => {"),
- source.indexOf("const observer = new ResizeObserver"),
- );
- assert.ok(measure, "the measure callback moved");
- assert.match(
- measure,
- /node\.style\.maxHeight = "none";[\s\S]*node\.scrollHeight/,
- "scrollHeight is read while the cap still applies",
- );
- assert.match(
- measure,
- /node\.scrollHeight[\s\S]*node\.style\.maxHeight = capped;/,
- "the cap is not restored after the read",
- );
-});
-
-// A rect is read through the update cards' scale 0.96 enter transform, and a
-// finished transform resizes nothing, so the short reading is the floor the
-// placement keeps. See cardHeight.
-test("the card floors are read off the layout box, not the painted one", async () => {
- const source = await readFile(
- new URL(
- "../src/features/settings/stores/monitor-frame-store.ts",
- import.meta.url,
- ),
- "utf8",
- );
- const measure = source.slice(
- source.indexOf("const measure = () => {"),
- source.indexOf("const observer = new ResizeObserver"),
- );
- assert.match(
- source,
- /function cardHeight\([\s\S]*?\)\.offsetHeight;/,
- "a card's height is not the untransformed layout box",
- );
- assert.match(measure, /const grown = cards\.map\(cardHeight\)/);
- assert.match(measure, /squeezed: cardHeight\(child\)/);
- assert.match(measure, /tail \+= cardHeight\(child\) \+ STACK_GAP/);
-});
-
-// Dragged, the loaded models card pins itself `position: fixed` and leaves the
-// rail's flow. scrollHeight drops it, so a floor that still counted it asked
-// for 225px where 128 was needed and lifted the rail off a corner it fitted.
-test("a card dragged out of the rail is not floored for", async () => {
- const source = await readFile(
- new URL(
- "../src/features/settings/stores/monitor-frame-store.ts",
- import.meta.url,
- ),
- "utf8",
- );
- const measure = source.slice(
- source.indexOf("const measure = () => {"),
- source.indexOf("const observer = new ResizeObserver"),
- );
- assert.match(
- source,
- /function inRailFlow\([\s\S]*?position !== "fixed" && position !== "absolute";/,
- "an out-of-flow card is not recognised",
- );
- assert.match(
- measure,
- /const cards = \[\.\.\.node\.children\]\.filter\(inRailFlow\)/,
- );
-});
-
-// The sweep above, re-run at the heights the stack actually takes.
-// The stack scrolls now, and an uncapped box does not, so the measurement has
-// to put scrollTop back with the cap or a resize below throws a reader of the
-// download list back to the first card.
-test("the measurement restores the stack's scroll position", async () => {
- const source = await readFile(
- new URL(
- "../src/features/settings/stores/monitor-frame-store.ts",
- import.meta.url,
- ),
- "utf8",
- );
- const measure = source.slice(
- source.indexOf("const measure = () => {"),
- source.indexOf("const observer = new ResizeObserver"),
- );
- assert.match(
- measure,
- /const scrolled = node\.scrollTop;[\s\S]*node\.style\.maxHeight = "none";/,
- "scrollTop is read after the cap comes off, when it has already clamped",
- );
- assert.match(
- measure,
- /node\.style\.maxHeight = capped;[\s\S]*node\.scrollTop = scrolled;/,
- "the scroll position is never put back",
- );
-});
-
-test("no measured height leaves the stack overlapping a box", () => {
- const composer = { left: 412, top: 664, right: 1148, bottom: 814 };
- for (const needed of [0, 40, 80, 120, 200, 320]) {
- for (let bottom = 60; bottom <= CHAT_H - 16; bottom += 4) {
- const box = {
- left: 996,
- top: Math.max(0, bottom - 180),
- right: 1264,
- bottom,
- };
- for (const boxes of [[box], [box, composer]]) {
- const geometry = stackGeometry(boxes, CHAT_W, CHAT_H, needed);
- const label = `needed=${needed} bottom=${bottom} n=${boxes.length}`;
- assert.ok(geometry.maxHeight > 0, `non-positive cap for ${label}`);
- const stackTop = CHAT_H - geometry.bottom - geometry.maxHeight;
- for (const each of boxes) {
- const clearsAbove = CHAT_H - geometry.bottom <= each.top;
- const clearsBelow = stackTop >= each.bottom;
- assert.ok(clearsAbove || clearsBelow, `overlap for ${label}`);
- }
- }
- }
- }
-});
-
-// A window too short to hold the cards above the composer has no arrangement
-// that both dodges it and shows them whole. Clipping them is what the overlap
-// report was about, and a card sliced off at the rail's edge reads as one that
-// has slid behind the page, so the stack takes the corner and paints over the
-// composer instead. Only for a box that said it may be covered.
-test("a stack that cannot fit above the composer covers it rather than clipping", () => {
- // 534px tall, the size from the report, with the welcome composer centred.
- const H = 534;
- const composer = {
- left: 236,
- top: 300,
- right: 684,
- bottom: 420,
- coverable: true,
- };
- const needed = 339;
- const covered = stackGeometry(composer, 921, H, needed);
- assert.equal(covered.bottom, 16, "the stack left the corner");
- assert.ok(
- covered.maxHeight >= needed,
- `the cards are still clipped: ${covered.maxHeight} < ${needed}`,
- );
- // The same box that has to be dodged when dodging it costs nothing.
- const roomy = stackGeometry(composer, 921, 1200, needed);
- assert.ok(
- 1200 - roomy.bottom <= composer.top ||
- roomy.maxHeight <= 1200 - 16 - composer.bottom,
- "a composer that could have been dodged was covered anyway",
- );
-});
-
-test("a box that never said it may be covered is still never covered", () => {
- // The Live monitor. Its Close button and resize grip are why this store
- // exists, so it keeps the old answer even when the stack does not fit.
- const H = 534;
- const monitor = { left: 236, top: 300, right: 684, bottom: 420 };
- const geometry = stackGeometry(monitor, 921, H, 339);
- const stackTop = H - geometry.bottom - geometry.maxHeight;
- const clearsAbove = H - geometry.bottom <= monitor.top;
- const clearsBelow = stackTop >= monitor.bottom;
- assert.ok(
- clearsAbove || clearsBelow,
- "the stack was allowed over the monitor",
- );
-});
-
-// The fallback drops the coverable boxes and places against what is left, so
-// the monitor has to come out of it exactly as it would have on its own. Stated
-// as a comparison rather than an absolute: a window this short cannot always
-// clear a monitor either, and the claim here is that the composer's permission
-// is not inherited, not that the monitor is always dodged.
-test("a coverable composer does not licence covering the monitor beside it", () => {
- const composer = {
- left: 236,
- top: 300,
- right: 684,
- bottom: 420,
- coverable: true,
- };
- const monitor = { left: 640, top: 60, right: 905, bottom: 250 };
- for (const height of [534, 700, 900, 1200]) {
- for (const needed of [56, 200, 339, 600]) {
- const alone = stackGeometry(monitor, 921, height, needed);
- const withComposer = stackGeometry(
- [composer, monitor],
- 921,
- height,
- needed,
- );
- const clearance = (g: { bottom: number; maxHeight: number }) => ({
- edge: height - g.bottom,
- top: height - g.bottom - g.maxHeight,
- });
- const a = clearance(alone);
- const b = clearance(withComposer);
- const label = `height=${height} needed=${needed}`;
- assert.ok(
- b.top >= a.top || b.edge <= monitor.top,
- `the composer pushed the stack further over the monitor: ${label}`,
- );
- }
- }
-});
-
-// The cards may give up their notes, so a placement short of the height they
-// would PREFER still shows all of them. Covering the composer to win those few
-// pixels is the worse answer, and testing the fallback against the natural
-// height rather than the floor is what did it: at 1280x830 a 3px shortfall took
-// the stack off a dodge that fitted and put it over the composer.
-test("a placement that fits the cards at their floor is not given up on", () => {
- const H = 830;
- const composer = {
- left: 416,
- top: 415,
- right: 864,
- bottom: 530,
- coverable: true,
- };
- const natural = 394;
- const floor = 339;
- const geometry = stackGeometry(composer, 1280, H, natural, floor);
- assert.ok(
- H - geometry.bottom <= composer.top,
- "the stack covered a composer it could have dodged",
- );
- assert.ok(geometry.maxHeight >= floor, "and it still holds the cards");
-});
-
-// The loaded models indicator is the LAST child of the rail, so it is the one
-// that lands on the corner, and it is persistent: over Send it is #8210 again,
-// permanently rather than until a dismiss. #8346 ships it off by default, which
-// makes this whoever turned it on rather than nobody.
-test("a persistent card that would land on the composer stops the cover", () => {
- const H = 534;
- // Docked under a thread: it sits on the bottom edge, so the corner is where
- // the persistent tail would go and the tail would land on Send.
- const docked = {
- left: 236,
- top: 380,
- right: 684,
- bottom: 518,
- coverable: true,
- };
- const dodging = stackGeometry(docked, 921, H, 460, 420, 60);
- assert.ok(
- H - dodging.bottom <= docked.top,
- "the persistent tail took the docked composer's corner",
- );
-});
-
-test("a persistent card clear of the composer does not stop the cover", () => {
- const H = 534;
- // The welcome composer, centred. The corner underneath it is free, so the
- // cards that reach it are the dismissible ones and there is nothing to
- // protect: covering is still the right answer.
- const welcome = {
- left: 236,
- top: 275,
- right: 684,
- bottom: 387,
- coverable: true,
- };
- const covering = stackGeometry(welcome, 921, H, 460, 420, 60);
- assert.equal(covering.bottom, 16, "it gave up a cover that was safe");
- assert.ok(covering.maxHeight >= 460, "and the cards are whole");
-});
-
-test("covering is refused when it still cannot show the cards", () => {
- // A short window with a monitor across the top: dropping the composer buys a
- // few pixels and still leaves the rail under its floor. The rail scrolls
- // either way, so paying the composer for those pixels buys nothing.
- const H = 400;
- const monitor = { left: 473, top: 0, right: 921, bottom: 200 };
- const composer = {
- left: 236,
- top: 250,
- right: 684,
- bottom: 384,
- coverable: true,
- };
- const both = stackGeometry([monitor, composer], 921, H, 460, 192, 0);
- const dodging = stackGeometry([monitor, composer], 921, H, 460, 10_000, 0);
- assert.deepEqual(
- both,
- dodging,
- "it covered the composer for a placement that is still under the floor",
- );
-});
-
-test("covering is taken when it does reach the floor", () => {
- // The same shape with room above the composer once it is dropped: now the
- // cover earns its price and the cards come out whole.
- const H = 534;
- const composer = {
- left: 236,
- top: 275,
- right: 684,
- bottom: 500,
- coverable: true,
- };
- const covering = stackGeometry(composer, 921, H, 460, 300, 0);
- // 16, the corner inset: the stack took the corner and the composer with it.
- assert.equal(covering.bottom, 16, "it refused a cover that fits");
- assert.ok(covering.maxHeight >= 300, "and the cards are whole");
-});
-
-test("the persistent tail is judged where the fallback actually lands", () => {
- // Dropping the composer does not always leave the stack at the corner: an
- // uncoverable monitor at the bottom still lifts it, and the lift carries the
- // tail up onto the composer that the corner-based reading had just cleared.
- const H = 800;
- const monitor = { left: 473, top: 600, right: 921, bottom: 800 };
- // Well above the corner, so a corner-based check calls covering safe.
- const composer = {
- left: 236,
- top: 380,
- right: 684,
- bottom: 560,
- coverable: true,
- };
- const placement = stackGeometry([monitor, composer], 921, H, 700, 240, 80);
- const railBottom = H - placement.bottom;
- assert.ok(
- railBottom - 80 >= composer.bottom || railBottom <= composer.top,
- `the persistent tail landed on the composer (rail bottom ${railBottom})`,
- );
-});
-
-test("no persistent tail means the old answer", () => {
- const composer = {
- left: 236,
- top: 300,
- right: 684,
- bottom: 420,
- coverable: true,
- };
- const withZero = stackGeometry(composer, 921, 534, 420, 420, 0);
- const withoutArg = stackGeometry(composer, 921, 534, 420, 420);
- assert.deepEqual(withoutArg, withZero);
-});
-
-// One number means the strict reading of it, so nothing that knows only the
-// natural height silently starts covering things.
-test("a caller that passes one height gets the stricter answer", () => {
- const composer = {
- left: 416,
- top: 415,
- right: 864,
- bottom: 530,
- coverable: true,
- };
- const one = stackGeometry(composer, 1280, 830, 394);
- const two = stackGeometry(composer, 1280, 830, 394, 394);
- assert.deepEqual(one, two);
-});
-
-// Same rule, applied to the other publisher: a monitor dragged up the screen
-// leaves the corner free, so the stack belongs in it.
-test("a monitor away from the corner no longer lifts the stack", () => {
- const middle = { left: 996, top: 300, right: 1264, bottom: 560 };
- const geometry = stackGeometry(middle, CHAT_W, CHAT_H);
- assert.equal(geometry.bottom, 16);
- // It is still in the column, so the stack is capped short of it instead.
- assert.ok(geometry.maxHeight < CHAT_H - 16 - 16);
- assert.ok(geometry.maxHeight <= CHAT_H - 16 - middle.bottom);
-});
-
-// The capped branch used to be reachable with a floor that did not fit: a box
-// ending just above the old cutoff was left uncapped-in-practice, and the
-// stack's guaranteed MIN_STACK_ROOM put its top back over the box by up to
-// 24px. The cutoff is derived from the cap now, so the two cannot disagree.
-test("a capped stack always fits under the box it is capped by", () => {
- for (let bottom = 100; bottom <= CHAT_H - 16; bottom += 1) {
- const frame = {
- left: 996,
- top: Math.max(0, bottom - 260),
- right: 1264,
- bottom,
- };
- const geometry = stackGeometry(frame, CHAT_W, CHAT_H);
- // Lifted boxes sit under the stack by design; only the capped ones apply.
- if (geometry.bottom !== 16) continue;
- const stackTop = CHAT_H - geometry.bottom - geometry.maxHeight;
- assert.ok(
- stackTop >= bottom,
- `a box ending at ${bottom} left the stack top at ${stackTop}`,
- );
- }
-});
-
-// Reachability has to be asked at the inset actually in force. Folding each box
-// against the default one, a monitor with room at the corner kept the capped
-// branch after the composer had already lifted the stack into it, and the cap
-// came out negative. Browsers drop an invalid max-height, so the cap vanished
-// exactly where it was needed.
-test("a box the shared lift moves the stack into is lifted over too", () => {
- const composer = { left: 412, top: 664, right: 1148, bottom: 814 };
- const monitor = { left: 996, top: 400, right: 1264, bottom: 660 };
- assert.equal(
- stackGeometry(monitor, CHAT_W, CHAT_H).bottom,
- 16,
- "on its own the monitor leaves the corner free",
- );
- const both = stackGeometry([monitor, composer], CHAT_W, CHAT_H);
- assert.ok(both.maxHeight > 0, "a negative cap is dropped by the browser");
- assert.ok(
- CHAT_H - both.bottom <= monitor.top,
- "the stack has to clear the monitor, not just the composer",
- );
-});
-
-// The same, swept: no arrangement may leave the stack overlapping a box, and no
-// cap may come out at zero or below.
-test("no pairing produces an overlap or an unusable cap", () => {
- const composer = { left: 412, top: 664, right: 1148, bottom: 814 };
- for (let bottom = 60; bottom <= CHAT_H - 16; bottom += 2) {
- for (const height of [80, 180, 280, 400]) {
- const box = {
- left: 996,
- top: Math.max(0, bottom - height),
- right: 1264,
- bottom,
- };
- for (const boxes of [[box], [box, composer]]) {
- const geometry = stackGeometry(boxes, CHAT_W, CHAT_H);
- const label = `bottom=${bottom} height=${height} n=${boxes.length}`;
- assert.ok(geometry.maxHeight > 0, `non-positive cap for ${label}`);
- const stackTop = CHAT_H - geometry.bottom - geometry.maxHeight;
- for (const each of boxes) {
- const clearsAbove = CHAT_H - geometry.bottom <= each.top;
- const clearsBelow = stackTop >= each.bottom;
- assert.ok(clearsAbove || clearsBelow, `overlap for ${label}`);
- }
- }
- }
- }
-});
-
-// At its cap the stack's border box does not move when its content grows, so neither a
-// root-only ResizeObserver nor a childList watcher hears an image finish loading inside an
-// expanded release note, and the stack keeps the pre-load height and stays clipped.
-test("every box inside the stack is observed, not just the stack", async () => {
- const source = await readFile(
- new URL(
- "../src/features/settings/stores/monitor-frame-store.ts",
- import.meta.url,
- ),
- "utf8",
- );
- const wiring = source.slice(
- source.indexOf("const observer = new ResizeObserver"),
- );
- assert.ok(
- !/observer\.observe\(node\)/.test(wiring),
- "the root alone is observed, so an intrinsic descendant resize is missed",
- );
- assert.match(
- wiring,
- /querySelectorAll\("\*"\)/,
- "the descendants are never enumerated, so none of them is observed",
- );
- // A changed subtree has to be re-observed, or a banner arriving after mount is missed.
- const onMutation = wiring.slice(wiring.indexOf("new MutationObserver"));
- assert.match(
- onMutation,
- /syncObserved\(\)/,
- "the observed set is not resynced",
- );
- // And unobserved on the way out, or a detached node keeps the observer alive.
- assert.match(wiring, /observer\.unobserve\(/, "nothing is ever unobserved");
-});
-
-// The llama.cpp update banner animates its progress bar's width every frame, inside this
-// same stack. Observing descendants without filtering therefore remeasures at ~60Hz for a
-// stack whose height never moved, and each remeasure lifts the cap and reads scrollHeight,
-// which forces a synchronous layout.
-test("a width-only animation does not remeasure the stack", async () => {
- const source = await readFile(
- new URL(
- "../src/features/settings/stores/monitor-frame-store.ts",
- import.meta.url,
- ),
- "utf8",
- );
- const wiring = source.slice(
- source.indexOf("const observer = new ResizeObserver"),
- source.indexOf("const observed = new Set<Element>()"),
- );
- assert.ok(
- !/new ResizeObserver\(measure\)/.test(wiring),
- "every observed resize remeasures, width-only ones included",
- );
- assert.match(wiring, /blockSize/, "the entry's height is never read");
- assert.match(
- wiring,
- /if \(moved\) measure\(\)/,
- "measure runs whether or not a height moved",
- );
-});
diff --git a/studio/frontend/tests/overlay-shadow-gutter.test.ts b/studio/frontend/tests/overlay-shadow-gutter.test.ts
index fa2d073b8dd..d08085ac805 100644
--- a/studio/frontend/tests/overlay-shadow-gutter.test.ts
+++ b/studio/frontend/tests/overlay-shadow-gutter.test.ts
@@ -1,94 +1,77 @@
// 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".
+// The rail clips at its padding box, so it reserves a gutter around its cards
+// or their shadows are cut off and a cap a few px short slices a card's corners
+// (#9246). The gutter must not be taken out of the cards: the rail sits on the
+// floor and its bottom padding carries them back up to their inset, and its cap
+// grows by both gutters to pay for them.
//
-// 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.
+// Arithmetic in CSS rather than in JS, since the rail is anchored and not
+// placed, so this reads the source: the node suite has no DOM to compute in.
import assert from "node:assert/strict";
+import { readFileSync } from "node:fs";
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 PROVIDER = readFileSync(
+ new URL("../src/app/provider.tsx", import.meta.url),
+ "utf8",
+);
-const GUTTER = STACK_SHADOW_GUTTER_BOTTOM + STACK_SHADOW_GUTTER_TOP;
+/** A `const NAME = <number>;` declaration in the provider. */
+function constant(name: string): number {
+ const found = PROVIDER.match(new RegExp(`const ${name} = (\\d+);`));
+ assert.ok(found, `${name} is gone from the provider`);
+ return Number(found[1]);
+}
-const INSET = 16;
+const GUTTER_BOTTOM = constant("STACK_SHADOW_GUTTER_BOTTOM");
+const GUTTER_TOP = constant("STACK_SHADOW_GUTTER_TOP");
+
+/** Where the cards sit, and the band they may fill, before the gutter. */
+const CARDS_INSET = 16;
+const CARDS_BAND_TRIM = 32;
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");
+ assert.ok(GUTTER_BOTTOM >= 16, "the shadow below is clipped");
+ assert.ok(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);
+ // The rail is on the floor, so its bottom padding alone is the cards' inset.
+ const rails = PROVIDER.match(/pointer-events-none fixed bottom-(\d+) right-4/g);
+ assert.equal(rails?.length, 2, "a rail left its bottom-right corner");
+ for (const rail of rails ?? []) {
+ const edge = Number(rail.match(/bottom-(\d+)/)?.[1]);
+ assert.equal(
+ edge + GUTTER_BOTTOM,
+ CARDS_INSET,
+ "the bottom card moved off its inset",
+ );
+ }
});
test("the cap grows by both gutters, so the cards' band is unchanged", () => {
- for (const room of [0, 56, 137, 468]) {
+ // calc(100dvh - Npx), where N is the band's own trim less the gutter added
+ // back. Anything larger spends the cards' room on the padding.
+ const caps = PROVIDER.match(/max-h-\[calc\(100dvh_-_(\d+)px\)\]/g);
+ assert.equal(caps?.length, 2, "a rail lost its cap");
+ for (const cap of caps ?? []) {
+ const trim = Number(cap.match(/_(\d+)px/)?.[1]);
assert.equal(
- railMaxHeight(room) - GUTTER,
- room,
- "a gutter is being taken out of the cards",
+ trim,
+ CARDS_BAND_TRIM - GUTTER_BOTTOM - GUTTER_TOP,
+ "a gutter is being taken out of the cards' band",
);
}
});
-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",
- );
+test("the gutter is applied in px, not a rem utility", () => {
+ // pb-4/pt-2 resolve through --spacing in rem, so at any root but 16px the
+ // padding and the inset above would disagree and the cards would drift.
+ assert.match(PROVIDER, /paddingTop: STACK_SHADOW_GUTTER_TOP/);
+ assert.match(PROVIDER, /paddingBottom: STACK_SHADOW_GUTTER_BOTTOM/);
});
diff --git a/studio/frontend/tests/update-banner-flex-priority.test.ts b/studio/frontend/tests/update-banner-flex-priority.test.ts
index 219ec2badb9..2e730f3e9d1 100644
--- a/studio/frontend/tests/update-banner-flex-priority.test.ts
+++ b/studio/frontend/tests/update-banner-flex-priority.test.ts
@@ -144,60 +144,6 @@ test("the two update cards do not drift apart", () => {
}
});
-// Covering the composer is licensed per card, and the licence is carried on
-// the card rather than inferred in the store, so a new overlay added to the
-// rail is persistent until someone says otherwise. The loaded models indicator
-// and the download panel deliberately do not carry it: they are the last
-// children, so they are what would land on Send.
-test("only the dismissible cards licence covering the composer", () => {
- for (const [name, source] of CARDS) {
- assert.match(
- source,
- /data-overlay-dismissible="true"/,
- `the ${name} card lost its dismissible marker, so the stack will never cover`,
- );
- }
- // The llama.cpp card carries the licence CONDITIONALLY: its dismiss button
- // goes away for the length of an update, and a card that cannot be got rid
- // of must not be one the stack parks on Send.
- assert.match(
- LLAMA,
- /data-overlay-dismissible=\{applying \? undefined : "true"\}/,
- "the llama card licences covering the composer while it is mid-update",
- );
- assert.match(
- LLAMA,
- /\{applying \? null : \(\s*\n\s*<button/,
- "the dismiss button is no longer the thing the licence is tied to",
- );
- const indicator = read("features/loaded-models/loaded-models-indicator.tsx");
- const downloads = read(
- "features/hub/download-manager/download-manager-panel.tsx",
- );
- for (const [name, source] of [
- ["loaded models indicator", indicator],
- ["download panel", downloads],
- ] as const) {
- assert.ok(
- !/data-overlay-dismissible/.test(source),
- `the ${name} is persistent and must not licence covering the composer`,
- );
- }
- assert.match(
- STORE,
- /child\.hasAttribute\("data-overlay-dismissible"\)/,
- "the store no longer asks the cards whether it may cover",
- );
- // Measured up from the corner, so the run that stops a cover is the one that
- // would land on the composer, not any persistent card anywhere in the stack.
- // Over `cards`, the rail's in-flow children: a dragged loaded models card is
- // `position: fixed` somewhere else and lands on nothing.
- assert.match(
- STORE,
- /for \(let i = cards\.length - 1; i >= 0; i -= 1\)/,
- "the persistent run is no longer counted from the bottom of the stack",
- );
-});
test("the llama.cpp card keeps its full height in the rail", () => {
// Nothing inside it can give up height, so squeezing it only mangles it.
@@ -233,56 +179,46 @@ test("the collapsed notes summary scrolls, like the expanded notes", () => {
assert.match(expanded, /\boverscroll-contain\b/);
});
+/** The two rails' class strings, anchored on the corner they are pinned to. */
+const RAIL_ANCHOR = '"pointer-events-none fixed bottom-0 right-4 ';
+
+function rails(): string[] {
+ const parts = PROVIDER.split(RAIL_ANCHOR);
+ assert.equal(parts.length - 1, 2, "a rail left its bottom-right corner");
+ return parts.slice(1);
+}
+
test("the rail scrolls rather than spilling its cards", () => {
- const rails = PROVIDER.split('"fixed right-4 ');
- // The desktop rail and the browser rail.
- assert.equal(rails.length - 1, 2, "the rail count changed");
- for (const rail of rails.slice(1)) {
+ for (const rail of rails()) {
const rules = rail.slice(0, rail.indexOf('"'));
- assert.match(rules, /\boverflow-y-auto\b/, "a capped rail clips its cards");
+ // A cap without a scroller drops the overflow below the bottom of the
+ // screen: at a large type size the two banner floors exceed the cap on
+ // their own, and the cards under it cannot be reached.
+ assert.match(rules, /\boverflow-y-auto\b/, "a capped rail spills its cards");
// The scroller clips at the padding box, so without room reserved there the
// cards lose their shadows; the negative margin puts the rail back where it
// was.
assert.match(rules, /\bpx-3\b/);
assert.match(rules, /-mx-3/);
- // 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.
+// it. The rail sits on the floor and the bottom gutter carries the cards back
+// up to 16px, so the cap grows by both gutters to pay for them.
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)) {
+ for (const rail of rails()) {
const rules = rail.slice(0, rail.indexOf('"'));
const style = rail.slice(rail.indexOf("style={{"), rail.indexOf("}}"));
+ // 2rem for the cards' own band, less the 24px of gutter the rail adds
+ // around them, so the cards keep exactly the band they had.
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",
+ rules,
+ /max-h-\[calc\(100dvh_-_8px\)\]/,
+ "the gutter is being taken out of the cards' band",
);
- // 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.
+ // From the constants, not pb-4/pt-2: those are rem, so at any root size but
+ // 16px the cards would drift off the corner.
assert.match(
style,
/paddingTop: STACK_SHADOW_GUTTER_TOP/,
@@ -291,15 +227,15 @@ test("the rail's block gutter costs the cards no room", () => {
assert.match(
style,
/paddingBottom: STACK_SHADOW_GUTTER_BOTTOM/,
- "the bottom gutter can drift from the offset that pays for it",
+ "the bottom gutter can drift from the cap 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.
+ // edge, so it spans 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.
@@ -334,80 +270,54 @@ test("the rail's block gutter costs the cards no room", () => {
assert.match(
target,
/zIndex: Z_LAYER\.WINDOW_RESIZE_EDGE/,
- `the ${grip} target does not take the named layer, so a scrolling rail covers it`,
+ `the ${grip} target does not take the named layer, so the rail covers it`,
);
}
- }
});
-// pointer-events-none takes the rail's scrollbar with it, and only the cards
-// opt back in, so a scrolling rail nobody can drag hides the cards under the
-// fold. It is click-through only while there is nothing to scroll to.
-test("a scrolling rail takes pointer input, a fitting one stays click-through", () => {
- const rails = PROVIDER.split('"fixed right-4 ');
- assert.equal(rails.length - 1, 2, "the rail count changed");
- for (const rail of rails.slice(1)) {
+// The rail was placed from JS for a while, lifting clear of the boxes the
+// composer and the floating panels publish. Every input to that placement
+// changes on its own, so the rail drifted to the middle and the top of the
+// window. Anchored in CSS again; the floors above absorb a short window.
+test("the rail is anchored to its corner, not placed from JS", () => {
+ for (const rail of rails()) {
const branch = rail.slice(0, rail.indexOf("style={{"));
- assert.match(
+ // Click-through in every state. It used to take pointer input while it
+ // scrolled, which needed the JS that also placed it. The fold is reached by
+ // wheeling over a card, whose nearest scrollable ancestor is the rail, or
+ // by focus, which scrolls it into view.
+ assert.doesNotMatch(
branch,
- /stack\.overflowing\s*\?\s*"pointer-events-auto"\s*:\s*"pointer-events-none"/,
- "the rail is click-through unconditionally",
+ /pointer-events-auto/,
+ "the rail takes pointer input again, which the placement paid for",
);
}
- // Derived from the placement, never read back off the node. A DOM reading
- // latches: the stack scrolls for a frame, the placement then changes to one
- // that fits, and nothing resizes afterwards to correct the flag, so a rail
- // with nothing to scroll to keeps the pointer input it took. Compared
- // against the height the cards collapse to, not their natural height nor the
- // floor the placement asks for: a card clipped below its floor is not a fold
- // to scroll to.
- assert.match(
- STORE,
- /overflowing: collapsedRoom > geometry\.maxHeight/,
- "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",
+ // The offset and the cap are the two things the placement used to own, so
+ // they are the two that must stay out of the render.
+ for (const banned of [
+ "useStackGeometry",
+ "stackGeometry",
+ "stack.bottom",
+ "stack.maxHeight",
+ "railBottomOffset",
+ "railMaxHeight",
]) {
- assert.match(
- emptied,
- new RegExp(`${cleared}\\(`),
- `an emptied rail keeps its ${cleared} reading, so it still holds the corner`,
+ assert.ok(
+ !PROVIDER.includes(banned),
+ `the rail is placed from JS again (${banned})`,
+ );
+ }
+ // And the arithmetic it was placed by does not come back to the store, which
+ // is now only a register of where the draggable panels are.
+ for (const banned of [
+ "stackBottomInset",
+ "stackMaxHeight",
+ "dodgeInset",
+ "railCardsHeight",
+ ]) {
+ assert.ok(
+ !STORE.includes(banned),
+ `the dodge arithmetic is back in the frame store (${banned})`,
);
}
- // 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
- // until the timeline advances: the box computes 0px while its inline style
- // reads back as the cap, and three whole cards lay out below it.
- const suppressed = STORE.indexOf('node.style.transition = "none"');
- const probe = STORE.slice(
- suppressed,
- STORE.indexOf("setNeededRoom", suppressed),
- );
- assert.ok(
- probe.length > 0 && /node\.style\.maxHeight = "none"/.test(probe),
- "the height probe is not run with transitions suppressed",
- );
- assert.match(
- STORE,
- /void node\.scrollHeight;\s*\n\s*node\.style\.transition = eased;/,
- "the restored cap is handed back to a transition",
- );
});
diff --git a/studio/frontend/tsconfig.app.json b/studio/frontend/tsconfig.app.json
index 4dbea5ef86c..bdda66808bb 100644
--- a/studio/frontend/tsconfig.app.json
+++ b/studio/frontend/tsconfig.app.json
@@ -37,7 +37,6 @@
"smoke-thread-weight-main.tsx",
"smoke-settings-main.tsx",
"smoke-stream-pacing-main.tsx",
- "smoke-code-block-flicker-main.tsx",
- "smoke-overlay-rail-main.tsx"
+ "smoke-code-block-flicker-main.tsx"
]
}
diff --git a/tests/studio/playwright_overlay_rail.py b/tests/studio/playwright_overlay_rail.py
deleted file mode 100644
index a0d0a2c6154..00000000000
--- a/tests/studio/playwright_overlay_rail.py
+++ /dev/null
@@ -1,963 +0,0 @@
-# SPDX-License-Identifier: AGPL-3.0-only
-# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
-
-"""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())
diff --git a/tests/studio/playwright_update_banner_layout.py b/tests/studio/playwright_update_banner_layout.py
index f6c45cfd045..43c307d82a5 100644
--- a/tests/studio/playwright_update_banner_layout.py
+++ b/tests/studio/playwright_update_banner_layout.py
@@ -3,15 +3,20 @@
"""The overlay rail's update banners must never print over each other.
-The reported failure: on New chat, in a window short enough that the composer
-crowds the rail, the app-update card's release notes were painted over its own
-row of buttons. Train and Model hub were fine, because only the chat routes
-publish a composer box into the frame store and only that box caps the rail.
+The reported failure: in a window short enough that the rail hits its cap, the
+app-update card's release notes were painted over its own row of buttons.
-The node suite cannot catch this: it is a flex shrink across a capped column, so
-it needs a real layout, a real ResizeObserver and the real route, and it shows
-only at some viewport heights. Rects are intersected with whatever clips them,
-so anything an overflow-hidden ancestor hides does not count as visible.
+The second thing checked here is where the rail is. It was placed from JS for a
+while, dodging the boxes the composer and the floating panels publish, and every
+input to that placement moved on its own, so the rail drifted out of its corner
+into the middle and the top of the window. It is anchored in CSS again, and the
+indicator pass at the end asserts it stays there while cards come and go.
+
+The node suite cannot catch either: one is a flex shrink across a capped column
+and the other is where a fixed box actually lands, so both need a real layout,
+a real ResizeObserver and the real route, and they show only at some viewport
+heights. Rects are intersected with whatever clips them, so anything an
+overflow-hidden ancestor hides does not count as visible.
Both update endpoints are stubbed with page.route, so this runs on any host: no
GPU, no pypi release, no llama.cpp build.
@@ -229,35 +234,58 @@ NOTHING_STT = {
"gguf": {"loaded_model": None, "device": None},
}
-# Where the stack is tight enough that it would cover the composer if it were
-# allowed to. Two is enough: the rule is per card, not per size.
+# Short windows on the chat route: the ones where the rail used to leave its
+# corner. Two is enough, since what is being checked does not vary with size.
INDICATOR_VIEWPORTS = [(921, 534), (768, 500)]
-# Does anything in the rail overlap the composer? Read off the same page, since
-# the composer is not one of the boxes the cards know about.
-COMPOSER_CLEARANCE = """
+# Where the rail actually is, against the corner it is anchored to. It was
+# placed from JS for a while, lifting clear of the boxes in the frame store,
+# and drifted to the middle and the top of the window as those boxes and its
+# own cards changed. Nothing on the page may move it now.
+RAIL_CORNER = """
() => {
const card = document.querySelector('[data-testid="web-update-banner"]');
- const composer = document.querySelector('form');
- if (!card || !composer) return {composer: null, overlap: 0};
+ if (!card) return null;
const rail = card.parentElement;
const a = rail.getBoundingClientRect();
- const b = composer.getBoundingClientRect();
- const dy = Math.min(a.bottom, b.bottom) - Math.max(a.top, b.top);
- const dx = Math.min(a.right, b.right) - Math.max(a.left, b.left);
+ // Cards in the rail's own flow. A dragged loaded models card is `fixed`
+ // somewhere else and says nothing about the rail.
+ const flowed = Array.from(rail.children).filter(
+ (kid) => getComputedStyle(kid).position === 'static',
+ );
return {
- composer: {top: Math.round(b.top), bottom: Math.round(b.bottom)},
- rail: {top: Math.round(a.top), bottom: Math.round(a.bottom)},
- // In the RAIL, not merely on the page: the card is draggable, and one
- // parked elsewhere would satisfy a page-wide search while telling us
- // nothing about the stack whose placement is under test.
- // The inline cap next to what the box actually computes: a rail whose
- // measurement leaves a transition behind reports a healthy cap and lays
- // its cards out below a zero-height box.
+ rail: {top: Math.round(a.top), bottom: Math.round(a.bottom),
+ right: Math.round(a.right)},
+ viewport: {width: window.innerWidth, height: window.innerHeight},
+ // Where the CARDS sit, 16px off both edges. Neither reading comes off the
+ // rail's border box: it carries the shadow gutter on all four sides, so it
+ // sits 4px from the right and flush with the floor while the cards it pads
+ // sit at 16. Measuring the border box reported 4 and 0.
+ //
+ // The bottom off the padding box, which is the cards' own floor and stays
+ // put however far they are scrolled. The right off a card directly, since
+ // the horizontal gutter is a negative margin the padding cancels.
+ fromBottom: Math.round(
+ window.innerHeight - a.bottom
+ + parseFloat(getComputedStyle(rail).paddingBottom || '0'),
+ ),
+ fromRight: flowed.length
+ ? Math.max(...flowed.map(
+ (kid) => Math.round(
+ window.innerWidth - kid.getBoundingClientRect().right,
+ ),
+ ))
+ : null,
+ flowedCards: flowed.length,
+ // Nothing inline may set either: an offset or a cap written by JS is the
+ // placement coming back, whatever value it happens to have landed on.
railStyle: {bottom: rail.style.bottom, maxHeight: rail.style.maxHeight,
kids: rail.childElementCount,
height: getComputedStyle(rail).height,
cappedTo: getComputedStyle(rail).maxHeight},
+ // In the RAIL, not merely on the page: the card is draggable, and one
+ // parked elsewhere would satisfy a page-wide search while telling us
+ // nothing about the stack under test.
indicator: (() => {
const label = Array.from(document.querySelectorAll('*')).find(
(el) => el.childElementCount === 0
@@ -265,23 +293,6 @@ COMPOSER_CLEARANCE = """
);
return Boolean(label && rail.contains(label));
})(),
- overlap: (dy > 0.5 && dx > 0.5) ? Math.round(Math.min(dy, dx) * 10) / 10 : 0,
- // The same question asked of the part of the stack the reader cannot get
- // rid of. A dismissible card over Send is the trade the placement makes to
- // show that card whole; the tail below it would be over Send for good.
- tailOverlap: (() => {
- let worst = 0;
- for (let i = rail.children.length - 1; i >= 0; i -= 1) {
- const kid = rail.children[i];
- if (kid.hasAttribute('data-overlay-dismissible')) break;
- const k = kid.getBoundingClientRect();
- if (k.width < 1 || k.height < 1) continue;
- const ky = Math.min(k.bottom, b.bottom) - Math.max(k.top, b.top);
- const kx = Math.min(k.right, b.right) - Math.max(k.left, b.left);
- if (ky > 0.5 && kx > 0.5) worst = Math.max(worst, Math.min(ky, kx));
- }
- return Math.round(worst * 10) / 10;
- })(),
};
}
"""
@@ -606,17 +617,21 @@ def measure(page, label: str) -> dict:
)
if facts["railScrolls"] is not None:
scrolls = facts["railScrolls"]
+ # Click-through in every state, scrolling or not. It used to take pointer
+ # input while it scrolled, which needed the JS that also placed it. The
+ # fold is reached by wheeling over a card, whose nearest scrollable
+ # ancestor is the rail, or by focus, which scrolls it into view.
check(
- f"{label}: the rail takes pointer input exactly when it scrolls",
- facts["railPointerEvents"] == ("auto" if scrolls else "none"),
+ f"{label}: the rail stays click-through",
+ facts["railPointerEvents"] == "none",
f"scrolls={scrolls} pointerEvents={facts['railPointerEvents']} "
f"why={json.dumps(facts['widthWhy'], sort_keys = True)}",
)
- # Click-through is what pointer-events-none is for, and the gutter is
- # the widest part of the rail that no card covers.
+ # The gutter is the widest part of the rail that no card covers, so it
+ # is where a swallowed click would show up first.
check(
- f"{label}: a rail with nothing to scroll to stays click-through",
- scrolls or facts["gutterIsRail"] is False,
+ f"{label}: the rail's gutter never swallows a click",
+ facts["gutterIsRail"] is False,
f"scrolls={scrolls} gutterIsRail={facts['gutterIsRail']}",
)
# The notes are allowed to yield all of their height, and do; the controls
@@ -830,10 +845,8 @@ def main() -> int:
context.close()
# The loaded models indicator, switched on. It is the last child of the
- # rail, so it is the card that lands on the corner, and it is a
- # persistent status card rather than a dismissible banner: over Send it
- # is the bug the rail dodges the composer for in the first place. With
- # it up the stack must go back to dodging, however tight the window.
+ # rail, so it lands on the corner, and its arrival used to re-measure
+ # the rail and move the whole stack. That is the case to check.
# #8346 ships it off by default, so nothing above this point sees it.
for width, height in INDICATOR_VIEWPORTS:
context = browser.new_context(
@@ -860,27 +873,28 @@ def main() -> int:
page = context.new_page()
boot(page, "/")
page.wait_for_selector("text=Loaded models", timeout = 30_000)
- # A third card in the stack re-measures the placement, and the rail
- # moves on the frame after that.
+ # A third card changes the rail's height, which is what used to
+ # move it; give the layout a frame to prove it does not.
settle_stack(page)
measure(page, f"{width}x{height} with the models indicator")
- seen = page.evaluate(COMPOSER_CLEARANCE)
+ seen = page.evaluate(RAIL_CORNER)
check(
- f"{width}x{height}: the rail computes the cap it was given",
- not seen["railStyle"]["maxHeight"]
- or seen["railStyle"]["cappedTo"] == seen["railStyle"]["maxHeight"],
- f"{seen['railStyle']}, so the cards are laid out below a box"
- " that is not the size the placement asked for",
+ f"{width}x{height}: the models indicator is actually up",
+ seen is not None and seen["indicator"],
+ f"{seen}, so the corner checks below prove nothing",
)
check(
- f"{width}x{height}: the models indicator is actually up",
- seen["indicator"],
- f"{seen}, so the clearance check below proves nothing",
+ f"{width}x{height}: the rail is still in its bottom-right corner",
+ seen is not None and seen["fromBottom"] == 16 and seen["fromRight"] == 16,
+ f"{seen}, so the rail has left the corner it is anchored to",
)
check(
- f"{width}x{height}: a persistent card in the rail keeps off the composer",
- seen["composer"] is None or seen["tailOverlap"] == 0,
- f"{seen}, so the models indicator is sitting on Send",
+ f"{width}x{height}: nothing places the rail from JS",
+ seen is not None
+ and not seen["railStyle"]["bottom"]
+ and not seen["railStyle"]["maxHeight"],
+ f"{seen['railStyle'] if seen else seen}, so an inline offset or"
+ " cap is back on the rail",
)
page.screenshot(path = str(ART / f"{width}x{height}-indicator.png"))
context.close()
diff --git a/tests/studio/test_overlay_layering.py b/tests/studio/test_overlay_layering.py
index afc780a7d91..13805581f79 100644
--- a/tests/studio/test_overlay_layering.py
+++ b/tests/studio/test_overlay_layering.py
@@ -4,13 +4,12 @@
"""Who paints over whom in the bottom-right corner.
The Live resource monitor, the API monitor panel and the notification stack all
-live there. The first two keep out of each other's way geometrically and the
-stack steps over both (stackGeometry, panel-placement, monitor-stack-inset.test.ts
-and panel-placement.test.ts), but the dodge has a floor: a monitor dragged to the
-corner and resized to fill the viewport leaves nowhere to dodge to, and the stack
-is parked at the top of the screen, on top of the monitor's own title bar. At that
-point z-order is the only thing deciding whether the monitor's Close button can be
-clicked.
+live there. The first two keep out of each other's way geometrically
+(panel-placement and panel-placement.test.ts); the stack does not move for
+anyone -- it is anchored to the corner in CSS, because placing it from the
+boxes the others publish is what moved it to the middle and the top of the
+window. So the corner is shared, and z-order is the only thing deciding whether
+a monitor sitting under the stack still has a clickable Close button.
The Windows UI smoke does exactly that drag-and-resize and then clicks Close, so
it catches a regression here for real. It takes about twenty minutes and needs a
@@ -63,8 +62,8 @@ def _container(path: Path, ref: str) -> str:
def test_the_floating_panels_paint_over_the_notification_stack():
- """A full-viewport monitor parks the stack over its own title bar. The stack is
- passive status; the panels are windows being dragged, resized and closed."""
+ """The stack holds its corner, so a monitor parked there is under it. The stack
+ is passive status; the panels are windows being dragged, resized and closed."""
layers = _layers()
assert layers["FLOATING_PANEL"] > layers["OVERLAY_STACK"], (
"the notification stack paints over the floating panels, so their Close "
@@ -103,9 +102,7 @@ def test_both_floating_panels_stack_on_the_shared_layer(path: Path):
def test_the_notification_stack_uses_the_named_layer():
"""Both copies, browser and desktop. They drifted apart once already."""
src = PROVIDER.read_text(encoding = "utf-8")
- # The click-through class is applied conditionally now, so it is not part
- # of the literal the rail's own classes are authored in.
- stacks = re.findall(r'"fixed right-4 ([^"]*)"', src)
+ stacks = re.findall(r'"pointer-events-none fixed bottom-0 right-4 ([^"]*)"', src)
assert len(stacks) == 2, f"expected the two bottom-right stacks, found {len(stacks)}"
for stack in stacks:
assert not _Z.search(stack), f"the stack still carries a hard-coded z-index: {stack!r}"
diff --git a/tests/studio/test_update_release_notes.py b/tests/studio/test_update_release_notes.py
index dd9debbd3f7..a65912d62b8 100644
--- a/tests/studio/test_update_release_notes.py
+++ b/tests/studio/test_update_release_notes.py
@@ -1275,70 +1275,75 @@ _SCALED_FLOOR_TAURI = "min-h-[calc(117px+93px*var(--ui-font-scale,1))]"
_NARROW_FLOOR_TAURI = "max-[383px]:min-h-[calc(24px+224px*var(--ui-font-scale,1))]"
-def _capped_stacks(provider: str) -> int:
- """How many overlay stacks cap themselves to the measured geometry.
-
- Matched on the value being derived from `stack.maxHeight`, not on the literal
- `maxHeight: stack.maxHeight`, because the cap is allowed to be wrapped: the
- shadow-gutter work passes it through `railMaxHeight(...)` so the rail keeps
- room under its bottom card. That is the same cap, plus a constant.
-
- Pinning the bare expression made a wrapper read as a missing cap, which is the
- mistake this file already made once with the z-index and fixed the same way --
- see "counted by the layer they sit on, not by a literal z-index" below. What
- the tests are about is that EVERY stack is capped; how the number is spelled is
- that code's business. A cap that stops reading stack.maxHeight still fails.
+def _corner_rails(provider: str) -> list[str]:
+ """The class strings of the bottom-right overlay rails.
+
+ Matched on the corner they are pinned to, which is the thing under test.
+ The rail is anchored in CSS, so that corner is spelled in its classes.
"""
- return len(re.findall(r"maxHeight:\s*(?:[A-Za-z_$][\w$]*\(\s*)?stack\.maxHeight", provider))
+ return re.findall(r'"pointer-events-none fixed bottom-0 right-4 ([^"]*)"', provider)
+
+def _capped_rails(provider: str) -> int:
+ """How many of those rails cap themselves to the viewport, in CSS.
-def _overlay_stacks(provider: str) -> int:
- """How many bottom-right overlay stacks the provider renders."""
- return len(re.findall(r"z-\[9998\][^\"]*flex flex-col items-end gap-2", provider))
+ 2rem for the cards' band, less the 24px shadow gutter the rail adds around
+ them, so the gutter is not spent on the cards. See overlay-shadow-gutter.
+ """
+ return sum(1 for rail in _corner_rails(provider) if "max-h-[calc(100dvh_-_8px)]" in rail)
def test_the_overlay_stack_fits_the_viewport():
"""The card's own cap does not account for a download list stacked beneath
- it. The cap is `stackGeometry` now, checked numerically in
- studio/frontend/tests/monitor-stack-inset.test.ts; here the stack must read it."""
+ it, so the rail carries one of its own. A static cap, not a measured one:
+ a rail whose height and offset are computed from whatever else is on screen
+ is a rail that moves out of its corner (#8082 and the chain after it)."""
provider = (FRONTEND / "app/provider.tsx").read_text(encoding = "utf-8")
# Counted by the layer they sit on, not by a literal z-index: the
# overlay rail reads its depth from Z_LAYER now.
stacks = provider.count("zIndex: Z_LAYER.OVERLAY_STACK")
assert stacks, "the bottom-right overlay stack is gone"
+ assert len(_corner_rails(provider)) == stacks, "a rail left its bottom-right corner"
# Counted, not merely present: capping only one of the stacks is the bug here.
- assert _capped_stacks(provider) == stacks, "every stack is capped"
+ assert _capped_rails(provider) == stacks, "every stack is capped"
panel = (FRONTEND / "features/hub/download-manager/download-manager-panel.tsx").read_text(
encoding = "utf-8"
)
# The download list scrolls internally, so it can give up height.
assert "flex min-h-0" in panel
# The update card cannot: its header and buttons are fixed and only its
- # notes yield, so it floors instead and the stack scrolls past it.
+ # notes yield, so it floors instead.
web = WEB_BANNER.read_text(encoding = "utf-8")
assert _SCALED_FLOOR_WEB in web, "the floor is fixed, so it is wrong at other type sizes"
assert _NARROW_FLOOR_WEB in web, "the floor misses the narrow card's extra button row"
- assert provider.count("overflow-y-auto") >= stacks, "a capped stack clips its cards"
+ # Those floors can add up to more than the cap at a large type size, so the
+ # rail scrolls. Without this the overflow lands below the bottom of the
+ # screen with no way to reach it.
+ assert provider.count("overflow-y-auto") >= stacks, "a capped stack spills its cards"
def test_the_desktop_stack_is_capped_like_the_browser_one():
"""The download panel shares the desktop stack, left uncapped before now."""
provider = (FRONTEND / "app/provider.tsx").read_text(encoding = "utf-8")
- assert provider.count("useStackGeometry()") == 2, "both stacks measure themselves"
- assert _capped_stacks(provider) == 2, "both stacks are capped"
+ assert len(_corner_rails(provider)) == 2, "both rails sit in the bottom-right corner"
+ assert _capped_rails(provider) == 2, "both stacks are capped"
tauri = TAURI_BANNER.read_text(encoding = "utf-8")
assert _SCALED_FLOOR_TAURI in tauri, "the floor is fixed, so it is wrong at other type sizes"
assert _NARROW_FLOOR_TAURI in tauri, "the floor misses the narrow card's extra button row"
-def test_the_stack_geometry_is_checked_numerically():
- """The cap is arithmetic now, so the node test owns it. Named here so
- deleting that test does not quietly leave the cap unchecked."""
- geometry = REPO / "studio/frontend/tests/monitor-stack-inset.test.ts"
- src = geometry.read_text(encoding = "utf-8")
- assert (
- "stackGeometry(null, W, H).maxHeight, H - 32" in src
- ), "nothing pins the no-obstacle cap to the 2rem the class used to spell"
+def test_the_rail_offset_is_not_computed():
+ """The rail used to place itself around the boxes in the frame store, so a
+ composer growing by a line or a download row arriving moved it to the middle
+ of the window, and a maximised monitor to the top. Its offset and cap must
+ stay out of JS."""
+ provider = (FRONTEND / "app/provider.tsx").read_text(encoding = "utf-8")
+ for banned in ("useStackGeometry", "stackGeometry", "stack.bottom", "stack.maxHeight"):
+ assert banned not in provider, f"the rail is placed from JS again ({banned})"
+ store = (FRONTEND / "features/settings/stores/monitor-frame-store.ts").read_text(
+ encoding = "utf-8"
+ )
+ assert "stackBottomInset" not in store, "the dodge arithmetic is back in the frame store"
def test_desktop_notes_are_not_keyed_by_the_pinned_backend_version():
@@ -1533,7 +1538,7 @@ def test_the_download_panel_can_shrink_inside_the_capped_stack():
# Counted by the layer they sit on, not by a literal z-index: the
# overlay rail reads its depth from Z_LAYER now.
stacks = provider.count("zIndex: Z_LAYER.OVERLAY_STACK")
- assert _capped_stacks(provider) == stacks, "the cap this has to absorb"
+ assert _capped_rails(provider) == stacks, "the cap this has to absorb"
@pytest.fixture(scope="module")