Skip to content

Studio: UI font size scales all text consistently without moving layout - #7355

Merged
danielhanchen merged 6 commits into
mainfrom
studio-ui-font-size-scaling
Jul 23, 2026
Merged

danielhanchen merged 6 commits into
mainfrom
studio-ui-font-size-scaling

Conversation

@shimmyshimmer

@shimmyshimmer shimmyshimmer commented Jul 23, 2026 •

Copy link
Copy Markdown
Member

Problem

The UI font size setting in Settings > Appearance was inconsistent. It works by changing the root font size (the rem base), so only rem sized text reacted to it. Everything with a px font size did not move at all: headings, sidebar labels, roughly 600 text-[13px] style classes across 130+ files, px font sizes in index.css and hub.css, and the training chart labels. At the same time, rem based padding, gaps, widths and radii wrongly grew with the setting, so bumping the font size also inflated the layout.

Fix

Two sided normalization, all exact at the default 16px root so default rendering is byte for byte identical:

Text follows the rem base

  • Converted every text-[Npx] and leading-[Npx] arbitrary class to its rem equivalent (text-[13px] becomes text-[0.8125rem]), including inside @apply blocks in CSS
  • Converted px font-size and line-height declarations in index.css and hub.css to rem
  • Recharts axis and label fontSize={10} props now use "0.625rem"
  • Library styles that ship px sizes (streamdown citation chips, react-flow node and edge labels) are re-based through small overrides at the end of index.css

Layout ignores the rem base

  • Pinned --spacing to 4px and --radius to 17.6px (same computed values as before), plus the --container-* scale used by max-w-md and friends
  • Sidebar width, thread max width, and the remaining rem based arbitrary widths, calc margins and hub.css dimensions are now px

Follow ups in this PR

Logo scales at half rate. The sidebar lockup (circle sticker, wordmark, beta badge) and the onboarding wizard lockup follow the UI font size at half the rate of the change: size = base + (root - 16px) / 2, written as calc((base - 8)px + 0.5rem). A 4px font size change moves the logo by 2px, and 16px renders the exact base sizes.

Tight controls fit the text. Audited every settings tab, the chat page and the run settings panel at the maximum setting (20px). The appearance color chips (fixed w-24) and the voice tab selects (fixed w-56) clipped their text. The chips now use min widths, while the selects use bounded min/max widths, so they render identically at 16px, widen when needed, and truncate unusually long device names before they can overflow the dialog.

Scrolling dropdowns keep rounded corners. When a menu overflows, WebKit paints the surface square wherever the rounded element itself hosts the scrollbar, so menus lost their rounding on the scrollbar side in the desktop app. DropdownMenuContent and SelectContent now clip the surface and scroll an inner viewport; the surface padding insets the scrollbar clear of the curve. Submenus are unaffected since sub content is portaled.

Verification

Measured in headless Chromium and WebKit through the real Settings control:

  • At UI font size 20 (1.25x), headings, sidebar labels, composer, buttons and the settings dialog all measure exactly 1.25x their default computed font size, while the sidebar stays 280px, buttons keep their size, padding and radius, and dialog widths are unchanged
  • Logo at setting 12: wordmark, badge and sticker measure 19, 6 and 32 (each down 2 from 21, 8 and 34); at setting 20 they measure 23, 10 and 36 (each up 2)
  • The permission mode menu and dictation language select forced into scrolling render rounded on all four corners in both engines, with the inner viewport scrolling instead of the surface
  • At the default 16px nothing changes anywhere

Notes

  • KaTeX keeps its internal font-size: 1px rule, which is a layout trick and not visible text
  • The separate Code font size setting still pins code blocks in px when set; unset code inherits rem sizes and scales with the UI setting

The UI font size setting changes the root rem base, so only rem sized
text reacted. Hundreds of px text classes, px font sizes in CSS, and
chart labels stayed fixed, while rem based padding, widths and radii
wrongly grew.

Convert all text sizes to rem so every font follows the setting, and
pin spacing, radius, container widths, sidebar and thread widths to px
so layout no longer follows the rem base. Library styles (streamdown,
react-flow) are re-based via overrides. All conversions are exact at
the default 16px root, so the default rendering is unchanged.
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@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: 25bee3bb11

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

Comment thread studio/frontend/src/index.css Resolved
The logo lockups (sidebar wordmark with beta badge, onboarding wizard)
are branding and now keep px sizes at any UI font size.

Two controls clipped their text at the largest setting: the appearance
color chips (fixed w-24) and the voice tab selects (fixed w-56). Both
use min widths now, so they keep the default look at 16px and only
grow when the text needs the room.
@shimmyshimmer

