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: preserve first app window size after setup (#7659)

oobaboogac67e6c02b508
diff --git a/studio/frontend/src/app/provider.tsx b/studio/frontend/src/app/provider.tsx
index b076c8cf8d6..356cde3a57c 100644
--- a/studio/frontend/src/app/provider.tsx
+++ b/studio/frontend/src/app/provider.tsx
@@ -42,11 +42,19 @@ interface AppProviderProps {
type TauriWindowMode = "setup" | "app";
type WindowLayoutGuard = () => boolean;
+type LogicalWindowSize = {
+ width: number;
+ height: number;
+};
const MIN_WINDOW_WIDTH = 900;
const MIN_WINDOW_HEIGHT = 600;
const SETUP_WINDOW_WIDTH = 760;
const SETUP_WINDOW_HEIGHT = 560;
+const MINIMUM_APP_WINDOW_SIZE: LogicalWindowSize = {
+ width: MIN_WINDOW_WIDTH,
+ height: MIN_WINDOW_HEIGHT,
+};
async function showSetupWindow(isCurrent: WindowLayoutGuard): Promise<void> {
const { getCurrentWindow, LogicalSize } = await import(
@@ -73,6 +81,7 @@ async function enforceMinimumWindowSize(
>,
LogicalSize: typeof import("@tauri-apps/api/window")["LogicalSize"],
isCurrent: WindowLayoutGuard,
+ requestedSize: LogicalWindowSize = MINIMUM_APP_WINDOW_SIZE,
): Promise<void> {
const [innerSize, scaleFactor] = await Promise.all([
win.innerSize(),
@@ -82,8 +91,19 @@ async function enforceMinimumWindowSize(
const logicalWidth = Math.round(innerSize.width / scaleFactor);
const logicalHeight = Math.round(innerSize.height / scaleFactor);
- const nextWidth = Math.max(logicalWidth, MIN_WINDOW_WIDTH);
- const nextHeight = Math.max(logicalHeight, MIN_WINDOW_HEIGHT);
+ // Linux reports innerSize from a cache updated by configure events. The
+ // AppImage's bundled GTK can deliver that event after this check, leaving the
+ // old setup size in the cache even though the first app resize has completed.
+ const nextWidth = Math.max(
+ logicalWidth,
+ MIN_WINDOW_WIDTH,
+ requestedSize.width,
+ );
+ const nextHeight = Math.max(
+ logicalHeight,
+ MIN_WINDOW_HEIGHT,
+ requestedSize.height,
+ );
if (nextWidth !== logicalWidth || nextHeight !== logicalHeight) {
await win.setSize(new LogicalSize(nextWidth, nextHeight));
}
@@ -115,6 +135,7 @@ async function applyAppWindowLayout(
await win.setResizable(true);
if (!isCurrent()) return;
+ let requestedSize: LogicalWindowSize | undefined;
if (hasInitializedAppLayout && hasSavedState) {
// Subsequent launch: plugin restores size/position/maximized, with built-in
// off-screen protection for positions saved on a now-disconnected display.
@@ -135,6 +156,7 @@ async function applyAppWindowLayout(
const targetH = Math.max(MIN_WINDOW_HEIGHT, Math.round(finalW / 1.618));
finalH = Math.min(targetH, Math.round(screenH * 0.85));
}
+ requestedSize = { width: finalW, height: finalH };
await win.setSize(new LogicalSize(finalW, finalH));
if (!isCurrent()) return;
await win.center();
@@ -149,7 +171,7 @@ async function applyAppWindowLayout(
minHeight: MIN_WINDOW_HEIGHT,
});
if (!isCurrent()) return;
- await enforceMinimumWindowSize(win, LogicalSize, isCurrent);
+ await enforceMinimumWindowSize(win, LogicalSize, isCurrent, requestedSize);
if (!isCurrent()) return;
await invoke("mark_app_window_layout_initialized");
diff --git a/tests/studio/test_desktop_reliability_frontend_contract.py b/tests/studio/test_desktop_reliability_frontend_contract.py
index 4848a825359..5e57375abae 100644
--- a/tests/studio/test_desktop_reliability_frontend_contract.py
+++ b/tests/studio/test_desktop_reliability_frontend_contract.py
@@ -197,6 +197,21 @@ def test_full_app_layout_uses_its_own_initialized_marker():
assert "hasInitializedAppLayout && hasSavedState" in source
+def test_first_app_layout_survives_a_stale_setup_window_size():
+ source = APP_PROVIDER.read_text(encoding = "utf-8")
+ minimum_helper = source.split("async function enforceMinimumWindowSize", 1)[1].split(
+ "async function applyAppWindowLayout", 1
+ )[0]
+ app_layout = source.split("async function applyAppWindowLayout", 1)[1].split(
+ "async function showWindowFallback", 1
+ )[0]
+
+ assert "requestedSize.width" in minimum_helper
+ assert "requestedSize.height" in minimum_helper
+ assert "requestedSize = { width: finalW, height: finalH };" in app_layout
+ assert "enforceMinimumWindowSize(win, LogicalSize, isCurrent, requestedSize)" in app_layout
+
+
def test_expanded_titlebar_button_and_corner_match_sidebar_edge():
source = TITLEBAR.read_text(encoding = "utf-8")