From 1b0778f3f33a41c61c7026f924ccf58c333a9eda Mon Sep 17 00:00:00 2001 From: Badcuban <108198679+badcuban@users.noreply.github.com> Date: Mon, 23 Nov 2026 03:40:22 -0500 Subject: [PATCH] fix(web): toasts show above the browser panel's page The browser panel's live page and the toast stack were both at z-index 40, and the page is added to the body after the toast viewport, so it won the tie and covered toasts in the top-right corner. A device floated over the chat had the same problem. Toasts now sit at z-45: above the workspace layers at 40 (browser page, floating device, floating thread list) and still below menus and dialogs at 50. The toast layering test now checks the toast stays above 40. --- .../src/components/browser/BrowserHostLayer.tsx | 1 + .../src/components/device/DeviceFloatingWindow.tsx | 1 + apps/web/src/components/ui/toast.browser.tsx | 14 ++++++++++++-- apps/web/src/components/ui/toast.tsx | 7 ++++++- 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/apps/web/src/components/browser/BrowserHostLayer.tsx b/apps/web/src/components/browser/BrowserHostLayer.tsx index 384d1ec10..c4d7fb1cd 100644 --- a/apps/web/src/components/browser/BrowserHostLayer.tsx +++ b/apps/web/src/components/browser/BrowserHostLayer.tsx @@ -605,6 +605,7 @@ export function LiveThreadBrowserView({ browser }: { browser: LiveThreadBrowserR left: "anchor(left)", width: "anchor-size(width)", height: "anchor-size(height)", + // Over the app, under toasts (z-45) and menus and dialogs (z-50). zIndex: 40, } : { diff --git a/apps/web/src/components/device/DeviceFloatingWindow.tsx b/apps/web/src/components/device/DeviceFloatingWindow.tsx index e3a624791..6ef676b69 100644 --- a/apps/web/src/components/device/DeviceFloatingWindow.tsx +++ b/apps/web/src/components/device/DeviceFloatingWindow.tsx @@ -225,6 +225,7 @@ function FloatingDevice(props: { aria-label={`${props.name}, floating`} data-testid="device-float" className={cn( + // Under toasts (z-45), which land in the same corner it first floats to. "fixed z-40 flex flex-col rounded-xl bg-popover text-popover-foreground ring-1 ring-border elevate-overlay", live && "select-none", )} diff --git a/apps/web/src/components/ui/toast.browser.tsx b/apps/web/src/components/ui/toast.browser.tsx index a85c7ed6d..5c44ff95b 100644 --- a/apps/web/src/components/ui/toast.browser.tsx +++ b/apps/web/src/components/ui/toast.browser.tsx @@ -31,6 +31,14 @@ import { ToastProvider, stackedThreadToast, toastManager } from "./toast"; */ const APP_OVERLAY_LAYER = 50; +/** + * The layer of things that are part of the workspace and float over the app: + * the browser panel's live page, a device floated over the chat, the floating + * thread list. They reach the toast corner and are added to the body after + * the toast viewport, so a tie with them puts the toast underneath. + */ +const WORKSPACE_LAYER = 40; + /** * Says whether this page has focus, for the rest of the spec. Notice clocks run * only while the window is in front, and a spec's frame has focus only if an @@ -76,8 +84,10 @@ describe("toast layering", () => { zIndex, `the toast viewport is at z-index ${zIndex}; anything at or above ${APP_OVERLAY_LAYER} swallows clicks meant for an open menu`, ).toBeLessThan(APP_OVERLAY_LAYER); - // Still above the page it floats over. - expect(zIndex).toBeGreaterThan(0); + expect( + zIndex, + `the toast viewport is at z-index ${zIndex}; the browser page and floating windows at ${WORKSPACE_LAYER} cover it`, + ).toBeGreaterThan(WORKSPACE_LAYER); // The card inside inherits the viewport's stacking context, so its own // very high z-index cannot lift it out past the overlays. diff --git a/apps/web/src/components/ui/toast.tsx b/apps/web/src/components/ui/toast.tsx index 5ec7c1c75..3e4759257 100644 --- a/apps/web/src/components/ui/toast.tsx +++ b/apps/web/src/components/ui/toast.tsx @@ -794,9 +794,14 @@ function Toasts({ position = "top-right" }: { position: ToastPosition }) { // top-right corner the panel's tab menu opens into, so at z-100 it // was swallowing clicks meant for a menu the user had just opened. // Ambient notice yields to whatever the user is actually doing. + // Above the layers that are part of the workspace, all at z-40 and + // all able to reach this corner: the browser panel's live page, a + // device floated over the chat, the floating thread list. A tie + // would go to whichever was added to the body last, and the browser + // page and the device float both arrive after this viewport. // A dimmed backdrop is the exception: the user is in a dialog, and // a notice raised then must not sit blurred underneath it. - raisedAboveBackdrops ? "z-60" : "z-40", + raisedAboveBackdrops ? "z-60" : "z-45", "fixed mx-auto flex w-[calc(100%-var(--toast-inset)*2)] max-w-[20rem] [--toast-header-offset:52px] [--toast-inset:--spacing(4)] sm:[--toast-inset:--spacing(6)]", // Vertical positioning "data-[position*=top]:top-[calc(var(--toast-inset)+var(--toast-header-offset))]",