Copy link
Copy Markdown
Member Author

Pushed a follow up commit:

  • The logo lockups (sidebar unsloth wordmark with the beta badge, onboarding wizard) now keep fixed px sizes at any UI font size, since they are branding rather than UI text
  • Audited every settings tab, the chat page and the run settings panel at the maximum setting (20px) for clipped text. Two controls needed room: the appearance color chips (fixed w-24) and the voice tab selects (fixed w-56). Both are min widths now, so they render identically at the default 16px and only widen when the text actually needs it
  • Everything else holds up at 20px: labels wrap or truncate cleanly and no other element clips

A scrolling dropdown lost its rounded corners on the scrollbar side:
WebKit paints the surface square when the rounded element itself hosts
the scrollbar, which shows up in the desktop app whenever a menu
overflows, for example at larger UI font sizes.

Dropdown menu and select content now clip with overflow hidden and
scroll an inner viewport instead. The surface padding insets the
scrollbar clear of the curve, so corners stay rounded in every engine.
Submenus are unaffected since sub content is portaled.
@shimmyshimmer

Copy link
Copy Markdown
Member Author

Pushed another fix: scrolling dropdowns lost their rounded corners on the scrollbar side. When a menu overflows (easy to hit at larger UI font sizes), WebKit paints the surface square wherever the rounded element itself hosts the scrollbar, so the right edge of the menu went flat in the desktop app.

DropdownMenuContent and SelectContent now keep the rounding and clipping on the surface and scroll an inner viewport instead. The surface padding naturally insets the scrollbar away from the curve, so corners stay rounded in WebKit and Chromium. Verified in both engines with the permission mode menu and the dictation language select forced into scrolling at the 20px setting: the surface no longer scrolls, the inner viewport does, and the radius renders on all four corners. Submenus are unaffected because sub content is portaled out of the menu.

Also swept the rest of the codebase for the same pattern. The remaining rounded scrollers are small inline log and code boxes with subtle radii where the artifact does not read, so they were left alone.

Rather than pinning the logo, the sidebar lockup (sticker, wordmark,
beta badge) and the onboarding lockup now follow the UI font size at
half the rate of the change: size = base + (root - 16px) / 2, written
as calc((base - 8)px + 0.5rem). A 4px font size change moves the logo
by 2px, and the default 16px root renders the exact base sizes.
@shimmyshimmer

Copy link
Copy Markdown
Member Author

Changed the logo behavior: instead of staying pinned, the logo lockups now follow the UI font size at half the rate of the change. The formula is size = base + (root - 16px) / 2, written in CSS as calc((base - 8)px + 0.5rem), applied to the sidebar lockup (circle sticker, wordmark, beta badge) and the onboarding wizard lockup (sticker plus text).

So a 4px font size change moves the logo by 2px, and the default 16px root still renders the exact base sizes. Verified through the actual Settings control: at 12px the wordmark, badge and sticker measure 19, 6 and 32 (each down 2 from 21, 8 and 34), and at 20px they measure 23, 10 and 36 (each up 2).

@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: 745b11d468

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

@shimmyshimmer

Copy link
Copy Markdown
Member Author

Ran a full simulation matrix against this branch to verify the fix end to end. Setup: isolated sandbox with a Playwright harness driving the real app (login, real Settings controls, real backend sync), plus a static audit of the built bundle running in a uv venv. Engines covered: Chromium (Chrome and Edge), WebKit (Safari and the desktop app), and Firefox, each at 1440x900, plus a Chromium pass at devicePixelRatio 1.25 to simulate Windows 125 percent display scaling. The changes are frontend only, so the browser engine is the compatibility variable rather than the OS.

Results: 344 browser assertions passed with 0 failures, and 12 static checks passed.

What was asserted, per engine:

  • Font sweep at 12, 14, 16, 18, 20 through the actual Settings input: five text samples (sidebar, section labels, dialog headings, row labels, profile) scale by exactly size/16, while sidebar width, nav item height, dialog width and dialog radius stay fixed to within a fraction of a pixel
  • Logo lockup measures base + (root - 16px)/2 at every size for the wordmark, beta badge and sticker image
  • Computed --spacing resolves to 4px, confirming the unlayered pin beats the Tailwind default
  • Clipped text scan across the chat page and all seven settings tabs at sizes 12 and 20: zero horizontally clipped visible text anywhere; color chips fit at every size
  • Dropdown under a 300px viewport: surface clips with rounded corners intact, the inner viewport scrolls, arrow keys move the highlight and drive scroll into view, Escape leaves the mode unchanged
  • Select: opens with the full option list, the inner wrapper scrolls instead of the surface, keyboard commit changes the value and a second commit restores it
  • Garbage persisted values (99, -5, a string) clamp into the 12 to 20 range without crashing the app
  • The 1.25 DPR pass repeats the font sweep and clip scan with identical results

