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.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
Studio desktop: Cmd/Ctrl + and - zoom with a zoom popup (#12280)
Michael Hanb8440cc60165
diff --git a/studio/frontend/src/app/provider.tsx b/studio/frontend/src/app/provider.tsxindex e482186caea..41f23cf4fb9 100644--- a/studio/frontend/src/app/provider.tsx+++ b/studio/frontend/src/app/provider.tsx@@ -930,7 +930,10 @@ function TauriWrapper({ children }: { children: ReactNode }) {</div>)}{!showApp && (- <div className="fixed inset-0 z-40 bg-background">+ <div+ data-blocking-screen=""+ className="fixed inset-0 z-40 bg-background"+ ><StartupScreenstatus={startupStatus}logs={logs}diff --git a/studio/frontend/src/app/routes/__root.tsx b/studio/frontend/src/app/routes/__root.tsxindex b7c83d31e8b..f92653a41d4 100644--- a/studio/frontend/src/app/routes/__root.tsx+++ b/studio/frontend/src/app/routes/__root.tsx@@ -31,6 +31,7 @@ import {import { useExportRuntimeLifecycle } from "@/features/export";import { FIND_SCOPE_ATTRIBUTE, FindInPage } from "@/features/find-in-page";import { HfTokenWarningDialog } from "@/features/hf-auth";+import { InterfaceZoom, zoomInterfaceFromMenu } from "@/features/interface-zoom";import { bootstrapPersistedCredentials } from "@/features/credentials/bootstrap";import { backfillModelOverrides } from "@/features/model-picker/api/migrate-model-overrides";import { usePersonalizationSync } from "@/features/profile";@@ -39,9 +40,7 @@ import {SETTINGS_TABS,SettingsDialogMount,settingsTabVisible,- stepInterfaceScale,triggerShortcut,- useInterfaceScaleStore,useHubSourceNotice,useSettingsDialogStore,useShortcut,@@ -546,10 +545,6 @@ function RootLayout() {const nextChatMounted = useShortcutAvailable("nextChat", isTauri);const viaShortcut = (id: Parameters<typeof triggerShortcut>[0], mounted: boolean) =>mounted ? () => void triggerShortcut(id) : null;- const zoomBy = (direction: 1 | -1) => () => {- const scale = useInterfaceScaleStore.getState();- scale.setScale(stepInterfaceScale(scale.scale, direction));- };// Help opens settings or a web page, so it works anywhere past sign-in.// Pages this account cannot open stay disabled, as in Go > Settings.const isOwner = useIsAccountOwner();@@ -589,9 +584,9 @@ function RootLayout() {"next-chat": viaShortcut("nextChat", nextChatMounted),"back": routeShortcutEnabled ? () => window.history.back() : null,"forward": routeShortcutEnabled ? () => window.history.forward() : null,- "zoom-in": zoomBy(1),- "zoom-out": zoomBy(-1),- "actual-size": () => useInterfaceScaleStore.getState().reset(),+ "zoom-in": () => zoomInterfaceFromMenu(1),+ "zoom-out": () => zoomInterfaceFromMenu(-1),+ "actual-size": () => zoomInterfaceFromMenu(0),"help-documentation": helpAction("help-documentation"),"help-keyboard-shortcuts": helpAction("help-keyboard-shortcuts"),"help-whats-new": helpAction("help-whats-new"),@@ -671,6 +666,8 @@ function RootLayout() {const content = (<><PersonalizationSyncMount />+ {/* Every route, sign-in included. */}+ <InterfaceZoom /><ReloadSnapshotPrivacy />{!isAuthFlowRoute && <ChatSettingsHydrationMount />}{!isAuthFlowRoute && <LowDiskNoticeMount />}diff --git a/studio/frontend/src/components/tauri/startup-screen.tsx b/studio/frontend/src/components/tauri/startup-screen.tsxindex 0f1a9732c70..b2fded894a6 100644--- a/studio/frontend/src/components/tauri/startup-screen.tsx+++ b/studio/frontend/src/components/tauri/startup-screen.tsx@@ -445,7 +445,10 @@ export function ClosingScreen() {// the tray or Alt+F4 never closes that layer. Inheriting it would make the overlay// click-through onto the dialog it is hiding, so clicks meant for a screen that says// the app is closing would land on buttons the user can no longer see.- <div className="pointer-events-auto fixed inset-0 z-[9999]">+ <div+ data-blocking-screen=""+ className="pointer-events-auto fixed inset-0 z-[9999]"+ ><StartupSurface><div className="flex h-full w-full flex-col items-center justify-center text-center"><ClosingContent />diff --git a/studio/frontend/src/features/find-in-page/components/find-bar.tsx b/studio/frontend/src/features/find-in-page/components/find-bar.tsxindex 753d0e9c7e4..8810f743189 100644--- a/studio/frontend/src/features/find-in-page/components/find-bar.tsx+++ b/studio/frontend/src/features/find-in-page/components/find-bar.tsx@@ -2,7 +2,7 @@// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0import { Button } from "@/components/ui/button";-import { isImeComposing, isSurfaceBackgrounded } from "@/features/settings";+import { isImeComposing } from "@/features/settings";import { useT } from "@/i18n";import { cn } from "@/lib/utils";import { Cancel01Icon } from "@hugeicons/core-free-icons";@@ -11,7 +11,7 @@ import { HugeiconsIcon } from "@hugeicons/react";import { ArrowDownIcon, ArrowUpIcon } from "lucide-react";import { useEffect, useRef, useState } from "react";import { useFindInPage } from "../hooks/use-find-in-page.ts";-import { FIND_SCOPE_ATTRIBUTE } from "../lib/find-attributes.ts";+import { isFindScopeBackgrounded } from "../lib/find-backgrounded.ts";import {resolveDismissiblePortalSurfaces,resolveFindScope,@@ -166,7 +166,7 @@ export default function FindBar({useEffect(() => {const onEscape = (event: KeyboardEvent) => {if (event.key !== "Escape" || isImeComposing(event)) return;- if (isSurfaceBackgrounded(`[${FIND_SCOPE_ATTRIBUTE}]`)) return;+ if (isFindScopeBackgrounded()) return;if (resolveDismissiblePortalSurfaces(resolveFindScope()).length > 0)return;event.preventDefault();diff --git a/studio/frontend/src/features/find-in-page/components/find-in-page.tsx b/studio/frontend/src/features/find-in-page/components/find-in-page.tsxindex b25771a0532..7ca02a94a6c 100644--- a/studio/frontend/src/features/find-in-page/components/find-in-page.tsx+++ b/studio/frontend/src/features/find-in-page/components/find-in-page.tsx@@ -10,9 +10,10 @@ import { useT } from "@/i18n";import {isImeComposing,- isSurfaceBackgrounded,useShortcut,+ useShortcutAvailable,} from "@/features/settings";+import { Z_LAYER } from "@/lib/z-layers";import {type ReactNode,Suspense,@@ -23,7 +24,9 @@ import {useRef,useState,} from "react";+import { createPortal } from "react-dom";import { FIND_SCOPE_ATTRIBUTE } from "../lib/find-attributes.ts";+import { isFindScopeBackgrounded } from "../lib/find-backgrounded.ts";const DISMISSIBLE_SURFACE_SELECTOR ='[data-slot="popover-content"], [role="menu"], [role="listbox"]';@@ -85,7 +88,7 @@ function FindBarLoading({useEffect(() => {const onEscape = (event: KeyboardEvent) => {if (event.key !== "Escape" || isImeComposing(event)) return;- if (isSurfaceBackgrounded(`[${FIND_SCOPE_ATTRIBUTE}]`)) return;+ if (isFindScopeBackgrounded()) return;if (hasOpenDismissibleSurface()) return;event.preventDefault();event.stopPropagation();@@ -249,49 +252,61 @@ export function FindInPage({ enabled = true }: { enabled?: boolean }) {useShortcut("findInPage", requestFocus, {enabled,// A modal backgrounds the shell and owns the chord while its surface is active.- claims: () => !isSurfaceBackgrounded(`[${FIND_SCOPE_ATTRIBUTE}]`),+ claims: () => !isFindScopeBackgrounded(),});+ // False while a modal is open.+ const foreground = useShortcutAvailable("findInPage", true);+if (!enabled || !open) return null;- return (- <LazyImportBoundary- fallback={- <LazyImportFailure- message={t("settings.dialog.panelFailed")}- reloadLabel={t("settings.dialog.panelReload")}- dismissLabel={t("common.close")}- onDismiss={close}- testId="find-in-page-load-failure"- className="fixed top-3 right-3 z-[100] max-w-xs rounded-xl border border-border bg-popover p-4 text-popover-foreground shadow-lg"- />- }+ // Top layer, outside any stacking context. Hidden (not unmounted) under a modal so it returns as it was.+ return createPortal(+ <div+ data-find-bar-layer=""+ hidden={!foreground}+ className="fixed top-0 right-0"+ style={{ zIndex: Z_LAYER.WINDOW_BARS }}>- <Suspense+ <LazyImportBoundaryfallback={- <FindBarLoading- query={query}- setQuery={setQuery}- close={close}- focusToken={focusToken}- rememberSelection={rememberLoadingSelection}- queueStep={queueLoadingStep}- beginComposition={beginLoadingComposition}- endComposition={endLoadingComposition}+ <LazyImportFailure+ message={t("settings.dialog.panelFailed")}+ reloadLabel={t("settings.dialog.panelReload")}+ dismissLabel={t("common.close")}+ onDismiss={close}+ testId="find-in-page-load-failure"+ className="fixed top-3 right-3 z-[100] max-w-xs rounded-xl border border-border bg-popover p-4 text-popover-foreground shadow-lg"/>}>- <FindBarAfterComposition handoffBlock={handoffBlock}>- <FindBar- query={query}- setQuery={setQuery}- close={close}- focusToken={focusToken}- restoreSelection={restoreLoadingSelection}- pendingSteps={pendingSteps}- clearPendingSteps={clearPendingSteps}- />- </FindBarAfterComposition>- </Suspense>- </LazyImportBoundary>+ <Suspense+ fallback={+ <FindBarLoading+ query={query}+ setQuery={setQuery}+ close={close}+ focusToken={focusToken}+ rememberSelection={rememberLoadingSelection}+ queueStep={queueLoadingStep}+ beginComposition={beginLoadingComposition}+ endComposition={endLoadingComposition}+ />+ }+ >+ <FindBarAfterComposition handoffBlock={handoffBlock}>+ <FindBar+ query={query}+ setQuery={setQuery}+ close={close}+ focusToken={focusToken}+ restoreSelection={restoreLoadingSelection}+ pendingSteps={pendingSteps}+ clearPendingSteps={clearPendingSteps}+ />+ </FindBarAfterComposition>+ </Suspense>+ </LazyImportBoundary>+ </div>,+ document.body,);}diff --git a/studio/frontend/src/features/find-in-page/lib/find-backgrounded.ts b/studio/frontend/src/features/find-in-page/lib/find-backgrounded.tsnew file mode 100644index 00000000000..f596ab15c2d--- /dev/null+++ b/studio/frontend/src/features/find-in-page/lib/find-backgrounded.ts@@ -0,0 +1,26 @@+// 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 { isSurfaceBackgrounded } from "@/features/settings";+import { FIND_SCOPE_ATTRIBUTE } from "./find-attributes.ts";++/** Modal backdrops, custom modals (the artifact overlay), and the startup and closing screens. */+export const MODAL_BACKDROP_SELECTOR = [+ ...["dialog-overlay", "alert-dialog-overlay", "sheet-overlay"].map(+ (slot) => `[data-slot="${slot}"]:not([data-state="closed"])`,+ ),+ '[aria-modal="true"]',+ "[data-blocking-screen]",+].join(", ");++/**+ * Whether a modal covers the searched page. Radix never aria-hides ancestors of an `aria-live`+ * region, and the page always has one, so the backdrop is checked too.+ */+export function isFindScopeBackgrounded(): boolean {+ if (typeof document === "undefined") return false;+ return (+ document.querySelector(MODAL_BACKDROP_SELECTOR) !== null ||+ isSurfaceBackgrounded(`[${FIND_SCOPE_ATTRIBUTE}]`)+ );+}diff --git a/studio/frontend/src/features/interface-zoom/components/interface-zoom.tsx b/studio/frontend/src/features/interface-zoom/components/interface-zoom.tsxnew file mode 100644index 00000000000..fe1ce0f5736--- /dev/null+++ b/studio/frontend/src/features/interface-zoom/components/interface-zoom.tsx@@ -0,0 +1,217 @@+// 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 { Button } from "@/components/ui/button";+import {+ getAppliedInterfaceZoom,+ isImeComposing,+ subscribeAppliedInterfaceZoom,+ useInterfaceScaleStore,+} from "@/features/settings";+import {+ formatBindingValueLabel,+ isMacPlatform,+} from "@/features/settings/lib/keyboard-shortcuts";+import { INTERFACE_SCALE_RANGE } from "@/features/settings/stores/interface-scale-store";+import {+ shortcutOwningBinding,+ useKeyboardShortcutsStore,+} from "@/features/settings/stores/keyboard-shortcuts-store";+import { useT } from "@/i18n";+import { isTauri } from "@/lib/api-base";+import { Z_LAYER } from "@/lib/z-layers";+import { MinusIcon, PlusIcon } from "lucide-react";+import { useEffect, useState, useSyncExternalStore } from "react";+import { createPortal } from "react-dom";+import {+ useZoomPopupStore,+ zoomInterface,+ zoomInterfaceFromChord,+} from "../lib/zoom-actions.ts";+import {+ ZOOM_CHORDS,+ type ZoomDirection,+ zoomChordTaken,+ zoomDirectionForKey,+} from "../lib/zoom-chords.ts";+import { createWheelZoomAccumulator, isZoomWheel } from "../lib/zoom-wheel.ts";++/** Hide delay after the last zoom, paused while hovered or focused. */+export const ZOOM_POPUP_HIDE_MS = 2500;++/** Same hover wash as the find bar. */+const ZOOM_BUTTON_CLASS =+ "hover:bg-[rgb(0_0_0_/_calc(0.06*var(--contrast-wash-gain,1)))] dark:hover:bg-[rgb(255_255_255_/_calc(0.1*var(--contrast-wash-gain,1)))]";++/** Keeps focus where the user was typing. */+function keepFocus(event: { preventDefault: () => void }): void {+ event.preventDefault();+}++/** Tooltip with its chord, e.g. "Zoom in (⌘=)". */+function withChord(label: string, direction: ZoomDirection): string {+ const chord = formatBindingValueLabel(ZOOM_CHORDS[direction]);+ return chord ? `${label} (${chord})` : label;+}++function ZoomPopup() {+ const t = useT();+ const scale = useInterfaceScaleStore((s) => s.scale);+ const token = useZoomPopupStore((s) => s.token);+ const hide = useZoomPopupStore((s) => s.hide);+ // Divided back out below, so the popup keeps one on-screen size at every zoom.+ const pageZoom = useSyncExternalStore(+ subscribeAppliedInterfaceZoom,+ getAppliedInterfaceZoom,+ );+ const [hovered, setHovered] = useState(false);+ const [focused, setFocused] = useState(false);+ const held = hovered || focused;++ // biome-ignore lint/correctness/useExhaustiveDependencies: each zoom restarts the timer.+ useEffect(() => {+ if (held) return;+ const timer = setTimeout(hide, ZOOM_POPUP_HIDE_MS);+ return () => clearTimeout(timer);+ }, [token, held, hide]);++ return (+ // In the find bar's corner, in front of it. pointer-events-auto survives a modal's body lock.+ <div+ className="interface-zoom-position pointer-events-auto fixed right-4"+ style={{ zIndex: Z_LAYER.ZOOM_POPUP }}+ // Keeps an open modal from treating this as an outside click.+ onPointerDown={(event) => event.stopPropagation()}+ >+ <div+ // biome-ignore lint/a11y/useSemanticElements: a labelled group of zoom controls, not a form.+ role="group"+ aria-label={t("shell.zoom.label")}+ data-find-skip=""+ data-testid="interface-zoom-popup"+ onPointerEnter={() => setHovered(true)}+ onPointerLeave={() => setHovered(false)}+ onFocus={() => setFocused(true)}+ onBlur={(event) => {+ if (!event.currentTarget.contains(event.relatedTarget))+ setFocused(false);+ }}+ onKeyDown={(event) => {+ if (event.key !== "Escape") return;+ event.preventDefault();+ event.stopPropagation();+ hide();+ }}+ style={pageZoom === 1 ? undefined : { zoom: 1 / pageZoom }}+ className="find-bar-surface flex h-11 items-center gap-0.5 rounded-full pr-1.5 pl-4 duration-100 animate-in fade-in-0"+ >+ <span className="min-w-[calc(2.875rem*var(--ui-space-scale,1))] pr-1.5 font-medium text-ui-14 tabular-nums">+ {scale}%+ </span>+ <Button+ variant="ghost"+ size="icon-sm"+ className={ZOOM_BUTTON_CLASS}+ disabled={scale <= INTERFACE_SCALE_RANGE.min}+ onMouseDown={keepFocus}+ onClick={() => zoomInterface(-1)}+ aria-label={t("shell.zoom.zoomOut")}+ title={withChord(t("shell.zoom.zoomOut"), -1)}+ >+ <MinusIcon+ strokeWidth={1.75}+ className="size-[calc(16px*var(--ui-space-scale,1))]"+ />+ </Button>+ <Button+ variant="ghost"+ size="icon-sm"+ className={ZOOM_BUTTON_CLASS}+ disabled={scale >= INTERFACE_SCALE_RANGE.max}+ onMouseDown={keepFocus}+ onClick={() => zoomInterface(1)}+ aria-label={t("shell.zoom.zoomIn")}+ title={withChord(t("shell.zoom.zoomIn"), 1)}+ >+ <PlusIcon+ strokeWidth={1.75}+ className="size-[calc(16px*var(--ui-space-scale,1))]"+ />+ </Button>+ <span aria-hidden="true" className="mx-1 h-5 w-px bg-border" />+ <Button+ variant="ghost"+ size="sm"+ className={`rounded-full px-2.5 text-muted-foreground text-ui-14 ${ZOOM_BUTTON_CLASS}`}+ disabled={scale === INTERFACE_SCALE_RANGE.default}+ onMouseDown={keepFocus}+ onClick={() => zoomInterface(0)}+ title={withChord(t("shell.zoom.reset"), 0)}+ >+ {t("shell.zoom.reset")}+ </Button>+ </div>+ </div>+ );+}++/** Announces each zoom. Always mounted, so the first zoom is announced too. */+function ZoomAnnouncer({ open }: { open: boolean }) {+ const t = useT();+ const scale = useInterfaceScaleStore((s) => s.scale);+ return (+ <output aria-live="polite" className="sr-only">+ {open ? t("shell.zoom.announce", { percent: String(scale) }) : ""}+ </output>+ );+}++/**+ * Desktop zoom: Cmd/Ctrl +, - and 0 on every platform, plus Ctrl+wheel off macOS. Each zoom shows+ * a popup in the find bar's corner. Browsers keep their own zoom.+ */+export function InterfaceZoom() {+ const open = useZoomPopupStore((s) => s.open);++ useEffect(() => {+ if (!isTauri) return;+ const mac = isMacPlatform();+ // Capture phase, so it also works from text fields. On document, not window, so the+ // shortcut recorder's window capture listener takes the chord first and stops it.+ const onKeyDown = (event: KeyboardEvent) => {+ if (event.defaultPrevented || isImeComposing(event)) return;+ const direction = zoomDirectionForKey(event, mac);+ if (direction === null) return;+ const { overrides } = useKeyboardShortcutsStore.getState();+ const owned = (value: string) =>+ shortcutOwningBinding(overrides, value) !== null;+ if (zoomChordTaken(event, direction, mac, owned)) return;+ event.preventDefault();+ zoomInterfaceFromChord(direction);+ };+ document.addEventListener("keydown", onKeyDown, true);+ // Bubble phase, so canvases with their own Ctrl+wheel zoom keep it.+ const wheelStep = createWheelZoomAccumulator();+ const onWheel = (event: WheelEvent) => {+ if (event.defaultPrevented || !isZoomWheel(event)) return;+ event.preventDefault();+ const direction = wheelStep(event, getAppliedInterfaceZoom());+ if (direction !== null) zoomInterface(direction);+ };+ if (!mac) window.addEventListener("wheel", onWheel, { passive: false });+ return () => {+ document.removeEventListener("keydown", onKeyDown, true);+ window.removeEventListener("wheel", onWheel);+ };+ }, []);++ if (typeof document === "undefined") return null;+ // Portaled so a modal's inert/aria-hidden does not reach it.+ return createPortal(+ <>+ {isTauri && <ZoomAnnouncer open={open} />}+ {open && <ZoomPopup />}+ </>,+ document.body,+ );+}diff --git a/studio/frontend/src/features/interface-zoom/index.ts b/studio/frontend/src/features/interface-zoom/index.tsnew file mode 100644index 00000000000..bcd317fb582--- /dev/null+++ b/studio/frontend/src/features/interface-zoom/index.ts@@ -0,0 +1,5 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0++export { InterfaceZoom } from "./components/interface-zoom.tsx";+export { zoomInterfaceFromMenu } from "./lib/zoom-actions.ts";diff --git a/studio/frontend/src/features/interface-zoom/lib/zoom-actions.ts b/studio/frontend/src/features/interface-zoom/lib/zoom-actions.tsnew file mode 100644index 00000000000..dd186a96fe3--- /dev/null+++ b/studio/frontend/src/features/interface-zoom/lib/zoom-actions.ts@@ -0,0 +1,46 @@+// 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 {+ stepInterfaceScale,+ useInterfaceScaleStore,+} from "@/features/settings";+import { create } from "zustand";+import type { ZoomDirection } from "./zoom-chords.ts";++interface ZoomPopupState {+ /** Bumped on every zoom to restart the hide timer. */+ token: number;+ open: boolean;+ show: () => void;+ hide: () => void;+}++export const useZoomPopupStore = create<ZoomPopupState>()((set) => ({+ token: 0,+ open: false,+ show: () => set((s) => ({ open: true, token: s.token + 1 })),+ hide: () => set({ open: false }),+}));++/** Step the interface scale and show the popup. */+export function zoomInterface(direction: ZoomDirection): void {+ const scale = useInterfaceScaleStore.getState();+ if (direction === 0) scale.reset();+ else scale.setScale(stepInterfaceScale(scale.scale, direction));+ useZoomPopupStore.getState().show();+}++// Guards against the macOS View menu repeating a chord the page already handled.+const MENU_ECHO_MS = 150;+let lastChordZoomAt = Number.NEGATIVE_INFINITY;++export function zoomInterfaceFromChord(direction: ZoomDirection): void {+ lastChordZoomAt = performance.now();+ zoomInterface(direction);+}++export function zoomInterfaceFromMenu(direction: ZoomDirection): void {+ if (performance.now() - lastChordZoomAt < MENU_ECHO_MS) return;+ zoomInterface(direction);+}diff --git a/studio/frontend/src/features/interface-zoom/lib/zoom-chords.ts b/studio/frontend/src/features/interface-zoom/lib/zoom-chords.tsnew file mode 100644index 00000000000..af397f0b028--- /dev/null+++ b/studio/frontend/src/features/interface-zoom/lib/zoom-chords.ts@@ -0,0 +1,57 @@+// 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 {+ bindingFromEvent,+ formatBindingValue,+} from "../../settings/lib/keyboard-shortcuts.ts";++/** 1 zooms in, -1 out, 0 back to 100%. */+export type ZoomDirection = 1 | -1 | 0;++/** Chord per direction. A user shortcut bound to one of these wins. */+export const ZOOM_CHORDS: Record<ZoomDirection, string> = {+ 1: "Mod+Equal",+ [-1]: "Mod+Minus",+ 0: "Mod+Digit0",+};++type ZoomKeyEvent = Pick<+ KeyboardEvent,+ "key" | "code" | "metaKey" | "ctrlKey" | "altKey" | "shiftKey"+>;++/** Browser-style zoom keys: Cmd on macOS, Ctrl elsewhere, Shift optional, keypad included. */+export function zoomDirectionForKey(+ event: ZoomKeyEvent,+ mac: boolean,+): ZoomDirection | null {+ const mod = mac+ ? event.metaKey && !event.ctrlKey+ : event.ctrlKey && !event.metaKey;+ if (!mod || event.altKey) return null;+ if (event.key === "+" || event.key === "=" || event.code === "NumpadAdd")+ return 1;+ if (event.key === "-" || event.key === "_" || event.code === "NumpadSubtract")+ return -1;+ if (event.key === "0" || event.code === "Digit0" || event.code === "Numpad0")+ return 0;+ if (event.code === "Equal") return 1;+ if (event.code === "Minus") return -1;+ return null;+}++/**+ * Whether a user shortcut takes this press instead: one bound to the canonical chord, or to the+ * exact keys pressed (Mod+Shift+Equal, a keypad key).+ */+export function zoomChordTaken(+ event: ZoomKeyEvent,+ direction: ZoomDirection,+ mac: boolean,+ owned: (value: string) => boolean,+): boolean {+ if (owned(ZOOM_CHORDS[direction])) return true;+ const pressed = bindingFromEvent(event, mac);+ return pressed !== null && owned(formatBindingValue(pressed));+}diff --git a/studio/frontend/src/features/interface-zoom/lib/zoom-wheel.ts b/studio/frontend/src/features/interface-zoom/lib/zoom-wheel.tsnew file mode 100644index 00000000000..13607c3ff20--- /dev/null+++ b/studio/frontend/src/features/interface-zoom/lib/zoom-wheel.ts@@ -0,0 +1,52 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0++/** Wheel travel per step: one mouse notch, or a short touchpad pinch. */+export const WHEEL_ZOOM_STEP_PX = 50;++/** A pause this long starts a new gesture. */+export const WHEEL_ZOOM_IDLE_MS = 250;++const LINE_PX = 40;+const PAGE_PX = 800;++type ZoomWheelEvent = Pick<+ WheelEvent,+ "deltaY" | "deltaMode" | "ctrlKey" | "metaKey" | "altKey" | "timeStamp"+>;++/** Vertical Ctrl+wheel without Alt or Meta. Anything else keeps its default. */+export function isZoomWheel(+ event: Pick<WheelEvent, "deltaY" | "ctrlKey" | "metaKey" | "altKey">,+): boolean {+ return event.ctrlKey && !event.metaKey && !event.altKey && event.deltaY !== 0;+}++/** Ctrl+wheel to zoom steps (1 in, -1 out). `zoom` converts CSS px deltas to screen px. */+export function createWheelZoomAccumulator(): (+ event: ZoomWheelEvent,+ zoom: number,+) => 1 | -1 | null {+ let travel = 0;+ let lastAt = Number.NEGATIVE_INFINITY;+ return (event, zoom) => {+ if (!isZoomWheel(event)) return null;+ const unit =+ event.deltaMode === 1 ? LINE_PX : event.deltaMode === 2 ? PAGE_PX : 1;+ const delta = event.deltaY * unit * zoom;+ // Reset on a pause or a direction change.+ if (+ event.timeStamp - lastAt > WHEEL_ZOOM_IDLE_MS ||+ Math.sign(delta) !== Math.sign(travel)+ ) {+ travel = 0;+ }+ lastAt = event.timeStamp;+ travel += delta;+ if (Math.abs(travel) < WHEEL_ZOOM_STEP_PX) return null;+ const direction = travel < 0 ? 1 : -1;+ // One step per crossing, however large the delta.+ travel = 0;+ return direction;+ };+}diff --git a/studio/frontend/src/features/settings/hooks/use-shortcut.ts b/studio/frontend/src/features/settings/hooks/use-shortcut.tsindex e455e62284a..c035dfbbbd9 100644--- a/studio/frontend/src/features/settings/hooks/use-shortcut.ts+++ b/studio/frontend/src/features/settings/hooks/use-shortcut.ts@@ -147,7 +147,8 @@ export function triggerShortcut(id: ShortcutId): boolean {return trigger !== undefined;}-// Claims mostly ask whether a modal covers the surface, which shows as aria-hidden or inert.+// Claims mostly ask whether a modal covers the surface, which shows as aria-hidden or inert,+// or only as a backdrop portaled to body when the surface holds an aria-live region.let modalObserver: MutationObserver | null = null;function subscribeTriggers(listener: () => void, watchModals: boolean): () => void {triggerListeners.add(listener);@@ -158,6 +159,7 @@ function subscribeTriggers(listener: () => void, watchModals: boolean): () => voattributes: true,attributeFilter: ["aria-hidden", "inert"],});+ modalObserver.observe(document.body, { childList: true });}return () => {triggerListeners.delete(listener);diff --git a/studio/frontend/src/features/settings/stores/interface-scale-store.ts b/studio/frontend/src/features/settings/stores/interface-scale-store.tsindex 1e176d72466..879d75bc114 100644--- a/studio/frontend/src/features/settings/stores/interface-scale-store.ts+++ b/studio/frontend/src/features/settings/stores/interface-scale-store.ts@@ -17,10 +17,8 @@ import {export { getAppliedInterfaceZoom };export const INTERFACE_SCALE_STORAGE_KEY = "unsloth_interface_scale";-// The floor is 50, not the 25 Chrome and VS Code allow, because both of those ship-// Cmd/Ctrl+0 and this does not yet. At 25% the Settings row you would use to undo it-// renders around 3.5px, and the value is device-local in localStorage, so recovery means-// clearing app data. Drop it back to 25 once a reset accelerator exists.+// Floor is 50, not 25: in the browser Cmd/Ctrl+0 resets the browser's zoom, not this one, and at+// 25% the Settings row that undoes it is about 3.5px tall.export const INTERFACE_SCALE_RANGE = {min: 50,max: 200,diff --git a/studio/frontend/src/features/tour/components/guided-tour.tsx b/studio/frontend/src/features/tour/components/guided-tour.tsxindex 91b9aac82e4..fe6d39b7d0e 100644--- a/studio/frontend/src/features/tour/components/guided-tour.tsx+++ b/studio/frontend/src/features/tour/components/guided-tour.tsx@@ -243,6 +243,8 @@ export function GuidedTour({<><DialogPrimitive.Overlay asChild><motion.div+ // The shared slot, so modal checks see the tour.+ data-slot="dialog-overlay"className="fixed inset-0 z-50"initial={{ opacity: 0 }}animate={{ opacity: 1 }}diff --git a/studio/frontend/src/i18n/locales/ar.ts b/studio/frontend/src/i18n/locales/ar.tsindex 319d3b3fb76..94d7bb2fa16 100644--- a/studio/frontend/src/i18n/locales/ar.ts+++ b/studio/frontend/src/i18n/locales/ar.ts@@ -142,6 +142,13 @@ export const ar = {close: "إغلاق البحث",truncated: "هذه الصفحة أطول من أن يتم البحث فيها بالكامل.",},+ zoom: {+ label: "التكبير",+ zoomOut: "تصغير",+ zoomIn: "تكبير",+ reset: "إعادة تعيين",+ announce: "التكبير {percent}%",+ },beta: "BETA",brand: "unsloth",product: "Unsloth",diff --git a/studio/frontend/src/i18n/locales/de.ts b/studio/frontend/src/i18n/locales/de.tsindex 78454f782a3..03057ec8751 100644--- a/studio/frontend/src/i18n/locales/de.ts+++ b/studio/frontend/src/i18n/locales/de.ts@@ -145,6 +145,13 @@ export const de = {close: "Suche schließen",truncated: "Diese Seite ist zu lang, um vollständig durchsucht zu werden.",},+ zoom: {+ label: "Zoom",+ zoomOut: "Verkleinern",+ zoomIn: "Vergrößern",+ reset: "Zurücksetzen",+ announce: "Zoom {percent} %",+ },beta: "BETA",brand: "unsloth",product: "Unsloth",diff --git a/studio/frontend/src/i18n/locales/en.ts b/studio/frontend/src/i18n/locales/en.tsindex d912f899df2..37395b48808 100644--- a/studio/frontend/src/i18n/locales/en.ts+++ b/studio/frontend/src/i18n/locales/en.ts@@ -143,6 +143,13 @@ export const en = {close: "Close find",truncated: "This page is too long to search in full.",},+ zoom: {+ label: "Zoom",+ zoomOut: "Zoom out",+ zoomIn: "Zoom in",+ reset: "Reset",+ announce: "Zoom {percent}%",+ },beta: "BETA",brand: "unsloth",product: "Unsloth",diff --git a/studio/frontend/src/i18n/locales/es.ts b/studio/frontend/src/i18n/locales/es.tsindex 2ca8d60fddf..15010182afe 100644--- a/studio/frontend/src/i18n/locales/es.ts+++ b/studio/frontend/src/i18n/locales/es.ts@@ -144,6 +144,13 @@ export const es = {close: "Cerrar búsqueda",truncated: "Esta página es demasiado larga para buscarla por completo.",},+ zoom: {+ label: "Zoom",+ zoomOut: "Alejar",+ zoomIn: "Acercar",+ reset: "Restablecer",+ announce: "Zoom {percent} %",+ },beta: "BETA",brand: "unsloth",product: "Unsloth",diff --git a/studio/frontend/src/i18n/locales/fr.ts b/studio/frontend/src/i18n/locales/fr.tsindex 44b55b20a94..62a6f62cb9b 100644--- a/studio/frontend/src/i18n/locales/fr.ts+++ b/studio/frontend/src/i18n/locales/fr.ts@@ -145,6 +145,13 @@ export const fr = {close: "Fermer la recherche",truncated: "Cette page est trop longue pour être parcourue en entier.",},+ zoom: {+ label: "Zoom",+ zoomOut: "Zoom arrière",+ zoomIn: "Zoom avant",+ reset: "Réinitialiser",+ announce: "Zoom {percent} %",+ },beta: "BETA",brand: "unsloth",product: "Unsloth",diff --git a/studio/frontend/src/i18n/locales/hi.ts b/studio/frontend/src/i18n/locales/hi.tsindex 66772a1fba3..31565e047d5 100644--- a/studio/frontend/src/i18n/locales/hi.ts+++ b/studio/frontend/src/i18n/locales/hi.ts@@ -145,6 +145,13 @@ export const hi = {close: "खोज बंद करें",truncated: "यह पेज पूरी तरह खोजने के लिए बहुत लंबा है।",},+ zoom: {+ label: "ज़ूम",+ zoomOut: "ज़ूम आउट",+ zoomIn: "ज़ूम इन",+ reset: "रीसेट करें",+ announce: "ज़ूम {percent}%",+ },beta: "BETA",brand: "unsloth",product: "Unsloth",diff --git a/studio/frontend/src/i18n/locales/it.ts b/studio/frontend/src/i18n/locales/it.tsindex 88982e9a27b..a45f798241f 100644--- a/studio/frontend/src/i18n/locales/it.ts+++ b/studio/frontend/src/i18n/locales/it.ts@@ -104,6 +104,13 @@ export const it = {close: "Chiudi ricerca",truncated: "Questa pagina è troppo lunga per essere cercata per intero.",},+ zoom: {+ label: "Zoom",+ zoomOut: "Riduci",+ zoomIn: "Ingrandisci",+ reset: "Reimposta",+ announce: "Zoom {percent}%",+ },beta: "BETA",brand: "unsloth",product: "Unsloth",diff --git a/studio/frontend/src/i18n/locales/ja.ts b/studio/frontend/src/i18n/locales/ja.tsindex 3cb71a906a5..c0cd1546514 100644--- a/studio/frontend/src/i18n/locales/ja.ts+++ b/studio/frontend/src/i18n/locales/ja.ts@@ -144,6 +144,13 @@ export const ja = {close: "検索を閉じる",truncated: "このページは長すぎるため、全体を検索できません。",},+ zoom: {+ label: "ズーム",+ zoomOut: "縮小",+ zoomIn: "拡大",+ reset: "リセット",+ announce: "ズーム {percent}%",+ },beta: "BETA",brand: "unsloth",product: "Unsloth",diff --git a/studio/frontend/src/i18n/locales/ko.ts b/studio/frontend/src/i18n/locales/ko.tsindex 59a22c70553..b205da8c15b 100644--- a/studio/frontend/src/i18n/locales/ko.ts+++ b/studio/frontend/src/i18n/locales/ko.ts@@ -142,6 +142,13 @@ export const ko = {close: "찾기 닫기",truncated: "이 페이지는 너무 길어 전체를 검색할 수 없습니다.",},+ zoom: {+ label: "확대/축소",+ zoomOut: "축소",+ zoomIn: "확대",+ reset: "재설정",+ announce: "확대/축소 {percent}%",+ },beta: "BETA",brand: "unsloth",product: "Unsloth",diff --git a/studio/frontend/src/i18n/locales/pt-br.ts b/studio/frontend/src/i18n/locales/pt-br.tsindex d09441b945c..37a05782c94 100644--- a/studio/frontend/src/i18n/locales/pt-br.ts+++ b/studio/frontend/src/i18n/locales/pt-br.ts@@ -144,6 +144,13 @@ export const ptBR = {close: "Fechar busca",truncated: "Esta página é longa demais para ser pesquisada por completo.",},+ zoom: {+ label: "Zoom",+ zoomOut: "Diminuir zoom",+ zoomIn: "Aumentar zoom",+ reset: "Redefinir",+ announce: "Zoom {percent}%",+ },beta: "BETA",brand: "unsloth",product: "Unsloth",diff --git a/studio/frontend/src/i18n/locales/ru.ts b/studio/frontend/src/i18n/locales/ru.tsindex c8cf0d56c9a..366ac1cf2bf 100644--- a/studio/frontend/src/i18n/locales/ru.ts+++ b/studio/frontend/src/i18n/locales/ru.ts@@ -144,6 +144,13 @@ export const ru = {close: "Закрыть поиск",truncated: "Эта страница слишком длинная, чтобы выполнить поиск целиком.",},+ zoom: {+ label: "Масштаб",+ zoomOut: "Уменьшить",+ zoomIn: "Увеличить",+ reset: "Сбросить",+ announce: "Масштаб {percent} %",+ },beta: "BETA",brand: "unsloth",product: "Unsloth",diff --git a/studio/frontend/src/i18n/locales/zh-CN.ts b/studio/frontend/src/i18n/locales/zh-CN.tsindex fde2696734e..6907c99d18d 100644--- a/studio/frontend/src/i18n/locales/zh-CN.ts+++ b/studio/frontend/src/i18n/locales/zh-CN.ts@@ -140,6 +140,13 @@ export const zhCN = {close: "关闭查找",truncated: "此页面过长,无法搜索全部内容。",},+ zoom: {+ label: "缩放",+ zoomOut: "缩小",+ zoomIn: "放大",+ reset: "重置",+ announce: "缩放 {percent}%",+ },beta: "BETA",brand: "unsloth",product: "Unsloth",diff --git a/studio/frontend/src/index.css b/studio/frontend/src/index.cssindex 60df490f63e..115ce993862 100644--- a/studio/frontend/src/index.css+++ b/studio/frontend/src/index.css@@ -5509,14 +5509,25 @@ html.force-reduced-motion .sidebar-section-drop-line {}.dark .find-bar-surface {- /* #2c2c2c, on the same curve as --card: the bar has to stay above the- cards it floats over at every contrast, not just the default. */- background-color: color-mix(in oklab, #2c2c2c, var(--contrast-panel-target, var(--contrast-target, transparent)) var(--contrast-surface-mix, 0%));+ /* Sidebar menu surface (7%) a step lighter; 8% stays under --border. */+ background-color: color-mix(in srgb, var(--card), white 8%);box-shadow: 0 4px 20px 6px var(--background);}-/* Toasts stack under the open find bar: its top, its h-13, then 8px. */-:root:has(.find-bar-surface) [data-sonner-toaster][data-y-position="top"] {+/* Zoom popup: the find bar's corner, drawn in front of the bar when both show. */+.interface-zoom-position {+ top: calc(var(--studio-content-top-inset, 0px) + 3.5rem);+}++/* Nothing notifies JS when these mount, so CSS keeps the portaled bars under them. */+html:has([aria-modal="true"], [data-blocking-screen]) [data-find-bar-layer],+html:has([data-blocking-screen]) .interface-zoom-position {+ display: none;+}++/* Toasts stack under the open find bar: its top, its h-13, then 8px. Not the zoom popup, which+ shares the surface class. */+:root:has([data-find-bar-layer]:not([hidden]) .find-bar-surface) [data-sonner-toaster][data-y-position="top"] {--offset-top: calc(var(--studio-content-top-inset, 0px) + 3.5rem + 3.25rem * var(--ui-space-scale, 1) + 0.5rem) !important;--mobile-offset-top: calc(var(--studio-content-top-inset, 0px) + 3.5rem + 3.25rem * var(--ui-space-scale, 1) + 0.5rem) !important;}diff --git a/studio/frontend/src/lib/z-layers.ts b/studio/frontend/src/lib/z-layers.tsindex da09cd812f9..e3673fb150f 100644--- a/studio/frontend/src/lib/z-layers.ts+++ b/studio/frontend/src/lib/z-layers.ts@@ -18,6 +18,8 @@* STARTUP_SCREEN blocks the app while the backend comes up or quits* TOOLTIP transient, must be readable above whatever spawned it* DRAG_CURSOR_OVERLAY owns the cursor and the hit test during a panel drag+ * WINDOW_BARS find bar, above everything+ * ZOOM_POPUP zoom popup, in front of the find bar** In-page surfaces -- dropdowns, popovers, dialogs, sheets, the sidebar, the* Tauri titlebar -- all sit in the 1..120 band on Tailwind's own `z-*` scale@@ -76,6 +78,10 @@ export const Z_LAYER = {* between pointerdown and pointerup, so nothing it covers is hidden.*/DRAG_CURSOR_OVERLAY: 1000000,+ /** Find bar. Above toasts (999999999), below only the reload snapshot. */+ WINDOW_BARS: 2147483000,+ /** Zoom popup, which shares the find bar's corner and draws in front of it. */+ ZOOM_POPUP: 2147483001,} as const;export type ZLayer = (typeof Z_LAYER)[keyof typeof Z_LAYER];diff --git a/studio/frontend/tests/contrast-slider.test.ts b/studio/frontend/tests/contrast-slider.test.tsindex 463ce4c88d6..7ad5760d104 100644--- a/studio/frontend/tests/contrast-slider.test.ts+++ b/studio/frontend/tests/contrast-slider.test.ts@@ -289,11 +289,9 @@ test("raising lifts palette fills away from their surfaces under any foreground");assert.match(STORE, /setVar\(CONTRAST_PANEL_TARGET_VAR, null\);/);assert.ok(SNAPSHOT.includes('"--contrast-panel-target"'));- // The dark find bar stands in for --card, so it follows the same target.+ // The dark find bar is built on --card, so it follows the same target.assert.ok(- CSS.includes(- "background-color: color-mix(in oklab, #2c2c2c, var(--contrast-panel-target, var(--contrast-target, transparent)) var(--contrast-surface-mix, 0%));",- ),+ CSS.includes("background-color: color-mix(in srgb, var(--card), white 8%);"),);});diff --git a/studio/frontend/tests/desktop-app-menus.test.ts b/studio/frontend/tests/desktop-app-menus.test.tsindex 6345c7c5e5d..e06cf65f758 100644--- a/studio/frontend/tests/desktop-app-menus.test.ts+++ b/studio/frontend/tests/desktop-app-menus.test.ts@@ -316,6 +316,8 @@ test("menu items for web shortcuts follow a mounted handler, and honour claims",// Availability asks claims(), and the root has it re-ask when a modal opens or closes.assert.match(hook, /\(triggers\.get\(id\) \?\? \[\]\)\.some\(\(t\) => t\.claims\(\)\)/);assert.match(hook, /attributeFilter: \["aria-hidden", "inert"\]/);+ // Backdrops portal to body, and Radix skips aria-hidden on anything holding aria-live.+ assert.match(hook, /modalObserver\.observe\(document\.body, \{ childList: true \}\)/);for (const id of ["toggleSidebar", "findInPage", "previousChat", "nextChat"]) {assert.ok(ROOT.includes(`useShortcutAvailable("${id}", isTauri)`), `${id} enables its item`);}@@ -324,9 +326,9 @@ test("menu items for web shortcuts follow a mounted handler, and honour claims",test("Back and Forward follow page history, and zoom steps the interface scale", () => {assert.match(ROOT, /"back": routeShortcutEnabled \? \(\) => window\.history\.back\(\) : null/);assert.match(ROOT, /"forward": routeShortcutEnabled \? \(\) => window\.history\.forward\(\) : null/);- assert.match(ROOT, /"zoom-in": zoomBy\(1\)/);- assert.match(ROOT, /"zoom-out": zoomBy\(-1\)/);- assert.match(ROOT, /"actual-size": \(\) => useInterfaceScaleStore\.getState\(\)\.reset\(\)/);+ assert.match(ROOT, /"zoom-in": \(\) => zoomInterfaceFromMenu\(1\)/);+ assert.match(ROOT, /"zoom-out": \(\) => zoomInterfaceFromMenu\(-1\)/);+ assert.match(ROOT, /"actual-size": \(\) => zoomInterfaceFromMenu\(0\)/);});test("Help items reuse the icon of the Settings tab they open", () => {diff --git a/studio/frontend/tests/find-in-page.test.ts b/studio/frontend/tests/find-in-page.test.tsindex 4a6e6c075e5..1e04e85d526 100644--- a/studio/frontend/tests/find-in-page.test.ts+++ b/studio/frontend/tests/find-in-page.test.ts@@ -1462,20 +1462,46 @@ test("dark mode sits above the cards it floats over", async () => {assert.ok(hex, `no colour in ${declaration}`);return Number.parseInt(hex[0].slice(1, 3), 16);};- // A bar at `--card` dissolves into what scrolls under it; past `--border` it reads as an edge.+ // The bar is `--card` lifted toward white, as the dark sidebar menu is: read how far.+ const whiteMix = (declaration: string) => {+ const hit =+ /color-mix\(in srgb, var\(--card\), white (\d+(?:\.\d+)?)%\)/.exec(+ declaration,+ );+ assert.ok(hit, `not --card mixed toward white: ${declaration}`);+ return Number(hit[1]) / 100;+ };const barDeclaration = value(".dark .find-bar-surface", "background-color");- const bar = grey(barDeclaration);+ // The menu's selector heads two rules (its shadow, then its surface), so find the surface.+ const menuSurface =+ /\.dark :is\(\.unsloth-plus-menu, \.app-user-menu\)\.sidebar-menu\[data-slot\] \{\s*background-color:\s*([^;]+);/.exec(+ INDEX,+ );+ assert.ok(menuSurface, "the dark sidebar menu has no surface colour");+ const menuDeclaration = menuSurface[1];const card = grey(value(".dark", "--card-base"));const border = grey(value(".dark", "--border-base"));+ const lift = (mix: number) => card + (255 - card) * mix;+ const bar = lift(whiteMix(barDeclaration));+ const menu = lift(whiteMix(menuDeclaration));+ // A bar at `--card` dissolves into what scrolls under it; past `--border` it reads as an edge.assert.ok(bar > card, `bar ${bar} is not lighter than --card ${card}`);assert.ok(bar < border, `bar ${bar} is not darker than --border ${border}`);+ // The sidebar menu's surface, a hair lighter: the same family, not a copy.+ assert.ok(+ bar > menu,+ `bar ${bar} is not lighter than the sidebar menu ${menu}`,+ );+ assert.ok(+ bar - menu <= 4,+ `bar ${bar} is more than slightly lighter than ${menu}`,+ );assert.match(value(".dark .find-bar-surface", "box-shadow"),/var\(--background\)/,);- // Both take the same step at the same time, so the order above survives the- // contrast slider instead of holding only at the default.- assert.match(barDeclaration, /var\(--contrast-surface-mix, 0%\)/);+ // Built on --card, which takes the contrast step itself, so the order above+ // survives the contrast slider instead of holding only at the default.assert.match(value("html[data-contrast-adjust]", "--card"),/var\(--contrast-surface-mix\)/,@@ -1483,10 +1509,27 @@ test("dark mode sits above the cards it floats over", async () => {});test("the bar stays out of a backgrounded scope, and off the document origin", async () => {- // Every modal, not just Settings: Radix marks the shell aria-hidden for as long as one is up,- // and `enabled` is read at render, which a dialog opening need not cause.+ // Every modal, not just Settings: `enabled` is read at render, which a dialog opening need not+ // cause. Read from the backdrop, not aria-hidden alone, which Radix never puts on the searched+ // region because it holds live regions (see find-backgrounded.ts).+ assert.match(FIND_BAR, /if \(isFindScopeBackgrounded\(\)\) return;/);+ const backgrounded = await readSrcAsync(+ "features/find-in-page/lib/find-backgrounded.ts",+ );+ for (const slot of ["dialog-overlay", "alert-dialog-overlay", "sheet-overlay"]) {+ assert.ok(backgrounded.includes(`"${slot}"`), `${slot} is not read as a modal`);+ }+ assert.match(backgrounded, /:not\(\[data-state="closed"\]\)/);+ // The chat artifact overlay is a custom modal; the startup and closing screens cover everything.+ assert.ok(backgrounded.includes(`'[aria-modal="true"]'`));+ assert.ok(backgrounded.includes('"[data-blocking-screen]"'));+ // The guided tour renders its own overlay, with the same slot.assert.match(- FIND_BAR,+ await readSrcAsync("features/tour/components/guided-tour.tsx"),+ /<DialogPrimitive\.Overlay asChild>\s*<motion\.div[\s\S]*?data-slot="dialog-overlay"/,+ );+ assert.match(+ backgrounded,/isSurfaceBackgrounded\(`\[\$\{FIND_SCOPE_ATTRIBUTE\}\]`\)/,);// Fixed, not absolute: on a route whose outer container scrolls, an absolute bar scrolls away.@@ -1521,7 +1564,10 @@ test("toasts clear the bar while it is open", () => {assert.match(FIND_BAR, FIND_SURFACE_GEOMETRY);assert.match(FIND_IN_PAGE, FIND_SURFACE_GEOMETRY);const toaster = '[data-sonner-toaster][data-y-position="top"]';- const rule = cssRule(INDEX, `:root:has(.find-bar-surface) ${toaster}`);+ const rule = cssRule(+ INDEX,+ `:root:has([data-find-bar-layer]:not([hidden]) .find-bar-surface) ${toaster}`,+ );assert.match(rule, TOAST_UNDER_FIND_BAR);// The toaster renders outside the chrome wrapper, so the bar's inset has to reach <html>.assert.match(@@ -2633,7 +2679,7 @@ test("Escape closes the bar from the walk buttons, not just the field", async ()/window\.removeEventListener\("keydown", onEscape, true\)/,);// A modal above the bar owns Escape, and an open popover is dismissed by its own first.- assert.match(body, /isSurfaceBackgrounded\(/);+ assert.match(body, /isFindScopeBackgrounded\(\)/);assert.match(body, /resolveDismissiblePortalSurfaces\(/);// And nothing left on the landmark, which would take the inside presses before the window does.const landmark = FIND_BAR.slice(FIND_BAR.indexOf('role="search"'));@@ -2662,7 +2708,7 @@ test("only threads this search can read are forced to finish mounting", async ()test("the chord is left to the browser when the scope is behind a modal", async () => {// `useShortcut` prevents the event BEFORE the handler, so declining inside it kills the chord.const controller = await readComponentSource();- assert.match(controller, /claims: \(\) => !isSurfaceBackgrounded\(/);+ assert.match(controller, /claims: \(\) => !isFindScopeBackgrounded\(\)/);const consume = USE_SHORTCUT.indexOf("event.preventDefault();");assert.ok(consume > 0);assert.ok(diff --git a/studio/frontend/tests/interface-zoom.test.ts b/studio/frontend/tests/interface-zoom.test.tsnew file mode 100644index 00000000000..795aec87cec--- /dev/null+++ b/studio/frontend/tests/interface-zoom.test.ts@@ -0,0 +1,312 @@+// 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 { readdirSync } from "node:fs";+import test from "node:test";++import {+ ZOOM_CHORDS,+ zoomChordTaken,+ zoomDirectionForKey,+} from "../src/features/interface-zoom/lib/zoom-chords.ts";+import {+ WHEEL_ZOOM_IDLE_MS,+ WHEEL_ZOOM_STEP_PX,+ createWheelZoomAccumulator,+ isZoomWheel,+} from "../src/features/interface-zoom/lib/zoom-wheel.ts";+import { readSrc } from "./helpers/kit.ts";++const press = (+ key: string,+ code: string,+ mods: { meta?: boolean; ctrl?: boolean; alt?: boolean; shift?: boolean } = {},+) => ({+ key,+ code,+ metaKey: Boolean(mods.meta),+ ctrlKey: Boolean(mods.ctrl),+ altKey: Boolean(mods.alt),+ shiftKey: Boolean(mods.shift),+});++test("Cmd on macOS and Ctrl elsewhere zoom in, out and back", () => {+ for (const [mac, mod] of [+ [true, { meta: true }],+ [false, { ctrl: true }],+ ] as const) {+ assert.equal(zoomDirectionForKey(press("=", "Equal", mod), mac), 1);+ assert.equal(zoomDirectionForKey(press("+", "Equal", mod), mac), 1);+ assert.equal(zoomDirectionForKey(press("-", "Minus", mod), mac), -1);+ assert.equal(zoomDirectionForKey(press("_", "Minus", mod), mac), -1);+ assert.equal(zoomDirectionForKey(press("0", "Digit0", mod), mac), 0);+ }+});++test("the keypad zooms too", () => {+ const ctrl = { ctrl: true };+ assert.equal(zoomDirectionForKey(press("+", "NumpadAdd", ctrl), false), 1);+ assert.equal(+ zoomDirectionForKey(press("-", "NumpadSubtract", ctrl), false),+ -1,+ );+ assert.equal(zoomDirectionForKey(press("0", "Numpad0", ctrl), false), 0);+});++test("a layout's own + key zooms, and the physical keys still do when they type something else", () => {+ // German: + has its own key (BracketRight); AZERTY: Digit0 types "à".+ assert.equal(+ zoomDirectionForKey(press("+", "BracketRight", { ctrl: true }), false),+ 1,+ );+ assert.equal(+ zoomDirectionForKey(press("à", "Digit0", { ctrl: true }), false),+ 0,+ );+ assert.equal(+ zoomDirectionForKey(press("ß", "Minus", { ctrl: true }), false),+ -1,+ );+});++test("the wrong modifier, Alt, or no modifier leaves the key alone", () => {+ assert.equal(+ zoomDirectionForKey(press("=", "Equal", { ctrl: true }), true),+ null,+ );+ assert.equal(+ zoomDirectionForKey(press("=", "Equal", { meta: true }), false),+ null,+ );+ assert.equal(+ zoomDirectionForKey(press("=", "Equal", { meta: true, alt: true }), true),+ null,+ );+ assert.equal(+ zoomDirectionForKey(press("=", "Equal", { meta: true, ctrl: true }), true),+ null,+ );+ assert.equal(zoomDirectionForKey(press("-", "Minus"), false), null);+ assert.equal(+ zoomDirectionForKey(press("a", "KeyA", { ctrl: true }), false),+ null,+ );+});++test("a user shortcut on the exact keys pressed wins over a zoom alias", () => {+ const ctrlShiftPlus = press("+", "Equal", { ctrl: true, shift: true });+ const ownedBy = (values: string[]) => (value: string) =>+ values.includes(value);+ // Nothing bound: the alias zooms.+ assert.equal(zoomChordTaken(ctrlShiftPlus, 1, false, ownedBy([])), false);+ // Bound to Ctrl+Shift+= itself: that shortcut runs instead.+ assert.equal(+ zoomChordTaken(ctrlShiftPlus, 1, false, ownedBy(["Mod+Shift+Equal"])),+ true,+ );+ // Bound to the canonical chord: every alias steps aside too, as before.+ assert.equal(+ zoomChordTaken(ctrlShiftPlus, 1, false, ownedBy(["Mod+Equal"])),+ true,+ );+ // Keypad and macOS Cmd presses are checked the same way.+ const keypad = press("+", "NumpadAdd", { ctrl: true });+ assert.equal(+ zoomChordTaken(keypad, 1, false, ownedBy(["Mod+NumpadAdd"])),+ true,+ );+ const cmdShiftPlus = press("+", "Equal", { meta: true, shift: true });+ assert.equal(+ zoomChordTaken(cmdShiftPlus, 1, true, ownedBy(["Mod+Shift+Equal"])),+ true,+ );+ assert.equal(+ zoomChordTaken(cmdShiftPlus, 1, true, ownedBy(["Mod+Shift+Minus"])),+ false,+ );+});++test("the chords match the ones the View menu shows", () => {+ const chords = readSrc("app/app-menu-chords.ts");+ assert.ok(chords.includes(`"zoom-in": { chord: "${ZOOM_CHORDS[1]}" }`));+ assert.ok(chords.includes(`"zoom-out": { chord: "${ZOOM_CHORDS[-1]}" }`));+ assert.ok(chords.includes(`"actual-size": { chord: "${ZOOM_CHORDS[0]}" }`));+});++test("the popup is mounted on every route and only takes chords in the desktop app", () => {+ const root = readSrc("app/routes/__root.tsx");+ const zoom = readSrc("features/interface-zoom/components/interface-zoom.tsx");+ assert.match(root, /<InterfaceZoom \/>/);+ assert.match(zoom, /if \(!isTauri\) return;/);+ assert.match(+ zoom,+ /if \(zoomChordTaken\(event, direction, mac, owned\)\) return;/,+ );+});++test("one Ctrl+wheel notch is one step, up zooms in, and a pause starts over", () => {+ const step = createWheelZoomAccumulator();+ const wheel = (+ deltaY: number,+ timeStamp: number,+ mods: { ctrl?: boolean } = { ctrl: true },+ ) => ({+ deltaY,+ deltaMode: 0,+ ctrlKey: Boolean(mods.ctrl),+ metaKey: false,+ altKey: false,+ timeStamp,+ });+ // A Windows notch is 100px: one step, not two.+ assert.equal(step(wheel(-100, 0), 1), 1);+ assert.equal(step(wheel(100, 400), 1), -1);+ // Without Ctrl, a wheel scrolls.+ assert.equal(step(wheel(-100, 800, {}), 1), null);+ // A touchpad pinch arrives in small pieces and steps once it has travelled far enough.+ assert.equal(step(wheel(-20, 1200), 1), null);+ assert.equal(step(wheel(-20, 1210), 1), null);+ assert.equal(step(wheel(-20, 1220), 1), 1);+ // Leftover travel does not carry over a pause.+ assert.equal(step(wheel(-40, 1300), 1), null);+ assert.equal(step(wheel(-40, 1300 + WHEEL_ZOOM_IDLE_MS + 1), 1), null);+ // Deltas come in CSS pixels, which shrink as the zoom grows: at 200% a notch reads 50.+ assert.equal(step(wheel(-50, 5000), 2), 1);+ assert.equal(step(wheel(-25, 6000), 1), null);+ assert.ok(WHEEL_ZOOM_STEP_PX <= 50);+});++test("only a vertical Ctrl+wheel without Alt or Meta zooms", () => {+ const wheel = { deltaY: -100, ctrlKey: true, metaKey: false, altKey: false };+ assert.equal(isZoomWheel(wheel), true);+ assert.equal(isZoomWheel({ ...wheel, ctrlKey: false }), false);+ assert.equal(isZoomWheel({ ...wheel, altKey: true }), false);+ assert.equal(isZoomWheel({ ...wheel, metaKey: true }), false);+ // Ctrl+horizontal wheel keeps its default.+ assert.equal(isZoomWheel({ ...wheel, deltaY: 0 }), false);+});++test("the popup keeps one on-screen size and does not dismiss a modal", () => {+ const zoom = readSrc("features/interface-zoom/components/interface-zoom.tsx");+ // The page zoom is divided back out.+ assert.match(zoom, /\{ zoom: 1 \/ pageZoom \}/);+ assert.match(+ zoom,+ /onPointerDown=\{\(event\) => event\.stopPropagation\(\)\}/,+ );+ assert.match(zoom, /pointer-events-auto/);+ // The live region outlives the popup, so the first zoom is announced too.+ assert.match(+ zoom,+ /\{isTauri && <ZoomAnnouncer open=\{open\} \/>\}\s*\{open && <ZoomPopup \/>\}/,+ );+ // Canvases that zoom on Ctrl+wheel themselves get the event first; macOS keeps its own.+ // Only a wheel the accumulator would take is prevented.+ assert.match(+ zoom,+ /if \(event\.defaultPrevented \|\| !isZoomWheel\(event\)\) return;\s*event\.preventDefault\(\);/,+ );+ assert.match(+ zoom,+ /if \(!mac\) window\.addEventListener\("wheel", onWheel, \{ passive: false \}\)/,+ );+ // Below the shortcut recorder's window capture listener, so recording Mod+= does not zoom.+ assert.match(zoom, /document\.addEventListener\("keydown", onKeyDown, true\)/);+ assert.match(+ readSrc("features/settings/tabs/keyboard-shortcuts-tab.tsx"),+ /event\.stopPropagation\(\);[\s\S]*window\.addEventListener\("keydown", onKeyDown, \{ capture: true \}\)/,+ );+});++test("the zoom popup takes the find bar's corner", () => {+ const css = readSrc("index.css");+ const provider = readSrc("app/provider.tsx");+ const findBar = readSrc("features/find-in-page/components/find-bar.tsx");+ const findInPage = readSrc(+ "features/find-in-page/components/find-in-page.tsx",+ );+ // The wrapper's inset, mirrored onto <html> where both body-portaled bars read it.+ assert.match(provider, /"--studio-content-top-inset": "34px"/);+ assert.match(+ provider,+ /set\("--studio-content-top-inset", usesCustomTitlebar \? "34px" : null\);/,+ );+ const top =+ /top-\[calc\(var\(--studio-content-top-inset,0px\)\+3\.5rem\)\] right-4 z-50 flex h-13/;+ assert.match(findBar, top);+ assert.match(findInPage, top);+ assert.match(+ css,+ /\.interface-zoom-position \{\s*top: calc\(var\(--studio-content-top-inset, 0px\) \+ 3\.5rem\);/,+ );+ // One place only: it does not move out from under an open find bar.+ assert.equal(css.match(/^\.interface-zoom-position \{/gm)?.length, 1);+ // Under the startup and closing screens, like the find bar.+ assert.match(+ css,+ /html:has\(\[aria-modal="true"\], \[data-blocking-screen\]\) \[data-find-bar-layer\],\s*html:has\(\[data-blocking-screen\]\) \.interface-zoom-position \{\s*display: none;/,+ );+ assert.match(provider, /data-blocking-screen=""\s*className="fixed inset-0 z-40 bg-background"/);+ assert.match(+ readSrc("components/tauri/startup-screen.tsx"),+ /data-blocking-screen=""\s*className="pointer-events-auto fixed inset-0 z-\[9999\]"/,+ );+ // A little smaller than the bar.+ assert.match(+ readSrc("features/interface-zoom/components/interface-zoom.tsx"),+ /find-bar-surface flex h-11 /,+ );+});++test("both bars paint over everything, the zoom popup in front of the find bar", () => {+ const layers = readSrc("lib/z-layers.ts");+ const layer = (name: string) =>+ Number(new RegExp(`^ ${name}: (\\d+),$`, "m").exec(layers)?.[1]);+ const bars = layer("WINDOW_BARS");+ assert.ok(layer("ZOOM_POPUP") > bars);+ for (const [, name, value] of /^ {2}([A-Z_]+): (\d+),$/gm[Symbol.matchAll](+ layers,+ )) {+ if (name !== "WINDOW_BARS" && name !== "ZOOM_POPUP")+ assert.ok(bars > Number(value), `${name} is not under the bars`);+ }+ // Every literal number in the app (classes, the stylesheet, inline styles) and the toaster's,+ // bar the reload snapshot.+ const sonner = readSrc("../node_modules/sonner/dist/styles.css");+ const sources = readdirSync(new URL("../src/", import.meta.url), {+ recursive: true,+ })+ .map(String)+ .filter((file) => /\.(tsx?|css)$/.test(file))+ .map((file) => readSrc(file));+ const numbers = [+ ...sources.flatMap((text) => [+ ...text.matchAll(/z-index:\s*(\d+)/g),+ ...text.matchAll(/\bz-\[(\d+)\]/g),+ ...text.matchAll(/zIndex(?:\s*=|:)\s*"?(\d+)/g),+ ]),+ ...sonner.matchAll(/z-index:\s*(\d+)/g),+ ]+ .map((hit) => Number(hit[1]))+ .filter((value) => value !== 2147483647);+ assert.ok(numbers.includes(999999999), "the toaster's layer was not read");+ for (const value of numbers)+ assert.ok(bars > value, `z-index ${value} is over the bars`);+ assert.ok(layer("ZOOM_POPUP") < 2147483647);+ // Both are portaled to <body> onto that layer, out of every stacking context in the shell.+ const findInPage = readSrc(+ "features/find-in-page/components/find-in-page.tsx",+ );+ const zoom = readSrc("features/interface-zoom/components/interface-zoom.tsx");+ assert.match(+ findInPage,+ /createPortal\(\s*<div\s+data-find-bar-layer=""\s+hidden=\{!foreground\}\s+className="fixed top-0 right-0"\s+style=\{\{ zIndex: Z_LAYER\.WINDOW_BARS \}\}/,+ );+ assert.match(findInPage, /document\.body,\s*\);\s*\}\s*$/);+ assert.match(+ zoom,+ /interface-zoom-position pointer-events-auto fixed right-4"\s+style=\{\{ zIndex: Z_LAYER\.ZOOM_POPUP \}\}/,+ );+ assert.match(zoom, /createPortal\([\s\S]*document\.body,\s*\);/);+});diff --git a/studio/frontend/tests/z-layers.test.ts b/studio/frontend/tests/z-layers.test.tsindex 885949c7343..a27be6b0f56 100644--- a/studio/frontend/tests/z-layers.test.ts+++ b/studio/frontend/tests/z-layers.test.ts@@ -20,6 +20,8 @@ const ORDER = ["STARTUP_SCREEN","TOOLTIP","DRAG_CURSOR_OVERLAY",+ "WINDOW_BARS",+ "ZOOM_POPUP",] as const;test("the named layers are strictly ordered", () => {