Skip to content

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

Merged
danielhanchen merged 3 commits into
mainfrom
dh/desktop-windows-scaling-fixes
Aug 5, 2026
Merged

danielhanchen merged 3 commits into
mainfrom
dh/desktop-windows-scaling-fixes

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Aug 5, 2026 •

Copy link
Copy Markdown
Member

Problem

Reported on Windows 11: the sidebar toggle in the titlebar does nothing in a normal window (a second control lower down works), and the Settings rows for Hugging Face token and Embedding model are badly misaligned. Maximizing the window fixes both.

Both are the same root cause, and it is not a Windows-only concern in principle.

Windows text scaling multiplies the webview's device scale factor. On the reporting machine, a 2880x1800 panel at 250% display scaling with HKCU:\Software\Microsoft\Accessibility\TextScaleFactor = 125 gives an effective CSS device pixel ratio of 3.125, not 2.5. Measured, not assumed: the sidebar is 17.5rem = 280 CSS px and renders 873 physical px.

So the app's 900 logical px minimum window is only about 722 CSS px, which is under MOBILE_BREAKPOINT = 768 in hooks/use-mobile.ts. The desktop app renders its mobile layout in an ordinary window. Maximized gives 1152 logical, about 924 CSS px, which is why maximizing appears to fix it.

Two controls break there:

  1. The titlebar's sidebar toggle calls togglePinned. In mobile mode the sidebar is a sheet keyed off openMobile and pin state does nothing, so the button focuses, shows its tooltip, and has no effect.
  2. Navbar's SidebarTrigger, the control that does work, sits at z-[45] under the custom titlebar's z-[70] header. Only about 11px of it is clickable, which is the sliver users find by accident.

Confirmed by driving the shipped app: clicking that sliver opens the mobile sheet.

Changes

components/tauri/window-titlebar.tsx - new showSidebarToggle prop, default true. In the mobile layout an inert same-size spacer holds the slot so back/forward keep their position, instead of rendering a toggle that cannot work.

components/navbar.tsx - when the custom titlebar is in use, the mobile SidebarTrigger moves into the titlebar band at z-[80], where the desktop toggle would have been. One control, in the expected place, that works.

app/provider.tsx - first launch clamps the window width up to whatever buys 768 CSS px, bounded by the screen. The old max(900, screenW * 0.75) rule lands on 864 logical = 691 CSS px on the reporting machine, so the app opened in the mobile layout by construction. devicePixelRatio already includes the display scale, so the ratio is 1 and this is a no-op wherever there is no extra webview zoom.

This is deliberately first launch only. An existing install takes the restoreStateCurrent path, so a window already saved under the breakpoint stays there. Clamping that path too would override a size the user chose on purpose, and would have to fight the plugin's maximized-state restore. The two changes above are what make that case usable, and maximizing or widening still escapes it.

features/settings/components/settings-row.tsx - the row wraps instead of crushing the label. Controls are fixed-width and shrink-0, so a narrow content column starved the label. The settings dialog reserves 248px of nav plus 48px of padding, so this is reachable well before any viewport-width breakpoint fires.

Note justify-end rather than an auto margin on the control. Three callers (appearance-tab.tsx:76, resources-tab.tsx:579, general-tab.tsx:642) override the row to flex-col items-stretch. On a column axis an auto cross-axis margin suppresses align-self: stretch per CSS Flexbox 9.4/9.6, which would have shrink-to-fit the folder input and the embedding-model combobox instead of letting their w-full span the row. resources-tab's override is max-[840px], so that branch is live exactly at the reporting width.

Verification

Measured with real rendering, comparing origin/main against this branch in a harness that reproduces the settings dialog shell (min(960px, 100vw-2rem) dialog, 248px nav, p-6 main).

Label column width and line count for the two rows in the bug report:

viewport row origin/main this branch
722 Hugging Face token 43px, 3 lines 394px, 1 line
722 Embedding model 26px, 2 lines 394px, 1 line
924 Hugging Face token 245px, 1 line 245px, 1 line
924 Embedding model 228px, 1 line 228px, 1 line
1400 Hugging Face token 245px, 1 line 245px, 1 line

