Skip to content

Studio: stop iOS Safari zooming into chat text fields - #10972

Merged
danielhanchen merged 6 commits into
unslothai:mainfrom
oobabooga:worktree-ios-composer-focus-zoom
Sep 15, 2026
Merged

danielhanchen merged 6 commits into
unslothai:mainfrom
oobabooga:worktree-ios-composer-focus-zoom

Conversation

@oobabooga

@oobabooga oobabooga commented Sep 15, 2026 •

Copy link
Copy Markdown
Member

On an iPhone, focusing the chat composer zooms the page, and the zoom remains after the keyboard closes. This pushes the header and send button off-screen and forces the user to pinch back out after each message.

Reported on Reddit.

Cause and fix

iOS Safari zooms into focused text fields smaller than 16px. At the default UI font size, the composer renders at 14.06px and the shared mobile Input and Textarea components render at 15px because their font tokens include --ui-font-scale.

An unlayered rule in index.css, limited to (hover: none) and (pointer: coarse), gives text inputs, textareas and selects a 16px minimum while preserving larger UI font preferences. It overrides Tailwind utilities without !important and excludes checkboxes, radios, ranges, file pickers and buttons.

Before and after

pr-ios-text-field-zoom-before-after

Measured in the iOS 17.5 Simulator using an iPhone 15 and Mobile Safari:

Check main This PR
Composer font size 14.06px 16px
Focus composer, then close keyboard scale 1.137 remains; header and send button are off-screen scale 1 throughout
Login password field 15px; zooms to 1.066 16px; stays at 1

As a control, a bare 14px textarea zoomed to 1.142 while a 16px textarea stayed at 1. A desktop Chromium viewport was unchanged. A larger UI font preference still applied, and a three-line composer draft still wrapped and grew correctly.

Verification and scope

  • Frontend production build passed, with the rule present in the built CSS.
  • Full frontend suite: 7,482 of 7,489 passed. Six failures reproduce on main; the remaining failure passed three isolated reruns on this branch.
  • The rule also raises smaller fields to 16px on Android and other coarse-pointer devices. Mouse and trackpad layouts are unchanged.
  • Not exercised: a physical iPhone or sending and streaming a reply with a model loaded.

Before and after on a touch viewport

Two isolated Studio installs, built from this PR's merge base (66a38c7) and from its head (08532c6), driven on the same 393x852 viewport with a coarse primary pointer. Both sides report matches_coarse: true and --ui-font-scale: .9375.

Chat composer, clipped to its own box:

Composer before and after

The same pair, whole page:

Chat page before and after

Measured on the servers that were photographed:

Fact Merge base This PR
Composer font size 14.06px 16px
Composer font size while focused 14.06px 16px
Visible fields below 16px 1 0
Composer box 349x40 349x40

The composer row does not move: leading-6 is a fixed length, so the collapsed height stays 40px.

Compact controls that needed a companion

The floor lands on every text control under a coarse pointer, which includes tablets at desktop widths. Three controls were sized against 9px to 12px text, so a base-versus-head sweep in Chromium 151, Firefox 153 and WebKit 26.5 across iPhone SE, iPhone 15, Pixel 7, iPad mini, iPad Pro landscape, an Android tablet, a Windows tablet-mode viewport and two desktop widths, at UI font scales 0.9375 and 1.25, found them clipping their value:

Control Symptom at the floor Fix
GPU monitor select (h-6) descenders of a device name clipped; a long name took a 393px page to 404px pointer-coarse:h-auto min-w-0 max-w-full
Training params numeric (w-12) "2048" cut to "204" pointer-coarse:w-16
Step count (w-14) last digit cut pointer-coarse:w-20

Each companion is coarse-pointer only, and the same sweep reports zero geometry or computed-style deltas on the fine-pointer desktop profiles, including a desktop print context.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 15, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 026863e550

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

…m floor

The floor applies to every text control on a coarse pointer, which includes
tablets at desktop widths, and three controls were sized against 9px to 12px
text. Measured base against head, the GPU monitor select clips the descenders
of a device name inside its 24px box and a long name pushes the row past a
393px viewport, and the two mono numeric fields in the training params cut
their last digit out of w-12 and w-14. Each control gets a pointer-coarse
companion, so every mouse layout stays byte identical.

