Skip to content

desktop: add interface scaling setting - #9666

Merged
mahiatlinux merged 16 commits into
unslothai:mainfrom
mahiatlinux:feat/studio-ui-scaling
Sep 15, 2026
Merged

mahiatlinux merged 16 commits into
unslothai:mainfrom
mahiatlinux:feat/studio-ui-scaling

Conversation

@mahiatlinux

@mahiatlinux mahiatlinux commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

Add a device-local Interface scale control under Settings > Appearance. Desktop users can set the webview scale from 50% to 200% without changing system display scaling.

The setting is sanitized, persisted in local storage, applied before the first render, and updated live through Tauri’s webview zoom API. Reset customization and Reset all to defaults restore 100%. Browser builds hide the desktop-only control.

Screenshots

Before:

before

After:

after

Checks

  • npm test (4,816 passed)
  • npm run build
  • npm run typecheck
  • npm run i18n:check:strict
  • cargo check
  • Playwright settings flow
  • Tauri desktop manual test on macOS

@mahiatlinux

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d34d5124bc

ℹ️ 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".

@mahiatlinux

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1a699f832f

ℹ️ 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".

@mahiatlinux

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2e032f3ca7

ℹ️ 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".

@mahiatlinux

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

Reviewed commit: 60665a5b6a

ℹ️ 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".

@mahiatlinux

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: f7bea0d8c5

ℹ️ 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".

@LeoBorcherding LeoBorcherding left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review

At f7bea0d8c5. Codex converged across five rounds, the two P1s got real fixes, and the calc() rewrite of the mac chrome vars is value-preserving at 100%: 110 + 78 = 188, 24 + 34 = 58, matching the old literals. The capability test is a good guard, deleting core:webview:allow-set-webview-zoom now fails a test rather than breaking zoom at runtime.

One thing I'd change before this lands.

25% has no way back. There's no keyboard reset in the diff or on main, so at 0.25 zoom the Settings row you'd use to undo it renders at about 3.5px, and the value is device-local in localStorage. Chrome and VS Code both allow 25%, but both ship Cmd/Ctrl+0. Either raise the floor to something still readable or add a reset accelerator. Your call which, the accelerator is more useful.

Nit, no action needed: in nativeDropPointToCss, Windows reads devicePixelRatio live while macOS and GTK read the cached getAppliedInterfaceZoom(). That's correct, page zoom isn't readable from JS and devicePixelRatio on macOS carries a backing-scale factor NSView points don't have. Worth a comment saying so, so nobody later "fixes" both paths onto devicePixelRatio.

CI is clean. The one red is main's own: Repo tests (CPU) failed on main through 08-25 (45a371ce0, 76e05ba7f, bbcba92a6, 96a0900f4) and this run is from 07:10 that day. Green on main's last 14 completed runs. Merge main and it clears.

@LeoBorcherding LeoBorcherding left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Full pass over the diff. Consolidating everything into one checklist so it supersedes my earlier review, nothing there is dropped.

Clean: the Appearance reorg renders every row exactly once, all 12 locales are properly translated rather than English fallbacks, and the reset-all key wiring in general-tab.tsx is correct and test-asserted.

P2: 25% has no way back

INTERFACE_SCALE_RANGE.min is 25 and there's no keyboard reset in the diff or on main. At 0.25, the Settings row you'd use to undo it renders around 3.5px, and the value is device-local in localStorage, so recovery means clearing app data. Chrome and VS Code both allow 25% but both ship Cmd/Ctrl+0.

Either raise the floor to something still readable or add a reset accelerator. Your pick, the accelerator is more useful.

P2: 34 and 78 exist three times with nothing binding them

interface-scale-runtime.ts:5-6 divides by the literals, provider.tsx:468-470 repeats them as CSS fallbacks (var(--studio-native-titlebar-height, 34px)), and interface-scale.test.ts hardcodes 34 / 0.35 as its expectation. Change the mac titlebar height in one place and the other two silently disagree at any zoom but 100%. mac-titlebar-optical-alignment.test.ts only asserts the string in provider.tsx, so nothing fails.

Export both from interface-scale-runtime.ts and build the var(..., Npx) fallbacks from them. That makes the drift impossible rather than tested-around.