43px for a label reading "Hugging Face token" is the reported bug.

No regression above the bug width: at 924 and 1400 every measured row is geometrically identical to origin/main, including wrapped state and the stretch probe on the flex-col callers. The label floor is 11rem specifically because it is the widest value that keeps that true. 12rem and 13rem both made the Models folder row wrap at 924, which is the maximized width on the reporting machine.

tsc -b clean. npm run build clean. Biome against origin/main on these four files: one added useBlockStatements, from a braceless early return matching the 23 already in provider.tsx. Biome is non-blocking in this repo by design.

Cross-platform

Every branch is guarded or width-driven.

  • navbar.tsx: the non-custom-titlebar path keeps z-[45] h-[48px] items-start pt-[11px] pl-2 verbatim. shouldUseCustomWindowTitlebar() is false when not in Tauri and false on macOS, so plain web and macOS are untouched.
  • window-titlebar.tsx: showSidebarToggle defaults to true and the macOS caller in app-sidebar.tsx:1729 does not pass it. The only site passing false is inside WindowTitlebar, itself gated on shouldUseCustomWindowTitlebar(), and then only when mobile.
  • provider.tsx: ratio is 1 without extra webview zoom, so the computed width is unchanged elsewhere.
  • settings-row.tsx: the only unguarded file, hence the measurement table above.

Not verified

The titlebar and window-sizing changes need a desktop build to confirm end to end; only the settings-row geometry could be measured directly. The Tauri Linux debug build in CI covers compilation.

Windows text scaling multiplies WebView2's device scale factor, so the
desktop app can land in the mobile layout in an ordinary window: at 250%
display scaling plus 125% text scaling the effective CSS DPR is 3.125, and
the app's own 900px minimum window is only ~722 CSS px -- under
MOBILE_BREAKPOINT (768).

Two controls broke there, and neither is Windows-specific in principle:

- The titlebar's sidebar toggle calls togglePinned, which the sidebar
  ignores in mobile mode (the sheet is keyed off openMobile), so the
  button looked dead. Hold the slot open instead of rendering a toggle
  that cannot work, keeping back/forward in place.
- Navbar's SidebarTrigger -- the control that does work there -- sits at
  z-[45] under the custom titlebar's z-[70] header, leaving ~11px of it
  clickable. Move it into the titlebar band, above it.

Also stop SettingsRow from crushing its label: the controls are fixed-width
and shrink-0, so a narrow content column starved the label to one word per
line. Wrap instead. The dialog reserves 248px of nav plus padding, so this
is reachable well before any viewport-width breakpoint fires.

Every branch is guarded on shouldUseCustomWindowTitlebar() or is width
driven, so macOS, Linux and the web keep their existing layout.
First launch sizes the window from logical px, but Windows text scaling zooms
the webview on top of the display scale, so logical px buy fewer CSS px than
they look like. On a 2880x1800 panel at 250% scaling with text scaling at 125%
the CSS device pixel ratio is 3.125, the 0.75-of-screen rule lands on 864
logical px, and the window opens at 691 CSS px: under the 768 sidebar
breakpoint, so a normal desktop window came up in the mobile layout.

Clamp the first-launch width up to whatever buys 768 CSS px, bounded by the
screen. devicePixelRatio already includes the display scale, so the ratio is 1
and this is a no-op wherever there is no extra webview zoom.
@wasimysaid

Copy link
Copy Markdown
Collaborator

@codex review

danielhanchen added a commit to shimmyshimmer/unsloth-staging-4 that referenced this pull request Aug 5, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: 36bb2e8cb2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 5, 2026
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: 7576c5b339

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@danielhanchen
danielhanchen merged commit 43407d7 into main Aug 5, 2026
39 of 41 checks passed
@danielhanchen
danielhanchen deleted the dh/desktop-windows-scaling-fixes branch August 5, 2026 16:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants