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 Desktop: keep a maximized window above the Windows taskbar (#13647)

Daniel Hancbf0f593d5a2
diff --git a/studio/frontend/src/app/provider.tsx b/studio/frontend/src/app/provider.tsx
index 8b21fe70544..c1f04381032 100644
--- a/studio/frontend/src/app/provider.tsx
+++ b/studio/frontend/src/app/provider.tsx
@@ -85,8 +85,10 @@ import {
} from "./window-layout";
import {
type MeasuredWindowLayout,
+ type MinimumSizeApplier,
type PixelRatioSource,
type WindowLayoutGuard,
+ createMinimumSizeApplier,
finalizeAppWindowLayout,
measureWindowLayout,
observeDevicePixelRatio,
@@ -222,6 +224,29 @@ function measureTauriWindowLayout(
);
}
+let minimumSizeApplier: MinimumSizeApplier | null = null;
+
+// One per app: the main window is the only one sized here.
+function windowMinimumSize(win: TauriWindow): MinimumSizeApplier {
+ minimumSizeApplier ??= createMinimumSizeApplier({
+ isRestored: async () => {
+ const [maximized, fullscreen, minimized] = await Promise.all([
+ win.isMaximized(),
+ win.isFullscreen(),
+ win.isMinimized(),
+ ]);
+ return !maximized && !fullscreen && !minimized;
+ },
+ onResized: (handler) => win.onResized(handler),
+ applyFloor: (minimum) =>
+ win.setSizeConstraints({
+ minWidth: minimum.width,
+ minHeight: minimum.height,
+ }),
+ });
+ return minimumSizeApplier;
+}
+
async function placeWindow(
win: TauriWindow,
{ LogicalSize, PhysicalPosition }: WindowModule,
@@ -274,10 +299,7 @@ async function reapplyWindowSizeConstraints(
if (!measured || !isCurrent()) return;
const { minimum } = measured.bounds;
- await win.setSizeConstraints({
- minWidth: minimum.width,
- minHeight: minimum.height,
- });
+ await windowMinimumSize(win).apply(minimum);
if (!isCurrent()) return;
// Grows a window now under the floor. No maximum: the work area has not
// changed, and capping here would fight a user's own larger size.
@@ -296,7 +318,10 @@ async function showSetupWindow(isCurrent: WindowLayoutGuard): Promise<void> {
!(await prepareSetupWindow({
resetLayout: () => invoke("reset_app_window_layout_initialized"),
unmaximize: () => win.unmaximize(),
- clearConstraints: () => win.setSizeConstraints(null),
+ clearConstraints: () => {
+ windowMinimumSize(win).cancel();
+ return win.setSizeConstraints(null);
+ },
enableResize: () => win.setResizable(true),
resizeForSetup: async () => {
const measured = await measureTauriWindowLayout(
@@ -421,11 +446,7 @@ async function applyAppWindowLayout(
? undefined
: layoutObserver?.waitForSettled,
measure: () => measureTauriWindowLayout(windowModule, win, isCurrent),
- setMinimumConstraints: (minimum) =>
- win.setSizeConstraints({
- minWidth: minimum.width,
- minHeight: minimum.height,
- }),
+ setMinimumConstraints: (minimum) => windowMinimumSize(win).apply(minimum),
enforceBounds: (bounds) =>
enforceWindowSizeBounds(
win,
diff --git a/studio/frontend/src/app/window-layout-lifecycle.ts b/studio/frontend/src/app/window-layout-lifecycle.ts
index 173b51dc4e2..017205638f5 100644
--- a/studio/frontend/src/app/window-layout-lifecycle.ts
+++ b/studio/frontend/src/app/window-layout-lifecycle.ts
@@ -218,3 +218,62 @@ export async function finalizeAppWindowLayout<Monitor extends WorkAreaMonitor>({
restored ? { minimum: measured.bounds.minimum } : measured.bounds,
);
}
+
+type MinimumSizeWindow = {
+ isRestored: () => Promise<boolean>;
+ onResized: (handler: () => void) => Promise<() => void>;
+ applyFloor: (minimum: LogicalWindowSize) => Promise<void>;
+};
+
+export type MinimumSizeApplier = {
+ apply: (minimum: LogicalWindowSize) => Promise<void>;
+ /** Drops a floor still waiting, e.g. before setup clears the constraints. */
+ cancel: () => void;
+};
+
+/**
+ * tao applies a size floor by resizing the window to its own inner size, which drops
+ * maximized first: a maximized window comes back unmaximized at full-screen size, its
+ * bottom under the Windows taskbar (#13616). The floor only matters to a restored
+ * window, so a call made while maximized, fullscreen or minimized waits for the restore.
+ */
+export function createMinimumSizeApplier(
+ win: MinimumSizeWindow,
+): MinimumSizeApplier {
+ let pending: LogicalWindowSize | null = null;
+ let listening: Promise<() => void> | null = null;
+
+ const stopListening = () => {
+ const unlisten = listening;
+ listening = null;
+ unlisten?.then((stop) => stop()).catch(() => undefined);
+ };
+
+ const flush = async () => {
+ if (!pending || !(await win.isRestored()) || !pending) return;
+ const minimum = pending;
+ pending = null;
+ stopListening();
+ await win.applyFloor(minimum);
+ };
+
+ return {
+ apply: async (minimum) => {
+ pending = minimum;
+ if (await win.isRestored()) {
+ await flush();
+ return;
+ }
+ listening ??= win.onResized(() => {
+ flush().catch(() => undefined);
+ });
+ await listening;
+ // A restore that landed while the listener was registering sent no resize here.
+ await flush();
+ },
+ cancel: () => {
+ pending = null;
+ stopListening();
+ },
+ };
+}
diff --git a/studio/frontend/tests/window-layout.test.ts b/studio/frontend/tests/window-layout.test.ts
index 1f39f98e301..b3c00610b41 100644
--- a/studio/frontend/tests/window-layout.test.ts
+++ b/studio/frontend/tests/window-layout.test.ts
@@ -5,6 +5,7 @@ import assert from "node:assert/strict";
import test from "node:test";
import {
+ createMinimumSizeApplier,
finalizeAppWindowLayout,
measureWindowLayout,
observeDevicePixelRatio,
@@ -589,3 +590,83 @@ test("stale layouts do not show the window", async () => {
assert.equal(shown, false);
});
+
+function fakeMinimumSizeWindow(restored: boolean) {
+ const state = {
+ restored,
+ applied: [] as { width: number; height: number }[],
+ handlers: [] as (() => void)[],
+ unlistened: 0,
+ };
+ const applier = createMinimumSizeApplier({
+ isRestored: async () => state.restored,
+ onResized: async (handler) => {
+ state.handlers.push(handler);
+ return () => {
+ state.unlistened += 1;
+ };
+ },
+ applyFloor: async (minimum) => {
+ state.applied.push(minimum);
+ },
+ });
+ const resize = async (nextRestored: boolean) => {
+ state.restored = nextRestored;
+ for (const handler of state.handlers) handler();
+ await new Promise((resolve) => setTimeout(resolve, 0));
+ };
+ return { state, applier, resize };
+}
+
+test("a restored window gets its floor at once", async () => {
+ const { state, applier } = fakeMinimumSizeWindow(true);
+ await applier.apply({ width: 900, height: 600 });
+ assert.deepEqual(state.applied, [{ width: 900, height: 600 }]);
+ assert.equal(state.handlers.length, 0);
+});
+
+test("a maximized window keeps maximized until it is restored", async () => {
+ const { state, applier, resize } = fakeMinimumSizeWindow(false);
+ await applier.apply({ width: 900, height: 600 });
+ await applier.apply({ width: 960, height: 640 });
+ assert.deepEqual(state.applied, []);
+ assert.equal(state.handlers.length, 1);
+
+ await resize(false);
+ assert.deepEqual(state.applied, []);
+
+ await resize(true);
+ assert.deepEqual(state.applied, [{ width: 960, height: 640 }]);
+ assert.equal(state.unlistened, 1);
+
+ await resize(true);
+ assert.equal(state.applied.length, 1);
+});
+
+test("a restore during listener setup still applies the floor", async () => {
+ const applied: { width: number; height: number }[] = [];
+ let restored = false;
+ const applier = createMinimumSizeApplier({
+ isRestored: async () => restored,
+ onResized: async () => {
+ restored = true;
+ return () => undefined;
+ },
+ applyFloor: async (minimum) => {
+ applied.push(minimum);
+ },
+ });
+ await applier.apply({ width: 900, height: 600 });
+ assert.deepEqual(applied, [{ width: 900, height: 600 }]);
+});
+
+test("setup cancels a floor still waiting for the restore", async () => {
+ const { state, applier, resize } = fakeMinimumSizeWindow(false);
+ await applier.apply({ width: 900, height: 600 });
+ applier.cancel();
+ await new Promise((resolve) => setTimeout(resolve, 0));
+ assert.equal(state.unlistened, 1);
+
+ await resize(true);
+ assert.deepEqual(state.applied, []);
+});