P3: native-drop-position.ts:6-7 lost the specifics

The rewrite dropped ScreenToClient device pixels, NSView points and widget coordinates. Those were what let a reader check the math against the platform docs, and they are the reason the two branches of this function are allowed to differ. It is also now the only lowercase comment in the file, ten lines above physicalPerCssPx's capitalized one that the diff leaves alone.

Keeping the old sentence and appending the zoom caveat covers both cases.

P3: native-training-dataset-drop.test.ts:114 deleted the regression it documents

Gone: "scaling those halved every hit test on a HiDPI display and the zone never matched." That is why the test exists. The test body is unchanged in this diff, so the hunk only subtracts. Adding "at 100% zoom" to the old comment would have covered the new behaviour without losing the history.

NIT: the new drop tests never exercise the default argument

Both new cases pass 0.5 explicitly as the third arg, so webviewZoom = getAppliedInterfaceZoom() is never run. That default is the seam between the scale store and the drop path, and it would keep passing if it were wired to the wrong getter. One case without the third argument would close it.

Do not change

The platform split in nativeDropPointToCss is right. Windows reads devicePixelRatio live, macOS and GTK read the cached zoom, and that asymmetry is forced: page zoom is not readable from JS, and devicePixelRatio on macOS carries a backing-scale factor NSView points do not have. Worth a comment saying so, but do not collapse both paths onto devicePixelRatio.

Serialization in applyInterfaceScale is also correct as written. Rapid changes coalesce to the last value because the queued task reads requestedInterfaceScale at run time rather than capture time.

Happy to push any of the above myself if you would rather not, just say which.

@LeoBorcherding LeoBorcherding self-assigned this Aug 26, 2026
…first paint

Review follow-ups.

The floor moves 25 -> 50. Chrome and VS Code allow 25% but both ship
Cmd/Ctrl+0, and there is no reset accelerator here or on main, so at 0.25
the Settings row you would use to undo it renders around 3.5px and the
value is device-local in localStorage. A comment says to drop it back to
25 once the accelerator lands.

34 and 78 existed in three places with nothing binding them:
interface-scale-runtime.ts divided by the literals, provider.tsx repeated
them as CSS fallbacks, and interface-scale.test.ts hardcoded 34 / 0.35.
The runtime now exports both the numbers and the var(...) strings built
from them, provider.tsx imports those, and the test asserts the fallback
is built from the constant rather than retyped. Changing the titlebar
height in one place can no longer leave a stale divisor at any scale but
100%.

applyInterfaceScale is now wrapped for startup. It was the only thing
gating first paint on the Tauri IPC bridge, and a rejection was caught
while a hang was not, so a wedged bridge meant a permanently blank window
rather than a slow one. Past a 1s deadline the app renders at 100% and
the effect in provider.tsx applies the real scale when the bridge answers.
Two tests, one with a setZoom that never resolves.

The comment on nativeDropPointToCss lost ScreenToClient device pixels,
NSView points and widget coordinates in the rewrite. Those are why the
two branches are allowed to differ, so they are back, with the zoom
caveat appended and a note not to collapse both paths onto
devicePixelRatio. Same for the deleted regression note on
native-training-dataset-drop.test.ts:114.

The new drop tests all passed the zoom explicitly, so the default
argument, which is the seam between the scale store and the drop path,
never ran. One case now omits it.

4826 frontend tests pass, typecheck, build, i18n:check:strict clean, and
provider.tsx gains no new eslint findings.
@LeoBorcherding

Copy link
Copy Markdown
Collaborator

Pushed 44af5ccbdf under maintainer_can_modify, all five findings from the pass above plus one more. Happy to revert any of it.

The 25% call went to the floor, not the accelerator. INTERFACE_SCALE_RANGE.min is 50 now. I said the accelerator was more useful and I still think that, but it is a feature you did not propose, and putting it on this branch means another ~30 files and another review round on a PR that is otherwise done. At 50% the Settings row renders at half size, which is annoying but clickable, so the trap is gone today. There is a comment in interface-scale-store.ts saying to drop the floor back to 25 once Cmd/Ctrl+0 lands, and I will open that separately.

34 and 78 are now bound in one place. interface-scale-runtime.ts exports both the numbers and the var(...) strings built from them, provider.tsx imports those instead of retyping the fallbacks, and interface-scale.test.ts divides by the constant rather than a literal.

There was a third copy neither of us counted: mac-titlebar-optical-alignment.test.ts regex-asserted the exact string "var(--studio-native-titlebar-height, 34px)" in provider.tsx, so moving the constant broke that test. It now asserts the runtime builds the fallback from NATIVE_MAC_TITLEBAR_HEIGHT_PX and that no literal 34px fallback survives in provider.tsx, which is the version that actually makes the drift impossible instead of just tested-around.

nativeDropPointToCss got its specifics back. ScreenToClient device pixels, NSView points and widget coordinates, with the zoom caveat appended and an explicit note not to collapse both branches onto devicePixelRatio. Same for the deleted regression note at native-training-dataset-drop.test.ts:114.

The default argument is exercised now. Every new drop case passed the zoom explicitly, so the webviewZoom = getAppliedInterfaceZoom() default, which is the seam between the scale store and the drop path, never ran. One case omits it and drives it through setAppliedInterfaceZoom.

New, not in my earlier pass: first paint was gated on the Tauri IPC bridge with no timeout. main.tsx waited on applyInterfaceScale, which does a dynamic import plus a setZoom round trip. A rejection was caught, a hang was not, so a wedged bridge meant a permanently blank window rather than a slow one. There is now applyInterfaceScaleBeforeFirstPaint with a 1s deadline: past it the app renders at 100% and the effect in provider.tsx applies the real scale when the bridge answers. Two tests, one with a setZoom that never resolves.

Two mechanical notes. The first import I wrote tripped no-restricted-imports, so the constants are re-exported from the settings feature index; native-drop-position.ts still imports the runtime module directly so the native-intents bundle does not pull zustand in. And the test scale moved from 35 to 55 throughout, since 35 no longer round-trips under the new floor, plus an assertion that a below-floor value clamps.

Verification: 4,826 frontend tests pass at 44af5ccbdf, npm run typecheck, npm run build and npm run i18n:check:strict all clean, and provider.tsx gains no new eslint findings.

Correcting myself on CI. I said above that merging main would clear the one red. That is no longer true. Repo tests (CPU) is failing on main right now for two reasons that landed today and are not this PR:

FAILED tests/studio/test_playwright_suites_run_in_ci.py
  ['playwright_tool_activity.py'] is named by no workflow
FAILED tests/test_source_read_encoding.py
  studio/backend/tests/test_memory_contract.py:178: read_text() with no encoding

Those came in with #9803 and #9830. So do not merge main to clear a red yet, it swaps one main-owned failure for a different one. Worth waiting for main to go green.

@codex review

@LeoBorcherding

Copy link
Copy Markdown
Collaborator

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: c5e29fba70

ℹ️ 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".

…ants

Repo tests (CPU) has been red on this branch since f7bea0d and the log
had expired, so nobody had seen why. Two failures, both the same cause:
test_desktop_reliability_frontend_contract.py reads px values straight out
of provider.tsx, and the calc() rewrite replaced the literals it greps for.

test_collapsed_tauri_keeps_history_arrows_and_adds_new_chat_by_model_picker
asserted the literal string '"--studio-collapsed-chat-controls-inset":
"188px"'. It now resolves the block and asserts the number is 188, scoped
to the mac block because the custom titlebar sets the same var to 12px.

test_tauri_collapse_removes_the_icon_rail_but_web_keeps_it went through
_chrome_style_blocks, whose regex only captured "--var": "literal" pairs,
so --studio-desktop-titlebar-height read as absent once it became an
identifier and the offset + button <= titlebar assertion had nothing to
compare. The helper now also takes templates and identifiers, resolving
the latter out of interface-scale-runtime.ts so the 34 stays in one place.

_px understands var(--x, Npx) and calc(Apx + var(--x, Bpx)) as their 100%
values, with a docstring saying that is the only scale a static read can
see. Formatting via scripts/run_ruff_format.py.

36 of 36 in that file pass locally.
@mahiatlinux

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: 422069cfbe

ℹ️ 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".

@Etherll Etherll self-assigned this Sep 8, 2026
@Etherll

Etherll commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator

@codex review