Also add a test for the floor itself: it asserts the rule is still in
@layer base, since an unlayered copy loses to text-ui-13! and the field would
zoom again, and that the three companions survive.

Checked in Chromium 151, Firefox 153 and WebKit 26.5 across iPhone SE, iPhone
15, Pixel 7, iPad mini, iPad Pro landscape, an Android tablet, a Windows
tablet-mode viewport and two desktop widths, at UI font scales 0.9375 and 1.25.
@danielhanchen

Copy link
Copy Markdown
Member

I ran this one end to end against real browser engines rather than reading it, and pushed one commit (b448caf) for the three places the 16px floor outgrows its box. Summary of what was measured and what it found.

Setup

Built studio/frontend twice, at the merge base (66a38c7) and at the PR head, and drove the two production CSS bundles with Playwright Chromium 151, Firefox 153 and WebKit 26.5. 216 cells: 3 engines x 9 device classes (iPhone SE 320, iPhone 15 393, Pixel 7 412, Android tablet 800, iPad mini 768, iPad Pro landscape 1366, Windows tablet mode 1368, desktop 1440, desktop 2560) x UI font scale 0.9375 and 1.25 x base/head, each sweeping computed font size, line height, box geometry, scroll overflow and neighbour bounds over 22 fixtures copied verbatim from the components, plus content states (empty, placeholder, short, long unbroken, three line draft, CJK). All three engines report (hover: none) and (pointer: coarse) as matching on the touch profiles and not matching on the two desktops.

The rule itself holds up

  • The rule survives the Tailwind and esbuild pipeline intact, and in all three engines the CSSOM reports it inside layer=base, media=(hover: none) and (pointer: coarse), font-size: max(16px, 1rem * var(--ui-font-scale,1)) with !important. The :not() selector list parses everywhere, so the whole rule is never dropped.
  • It beats every competing declaration I could stage on an eligible field: normal utilities, the real text-ui-13! and text-ui-11!, an important declaration in @layer components, unlayered normal and unlayered important, an important font: shorthand, a normal inline style, and a stylesheet injected after load. The only thing that wins is an important inline declaration, which is correct and nothing in Studio uses.
  • Scale sweep: 0.8, 0.9375 and 1.0 all land on 16px, 1.25 on 20px, 1.5 on 24px. A larger UI font preference is preserved, the floor never drops below 16.
  • Nothing in Studio renders a field larger than 16px (the largest is text-base at 15px), so the !important never shrinks anything. Zero shrinks across 216 cells.
  • Excluded types, input[type=hidden], the Radix visually hidden select bubble, shadow roots and contenteditable are all untouched. The composer being a real textarea is what makes the fix work at all.

Desktop is provably unchanged

On the two fine pointer desktop profiles, base and head are identical on every probe in all three engines: font size, width, height, top, left, zero deltas. Same for a desktop print context. Printing from a touch device does pick up the 16px fields, since the rule is not scoped to screen, which seems right rather than wrong.

The composer, which is the point of the PR

14.06px to 16px, and the collapsed row does not move: leading-6 is a fixed length, so the line box stays 22.5px inside the 40px clamp, box height 40px before and after, send button unmoved. Nothing to fix there. Confirmed on the real component through smoke-find-in-page.html as well as the fixture.

What did break, and the fix in b448caf

Three controls were sized against 9px to 12px text and the floor overflows them. Each fix is a pointer-coarse: companion, so the desktop measurements above stay at zero deltas (re-verified after the fix: base vs head+fix desktop deltas, 0).

Control Base Head Symptom After
progress-section.tsx GPU select, h-6 10.31px, 181px wide 16px, 267px wide 24px line in a 22px content box clips descenders, and at scale 1.25 a long device name takes the page to 404px on a 393px phone pointer-coarse:h-auto min-w-0 max-w-full, no clipping at any scale, page overflow gone
params-section-controls.tsx numeric, w-12 11.25px 16px, content 51px in a 46px box "2048" cut to "204" pointer-coarse:w-16, fits
params-section.tsx step count, w-14 11.25px 16px, content 60px in a 54px box last digit cut pointer-coarse:w-20, fits

Screenshots of the select before and after the fix, with descender heavy text, are what settled it: the h-6 select really was cutting glyph bottoms in both Chromium and WebKit, while the h-6 input next to it was fine.