Static audit of the built CSS: no stray px font sizes outside the known allowlist (the KaTeX 1px layout rule and the overridden library rules), the streamdown and react-flow overrides are present with winning specificity, spacing, radius and container tokens are pinned to px, no px arbitrary text classes remain in the source, and every converted rem value is an exact binary fraction so there is no rounding drift at any setting.

No product issues surfaced. Two early scanner false positives (buttons inside the collapsed run settings panel, and Firefox reporting scrollWidth on inline boxes) were confirmed as measurement artifacts, and one flaky keyboard timing assertion was fixed in the harness, after which everything is green.

…rolling

Numeric leading utilities (leading-3 through leading-10) derive from
--spacing, so pinning spacing to px also froze their line-heights while
the paired text sizes now scale. Define them as rem theme tokens so
line-height follows the UI font size again; values are identical at the
16px default.

Convert the grid tracks the rem-to-px codemod missed (rem followed by
an underscore escaped the word boundary): the response details label
column and the on-device folder rows.

Make the Radix select viewport the bounded scroller instead of a
wrapper div, so Radix's scroll handling and the browser scroll the same
element. Restore the app's thin scrollbar with an inline style, which
beats the scrollbar hiding stylesheet Radix injects at runtime.

@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: a52536844c

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

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: e5888ba5cd

ℹ️ 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 fa5498d into main Jul 23, 2026
37 of 40 checks passed
@danielhanchen
danielhanchen deleted the studio-ui-font-size-scaling branch July 23, 2026 07:44
@shimmyshimmer

Copy link
Copy Markdown
Member Author

Follow up: #7359 replaces the scaling mechanism from this PR with an explicit typography scale. The preference now writes a --ui-font-scale variable instead of mutating the root font size, the layout-only rem to px conversions from this PR are reverted since the rem base no longer moves, and all the behavior fixes here (tight controls, rounded scrolling menus, logo half rate) carry over. It also adds contract tests, a Playwright regression wired into the UI smoke workflow, and a guard against new raw pixel typography.

danielhanchen pushed a commit that referenced this pull request Jul 23, 2026
…root font size (#7359)

* Studio: drive UI font size through a typography scale, not the root font size

Follow up to #7355. The preference now writes --ui-font-scale
(selected / 16) and a data-ui-font-size attribute on the root instead
of mutating the root font size, and the applier clears any stale inline
root font-size left by older builds. Because the rem base never moves,
every layout-only rem-to-px conversion from #7355 is reverted to its
original form: the spacing, radius and container tokens, sidebar and
thread widths, grid tracks, calc margins and hub.css dimensions match
pre-#7355 main again, which also restores rem-based accessibility
scaling for users with a larger browser default font size.

Typography scales through tokens in index.css, all exact at 16px:

- The named Tailwind sizes (--text-xs through --text-4xl) multiply
  their defaults by the scale, so standard utilities scale
- One token per design px size (--text-ui-8 ... --text-ui-34) replaces
  every arbitrary text-[Npx] class; leading-ui-* mirrors the exact
  line heights and the numeric --leading-3..10 scale as well
- CSS font-size and line-height declarations multiply by the scale
- Chart labels scale through a .recharts-text rule; streamdown and
  react-flow px text is re-based via scaled overrides; KaTeX's 1px
  layout trick stays fixed by design
- The logo lockups keep their half-rate behavior via the scale var
- The explicit Code font size remains unmultiplied

Keeps the #7355 behavior fixes: color chip min width, voice select
min/max widths, and the select and dropdown menus scrolling an inner
viewport so their corners stay rounded. The whitespace-password and
IME rename guards that merged alongside are preserved.

* Studio: contract and Playwright coverage for the UI font size scale

test_ui_font_scale_contract.py pins the mechanism (scale var written,
root font size never mutated, tokens scaled, code font size not
multiplied, the Radix select viewport owning scroll state) and guards
against new raw pixel typography, with a documented allowlist for the
recharts fontSize props covered by the stylesheet override and the
offscreen clipboard textarea.

playwright_ui_font_scale.py drives the real appearance controls: root
font size fixed at 12/16/20, text and line height scale by size/16,
sidebar width invariant, explicit code font size stays fixed, an
overflowing dictation select scrolls its Radix viewport by keyboard
and wheel, and the default restores exactly. Wired into the UI smoke
workflow against the second studio boot.

The thinking-compact and descender contracts move back to the rem and
token forms now that layout values no longer need px pinning.
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