Skip to content

Unsloth Desktop: keep the page sized to the window after a fast resize on Windows - #12542

Closed
LeoBorcherding wants to merge 3 commits into
unslothai:mainfrom
LeoBorcherding:desktop-webview-bounds-resync
Closed

LeoBorcherding wants to merge 3 commits into
unslothai:mainfrom
LeoBorcherding:desktop-webview-bounds-resync

Conversation

@LeoBorcherding

@LeoBorcherding LeoBorcherding commented Oct 2, 2026 •

Copy link
Copy Markdown
Collaborator

On Windows, dragging the window edge quickly can leave the page stuck at an older size: the window grows, but the titlebar, sidebar and chat stop short, leaving a blank strip on the right and bottom.

Unsloth Desktop draws its own titlebar on Windows, so the native frame is turned off. In that mode wry resizes the WebView2 on WM_SIZE, but it moves the WebView's container window with SWP_ASYNCWINDOWPOS. During a fast drag, the container can end up behind the window. The page CSS is all sized relative to the viewport, so the stuck piece is the WebView bounds, not the layout.

This adds a Windows-only handler for Resized and ScaleFactorChanged. It re-reads the current client rect and resizes the container and the WebView2 controller to it synchronously. Because it reads the size when it runs instead of trusting the event, a stale event still ends up at the right size. Minimized windows are skipped. There are no frontend changes and nothing changes on macOS or Linux.

before (285d157a41) after (ad27c1952a)
fast corner drag, 10 tries pending pending
maximize / restore pending pending

Measured on: PC, Windows 11 build, display scale. Before/after runs and screenshots to follow.

Fast corner and edge drags on the tester PC (Windows 11, RX 5700 XT + RX 6500 XT), release Unsloth Desktop on the left and a shell built from this branch on the right, played at half speed. The release build's page stops short of the window mid-drag and leaves a blank strip; this branch keeps it filled.

fast resize, before and after

Follow-up idea, not in this PR: transparent: true reportedly cuts the lag during the drag itself (tauri-apps/tauri#13270), but it changes compositing for the whole app.

…size on Windows

wry moves the WebView2 container with SWP_ASYNCWINDOWPOS, so a fast drag of the custom resize grips can leave the page at an older size. On Resized and ScaleFactorChanged, re-read the client rect and resize the container and controller synchronously.
@danielhanchen

Copy link
Copy Markdown
Member

The Repo tests (CPU, rest) failure (test_studio_evaluated_unions_do_not_grow, naming studio/backend/requirements/engines/engine_compat.py) is red on main since #11491, not from this PR. #12556 fixes it; a re-run or push after it lands should clear the check.

@LeoBorcherding

Copy link
Copy Markdown
Collaborator Author

Closing this since #13255 fixed it. That PR cut the frontend work that was stalling the page while the window was being resized, and the blank strip doesn't show up on a fast drag on main anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants