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.

Desktop: fix the mobile-layout fallout of Windows text scaling (#7927)

Daniel Han43407d76b3ab
diff --git a/studio/frontend/src/app/provider.tsx b/studio/frontend/src/app/provider.tsx
index e41fc2e149d..3abc1c6c6b8 100644
--- a/studio/frontend/src/app/provider.tsx
+++ b/studio/frontend/src/app/provider.tsx
@@ -57,6 +57,16 @@ const MINIMUM_APP_WINDOW_SIZE: LogicalWindowSize = {
width: MIN_WINDOW_WIDTH,
height: MIN_WINDOW_HEIGHT,
};
+// Keep in step with MOBILE_BREAKPOINT in hooks/use-mobile.ts.
+const MIN_DESKTOP_LAYOUT_WIDTH = 768;
+
+// Logical px per CSS px: webview zoom above the display scale (Windows text
+// scaling); 1 if none.
+function logicalPerCssPx(monitorScale: number): number {
+ if (typeof window === "undefined" || !(monitorScale > 0)) return 1;
+ const ratio = window.devicePixelRatio / monitorScale;
+ return Number.isFinite(ratio) && ratio > 1 ? ratio : 1;
+}
async function showSetupWindow(isCurrent: WindowLayoutGuard): Promise<void> {
const { getCurrentWindow, LogicalSize } = await import(
@@ -154,7 +164,17 @@ async function applyAppWindowLayout(
const scale = monitor.scaleFactor;
const screenW = monitor.size.width / scale;
const screenH = monitor.size.height / scale;
- finalW = Math.max(MIN_WINDOW_WIDTH, Math.round(screenW * 0.75));
+ finalW = Math.max(
+ MIN_WINDOW_WIDTH,
+ Math.round(screenW * 0.75),
+ // Windows text scaling shrinks CSS px, so the window would open under
+ // the sidebar's mobile breakpoint. No-op elsewhere; never exceed the
+ // screen.
+ Math.min(
+ Math.round(MIN_DESKTOP_LAYOUT_WIDTH * logicalPerCssPx(scale)),
+ Math.round(screenW),
+ ),
+ );
const targetH = Math.max(MIN_WINDOW_HEIGHT, Math.round(finalW / 1.618));
finalH = Math.min(targetH, Math.round(screenH * 0.85));
}
diff --git a/studio/frontend/src/components/navbar.tsx b/studio/frontend/src/components/navbar.tsx
index deb3755f388..5c93be4bd0a 100644
--- a/studio/frontend/src/components/navbar.tsx
+++ b/studio/frontend/src/components/navbar.tsx
@@ -3,14 +3,17 @@
import {
DesktopTitlebarNavigation,
+ shouldUseCustomWindowTitlebar,
shouldUseNativeMacWindowTitlebar,
} from "@/components/tauri/window-titlebar";
import { SidebarTrigger, useSidebar } from "@/components/ui/sidebar";
+import { cn } from "@/lib/utils";
import { useState } from "react";
export function Navbar() {
const { isMobile, pinned, togglePinned } = useSidebar();
const [usesNativeMacTitlebar] = useState(shouldUseNativeMacWindowTitlebar);
+ const [usesCustomTitlebar] = useState(shouldUseCustomWindowTitlebar);
if (!isMobile) {
return (
@@ -35,9 +38,25 @@ export function Navbar() {
</>
);
}
+ // Desktop windows can land here under Windows text scaling, so sit inside the
+ // custom titlebar band instead of under its z-[70].
return (
- <header className="absolute top-0 inset-x-0 z-[45] h-[48px] pointer-events-none">
- <div className="flex h-full items-start pt-[11px] pl-2">
+ <header
+ className={cn(
+ "absolute top-0 inset-x-0 pointer-events-none",
+ usesCustomTitlebar
+ ? "z-[80] h-[var(--studio-custom-titlebar-height,34px)]"
+ : "z-[45] h-[48px]",
+ )}
+ >
+ <div
+ className={cn(
+ "flex h-full",
+ usesCustomTitlebar
+ ? "items-center pl-3"
+ : "items-start pt-[11px] pl-2",
+ )}
+ >
<SidebarTrigger className="pointer-events-auto !size-[34px]" />
</div>
</header>
diff --git a/studio/frontend/src/components/tauri/window-titlebar.tsx b/studio/frontend/src/components/tauri/window-titlebar.tsx
index 989856ce94f..09ac6345878 100644
--- a/studio/frontend/src/components/tauri/window-titlebar.tsx
+++ b/studio/frontend/src/components/tauri/window-titlebar.tsx
@@ -1,6 +1,7 @@
// 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 { useIsMobile } from "@/hooks/use-mobile";
import { useSidebarPin } from "@/hooks/use-sidebar-pin";
import { useSidebarWidth } from "@/hooks/use-sidebar-width";
import { isTauri } from "@/lib/api-base";
@@ -109,10 +110,13 @@ export function DesktopTitlebarNavigation({
expanded,
onToggleSidebar,
className,
+ showSidebarToggle = true,
}: {
expanded: boolean;
onToggleSidebar: () => void;
className?: string;
+ /** Off in mobile, where Navbar's SidebarTrigger owns the slot; a spacer holds it open. */
+ showSidebarToggle?: boolean;
}): ReactElement {
const stopTitlebarDrag = (event: MouseEvent<HTMLButtonElement>) => {
event.stopPropagation();
@@ -129,24 +133,28 @@ export function DesktopTitlebarNavigation({
role="toolbar"
aria-label="Sidebar and page navigation"
>
- <button
- type="button"
- title={expanded ? "Collapse sidebar" : "Expand sidebar"}
- aria-label={expanded ? "Collapse sidebar" : "Expand sidebar"}
- onMouseDown={stopTitlebarDrag}
- onDoubleClick={stopTitlebarDrag}
- onClick={(event) => {
- event.stopPropagation();
- onToggleSidebar();
- }}
- className={buttonClass}
- >
- <HugeiconsIcon
- icon={LayoutAlignLeftIcon}
- strokeWidth={1.75}
- className="size-icon"
- />
- </button>
+ {showSidebarToggle ? (
+ <button
+ type="button"
+ title={expanded ? "Collapse sidebar" : "Expand sidebar"}
+ aria-label={expanded ? "Collapse sidebar" : "Expand sidebar"}
+ onMouseDown={stopTitlebarDrag}
+ onDoubleClick={stopTitlebarDrag}
+ onClick={(event) => {
+ event.stopPropagation();
+ onToggleSidebar();
+ }}
+ className={buttonClass}
+ >
+ <HugeiconsIcon
+ icon={LayoutAlignLeftIcon}
+ strokeWidth={1.75}
+ className="size-icon"
+ />
+ </button>
+ ) : (
+ <div aria-hidden="true" className="size-[33px] shrink-0" />
+ )}
<button
type="button"
title="Go back"
@@ -195,6 +203,8 @@ export function WindowTitlebar({
const [enabled] = useState(shouldUseCustomWindowTitlebar);
const [maximized, setMaximized] = useState(false);
const { pinned, togglePinned } = useSidebarPin();
+ // Outside SidebarProvider, so read the same media query the provider does.
+ const isMobile = useIsMobile();
const maximizeRefreshSequence = useRef(0);
const maximizeRefreshTimer = useRef<number | null>(null);
@@ -381,6 +391,7 @@ export function WindowTitlebar({
<DesktopTitlebarNavigation
expanded={pinned}
onToggleSidebar={togglePinned}
+ showSidebarToggle={!isMobile}
/>
</div>
)}
diff --git a/studio/frontend/src/features/settings/components/settings-row.tsx b/studio/frontend/src/features/settings/components/settings-row.tsx
index 3cf9822811a..f50286350ad 100644
--- a/studio/frontend/src/features/settings/components/settings-row.tsx
+++ b/studio/frontend/src/features/settings/components/settings-row.tsx
@@ -26,7 +26,10 @@ export function SettingsRow({
<div
data-settings-label={label}
className={cn(
- "flex justify-between gap-6 py-3",
+ // Controls are fixed-width and shrink-0, so an unwrapped row starves the
+ // label. justify-end right-aligns a wrapped control without breaking
+ // items-stretch for flex-col callers.
+ "flex flex-wrap justify-end gap-x-6 gap-y-2 py-3",
alignTop ? "items-start" : "items-center",
destructive && "border-t border-border/60 mt-2 pt-4",
className,
@@ -34,7 +37,8 @@ export function SettingsRow({
>
<div
className={cn(
- "flex min-w-0 gap-2.5",
+ // Widest floor that leaves already-fitting rows unchanged.
+ "flex min-w-[11rem] flex-1 basis-0 gap-2.5",
alignTop ? "items-start" : "items-center",
)}
>
@@ -55,9 +59,8 @@ export function SettingsRow({
{children ? (
<div
className={cn(
- "flex shrink-0",
- // Drop the control past the label row so it lines up with the first
- // description line instead of the label.
+ "flex max-w-full shrink-0",
+ // Line the control up with the first description line, not the label.
alignTop ? "items-start pt-[21px]" : "items-center",
)}
>