The commit also adds tests/ios-input-zoom-floor.test.ts in the same style as the other index.css shape tests. It fails if the rule leaves @layer base (I checked by unlayering it: 2 of 3 assertions fail), which is exactly the regression the P2 comment on this PR was about.

Things I looked at and decided not to touch

  • The dataset labeling tile wraps to two lines and the tile grows on a touch device. That is the trade for not zooming, and the tile has no fixed height.
  • The readonly pip install --upgrade unsloth copy row scrolls its text instead of showing it all on a phone. It already did that at scale 1.25 on main, and there is a copy button next to it.
  • chat-settings-sheet system prompt overflows its h-20 box a line earlier, which is the same signal that already opens the popup editor.

Gates

npm run build, typecheck, lint, biome:check clean, and 7540 of 7540 tests pass with the commit applied, matching the base run. The built asset set is identical apart from content hashes and 498 bytes of CSS, so a pip install or a Tauri install keeps its current CSS until it upgrades and then just swaps a hashed asset. No new variable, setting, persisted state or API.

What this host could not answer

Playwright WebKit on Linux is desktop WebKit: it pins visualViewport.scale at 1 and does not implement the iOS focus auto zoom at all. Everything above verifies the precondition (computed font size at focus is 16px or more) and the layout consequences. Your iOS 17.5 Simulator numbers remain the only direct evidence of the zoom itself, and a physical iPhone and a real iPad in split view are still unexercised.

@danielhanchen

Copy link
Copy Markdown
Member

@codex security review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 15, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-15T13:35:43.113841Z 8abb5a5 Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 08532c681b

ℹ️ 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 pushed a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Sep 15, 2026
danielhanchen pushed a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Sep 15, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 15, 2026
@unslothai unslothai deleted a comment from oobabooga Sep 15, 2026
@unslothai unslothai deleted a comment from oobabooga Sep 15, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 15, 2026
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Something went wrong. Try again later by commenting “@codex review”.

Unknown error
ℹ️ 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

Copy link
Copy Markdown
Member

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

Reviewed commit: 8abb5a52c6

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

Copy link
Copy Markdown
Member

Merging this with admin. State at merge, for the record.

Codex has converged on the current head (8abb5a5): approved with no open items after the branch was brought up to date with main.

CI on 8abb5a5: 41 checks green, including Frontend unit tests (Windows), Chat UI tests, Inline images on all three OSes, Tauri, wheel, installer and the lint suites. Three long-running jobs (Repo tests CPU python, Chat UI + GGUF inference, Rust unit tests macos) are still sitting in the org Actions queue, which has been several hundred runs deep all day; none of them touches the code this PR changes, and Repo tests (CPU, python) already passed on the previous head after a re-run cleared a Kaggle launcher timeout flake.

One check is red and stays red: Frontend build + bundle sanity, on the startup bundle budget. It is pre-existing on main, not caused by this PR. Measured locally with the same script: this PR's merge base reports raw 5374.9 KB > 5371.1 KB, and current main reports exactly the same raw 5374.9 KB > 5371.1 KB. The figure is byte-identical with and without this PR, so the change adds nothing to the startup bundle. It needs its own fix on main, either lazy-loading whatever grew or raising the budget with the measurement that justifies it.

Cross-platform validation for this branch ran off the org queue on a staging replica: ubuntu-latest, windows-latest, macos-15 and the studio-live Playwright suite all succeeded. Those staging PRs are closed, never merged.

@danielhanchen
danielhanchen merged commit 9bf25a1 into unslothai:main Sep 15, 2026
51 of 53 checks passed
shaojun pushed a commit to shaojun/unsloth that referenced this pull request Sep 29, 2026
iOS Safari zooms the page when a focused field renders below 16px and never zooms back out, which pushed the header and send button off screen after every message. Floor every text-entry control at max(16px, 1rem * --ui-font-scale) under (hover: none) and (pointer: coarse), in @layer base so the important declaration beats the important utilities in the utilities layer.

Three compact controls were sized against 9px to 12px text and clip their value at the floor, so each gets a pointer-coarse companion: the GPU monitor select, and the two mono numeric fields in the training params. Mouse layouts are unchanged.

Co-authored-by: oobabooga <[email protected]>
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