Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

Studio: keep chat toasts clear of header controls (#8377)

oobabooga496a1c772864
diff --git a/studio/frontend/src/app/provider.tsx b/studio/frontend/src/app/provider.tsx
index dfc3ce05449..ea6aa9a712f 100644
--- a/studio/frontend/src/app/provider.tsx
+++ b/studio/frontend/src/app/provider.tsx
@@ -33,6 +33,7 @@ import { TauriUpdateContext } from "@/hooks/tauri-update-context";
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";
@@ -871,6 +872,12 @@ const REDUCED_MOTION_MAP = {
} as const;
export function AppProvider({ children }: AppProviderProps) {
+ const pathname = useRouterState({ select: (s) => s.location.pathname });
+ const toastOffsets = getToastOffsets(
+ pathname,
+ isTauri,
+ shouldUseCustomWindowTitlebar(),
+ );
const reduceMotion = useAppearanceCustomStore(
(s) => s.customization.reduceMotion,
);
@@ -886,10 +893,10 @@ export function AppProvider({ children }: AppProviderProps) {
visibleToasts={2}
expand={true}
closeButton={true}
- // Clear the chat header buttons on the right. On desktop, also drop
- // below the ~34px custom window titlebar so toasts don't cover the
- // minimize / maximize / close controls.
- offset={{ top: isTauri ? 46 : 12, right: 64 }}
+ // Header routes clear their controls. Desktop chrome also stays clear,
+ // except where a macOS page header overlays the native titlebar.
+ offset={toastOffsets.default}
+ mobileOffset={toastOffsets.mobile}
/>
</TooltipProvider>
</MotionConfig>
diff --git a/studio/frontend/src/lib/toast-offset.ts b/studio/frontend/src/lib/toast-offset.ts
new file mode 100644
index 00000000000..f9be6555264
--- /dev/null
+++ b/studio/frontend/src/lib/toast-offset.ts
@@ -0,0 +1,47 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+
+const EDGE_OFFSET = 12;
+const MOBILE_EDGE_OFFSET = 16;
+const HEADER_TOP_OFFSET = 52;
+const DESKTOP_TITLEBAR_HEIGHT = 34;
+
+const HEADER_ROUTES = new Set(["/chat", "/images", "/video"]);
+
+export type ToastOffset = {
+ top: number;
+ right: number;
+};
+
+export type ToastOffsets = {
+ default: ToastOffset;
+ mobile: ToastOffset;
+};
+
+export function getToastOffsets(
+ pathname: string,
+ isDesktopApp: boolean,
+ usesCustomTitlebar: boolean,
+): ToastOffsets {
+ const hasPageHeader =
+ HEADER_ROUTES.has(pathname) || pathname.startsWith("/chat/");
+ const titlebarOffset =
+ isDesktopApp && (!hasPageHeader || usesCustomTitlebar)
+ ? DESKTOP_TITLEBAR_HEIGHT
+ : 0;
+ const defaultTopOffset = hasPageHeader ? HEADER_TOP_OFFSET : EDGE_OFFSET;
+ const mobileTopOffset = hasPageHeader
+ ? HEADER_TOP_OFFSET
+ : MOBILE_EDGE_OFFSET;
+
+ return {
+ default: {
+ top: defaultTopOffset + titlebarOffset,
+ right: EDGE_OFFSET,
+ },
+ mobile: {
+ top: mobileTopOffset + titlebarOffset,
+ right: MOBILE_EDGE_OFFSET,
+ },
+ };
+}
diff --git a/studio/frontend/tests/toast-offset.test.ts b/studio/frontend/tests/toast-offset.test.ts
new file mode 100644
index 00000000000..69db00effb6
--- /dev/null
+++ b/studio/frontend/tests/toast-offset.test.ts
@@ -0,0 +1,105 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+
+import assert from "node:assert/strict";
+import test from "node:test";
+
+import { getToastOffsets } from "../src/lib/toast-offset.ts";
+
+test("web chat toasts clear the header and stay against the right edge", () => {
+ assert.deepEqual(getToastOffsets("/chat", false, false), {
+ default: { top: 52, right: 12 },
+ mobile: { top: 52, right: 16 },
+ });
+ assert.deepEqual(getToastOffsets("/chat/thread", false, false), {
+ default: { top: 52, right: 12 },
+ mobile: { top: 52, right: 16 },
+ });
+});
+
+test("web media toasts clear their workspace headers", () => {
+ for (const pathname of ["/images", "/video"]) {
+ assert.deepEqual(getToastOffsets(pathname, false, false), {
+ default: { top: 52, right: 12 },
+ mobile: { top: 52, right: 16 },
+ });
+ }
+});
+
+test("other web routes keep the normal corner inset", () => {
+ for (const pathname of ["/studio", "/settings"]) {
+ assert.deepEqual(getToastOffsets(pathname, false, false), {
+ default: { top: 12, right: 12 },
+ mobile: { top: 16, right: 16 },
+ });
+ }
+});
+
+test("desktop routes without page headers clear the titlebar", () => {
+ assert.deepEqual(getToastOffsets("/settings", true, false), {
+ default: { top: 46, right: 12 },
+ mobile: { top: 50, right: 16 },
+ });
+});
+
+test("custom-titlebar desktop headers clear both titlebar bands", () => {
+ for (const pathname of ["/chat", "/images", "/video"]) {
+ assert.deepEqual(getToastOffsets(pathname, true, true), {
+ default: { top: 86, right: 12 },
+ mobile: { top: 86, right: 16 },
+ });
+ }
+});
+
+test("macOS desktop headers overlay the native titlebar", () => {
+ for (const pathname of ["/chat", "/images", "/video"]) {
+ assert.deepEqual(getToastOffsets(pathname, true, false), {
+ default: { top: 52, right: 12 },
+ mobile: { top: 52, right: 16 },
+ });
+ }
+});
+
+test("a route that merely starts with a workspace name keeps the corner inset", () => {
+ // The header routes are matched exactly, so a longer path that happens to share the
+ // prefix must not inherit their clearance and drop 40px down a page with no header.
+ for (const pathname of ["/chatty", "/images-old", "/videos", "/chatgpt"]) {
+ assert.deepEqual(getToastOffsets(pathname, false, false), {
+ default: { top: 12, right: 12 },
+ mobile: { top: 16, right: 16 },
+ });
+ }
+});
+
+test("an unrecognised pathname falls back to the corner inset", () => {
+ // The 404 shell paints no page header. This also covers a trailing-slash URL: the
+ // router does not normalise it, so "/images/" rests as its own pathname and misses
+ // the route, which is why it wants the no-header placement rather than the media one.
+ for (const pathname of ["/unknown", "/images/", "/video/", ""]) {
+ assert.deepEqual(getToastOffsets(pathname, false, false), {
+ default: { top: 12, right: 12 },
+ mobile: { top: 16, right: 16 },
+ });
+ }
+});
+
+test("a custom titlebar is ignored off the desktop app", () => {
+ // shouldUseCustomWindowTitlebar() cannot return true while isTauri is false, but the
+ // signature allows the pair, and there is no titlebar to clear in a browser.
+ for (const pathname of ["/chat", "/studio"]) {
+ assert.deepEqual(
+ getToastOffsets(pathname, false, true),
+ getToastOffsets(pathname, false, false),
+ );
+ }
+});
+
+test("offsets are pure, so a caller cannot poison the next lookup", () => {
+ const first = getToastOffsets("/chat", false, false);
+ first.default.top = -999;
+ first.mobile.right = -999;
+ assert.deepEqual(getToastOffsets("/chat", false, false), {
+ default: { top: 52, right: 12 },
+ mobile: { top: 52, right: 16 },
+ });
+});