1 similar comment
@Etherll

Etherll commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 70775b3bdf

ℹ️ 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".

@Etherll

Etherll commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator

At 70775b3b, Interface scale produces real Windows WebView2 zoom at 50%, 100%, 150%, and 200%. Reset returns to 100%, and 175% survives reload. Fonts and the additive scale preference survive upgrade, rollback, and re-upgrade across source-built pre-change and PR native executables, using one retained profile and forced process restarts. Graceful shutdown was not verified. Chrome, Edge, and released Firefox keep font controls and hide desktop scale. Native checks used development builds, the actual Tauri bridge, and controlled production settings components and effects.

The full-app screenshot below uses a simulated desktop lifecycle. It shows the added control with a persisted 125% value, not physical zoom. Native macOS geometry, actual OS file dragging, and installer execution were untested. The implemented floor is 50%; the PR description still says 25%.

Before: 5c44c8c96b7fad0777cb6ea1240e5427f81e6fe4. After: 70775b3bdf147d10e941306c17c25d51d98a4bca.

Appearance settings before and after PR 9666

Windows native checks.

@Etherll Etherll left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM !

@Imagineer99

Copy link
Copy Markdown
Member

[P2] Preserve macOS window-button clearance when scaling activates the mobile Navbar

At a 900×600-point macOS window, changing Interface scale from 100% to 125% reduces the CSS viewport width to 720px and activates the mobile Navbar. That branch uses pl-2 pt-[11px] without the native macOS traffic-light inset, placing the sidebar toggle underneath the window buttons.

The native screenshot below shows the toggle clear of the window buttons on base 100% (left), and visibly overlapping their area on head 125% (right). Both captures use the same native window size; pixels are not resized.

Native macOS: base 100% clears the window buttons; head 125% overlaps their area

Measured native frame intersections corroborate the image:

Case Close overlap (pt²) Minimize overlap (pt²) Zoom overlap (pt²)
Base 100% 0 0 0
Head 100% 0 0 0
Head 125% (pictured) 224 224 0
Head 200% (measurements only here) 168 196 196

Please apply the existing zoom-adjusted macOS traffic-light inset to the mobile Navbar branch in studio/frontend/src/components/navbar.tsx:52–60, then verify clearance at 125% and 200%.

Native A/B run and artifacts: base 5c44c8c96b7fad0777cb6ea1240e5427f81e6fe4, head 70775b3bdf147d10e941306c17c25d51d98a4bca. Both scenes completed; the job failed on the clearance assertions. Zoom, reload persistence, and reset passed.

Scope: production components in real Tauri/WKWebView windows on macOS, using a controlled harness. The image demonstrates visual overlap; it does not establish click interception or accidental window closure.

@mahiatlinux

Copy link
Copy Markdown
Contributor Author

@codex review

@mahiatlinux

mahiatlinux commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor Author

Fixed the macOS mobile Navbar overlap reported in #9666 (comment) in 206516a26. The mobile sidebar toggle now uses the existing zoom-adjusted traffic-light inset plus the same 6px gap as the desktop navigation.

Native macOS A/B verification reproduced the original overlap on 70775b3bdf and passed on the exact published fix. At 125% and 200%, all three native window-button intersection areas are now zero. The sidebar toggle starts at 85.5pt and 90pt respectively. Native screenshots at both scales were inspected. Checks at 50% and 100%, reload persistence, and reset also pass.

The run is red because the native macOS before job intentionally tests the original failure; native macOS after is green. Screenshots and measured frames are in the pr9666-native-mac-before and pr9666-native-mac-after artifacts. These use production components in real Tauri/WKWebView windows with a controlled scene.

Typechecking, ESLint, 49 focused frontend tests, and 36 desktop contract tests pass.

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 206516a269

ℹ️ 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".

@mahiatlinux

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 044b44f993

ℹ️ 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".

@mahiatlinux

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

Reviewed commit: fcc0003f95

ℹ️ 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".

@mahiatlinux
mahiatlinux merged commit 8bc5530 into unslothai:main Sep 15, 2026
33 of 35 checks passed
@mahiatlinux
mahiatlinux deleted the feat/studio-ui-scaling branch September 25, 2026 05:32
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.

5 participants